added MagicPermanentState.DestroyAtEndOfCombat . added Deathgazer

master
beholder 2011-10-09 15:26:11 +02:00
parent 1d184a3fa9
commit bf43c6d7e1
4 changed files with 98 additions and 1 deletions

View File

@ -13095,3 +13095,15 @@ converted=5
cost={4}{G}
pt=3/3
timing=main
>Deathgazer
image=http://magiccards.info/scans/en/9e/124.jpg
value=3
rarity=U
type=Creature
subtype=Lizard
color=b
converted=4
cost={3}{B}
pt=2/2
timing=main

View File

@ -0,0 +1,77 @@
package magic.card;
import magic.model.MagicColor;
import magic.model.MagicGame;
import magic.model.MagicPermanent;
import magic.model.MagicPermanentList;
import magic.model.MagicPermanentState;
import magic.model.action.MagicChangeStateAction;
import magic.model.event.MagicEvent;
import magic.model.trigger.MagicWhenBecomesBlockedTrigger;
import magic.model.trigger.MagicWhenBlocksTrigger;
public class Deathgazer {
public static final MagicWhenBecomesBlockedTrigger T1 = new MagicWhenBecomesBlockedTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) {
if (creature == permanent) {
final MagicPermanentList plist = new MagicPermanentList();
for (final MagicPermanent blocker : permanent.getBlockingCreatures()) {
final int colorFlags = blocker.getColorFlags(game);
if (!MagicColor.Black.hasColor(colorFlags)) {
plist.add(blocker);
}
}
if (!plist.isEmpty()) {
return new MagicEvent(
permanent,
permanent.getController(),
new Object[]{plist},
this,
plist.size() > 1 ?
"Destroy blocking nonblack creatures at end of combat." :
"Destroy blocking nonblack creature at end of combat.");
}
}
return MagicEvent.NONE;
}
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicPermanentList plist = (MagicPermanentList)data[0];
for (final MagicPermanent blocker : plist) {
game.doAction(new MagicChangeStateAction(blocker,MagicPermanentState.DestroyAtEndOfCombat,true));
}
}
};
public static final MagicWhenBlocksTrigger T2 = new MagicWhenBlocksTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent data) {
final MagicPermanent blocked = permanent.getBlockedCreature();
return (permanent == data &&
blocked.isValid() &&
!MagicColor.Black.hasColor(blocked.getColorFlags(game))) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{blocked},
this,
"Destroy " + blocked + " at end of combat."):
MagicEvent.NONE;
}
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicPermanent creature = (MagicPermanent)data[0];
game.doAction(new MagicChangeStateAction(creature,MagicPermanentState.DestroyAtEndOfCombat,true));
}
};
}

View File

@ -19,7 +19,8 @@ public enum MagicPermanentState {
Kicked("kicked",""),
Destroyed("destroyed",""),
ReturnToOwnerAtEndOfTurn("return to owner at end of turn","{R}"),
ExileAtEndOfCombat("exile at end of combat","")
ExileAtEndOfCombat("exile at end of combat",""),
DestroyAtEndOfCombat("destroy at end of combat","")
;
public static final int CLEANUP_MASK=

View File

@ -6,6 +6,7 @@ import magic.model.MagicPermanent;
import magic.model.MagicPermanentList;
import magic.model.MagicPermanentState;
import magic.model.MagicPlayer;
import magic.model.action.MagicDestroyAction;
import magic.model.action.MagicRemoveFromCombatAction;
import magic.model.action.MagicRemoveFromPlayAction;
@ -30,9 +31,12 @@ public class MagicEndOfCombatPhase extends MagicPhase {
public void executeEndOfPhase(final MagicGame game) {
for (final MagicPlayer player : game.getPlayers()) {
final MagicPermanentList toBeExiled = new MagicPermanentList();
final MagicPermanentList toBeDestroyed = new MagicPermanentList();
for (final MagicPermanent permanent : player.getPermanents()) {
if (permanent.hasState(MagicPermanentState.ExileAtEndOfCombat)) {
toBeExiled.add(permanent);
} else if (permanent.hasState(MagicPermanentState.DestroyAtEndOfCombat)) {
toBeDestroyed.add(permanent);
} else if (permanent.isAttacking()||permanent.isBlocking()) {
game.doAction(new MagicRemoveFromCombatAction(permanent));
}
@ -40,6 +44,9 @@ public class MagicEndOfCombatPhase extends MagicPhase {
for (final MagicPermanent permanent : toBeExiled) {
game.doAction(new MagicRemoveFromPlayAction(permanent,MagicLocationType.Exile));
}
for (final MagicPermanent permanent : toBeDestroyed) {
game.doAction(new MagicDestroyAction(permanent));
}
}
}
}