mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
Test and fix for Issue#44: War Falcon - Attack condition does not work properly. Fixed changing controller for game state effects
This commit is contained in:
parent
335462c8c8
commit
f2229f9fd7
4 changed files with 62 additions and 8 deletions
|
@ -122,7 +122,7 @@ class DungeonGeistsEffect extends ReplacementEffectImpl<DungeonGeistsEffect> {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_CONTROL) {
|
||||
if (event.getPlayerId().equals(source.getControllerId()) && event.getTargetId().equals(source.getSourceId())) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -149,4 +149,32 @@ public class ExchangeControlTest extends CardTestPlayerBase {
|
|||
// this one is still on opponent's side
|
||||
assertPermanentCount(playerB, "Elite Vanguard", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests switching controls will affect restriction effect
|
||||
*/
|
||||
@Test
|
||||
public void testRestrictionEffect() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 5);
|
||||
addCard(Constants.Zone.HAND, playerA, "Switcheroo");
|
||||
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "War Falcon");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Llanowar Elves");
|
||||
|
||||
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Switcheroo", "War Falcon^Llanowar Elves");
|
||||
|
||||
attack(2, playerB, "War Falcon");
|
||||
|
||||
setStopAt(2, Constants.PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
// check creatures changes their controllers
|
||||
assertPermanentCount(playerA, "Llanowar Elves", 1);
|
||||
assertPermanentCount(playerB, "War Falcon", 1);
|
||||
|
||||
// War Falcon can't attack
|
||||
assertLife(playerA, 20);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ public class ContinuousEffects implements Serializable {
|
|||
private ContinuousEffectsList<AsThoughEffect> asThoughEffects = new ContinuousEffectsList<AsThoughEffect>();
|
||||
private ContinuousEffectsList<CostModificationEffect> costModificationEffects = new ContinuousEffectsList<CostModificationEffect>();
|
||||
|
||||
private List<ContinuousEffectsList<?>> allEffectsLists = new ArrayList<ContinuousEffectsList<?>>();
|
||||
|
||||
private final ApplyCountersEffect applyCounters;
|
||||
private final PlaneswalkerRedirectionEffect planeswalkerRedirectionEffect;
|
||||
private final AuraReplacementEffect auraReplacementEffect;
|
||||
|
@ -68,6 +70,7 @@ public class ContinuousEffects implements Serializable {
|
|||
applyCounters = new ApplyCountersEffect();
|
||||
planeswalkerRedirectionEffect = new PlaneswalkerRedirectionEffect();
|
||||
auraReplacementEffect = new AuraReplacementEffect();
|
||||
collectAllEffects();
|
||||
}
|
||||
|
||||
public ContinuousEffects(final ContinuousEffects effect) {
|
||||
|
@ -81,6 +84,17 @@ public class ContinuousEffects implements Serializable {
|
|||
restrictionEffects = effect.restrictionEffects.copy();
|
||||
asThoughEffects = effect.asThoughEffects.copy();
|
||||
costModificationEffects = effect.costModificationEffects.copy();
|
||||
collectAllEffects();
|
||||
}
|
||||
|
||||
private void collectAllEffects() {
|
||||
allEffectsLists.add(layeredEffects);
|
||||
allEffectsLists.add(replacementEffects);
|
||||
allEffectsLists.add(preventionEffects);
|
||||
allEffectsLists.add(requirementEffects);
|
||||
allEffectsLists.add(restrictionEffects);
|
||||
allEffectsLists.add(asThoughEffects);
|
||||
allEffectsLists.add(costModificationEffects);
|
||||
}
|
||||
|
||||
public ContinuousEffects copy() {
|
||||
|
@ -427,14 +441,25 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
public void setController(UUID cardId, UUID controllerId) {
|
||||
for (ContinuousEffectsList effectsList : allEffectsLists) {
|
||||
setControllerForEffect(effectsList, cardId, controllerId);
|
||||
}
|
||||
}
|
||||
|
||||
private void setControllerForEffect(ContinuousEffectsList<?> effects, UUID cardId, UUID controllerId) {
|
||||
for (Effect effect : effects) {
|
||||
Ability ability = effects.getAbility(effect.getId());
|
||||
if (ability.getSourceId().equals(cardId)) {
|
||||
ability.setControllerId(controllerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
layeredEffects.clear();
|
||||
replacementEffects.clear();
|
||||
preventionEffects.clear();
|
||||
requirementEffects.clear();
|
||||
restrictionEffects.clear();
|
||||
asThoughEffects.clear();
|
||||
costModificationEffects.clear();
|
||||
for (ContinuousEffectsList effectsList : allEffectsLists) {
|
||||
effectsList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -436,6 +436,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
}
|
||||
this.controllerId = controllerId;
|
||||
this.abilities.setControllerId(controllerId);
|
||||
game.getContinuousEffects().setController(this.objectId, controllerId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue