* Fixed a bug that damage was wrongly still assigned to players during combat that already left the game.

This commit is contained in:
LevelX2 2017-02-04 23:56:03 +01:00
parent a3a6760f4a
commit ff6d79829e
3 changed files with 48 additions and 10 deletions

View file

@ -25,19 +25,19 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.t;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
@ -47,14 +47,18 @@ import mage.filter.common.FilterCreaturePermanent;
*/
public class TrueConviction extends CardImpl {
public TrueConviction (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{W}{W}{W}");
public TrueConviction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{W}{W}");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(DoubleStrikeAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent())));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(LifelinkAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent())));
// Creatures you control have double strike and lifelink.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(DoubleStrikeAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent()));
Effect effect = new GainAbilityControlledEffect(LifelinkAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent());
effect.setText(" and lifelink");
ability.addEffect(effect);
this.addAbility(ability);
}
public TrueConviction (final TrueConviction card) {
public TrueConviction(final TrueConviction card) {
super(card);
}

View file

@ -47,6 +47,7 @@ public class PlayerLeftGameTest extends CardTestMultiPlayerBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
// Start Life = 2
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, 0, 2);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, playerA, "PlayerA");
@ -197,4 +198,35 @@ public class PlayerLeftGameTest extends CardTestMultiPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
}
/**
* Situation: I attacked an opponent with some creatures with True
* Conviction in play. There were multiple "deals combat damage to a
* player"-triggers (Edric, Spymaster of Trest, Daxos of Meletis et al),
* then the opponent lost the game during the first strike combat
* damage-step . In the second combat damage step the triggers went on the
* stack again, although there was no player being dealt damage (multiplayer
* game, so the game wasn't over yet). I don't think these abilities should
* trigger again here.
*/
@Test
public void TestPlayerDiesDuringFirstStrikeDamageStep() {
// Creatures you control have double strike and lifelink.
addCard(Zone.BATTLEFIELD, playerD, "True Conviction");
// Whenever a creature deals combat damage to one of your opponents, its controller may draw a card.
addCard(Zone.BATTLEFIELD, playerD, "Edric, Spymaster of Trest");
addCard(Zone.BATTLEFIELD, playerD, "Dross Crocodile", 8); // Creature 5/1
attack(2, playerD, "Dross Crocodile", playerC);
setStopAt(3, PhaseStep.END_TURN);
execute();
assertLife(playerC, -3);
assertLife(playerD, 7);
assertHandCount(playerD, 2); // 1 (normal draw) + 1 from True Convition
assertPermanentCount(playerC, 0);
}
}

View file

@ -399,7 +399,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
} else {
Player defender = game.getPlayer(defenderId);
defender.damage(amount, attacker.getId(), game, true, true);
if (defender.isInGame()) {
defender.damage(amount, attacker.getId(), game, true, true);
}
}
}