"Can be wounded X times check" now takes into account "can't take more than X wounds" effects into account.

This commit is contained in:
marcins78@gmail.com
2012-01-05 12:02:28 +00:00
parent 742fa6c031
commit 08b890e8ba
9 changed files with 11 additions and 11 deletions

View File

@@ -215,7 +215,7 @@ public class PlayConditions {
public boolean visitPhysicalCard(PhysicalCard physicalCard) {
if (filter.accepts(gameState, modifiersQuerying, physicalCard)
&& modifiersQuerying.getVitality(gameState, physicalCard) > times
&& modifiersQuerying.canTakeWound(gameState, physicalCard))
&& modifiersQuerying.canTakeWounds(gameState, physicalCard, times))
_woundableCount++;
return _woundableCount >= count;
}

View File

@@ -32,7 +32,7 @@ public class CantTakeMoreThanXWoundsModifier extends AbstractModifier {
}
@Override
public boolean canTakeWound(GameState gameState, ModifiersQuerying modifiersLogic, PhysicalCard physicalCard, int woundsAlreadyTaken) {
return woundsAlreadyTaken < _count;
public boolean canTakeWounds(GameState gameState, ModifiersQuerying modifiersLogic, PhysicalCard physicalCard, int woundsAlreadyTaken, int woundsToTake) {
return woundsAlreadyTaken + woundsToTake <= _count;
}
}

View File

@@ -18,7 +18,7 @@ public class CantTakeWoundsModifier extends AbstractModifier {
}
@Override
public boolean canTakeWound(GameState gameState, ModifiersQuerying modifiersLogic, PhysicalCard physicalCard, int woundsAlreadyTaken) {
public boolean canTakeWounds(GameState gameState, ModifiersQuerying modifiersLogic, PhysicalCard physicalCard, int woundsAlreadyTaken, int woundsToTake) {
return false;
}
}

View File

@@ -339,7 +339,7 @@ public class Filters {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canTakeWound(gameState, physicalCard) && modifiersQuerying.getVitality(gameState, physicalCard) >= count;
return modifiersQuerying.canTakeWounds(gameState, physicalCard, count) && modifiersQuerying.getVitality(gameState, physicalCard) >= count;
}
};
}

View File

@@ -54,7 +54,7 @@ public class WoundCharactersEffect extends AbstractPreventableCardEffect {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canTakeWound(gameState, physicalCard);
return modifiersQuerying.canTakeWounds(gameState, physicalCard, 1);
}
};
}

View File

@@ -132,7 +132,7 @@ public abstract class AbstractModifier implements Modifier {
}
@Override
public boolean canTakeWound(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int woundsAlreadyTaken) {
public boolean canTakeWounds(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int woundsAlreadyTaken, int woundsToTake) {
return true;
}

View File

@@ -54,7 +54,7 @@ public interface Modifier {
public int getOverwhelmMultiplier(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard);
public boolean canTakeWound(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int woundsAlreadyTakenInPhase);
public boolean canTakeWounds(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int woundsAlreadyTakenInPhase, int woundsToTake);
public boolean canTakeArcheryWound(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard);

View File

@@ -444,14 +444,14 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
}
@Override
public boolean canTakeWound(GameState gameState, PhysicalCard card) {
public boolean canTakeWounds(GameState gameState, PhysicalCard card, int woundsToTake) {
LoggingThreadLocal.logMethodStart(card, "canTakeWound");
try {
for (Modifier modifier : getModifiersAffectingCard(gameState, ModifierEffect.WOUND_MODIFIER, card)) {
Integer woundsTaken = _woundsPerPhaseMap.get(card.getCardId());
if (woundsTaken == null)
woundsTaken = 0;
if (!modifier.canTakeWound(gameState, this, card, woundsTaken))
if (!modifier.canTakeWounds(gameState, this, card, woundsTaken, woundsToTake))
return false;
}
return true;

View File

@@ -53,7 +53,7 @@ public interface ModifiersQuerying {
public boolean isAdditionalCardType(GameState gameState, PhysicalCard card, CardType cardType);
// Wounds/exertions
public boolean canTakeWound(GameState gameState, PhysicalCard card);
public boolean canTakeWounds(GameState gameState, PhysicalCard card, int woundsToTake);
public boolean canTakeArcheryWound(GameState gameState, PhysicalCard card);