use of mage.game.permanent.PermanentToken in project mage by magefree.
the class GarthOneEyeTest method testBlackLotus.
@Test
public void testBlackLotus() {
addCard(Zone.BATTLEFIELD, playerA, garth);
setChoice(playerA, lotus);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Choose");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
assertTapped(garth, true);
Permanent permanent = getPermanent(lotus);
Assert.assertNotNull(lotus + " should be on the battlefield", permanent);
Assert.assertTrue(lotus + " should be a token", permanent instanceof PermanentToken);
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class MillicentRestlessRevenantTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent;
switch(event.getType()) {
case ZONE_CHANGE:
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
permanent = zEvent.getTarget();
break;
case DAMAGED_PLAYER:
if (!((DamagedEvent) event).isCombatDamage()) {
return false;
}
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
break;
default:
return false;
}
if (permanent == null) {
return false;
}
return permanent.getId().equals(this.getSourceId()) || (!(permanent instanceof PermanentToken) && permanent.hasSubtype(SubType.SPIRIT, game));
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class EmbalmedThisTurnWatcher method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
for (Permanent entering : game.getPermanentsEntering().values()) {
if (!entering.getId().equals(copyToObjectId) || !(entering instanceof PermanentToken)) {
continue;
}
UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId();
EmbalmedThisTurnWatcher watcher = game.getState().getWatcher(EmbalmedThisTurnWatcher.class);
if (watcher == null) {
continue;
}
for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) {
if (!Objects.equals(mor.getSourceId(), originalCardId) || game.getState().getZoneChangeCounter(originalCardId) != mor.getZoneChangeCounter()) {
continue;
}
blueprint.getManaCost().clear();
if (!blueprint.getSubtype().contains(SubType.ZOMBIE)) {
blueprint.getSubtype().add(SubType.ZOMBIE);
}
blueprint.getColor().setColor(ObjectColor.WHITE);
}
}
return true;
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class VileRedeemerNonTokenCreaturesDiedWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().isCreature(game) && !(zEvent.getTarget() instanceof PermanentToken)) {
int count = getAmountOfNontokenCreatureDiedThisTurn(zEvent.getTargetId());
amountOfCreaturesThatDied.put(zEvent.getTarget().getControllerId(), ++count);
}
}
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class WorldgorgerDragonLeavesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exile != null) {
return controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
return false;
}
Aggregations