generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5a1eac
commit 964c9f6
Showing
8 changed files
with
99 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
...d/domain/src/main/java/tw/waterballsa/gaas/citadels/domain/BuildingCard/BuildingCard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
package tw.waterballsa.gaas.citadels.domain.BuildingCard; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import tw.waterballsa.gaas.citadels.domain.BuildingCard.BuildingCardFactory.Color; | ||
import lombok.Value; | ||
|
||
import java.util.Optional; | ||
|
||
@Data | ||
@Value | ||
@AllArgsConstructor | ||
public class BuildingCard { | ||
String name; | ||
int coins; | ||
Color color; | ||
|
||
public enum Color { | ||
PURPLE("特別地區"), | ||
GOLD("貴族地區"), | ||
RED("軍事地區"), | ||
BLUE("商業地區"), | ||
GREEN("宗教地區"); | ||
private final String area; | ||
|
||
Color(String area) { | ||
this.area = area; | ||
} | ||
|
||
public static Optional<Color> fromString(String str) { | ||
for (Color color : Color.values()) { | ||
if(str.equalsIgnoreCase(color.toString())) { | ||
return Optional.ofNullable(color); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} | ||
} |
75 changes: 2 additions & 73 deletions
75
...n/src/main/java/tw/waterballsa/gaas/citadels/domain/BuildingCard/BuildingCardFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,10 @@ | ||
package tw.waterballsa.gaas.citadels.domain.BuildingCard; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface BuildingCardFactory { | ||
|
||
public enum Type { | ||
TEMPLE, | ||
CHURCH, | ||
MONASTERY, | ||
CATHEDRAL, | ||
WATCHTOWER, | ||
PRISON, | ||
BATTLEFIELD, | ||
FORTRESS, | ||
MANOR, | ||
CASTLE, | ||
PALACE, | ||
TAVERN, | ||
INN, | ||
MARKET, | ||
BOATHOUSE, | ||
HARBOR, | ||
TOWN_HALL, | ||
LIBRARY, | ||
DRAGON_GATE, | ||
GRAVEYARD, | ||
GHOST_TOWN, | ||
SCHOOL_OF_MAGIC, | ||
LABORATORY, | ||
SMITHY, | ||
OBSERVATORY, | ||
UNIVERSITY, | ||
BASTION, | ||
GREAT_WALL; | ||
|
||
public static Optional<Type> fromInt(int value) { | ||
for(Type type : Type.values()) { | ||
if(type.ordinal() == value) { | ||
return Optional.ofNullable(type); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
public static Optional<Type> fromString(String str) { | ||
for (Type type : Type.values()) { | ||
if(str.equals(type.toString())) { | ||
return Optional.ofNullable(type); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public enum Color { | ||
PURPLE("特別地區"), | ||
GOLD("貴族地區"), | ||
RED("軍事地區"), | ||
BLUE("商業地區"), | ||
GREEN("宗教地區"); | ||
private final String area; | ||
|
||
Color(String area) { | ||
this.area = area; | ||
} | ||
|
||
public static Optional<Color> fromString(String str) { | ||
for (Color color : Color.values()) { | ||
if(str.equalsIgnoreCase(color.toString())) { | ||
return Optional.ofNullable(color); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public Optional<BuildingCard> createBuildingCard(Type type); | ||
public Optional<List<BuildingCard>> createBuildingCards(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.