generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
c25b4a9
commit bd4af84
Showing
26 changed files
with
992 additions
and
57 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
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
48 changes: 48 additions & 0 deletions
48
...oms/domain/src/main/java/com/gaas/threeKingdoms/behavior/behavior/PlusMountsBehavior.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,48 @@ | ||
package com.gaas.threeKingdoms.behavior.behavior; | ||
|
||
import com.gaas.threeKingdoms.Game; | ||
import com.gaas.threeKingdoms.Round; | ||
import com.gaas.threeKingdoms.behavior.Behavior; | ||
import com.gaas.threeKingdoms.events.*; | ||
import com.gaas.threeKingdoms.handcard.HandCard; | ||
import com.gaas.threeKingdoms.handcard.equipmentcard.mountscard.PlusMountsCard; | ||
import com.gaas.threeKingdoms.player.Player; | ||
|
||
import java.util.List; | ||
|
||
public class PlusMountsBehavior extends Behavior { | ||
public PlusMountsBehavior(Game game, Player behaviorPlayer, List<String> reactionPlayers, Player currentReactionPlayer, String cardId, String playType, HandCard card) { | ||
super(game, behaviorPlayer, reactionPlayers, currentReactionPlayer, cardId, playType, card, false, true); | ||
} | ||
|
||
@Override | ||
public List<DomainEvent> askTargetPlayerPlayCard() { | ||
playerPlayCard(behaviorPlayer, behaviorPlayer, cardId); | ||
PlusMountsCard mountsCard = behaviorPlayer.getEquipment().getPlusOne(); | ||
String originEquipmentId = ""; | ||
if (mountsCard != null) { | ||
originEquipmentId = mountsCard.getId(); | ||
} | ||
card.effect(behaviorPlayer); | ||
|
||
Round currentRound = game.getCurrentRound(); | ||
RoundEvent roundEvent = new RoundEvent(currentRound); | ||
List<PlayerEvent> playerEvents = game.getPlayers().stream().map(PlayerEvent::new).toList(); | ||
return List.of(new PlayCardEvent( | ||
"出牌", | ||
behaviorPlayer.getId(), | ||
behaviorPlayer.getId(), | ||
cardId, | ||
playType, | ||
game.getGameId(), | ||
playerEvents, | ||
roundEvent, | ||
game.getGamePhase().getPhaseName()), | ||
new PlayEquipmentCardEvent(behaviorPlayer.getId(), cardId, originEquipmentId)); | ||
} | ||
|
||
@Override | ||
protected List<DomainEvent> doAcceptedTargetPlayerPlayCard(String playerId, String targetPlayerId, String cardId, String playType) { | ||
return null; | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...main/src/main/java/com/gaas/threeKingdoms/behavior/handler/PlusMountsBehaviorHandler.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,41 @@ | ||
package com.gaas.threeKingdoms.behavior.handler; | ||
|
||
import com.gaas.threeKingdoms.Game; | ||
import com.gaas.threeKingdoms.behavior.Behavior; | ||
import com.gaas.threeKingdoms.behavior.PlayCardBehaviorHandler; | ||
import com.gaas.threeKingdoms.behavior.behavior.PlusMountsBehavior; | ||
import com.gaas.threeKingdoms.handcard.HandCard; | ||
import com.gaas.threeKingdoms.handcard.equipmentcard.mountscard.PlusMountsCard; | ||
import com.gaas.threeKingdoms.player.Player; | ||
|
||
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
public class PlusMountsBehaviorHandler extends PlayCardBehaviorHandler { | ||
public PlusMountsBehaviorHandler(PlayCardBehaviorHandler next, Game game) { | ||
super(next, game); | ||
} | ||
|
||
@Override | ||
protected boolean match(String playerId, String cardId, List<String> targetPlayerId, String playType) { | ||
Player player = getPlayer(playerId); | ||
Optional<HandCard> card = getCard(cardId, player); | ||
return card.filter(handCard -> handCard instanceof PlusMountsCard).isPresent(); | ||
} | ||
|
||
@Override | ||
protected Behavior doHandle(String playerId, String cardId, List<String> reactionPlayers, String playType) { | ||
Player player = game.getPlayer(playerId); | ||
|
||
List<String> players = game.getPlayers().stream() | ||
.map(Player::getId) | ||
.collect(Collectors.toList()); | ||
|
||
HandCard card = player.getHand().getCard(cardId).orElseThrow(NoSuchElementException::new); | ||
|
||
return new PlusMountsBehavior(game, player, players, player, cardId, playType, card); | ||
} | ||
|
||
} |
2 changes: 0 additions & 2 deletions
2
...ndsOfTheThreeKingdoms/domain/src/main/java/com/gaas/threeKingdoms/events/PlayerEvent.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
7 changes: 7 additions & 0 deletions
7
...ingdoms/domain/src/main/java/com/gaas/threeKingdoms/exception/DistanceErrorException.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,7 @@ | ||
package com.gaas.threeKingdoms.exception; | ||
|
||
public class DistanceErrorException extends RuntimeException { | ||
public DistanceErrorException(String e){ | ||
super(e); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...c/main/java/com/gaas/threeKingdoms/handcard/equipmentcard/mountscard/MinusMountsCard.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,16 @@ | ||
package com.gaas.threeKingdoms.handcard.equipmentcard.mountscard; | ||
|
||
import com.gaas.threeKingdoms.handcard.PlayCard; | ||
import com.gaas.threeKingdoms.handcard.equipmentcard.EquipmentCard; | ||
import com.gaas.threeKingdoms.player.Player; | ||
|
||
public class MinusMountsCard extends EquipmentCard { | ||
public MinusMountsCard(PlayCard playCard) { | ||
super(playCard); | ||
} | ||
|
||
@Override | ||
public void effect(Player player) { | ||
player.getEquipment().setMinusOne(this); | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
...in/src/main/java/com/gaas/threeKingdoms/handcard/equipmentcard/mountscard/MountsCard.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...rc/main/java/com/gaas/threeKingdoms/handcard/equipmentcard/mountscard/PlusMountsCard.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,16 @@ | ||
package com.gaas.threeKingdoms.handcard.equipmentcard.mountscard; | ||
|
||
import com.gaas.threeKingdoms.handcard.equipmentcard.EquipmentCard; | ||
import com.gaas.threeKingdoms.handcard.PlayCard; | ||
import com.gaas.threeKingdoms.player.Player; | ||
|
||
public class PlusMountsCard extends EquipmentCard { | ||
|
||
public PlusMountsCard(PlayCard playCard) { | ||
super(playCard); | ||
} | ||
@Override | ||
public void effect(Player player) { | ||
player.getEquipment().setPlusOne(this); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...n/src/main/java/com/gaas/threeKingdoms/handcard/equipmentcard/mountscard/ShadowHorse.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,11 @@ | ||
package com.gaas.threeKingdoms.handcard.equipmentcard.mountscard; | ||
|
||
import com.gaas.threeKingdoms.handcard.PlayCard; | ||
|
||
public class ShadowHorse extends PlusMountsCard { | ||
|
||
|
||
public ShadowHorse(PlayCard playCard) { | ||
super(playCard); | ||
} | ||
} |
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.