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.
fix:StartGame API : Game -> CitadelsGame, remove GameView (roles and …
…building)
- Loading branch information
Showing
28 changed files
with
304 additions
and
397 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
...ckend/app/src/main/java/tw/waterballsa/gaas/citadels/app/repositories/GameRepository.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,13 +1,12 @@ | ||
package tw.waterballsa.gaas.citadels.app.repositories; | ||
|
||
import tw.waterballsa.gaas.citadels.domain.Game; | ||
import tw.waterballsa.gaas.citadels.domain.Room; | ||
import tw.waterballsa.gaas.citadels.domain.CitadelsGame; | ||
|
||
import java.util.Optional; | ||
|
||
public interface GameRepository { | ||
|
||
Game createGame(Game game); | ||
CitadelsGame createGame(CitadelsGame citadelsGame); | ||
|
||
Optional<Game> findGameById(String gameId); | ||
Optional<CitadelsGame> findGameById(String gameId); | ||
} |
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
70 changes: 70 additions & 0 deletions
70
packages/backend/domain/src/main/java/tw/waterballsa/gaas/citadels/domain/CitadelsGame.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package tw.waterballsa.gaas.citadels.domain; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static java.util.UUID.randomUUID; | ||
|
||
public class CitadelsGame { | ||
private final String id; | ||
private final List<Player> players; | ||
private final List<RoleCard> roleCards; | ||
private final List<BuildingCard> buildingCards; | ||
public static final Integer DEFAULT_COINS = 2; | ||
public static final Integer DEFAULT_CARD_QUANTITY = 2; | ||
|
||
public CitadelsGame(List<Player> players, List<RoleCard> roleCards, List<BuildingCard> buildingCards) { | ||
this.id = randomUUID().toString(); | ||
this.players = players; | ||
this.roleCards = roleCards; | ||
this.buildingCards = buildingCards; | ||
} | ||
|
||
public CitadelsGame(String id, List<Player> players, List<RoleCard> roleCards, List<BuildingCard> buildingCards) { | ||
this.id = id; | ||
this.players = players; | ||
this.roleCards = roleCards; | ||
this.buildingCards = buildingCards; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public List<Player> getPlayers() { | ||
return List.copyOf(players); | ||
} | ||
|
||
public List<BuildingCard> getBuildingCards() { | ||
return List.copyOf(buildingCards); | ||
} | ||
|
||
public List<RoleCard> getRoleCards() { | ||
return List.copyOf(roleCards); | ||
} | ||
|
||
public void randomlyAwardCrownToOnePlayer() { | ||
Collections.shuffle(players); | ||
Player kingPlayer = players.get(0); | ||
kingPlayer.acquireCrown(); | ||
} | ||
|
||
public void start() { | ||
randomlyAwardCrownToOnePlayer(); | ||
distributingCardsAndCoinsToEachPlayer(); | ||
} | ||
|
||
private void distributingCardsAndCoinsToEachPlayer() { | ||
players.forEach(player -> { | ||
player.plusCards(getTwoCards()); | ||
player.plusCoins(2); | ||
}); | ||
|
||
} | ||
|
||
public List<BuildingCard> getTwoCards() { | ||
return Arrays.asList(new BuildingCard("test", 3, BuildingCard.Color.BLUE), new BuildingCard("test", 2, BuildingCard.Color.BLUE)); | ||
} | ||
|
||
} |
119 changes: 0 additions & 119 deletions
119
packages/backend/domain/src/main/java/tw/waterballsa/gaas/citadels/domain/Game.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.