Merge pull request #6502 from SpeedProg/angel_of_serenity_mp_fix

Multiplayer test and fix for Angel of Serenity leaves battlefied trig…
This commit is contained in:
Oleg Agafonov 2020-05-03 19:56:21 +02:00 committed by GitHub
commit f3990caf22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 1 deletions

View file

@ -0,0 +1,69 @@
package org.mage.test.multiplayer;
import mage.constants.MultiplayerAttackOption;
import mage.constants.PhaseStep;
import mage.constants.RangeOfInfluence;
import mage.constants.Zone;
import mage.game.FreeForAll;
import mage.game.Game;
import mage.game.GameException;
import mage.game.mulligan.MulliganType;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestMultiPlayerBase;
import java.io.FileNotFoundException;
public class AngelOfSerenityTest extends CardTestMultiPlayerBase {
@Override
protected Game createNewGameAndPlayers() throws GameException, FileNotFoundException {
// Start Life = 2
Game game = new FreeForAll(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, MulliganType.GAME_DEFAULT.getMulligan(0), 2);
// Player order: A -> D -> C -> B
playerA = createPlayer(game, playerA, "PlayerA");
playerB = createPlayer(game, playerB, "PlayerB");
playerC = createPlayer(game, playerC, "PlayerC");
playerD = createPlayer(game, playerD, "PlayerD");
return game;
}
/**
* In a multiplayer game when Angel of Serenity leaves the Battlefield because the OWNER leaves the game 800.4a,
* it should return the exiled creatures if Angel of Serenity is controlled by a player that does not leave,
* since then 800.4d does not apply.
* 20200417 - 800.4a/800.4d
*/
@Test
public void TestAngelOfSerenityTakeoverExileReturn() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 7); // add mana to cast card to take over Angel
addCard(Zone.HAND, playerA, "Agent of Treachery");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 3);
addCard(Zone.BATTLEFIELD, playerB, "Dromoka Dunecaster", 3);
addCard(Zone.BATTLEFIELD, playerC, "Plains", 7);
addCard(Zone.HAND, playerC, "Angel of Serenity"); // {4}{W}{W}{W}
// player C turn is 3
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerC, "Angel of Serenity");
addTarget(playerC, "Dromoka Dunecaster^Dromoka Dunecaster^Dromoka Dunecaster");
// player A 2nd turn is 5
castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, "Agent of Treachery");
addTarget(playerA, "Angel of Serenity");
concede(5, PhaseStep.POSTCOMBAT_MAIN, playerC);
setStopAt(6, PhaseStep.UPKEEP);
execute();
assertAllCommandsUsed();
Assert.assertFalse("Player of Angel of Serenity did not leave the game", playerC.isInGame());
assertPermanentCount(playerA, 8);
assertPermanentCount(playerB, 3);
assertHandCount(playerB, 4);
}
}

View file

@ -2581,6 +2581,9 @@ public abstract class GameImpl implements Game, Serializable {
}
}
}
for(Card card : toOutside) {
rememberLKI(card.getId(), Zone.BATTLEFIELD, card);
}
// needed to send event that permanent leaves the battlefield to allow non stack effects to execute
player.moveCards(toOutside, Zone.OUTSIDE, null, this);
// triggered abilities that don't use the stack have to be executed

View file

@ -3987,7 +3987,7 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Card card : cards) {
if (card instanceof Permanent) {
game.getBattlefield().removePermanent(card.getId());
ZoneChangeEvent event = new ZoneChangeEvent(card.getId(),
ZoneChangeEvent event = new ZoneChangeEvent((Permanent)card,
(source == null ? null : source.getSourceId()),
byOwner ? card.getOwnerId() : getId(), Zone.BATTLEFIELD, Zone.OUTSIDE, appliedEffects);
game.fireEvent(event);