DeclareCombatants tested and debugged

This commit is contained in:
Maxmtg
2013-06-02 17:42:54 +00:00
parent ff489765e2
commit 809234fda8
3 changed files with 13 additions and 10 deletions

View File

@@ -138,7 +138,7 @@ public enum ApiType {
DealDamage (DamageDealEffect.class, DamageDealAi.class), DealDamage (DamageDealEffect.class, DamageDealAi.class),
Debuff (DebuffEffect.class, DebuffAi.class), Debuff (DebuffEffect.class, DebuffAi.class),
DebuffAll (DebuffAllEffect.class, DebuffAllAi.class), DebuffAll (DebuffAllEffect.class, DebuffAllAi.class),
DeclaresCombatants(DeclareCombatantsEffect.class, CannotPlayAi.class), DeclareCombatants(DeclareCombatantsEffect.class, CannotPlayAi.class),
DelayedTrigger (DelayedTriggerEffect.class, DelayedTriggerAi.class), DelayedTrigger (DelayedTriggerEffect.class, DelayedTriggerAi.class),
Destroy (DestroyEffect.class, DestroyAi.class), Destroy (DestroyEffect.class, DestroyAi.class),
DestroyAll (DestroyAllEffect.class, DestroyAllAi.class), DestroyAll (DestroyAllEffect.class, DestroyAllAi.class),

View File

@@ -473,7 +473,7 @@ public class PlayerControllerHuman extends PlayerController {
public void declareAttackers(Player attacker) { public void declareAttackers(Player attacker) {
game.getCombat().initiatePossibleDefenders(attacker.getOpponents()); game.getCombat().initiatePossibleDefenders(attacker.getOpponents());
// This input should not modify combat object itself, but should return user choice // This input should not modify combat object itself, but should return user choice
InputSynchronized inpAttack = new InputAttack(player, game.getCombat()); InputSynchronized inpAttack = new InputAttack(attacker, player, game.getCombat());
Singletons.getControl().getInputQueue().setInputAndWait(inpAttack); Singletons.getControl().getInputQueue().setInputAndWait(inpAttack);
} }

View File

@@ -49,10 +49,12 @@ public class InputAttack extends InputSyncronizedBase {
private final Combat combat; private final Combat combat;
private final List<GameEntity> defenders; private final List<GameEntity> defenders;
private GameEntity currentDefender; private GameEntity currentDefender;
private final Player player; private final Player playerAttacks;
private final Player playerDeclares;
public InputAttack(Player human, Combat combat) { public InputAttack(Player attacks, Player declares, Combat combat) {
this.player = human; this.playerAttacks = attacks;
this.playerDeclares = declares;
this.combat = combat; this.combat = combat;
this.defenders = combat.getDefenders(); this.defenders = combat.getDefenders();
} }
@@ -72,7 +74,7 @@ public class InputAttack extends InputSyncronizedBase {
return; // should even throw here! return; // should even throw here!
} }
List<Card> possibleAttackers = player.getCardsIn(ZoneType.Battlefield); List<Card> possibleAttackers = playerAttacks.getCardsIn(ZoneType.Battlefield);
for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) { for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) {
if (!c.hasKeyword("CARDNAME attacks each turn if able.")) if (!c.hasKeyword("CARDNAME attacks each turn if able."))
continue; // do not force continue; // do not force
@@ -87,7 +89,7 @@ public class InputAttack extends InputSyncronizedBase {
} }
private void showCombat() { private void showCombat() {
player.getZone(ZoneType.Battlefield).updateObservers(); // redraw sword icons playerAttacks.getZone(ZoneType.Battlefield).updateObservers(); // redraw sword icons
CombatUtil.showCombat(); CombatUtil.showCombat();
} }
@@ -121,14 +123,14 @@ public class InputAttack extends InputSyncronizedBase {
return; return;
} }
if ( card.getController().isOpponentOf(player) ) { if ( card.getController().isOpponentOf(playerAttacks) ) {
if ( defenders.contains(card) ) { // planeswalker? if ( defenders.contains(card) ) { // planeswalker?
setCurrentDefender(card); setCurrentDefender(card);
return; return;
} }
} }
if (player.getZone(ZoneType.Battlefield).contains(card) && CombatUtil.canAttack(card, currentDefender, combat)) { if (playerAttacks.getZone(ZoneType.Battlefield).contains(card) && CombatUtil.canAttack(card, currentDefender, combat)) {
if( combat.isAttacking(card)) { if( combat.isAttacking(card)) {
combat.removeFromCombat(card); combat.removeFromCombat(card);
} }
@@ -154,7 +156,8 @@ public class InputAttack extends InputSyncronizedBase {
} }
} }
showMessage("Declare Attackers.\nSelecting Creatures to Attack " + currentDefender + String header = playerAttacks == playerDeclares ? "declare attackers." : "declare attackers for " + playerAttacks.getName();
showMessage(playerDeclares.getName() + ", " + header + "\nSelecting Creatures to Attack " + currentDefender +
"\n\nTo attack other players or their planewalkers just click on them"); "\n\nTo attack other players or their planewalkers just click on them");
// This will instantly highlight targets // This will instantly highlight targets