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.
Merge pull request #52 from Game-as-a-Service/feature/kill-continue-w…
…eapon finish RepeatingCrossbow TDD and ATDD
- Loading branch information
Showing
14 changed files
with
844 additions
and
3 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
50 changes: 50 additions & 0 deletions
50
...ain/src/main/java/com/gaas/threeKingdoms/behavior/behavior/RepeatingCrossbowBehavior.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,50 @@ | ||
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.armorcard.ArmorCard; | ||
import com.gaas.threeKingdoms.handcard.equipmentcard.armorcard.RepeatingCrossbowArmorCard; | ||
import com.gaas.threeKingdoms.handcard.equipmentcard.mountscard.PlusMountsCard; | ||
import com.gaas.threeKingdoms.player.Player; | ||
|
||
import java.util.List; | ||
|
||
public class RepeatingCrossbowBehavior extends Behavior { | ||
public RepeatingCrossbowBehavior(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); | ||
ArmorCard armorCard = behaviorPlayer.getEquipment().getArmor(); | ||
String originEquipmentId = ""; | ||
if (armorCard != null) { | ||
originEquipmentId = armorCard.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; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...c/main/java/com/gaas/threeKingdoms/behavior/handler/RepeatingCrossbowBehaviorHandler.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.armorcard.RepeatingCrossbowArmorCard; | ||
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 RepeatingCrossbowBehaviorHandler extends PlayCardBehaviorHandler { | ||
|
||
public RepeatingCrossbowBehaviorHandler(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 RepeatingCrossbowArmorCard).isPresent(); | ||
} | ||
|
||
@Override | ||
protected Behavior doHandle(String playerId, String cardId, List<String> targetPlayerId, 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); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...a/com/gaas/threeKingdoms/handcard/equipmentcard/armorcard/RepeatingCrossbowArmorCard.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,9 @@ | ||
package com.gaas.threeKingdoms.handcard.equipmentcard.armorcard; | ||
|
||
import com.gaas.threeKingdoms.handcard.PlayCard; | ||
|
||
public class RepeatingCrossbowArmorCard extends ArmorCard { | ||
public RepeatingCrossbowArmorCard(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.