merged changes to main repo with new cards

master
melvin 2012-09-23 14:08:13 +08:00
commit cd11dca989
50 changed files with 498 additions and 472 deletions

View File

@ -180,7 +180,8 @@ inf: $(MAG)
%.t: $(MAG)
echo `hg id -n` > $*.log
$(JAVAEA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release -DselfMode -jar $^ >> $*.log 2>&1
$(JAVA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release magic.DeckStrCal --str1 1 --str2 1 --life 10 --games 1 --repeat 1000000 >> $*.log 2>&1
#$(JAVAEA) -DrndSeed=$* -Dmagarena.dir=`pwd`/release -DselfMode -jar $^ >> $*.log 2>&1
test: $(MAG)
-make `date +%s`.d
@ -409,7 +410,7 @@ update_value_from_rankings: cards/gatherer_rankings
hg add $^
check_data: scripts/check_data.awk
for i in src/magic/card/*; do \
for i in src/magic/card/* src/magic/model/event/* src/magic/model/trigger/* ; do \
grep "new Object\|data\[[0-9\]" $$i > /dev/null && echo $$i; \
grep "new Object\|data\[[0-9\]" $$i | awk -f $^ | sed 's/ //g' | sed 's/:/:\t/'; \
done > $@

View File

@ -5,6 +5,7 @@ import magic.ai.MagicAIImpl;
import magic.data.DeckUtils;
import magic.data.DuelConfig;
import magic.model.MagicGame;
import magic.model.MagicGameReport;
import magic.model.MagicDuel;
import magic.ui.GameController;
@ -13,8 +14,10 @@ import java.io.File;
public class DeckStrCal {
private static int games = 10;
private static int repeat = 1;
private static int str1 = 6;
private static int str2 = 6;
private static int life = 20;
private static String deck1 = "";
private static String deck2 = "";
private static MagicAIImpl ai1 = MagicAIImpl.MMAB;
@ -65,24 +68,35 @@ public class DeckStrCal {
System.err.println("Error: " + next + " is not valid AI");
validArgs = false;
}
}
else {
} else if ("--life".equals(curr)) {
try { //parse CLI option
life = Integer.parseInt(next);
} catch (final NumberFormatException ex) {
System.err.println("ERROR! starting life is not an integer");
validArgs = false;
}
} else if ("--repeat".equals(curr)) {
try { //parse CLI option
repeat = Integer.parseInt(next);
} catch (final NumberFormatException ex) {
System.err.println("ERROR! repeat is not an integer");
validArgs = false;
}
} else {
System.err.println("Error: unknown option " + curr);
validArgs = false;
}
}
if (deck1.length() == 0) {
System.err.println("Error: no file specified for deck 1");
validArgs = false;
System.err.println("Using player profile to generate deck 1");
} else if (!(new File(deck1)).exists()) {
System.err.println("Error: file " + deck1 + " does not exist");
validArgs = false;
}
if (deck2.length() == 0) {
System.err.println("Error: no file specified for deck 2");
validArgs = false;
System.err.println("Using player profile to generate deck 2");
} else if (!(new File(deck2)).exists()) {
System.err.println("Error: file " + deck2 + " does not exist");
validArgs = false;
@ -92,12 +106,10 @@ public class DeckStrCal {
}
private static MagicDuel setupDuel() {
// Load cards and cubes.
MagicMain.initializeEngine();
// Set number of games.
final DuelConfig config=new DuelConfig();
config.setNrOfGames(games);
config.setStartLife(life);
// Set difficulty.
final MagicDuel testDuel=new MagicDuel(config);
@ -111,13 +123,20 @@ public class DeckStrCal {
testDuel.getPlayer(1).setArtificial(true);
// Set the deck.
DeckUtils.loadDeck(deck1, testDuel.getPlayer(0));
DeckUtils.loadDeck(deck2, testDuel.getPlayer(1));
if (deck1.length() > 0) {
DeckUtils.loadDeck(deck1, testDuel.getPlayer(0));
}
if (deck2.length() > 0) {
DeckUtils.loadDeck(deck2, testDuel.getPlayer(1));
}
return testDuel;
}
public static void main(final String[] args) {
// setup the handler for any uncaught exception
Thread.setDefaultUncaughtExceptionHandler(new magic.model.MagicGameReport());
if (!parseArguments(args)) {
System.err.println("Usage: java -cp <path to Magarena.jar/exe> magic.DeckStrCal --deck1 <.dec file> --deck2 <.dec file> [options]");
System.err.println("Options:");
@ -127,7 +146,16 @@ public class DeckStrCal {
System.err.println("--games <1-*> (number of games to play, default 10)");
System.exit(1);
}
// Load cards and cubes.
MagicMain.initializeEngine();
for (int i = 0; i < repeat; i++) {
runDuel();
}
}
private static void runDuel() {
final MagicDuel testDuel = setupDuel();
System.out.println(

View File

@ -33,12 +33,13 @@ public class Kjeldoran_Javelineer {
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
final int amount = source.getCounters(MagicCounterType.Charge);
return new MagicEvent(
source,
MagicTargetChoice.NEG_TARGET_ATTACKING_OR_BLOCKING_CREATURE,
new MagicDamageTargetPicker(amount),
new Object[]{source,amount},
this,
"SN deals " + amount + " damage to target creature$.");
source,
MagicTargetChoice.NEG_TARGET_ATTACKING_OR_BLOCKING_CREATURE,
new MagicDamageTargetPicker(amount),
new Object[]{amount},
this,
"SN deals " + amount + " damage to target creature$."
);
}
@Override
@ -46,10 +47,10 @@ public class Kjeldoran_Javelineer {
event.processTarget(game,choiceResults,0,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final MagicDamage damage = new MagicDamage(
(MagicSource)data[0],
target,
(Integer)data[1],
false);
event.getSource(),
target,
(Integer)data[0],
false);
game.doAction(new MagicDealDamageAction(damage));
}
});

View File

@ -18,13 +18,15 @@ import magic.model.mstatic.MagicLayer;
public class MagicCardActivation extends MagicActivation {
public MagicCardActivation(final MagicCardDefinition cdef) {
super(0,
new MagicCondition[]{
MagicCondition.CARD_CONDITION,
cdef.getCost().getCondition()},
cdef.getActivationHints(),
"Play"
);
super(
0,
new MagicCondition[]{
MagicCondition.CARD_CONDITION,
cdef.getCost().getCondition()
},
cdef.getActivationHints(),
"Play"
);
setCardDefinition(cdef);
}
@ -46,12 +48,16 @@ public class MagicCardActivation extends MagicActivation {
@Override
public MagicEvent getEvent(final MagicSource source) {
return new MagicEvent(source,source.getController(),new Object[]{source},this,"Play "+source.getName()+".");
return new MagicEvent(
source,
this,
"Play SN."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final MagicCard card=(MagicCard)data[0];
final MagicCard card = event.getCard();
if (card.getCardDefinition().isLand()) {
game.incLandPlayed();
}

View File

@ -10,22 +10,6 @@ import magic.model.stack.MagicItemOnStack;
public class MagicCounterUnlessEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object choiceResults[]) {
final MagicItemOnStack itemOnStack=(MagicItemOnStack)data[0];
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
MagicEvent.payManaCost(game,itemOnStack.getController(),choiceResults,1);
} else {
game.doAction(new MagicCounterItemOnStackAction(itemOnStack));
}
}
};
public MagicCounterUnlessEvent(final MagicSource source,final MagicItemOnStack itemOnStack,final MagicManaCost cost) {
super(
source,
@ -40,4 +24,20 @@ public class MagicCounterUnlessEvent extends MagicEvent {
"If you don't, counter "+itemOnStack.getName()+"."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object choiceResults[]) {
final MagicItemOnStack itemOnStack=(MagicItemOnStack)data[0];
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
MagicEvent.payManaCost(game,itemOnStack.getController(),choiceResults,1);
} else {
game.doAction(new MagicCounterItemOnStackAction(itemOnStack));
}
}
};
}

View File

@ -6,24 +6,23 @@ import magic.model.MagicSource;
import magic.model.action.MagicDrawAction;
public class MagicDrawEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choices) {
game.doAction(new MagicDrawAction((MagicPlayer)data[0],(Integer)data[1]));
}
};
public MagicDrawEvent(final MagicSource source,final MagicPlayer player,final int amount) {
super(
source,
player,
new Object[]{player,amount},
new Object[]{amount},
EVENT_ACTION,
player.getName() + genDescription(amount)
"PN " + genDescription(amount)
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choices) {
game.doAction(new MagicDrawAction(event.getPlayer(),(Integer)data[0]));
}
};
private static final String genDescription(final int amount) {
if (amount!=1) {
return " draws "+amount+" cards.";

View File

@ -24,7 +24,7 @@ public class MagicEquipActivation extends MagicPermanentActivation {
},
new MagicActivationHints(MagicTiming.Equipment,false,2),
"Equip"
);
);
this.equipCost=equipCost;
}
@ -36,20 +36,19 @@ public class MagicEquipActivation extends MagicPermanentActivation {
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
MagicTargetChoice.TARGET_CREATURE_YOU_CONTROL,
new MagicEquipTargetPicker(source),
new Object[]{source},
this,
"Attach " + source + " to target creature$ you control.");
source,
MagicTargetChoice.TARGET_CREATURE_YOU_CONTROL,
new MagicEquipTargetPicker(source),
this,
"Attach SN to target creature$ you control."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
event.processTargetPermanent(game,choiceResults,0,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicAttachEquipmentAction((MagicPermanent)data[0],creature));
game.doAction(new MagicAttachEquipmentAction(event.getPermanent(),creature));
}
});
}

View File

@ -7,17 +7,18 @@ import magic.model.action.MagicRemoveFromPlayAction;
public class MagicExileEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
public MagicExileEvent(final MagicPermanent permanent) {
super(
permanent,
EVENT_ACTION,
"Exile SN."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicRemoveFromPlayAction((MagicPermanent)data[0],MagicLocationType.Exile));
game.doAction(new MagicRemoveFromPlayAction(event.getPermanent(),MagicLocationType.Exile));
}
};
public MagicExileEvent(final MagicPermanent permanent) {
super(permanent,permanent.getController(),new Object[]{permanent},EVENT_ACTION,"Exile "+permanent.getName()+".");
}
}
}

View File

@ -23,22 +23,22 @@ public class MagicGainActivation extends MagicPermanentActivation {
@Override
public MagicEvent[] getCostEvent(final MagicSource source) {
return new MagicEvent[]{
new MagicPayManaCostEvent(source,source.getController(),cost),
new MagicPlayAbilityEvent((MagicPermanent)source)};
new MagicPayManaCostEvent(source,source.getController(),cost),
new MagicPlayAbilityEvent((MagicPermanent)source)
};
}
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
new Object[]{source},
this,
source + " gains "+ability+" until end of turn.");
source,
this,
"SN gains "+ability+" until end of turn."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicSetAbilityAction((MagicPermanent)data[0],ability));
game.doAction(new MagicSetAbilityAction(event.getPermanent(),ability));
}
}

View File

@ -23,11 +23,13 @@ public class MagicLevelUpActivation extends MagicPermanentActivation {
MagicCondition.SORCERY_CONDITION,
new MagicArtificialCondition(
MagicCondition.NONE,
new MaximumCondition(maximum)),
cost.getCondition()
new MaximumCondition(maximum)
),
cost.getCondition()
},
ACTIVATION_HINTS,
"Level");
"Level"
);
this.cost=cost;
}
@ -39,16 +41,15 @@ public class MagicLevelUpActivation extends MagicPermanentActivation {
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
new Object[]{source},
this,
"Put a level counter on "+source+'.');
source,
this,
"Put a level counter on SN."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicChangeCountersAction((MagicPermanent)data[0],MagicCounterType.Charge,1,true));
game.doAction(new MagicChangeCountersAction(event.getPermanent(),MagicCounterType.Charge,1,true));
}
private static final class MaximumCondition implements MagicCondition {

View File

@ -9,20 +9,21 @@ import magic.model.action.MagicTapAction;
public class MagicPainTapEvent extends MagicEvent {
public MagicPainTapEvent(final MagicSource source) {
super(
source,
EVENT_ACTION,
"Tap SN. SN deals 1 damage to you."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final MagicPermanent permanent=(MagicPermanent)data[0];
final MagicPermanent permanent=event.getPermanent();
final MagicDamage damage=new MagicDamage(permanent,permanent.getController(),1,false);
game.doAction(new MagicTapAction(permanent,true));
game.doAction(new MagicDealDamageAction(damage));
}
};
public MagicPainTapEvent(final MagicSource source) {
super(source,source.getController(),new Object[]{source},EVENT_ACTION,"Tap "+source.getName()+". "+source.getName()+" deals 1 damage to you.");
}
}
}

View File

@ -7,18 +7,20 @@ import magic.model.action.MagicChangeLifeAction;
public class MagicPayLifeEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
public MagicPayLifeEvent(final MagicSource source,final MagicPlayer player,final int amount) {
super(
source,
player,
new Object[]{-amount},
EVENT_ACTION,
"Pay "+amount+" life."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choices) {
game.doAction(new MagicChangeLifeAction((MagicPlayer)data[0],(Integer)data[1]));
game.doAction(new MagicChangeLifeAction(event.getPlayer(),(Integer)data[0]));
}
};
public MagicPayLifeEvent(final MagicSource source,final MagicPlayer player,final int amount) {
super(source,player,new Object[]{player,-amount},EVENT_ACTION,"Pay "+amount+" life.");
}
}
}

View File

@ -13,22 +13,6 @@ import magic.model.stack.MagicAbilityOnStack;
public abstract class MagicPermanentActivation extends MagicActivation implements MagicChangeCardDefinition {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public final void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object[] data,
final Object[] choiceResults) {
final MagicPermanentActivation permanentActivation = (MagicPermanentActivation)data[0];
final MagicPermanent permanent = (MagicPermanent)data[1];
final MagicAbilityOnStack abilityOnStack =
new MagicAbilityOnStack(permanentActivation,permanent,game.getPayedCost());
game.doAction(new MagicPutItemOnStackAction(abilityOnStack));
}
};
private static int currentIndex = 1;
public MagicPermanentActivation(
@ -46,13 +30,30 @@ public abstract class MagicPermanentActivation extends MagicActivation implement
@Override
public final MagicEvent getEvent(final MagicSource source) {
return new MagicEvent(
source,
source.getController(),
new Object[]{this,source},
EVENT_ACTION,
"Play activated ability of "+source.getName()+"."
);
source,
new Object[]{this},
EVENT_ACTION,
"Play activated ability of SN."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public final void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object[] data,
final Object[] choiceResults) {
final MagicPermanentActivation permanentActivation = (MagicPermanentActivation)data[0];
final MagicPermanent permanent = event.getPermanent();
final MagicAbilityOnStack abilityOnStack = new MagicAbilityOnStack(
permanentActivation,
permanent,
game.getPayedCost()
);
game.doAction(new MagicPutItemOnStackAction(abilityOnStack));
}
};
@Override
public final MagicTargetChoice getTargetChoice(final MagicSource source) {

View File

@ -31,13 +31,12 @@ public class MagicPingActivation extends MagicPermanentActivation {
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
MagicTargetChoice.NEG_TARGET_CREATURE_OR_PLAYER,
new MagicDamageTargetPicker(n),
new Object[]{source},
this,
source + " deals " + n + " damage to target creature or player$.");
source,
MagicTargetChoice.NEG_TARGET_CREATURE_OR_PLAYER,
new MagicDamageTargetPicker(n),
this,
"SN deals " + n + " damage to target creature or player$."
);
}
@Override
public void executeEvent(
@ -47,7 +46,7 @@ public class MagicPingActivation extends MagicPermanentActivation {
final Object[] choiceResults) {
event.processTarget(game,choiceResults,0,new MagicTargetAction() {
public void doAction(final MagicTarget target) {
final MagicDamage damage=new MagicDamage((MagicSource)data[0],target,n,false);
final MagicDamage damage=new MagicDamage(event.getSource(),target,n,false);
game.doAction(new MagicDealDamageAction(damage));
}
});

View File

@ -11,17 +11,6 @@ import magic.model.choice.MagicPayManaCostChoice;
public class MagicPlayOgreUnlessEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object choiceResults[]) {
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
MagicEvent.payManaCost(game,event.getPlayer(),choiceResults,1);
} else {
game.doAction(new MagicPlayTokenAction((MagicPlayer)data[0],TokenCardDefinitions.get("Ogre")));
}
}
};
public MagicPlayOgreUnlessEvent(final MagicSource source,final MagicPlayer player,final MagicPlayer controller,final MagicManaCost cost) {
super(
source,
@ -35,4 +24,15 @@ public class MagicPlayOgreUnlessEvent extends MagicEvent {
"You may$ pay "+cost.getText()+"$."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object choiceResults[]) {
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
MagicEvent.payManaCost(game,event.getPlayer(),choiceResults,1);
} else {
game.doAction(new MagicPlayTokenAction((MagicPlayer)data[0],TokenCardDefinitions.get("Ogre")));
}
}
};
}

View File

@ -30,15 +30,14 @@ public class MagicPumpActivation extends MagicPermanentActivation {
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
new Object[]{source},
this,
source+" gets +"+power+"/+"+toughness+" until end of turn.");
source,
this,
"SN gets +"+power+"/+"+toughness+" until end of turn."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicChangeTurnPTAction((MagicPermanent)data[0],power,toughness));
game.doAction(new MagicChangeTurnPTAction(event.getPermanent(),power,toughness));
}
}

View File

@ -22,7 +22,8 @@ public class MagicRegenerationActivation extends MagicPermanentActivation {
new MagicSingleActivationCondition(),
},
ACTIVATION_HINTS,
"Regen");
"Regen"
);
this.cost=cost;
}
@ -34,15 +35,14 @@ public class MagicRegenerationActivation extends MagicPermanentActivation {
@Override
public MagicEvent getPermanentEvent(final MagicPermanent source,final MagicPayedCost payedCost) {
return new MagicEvent(
source,
source.getController(),
new Object[]{source},
this,
"Regenerate "+source+".");
source,
this,
"Regenerate SN."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicRegenerateAction((MagicPermanent)data[0]));
game.doAction(new MagicRegenerateAction(event.getPermanent()));
}
}

View File

@ -7,24 +7,28 @@ import magic.model.action.MagicChangeCountersAction;
public class MagicRemoveCounterEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final int amount=(Integer)data[2];
game.doAction(new MagicChangeCountersAction((MagicPermanent)data[0],(MagicCounterType)data[1],-amount,true));
}
};
public MagicRemoveCounterEvent(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
super(
permanent,
permanent.getController(),
new Object[]{permanent,counterType,amount},
new Object[]{counterType,amount},
EVENT_ACTION,
genDescription(permanent,counterType,amount));
genDescription(permanent,counterType,amount)
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final int amount=(Integer)data[1];
game.doAction(new MagicChangeCountersAction(
event.getPermanent(),
(MagicCounterType)data[0],
-amount,
true
));
}
};
private static String genDescription(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
final StringBuilder description=new StringBuilder("Remove ");
if (amount==1) {

View File

@ -6,14 +6,18 @@ import magic.model.action.MagicSacrificeAction;
public class MagicSacrificeEvent extends MagicEvent {
public MagicSacrificeEvent(final MagicPermanent permanent) {
super(
permanent,
EVENT_ACTION,
"Sacrifice SN."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicSacrificeAction((MagicPermanent)data[0]));
game.doAction(new MagicSacrificeAction(event.getPermanent()));
}
};
public MagicSacrificeEvent(final MagicPermanent permanent) {
super(permanent,permanent.getController(),new Object[]{permanent},EVENT_ACTION,"Sacrifice "+permanent.getName()+".");
}
}

View File

@ -5,16 +5,6 @@ import magic.model.stack.MagicItemOnStack;
public class MagicStackChangeTargetsEvent extends MagicEvent {
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
final MagicItemOnStack itemOnStack=(MagicItemOnStack)data[0];
itemOnStack.getChoiceResults()[0]=choiceResults[0];
}
};
public MagicStackChangeTargetsEvent(final MagicItemOnStack itemOnStack) {
super(
itemOnStack.getSource(),
@ -23,6 +13,15 @@ public class MagicStackChangeTargetsEvent extends MagicEvent {
itemOnStack.getEvent().getTargetPicker(),
new Object[]{itemOnStack},
EVENT_ACTION,
"");
""
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
final MagicItemOnStack itemOnStack=(MagicItemOnStack)data[0];
itemOnStack.getChoiceResults()[0]=choiceResults[0];
}
};
}

View File

@ -10,6 +10,18 @@ import magic.model.trigger.MagicTriggerType;
import magic.model.trigger.MagicTrigger;
public class MagicStackGetChoicesEvent extends MagicEvent {
public MagicStackGetChoicesEvent(final MagicItemOnStack itemOnStack) {
super(
itemOnStack.getEvent().getSource(),
itemOnStack.getController(),
itemOnStack.getEvent().getChoice(),
itemOnStack.getEvent().getTargetPicker(),
new Object[]{itemOnStack},
EVENT_ACTION,
""
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(
@ -40,15 +52,4 @@ public class MagicStackGetChoicesEvent extends MagicEvent {
}
}
};
public MagicStackGetChoicesEvent(final MagicItemOnStack itemOnStack) {
super(
itemOnStack.getEvent().getSource(),
itemOnStack.getController(),
itemOnStack.getEvent().getChoice(),
itemOnStack.getEvent().getTargetPicker(),
new Object[]{itemOnStack},
EVENT_ACTION,
"");
}
}

View File

@ -5,15 +5,18 @@ import magic.model.MagicPermanent;
import magic.model.action.MagicTapAction;
public class MagicTapEvent extends MagicEvent {
public MagicTapEvent(final MagicPermanent permanent) {
super(
permanent,
EVENT_ACTION,
"Tap SN."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicTapAction((MagicPermanent)data[0],true));
game.doAction(new MagicTapAction(event.getPermanent(),true));
}
};
public MagicTapEvent(final MagicPermanent permanent) {
super(permanent,permanent.getController(),new Object[]{permanent},EVENT_ACTION,"Tap "+permanent.getName()+".");
}
}

View File

@ -5,18 +5,18 @@ import magic.model.MagicPermanent;
import magic.model.action.MagicUntapAction;
public class MagicUntapEvent extends MagicEvent {
public MagicUntapEvent(final MagicPermanent permanent) {
super(
permanent,
EVENT_ACTION,
"Untap SN."
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicUntapAction((MagicPermanent)data[0]));
game.doAction(new MagicUntapAction(event.getPermanent()));
}
};
public MagicUntapEvent(final MagicPermanent permanent) {
super(permanent,permanent.getController(),new Object[]{permanent},EVENT_ACTION,"Untap "+permanent.getName()+".");
}
}
}

View File

@ -23,12 +23,11 @@ public class MagicAnnihilatorTrigger extends MagicWhenAttacksTrigger {
final MagicPlayer opponent = permanent.getController().getOpponent();
return (permanent == creature) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent,opponent},
this,
opponent + " sacrifices " + amount +
(amount == 1 ? " permanent." : " permanents.")):
permanent,
opponent,
this,
"PN sacrifices " + amount + (amount == 1 ? " permanent." : " permanents.")
):
MagicEvent.NONE;
}
@Override
@ -37,14 +36,14 @@ public class MagicAnnihilatorTrigger extends MagicWhenAttacksTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicPermanent permanent = (MagicPermanent)data[0];
final MagicPlayer player = (MagicPlayer)data[1];
final MagicPlayer player = event.getPlayer();
int count = amount;
while (count > 0 && player.getPermanents().size() > 0) {
game.addEvent(new MagicSacrificePermanentEvent(
permanent,
player,
MagicTargetChoice.SACRIFICE_PERMANENT));
event.getSource(),
player,
MagicTargetChoice.SACRIFICE_PERMANENT
));
count--;
}
}

View File

@ -22,12 +22,12 @@ public class MagicAttacksPumpTrigger extends MagicWhenAttacksTrigger {
final MagicPermanent creature) {
return (permanent == creature) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent},
this,
permanent + " gets " + getString(power) +
"/" + getString(toughness) + " until end of turn.") :
permanent,
this,
"SN gets " +
getString(power) + "/" + getString(toughness) +
" until end of turn."
) :
MagicEvent.NONE;
}
@Override
@ -37,14 +37,13 @@ public class MagicAttacksPumpTrigger extends MagicWhenAttacksTrigger {
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeTurnPTAction(
(MagicPermanent)data[0],
power,
toughness));
event.getPermanent(),
power,
toughness
));
}
private String getString(final int pt) {
return pt >= 0 ?
"+" + pt :
Integer.toString(pt);
return pt >= 0 ? "+" + pt : Integer.toString(pt);
}
}

View File

@ -27,14 +27,12 @@ public class MagicBattleCryTrigger extends MagicWhenAttacksTrigger {
final MagicGame game,
final MagicPermanent permanent,
final MagicPermanent data) {
final MagicPlayer player = permanent.getController();
return (permanent == data) ?
new MagicEvent(
permanent,
player,
new Object[]{permanent,player},
this,
"Each other attacking creature gets +1/+0 until end of turn."):
permanent,
this,
"Each other attacking creature gets +1/+0 until end of turn."
):
MagicEvent.NONE;
}
@ -44,9 +42,9 @@ public class MagicBattleCryTrigger extends MagicWhenAttacksTrigger {
final MagicEvent event,
final Object[] data,
final Object[] choiceResults) {
final MagicPermanent permanent = (MagicPermanent)data[0];
final MagicPermanent permanent = event.getPermanent();
final Collection<MagicTarget> targets = game.filterTargets(
(MagicPlayer)data[1],
event.getPlayer(),
MagicTargetFilter.TARGET_ATTACKING_CREATURE);
for (final MagicTarget target : targets) {
final MagicPermanent creature = (MagicPermanent)target;

View File

@ -25,19 +25,19 @@ public class MagicBecomesBlockedPumpTrigger extends MagicWhenBecomesBlockedTrigg
final MagicGame game,
final MagicPermanent permanent,
final MagicPermanent data) {
if (permanent == data ) {
if (permanent == data) {
int size = forEachBlocker ?
permanent.getBlockingCreatures().size() :
1;
final int totalAmountPower = amountPower * size;
final int totalAmountToughness = amountToughness * size;
return new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent},
this,
permanent + " gets " + getString(totalAmountPower) +
"/" + getString(totalAmountToughness) + " until end of turn.");
permanent,
this,
"SN gets " +
getString(totalAmountPower) + "/" + getString(totalAmountToughness) +
" until end of turn."
);
}
return MagicEvent.NONE;
}
@ -48,9 +48,10 @@ public class MagicBecomesBlockedPumpTrigger extends MagicWhenBecomesBlockedTrigg
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeTurnPTAction(
(MagicPermanent)data[0],
amountPower,
amountToughness));
event.getPermanent(),
amountPower,
amountToughness
));
}
private String getString(final int pt) {

View File

@ -21,20 +21,15 @@ public class MagicBloodthirstTrigger extends MagicWhenComesIntoPlayTrigger {
final MagicGame game,
final MagicPermanent permanent,
final MagicPlayer player) {
final MagicPlayer opponent = player.getOpponent();
return (opponent.hasState(MagicPlayerState.WasDealtDamage)) ?
new MagicEvent(
return (player.getOpponent().hasState(MagicPlayerState.WasDealtDamage)) ?
new MagicEvent(
permanent,
player,
new Object[]{permanent},
this,
amount > 1 ?
permanent + " enters the battlefield with " +
amount + " +1/+1 counters on it."
:
permanent + " enters the battlefield with " +
"a +1/+1 counter on it."):
MagicEvent.NONE;
"SN enters the battlefield with " + amount + " +1/+1 counters on it." :
"SN enters the battlefield with a +1/+1 counter on it."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(
@ -43,10 +38,11 @@ public class MagicBloodthirstTrigger extends MagicWhenComesIntoPlayTrigger {
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeCountersAction(
(MagicPermanent)data[0],
MagicCounterType.PlusOne,
amount,
false));
event.getPermanent(),
MagicCounterType.PlusOne,
amount,
false
));
}
@Override
public boolean usesStack() {

View File

@ -28,16 +28,12 @@ public class MagicComesIntoPlayWithCounterTrigger extends MagicWhenComesIntoPlay
final MagicPermanent permanent,
final MagicPlayer player) {
return new MagicEvent(
permanent,
player,
new Object[]{permanent},
this,
amount > 1 ?
permanent + " enters the battlefield with " + amount +
" " + description + " counters on it."
:
permanent + " enters the battlefield with a " +
description + " counter on it.");
permanent,
this,
amount > 1 ?
"SN enters the battlefield with " + amount + " " + description + " counters on it." :
"SN enters the battlefield with a " + description + " counter on it."
);
}
@Override
public void executeEvent(
@ -46,10 +42,11 @@ public class MagicComesIntoPlayWithCounterTrigger extends MagicWhenComesIntoPlay
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeCountersAction(
(MagicPermanent)data[0],
counterType,
amount,
false));
event.getPermanent(),
counterType,
amount,
false
));
}
@Override
public boolean usesStack() {

View File

@ -28,11 +28,10 @@ public class MagicDamageGrowTrigger extends MagicWhenDamageIsDealtTrigger {
((MagicPermanent)damage.getTarget()).isCreature())) &&
(!combat || damage.isCombat())) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent},
this,
"Put a +1/+1 counter on " + permanent + "."):
permanent,
this,
"Put a +1/+1 counter on SN."
):
MagicEvent.NONE;
}
@Override
@ -42,9 +41,10 @@ public class MagicDamageGrowTrigger extends MagicWhenDamageIsDealtTrigger {
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeCountersAction(
(MagicPermanent)data[0],
MagicCounterType.PlusOne,
1,
true));
event.getPermanent(),
MagicCounterType.PlusOne,
1,
true
));
}
}

View File

@ -28,29 +28,27 @@ public class MagicDevourTrigger extends MagicWhenComesIntoPlayTrigger {
@Override
public MagicEvent executeTrigger(
final MagicGame game,
final MagicPermanent permanent,
final MagicPermanent perm,
final MagicPlayer player) {
final String name = getCardDefinition().getFullName();
final MagicTargetFilter targetFilter = new MagicTargetFilter.MagicOtherPermanentTargetFilter(
MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL,
permanent);
perm);
final MagicTargetChoice targetChoice = new MagicTargetChoice(
targetFilter,
false,
MagicTargetHint.None,
"a creature other than " + name + " to sacrifice");
"a creature other than " + perm + " to sacrifice");
final MagicChoice devourChoice = new MagicMayChoice(
"You may sacrifice a creature to " + name + ".",
"You may sacrifice a creature to " + perm + ".",
targetChoice);
return (player.getNrOfPermanentsWithType(MagicType.Creature) > 1) ?
new MagicEvent(
permanent,
player,
devourChoice,
MagicSacrificeTargetPicker.create(),
new Object[] {permanent},
this,
"You may$ sacrifice a creature$ to " + name + ".") :
perm,
devourChoice,
MagicSacrificeTargetPicker.create(),
this,
"You may$ sacrifice a creature$ to SN."
) :
MagicEvent.NONE;
}
@ -68,7 +66,7 @@ public class MagicDevourTrigger extends MagicWhenComesIntoPlayTrigger {
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
event.processTargetPermanent(game,choiceResults,1,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
final MagicPermanent permanent = (MagicPermanent)data[0];
final MagicPermanent permanent = event.getPermanent();
game.doAction(new MagicSacrificeAction(creature));
game.doAction(new MagicChangeCountersAction(
permanent,

View File

@ -24,10 +24,8 @@ public class MagicEntersDrawCardTrigger extends MagicWhenComesIntoPlayTrigger {
final MagicPlayer player) {
return new MagicEvent(
permanent,
player,
new Object[]{player},
this,
player + " draws a card.");
"PN draws a card.");
}
@Override
public void executeEvent(
@ -35,7 +33,7 @@ public class MagicEntersDrawCardTrigger extends MagicWhenComesIntoPlayTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicDrawAction((MagicPlayer)data[0],1));
game.doAction(new MagicDrawAction(event.getPlayer(),1));
}
}

View File

@ -67,13 +67,11 @@ public class MagicEntersExileCreatureOrSacrificeTrigger extends MagicWhenComesIn
targetChoice);
return new MagicEvent(
permanent,
player,
championChoice,
MagicExileTargetPicker.create(),
new Object[]{permanent},
this,
"You may$ exile another " + targets + " you control$. " +
"If you don't, sacrifice " + permanent + ".");
"If you don't, sacrifice SN.");
}
@Override
@ -82,7 +80,7 @@ public class MagicEntersExileCreatureOrSacrificeTrigger extends MagicWhenComesIn
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicPermanent permanent = (MagicPermanent)data[0];
final MagicPermanent permanent = event.getPermanent();
if (MagicMayChoice.isYesChoice(choiceResults[0])) {
event.processTargetPermanent(game,choiceResults,1,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {

View File

@ -18,14 +18,14 @@ public class MagicExaltedTrigger extends MagicWhenAttacksTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) {
final MagicPlayer player=permanent.getController();
return (creature.getController()==player&&player.getNrOfAttackers()==1) ?
return (permanent.isFriend(creature) &&
permanent.getController().getNrOfAttackers()==1) ?
new MagicEvent(
permanent,
player,
new Object[]{creature},
this,
creature.getName() + " gets +1/+1 until end of turn."):
permanent,
new Object[]{creature},
this,
creature + " gets +1/+1 until end of turn."
):
MagicEvent.NONE;
}

View File

@ -17,9 +17,8 @@ public class MagicFadeVanishCounterTrigger extends MagicAtUpkeepTrigger {
}
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer data) {
final MagicPlayer player = permanent.getController();
if (player == data) {
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer upkeepPlayer) {
if (permanent.isController(upkeepPlayer)) {
boolean sacrifice = false;
final int amount = permanent.getCounters(MagicCounterType.Charge);
if (counterType == "fade") {
@ -29,13 +28,13 @@ public class MagicFadeVanishCounterTrigger extends MagicAtUpkeepTrigger {
game.doAction(new MagicChangeCountersAction(permanent,MagicCounterType.Charge,-1,true));
}
return new MagicEvent(
permanent,
player,
new Object[]{permanent,sacrifice},
this,
sacrifice ?
player + " sacrifices " + permanent + "." :
player + " removes a " + counterType + " counter from " + permanent + ".");
permanent,
new Object[]{sacrifice},
this,
sacrifice ?
"PN sacrifices SN." :
"PN removes a " + counterType + " counter from SN."
);
}
return MagicEvent.NONE;
}
@ -45,15 +44,16 @@ public class MagicFadeVanishCounterTrigger extends MagicAtUpkeepTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final boolean sacrifice = (Boolean)data[1];
final boolean sacrifice = (Boolean)data[0];
if (sacrifice) {
game.doAction(new MagicSacrificeAction((MagicPermanent)data[0]));
game.doAction(new MagicSacrificeAction(event.getPermanent()));
} else {
game.doAction(new MagicChangeCountersAction(
(MagicPermanent)data[0],
MagicCounterType.Charge,
-1,
true));
event.getPermanent(),
MagicCounterType.Charge,
-1,
true
));
}
}
}

View File

@ -28,13 +28,13 @@ public class MagicFlankingTrigger extends MagicWhenBecomesBlockedTrigger {
}
if (!plist.isEmpty()) {
return new MagicEvent(
permanent,
permanent.getController(),
new Object[]{plist},
this,
plist.size() > 1 ?
"Blocking creatures get -1/-1 until end of turn." :
plist.get(0) + " gets -1/-1 until end of turn.");
permanent,
new Object[]{plist},
this,
plist.size() > 1 ?
"Blocking creatures get -1/-1 until end of turn." :
plist.get(0) + " gets -1/-1 until end of turn."
);
}
}
return MagicEvent.NONE;
@ -51,4 +51,3 @@ public class MagicFlankingTrigger extends MagicWhenBecomesBlockedTrigger {
}
}
}

View File

@ -24,16 +24,15 @@ public class MagicFromGraveyardToLibraryTrigger extends MagicWhenPutIntoGraveyar
return (!card.isToken()) ?
new MagicEvent(
card,
triggerData.card.getController(),
new Object[]{card},
this,
"Shuffle "+card.getName()+" into its owners library."):
"Shuffle SN into its owners library."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
final MagicCard card=(MagicCard)data[0];
final MagicCard card = event.getCard();
if (card.getOwner().getGraveyard().contains(card)) {
game.doAction(new MagicRemoveCardAction(card,MagicLocationType.Graveyard));
game.doAction(new MagicMoveCardAction(card,MagicLocationType.Graveyard,MagicLocationType.OwnersLibrary));

View File

@ -17,16 +17,14 @@ public class MagicLeavesGainLifeTrigger extends MagicWhenLeavesPlayTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPermanent data) {
final MagicPlayer player = permanent.getController();
return (permanent == data) ?
new MagicEvent(
permanent,
player,
new Object[]{player},
this,
player +
(life > 0 ? " gains " + life : " loses " + -life) +
" life."):
permanent,
this,
"PN " +
(life > 0 ? " gains " + life : " loses " + -life) +
" life."
):
MagicEvent.NONE;
}
@Override
@ -35,6 +33,6 @@ public class MagicLeavesGainLifeTrigger extends MagicWhenLeavesPlayTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeLifeAction((MagicPlayer)data[0],life));
game.doAction(new MagicChangeLifeAction(event.getPlayer(),life));
}
};

View File

@ -19,16 +19,16 @@ public class MagicLeavesReturnExileTrigger extends MagicWhenLeavesPlayTrigger {
}
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPermanent data) {
if (permanent == data &&
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPermanent left) {
if (permanent == left &&
!permanent.getExiledCards().isEmpty()) {
final MagicCard exiledCard = permanent.getExiledCards().get(0);
return new MagicEvent(
permanent,
permanent.getController(),
new Object[]{exiledCard,permanent.getController()},
this,
"Return " + exiledCard + " to the battlefield");
permanent,
new Object[]{exiledCard},
this,
"Return " + exiledCard + " to the battlefield"
);
}
return MagicEvent.NONE;
}

View File

@ -26,9 +26,9 @@ public class MagicLivingWeaponTrigger extends MagicWhenComesIntoPlayTrigger {
return new MagicEvent(
permanent,
player,
new Object[]{permanent,player},
this,
player + " puts a 0/0 black Germ creature token onto the battlefield, then attaches this to it.");
"PN puts a 0/0 black Germ creature token onto the battlefield, then attaches SN to it."
);
}
@Override
@ -40,14 +40,16 @@ public class MagicLivingWeaponTrigger extends MagicWhenComesIntoPlayTrigger {
//create the token
final MagicPlayTokenAction play_token=new MagicPlayTokenAction(
(MagicPlayer)data[1],
TokenCardDefinitions.get("Germ"));
event.getPlayer(),
TokenCardDefinitions.get("Germ")
);
game.doAction(play_token);
//attach the equipment to the token
final MagicAttachEquipmentAction attach_equip = new MagicAttachEquipmentAction(
(MagicPermanent)data[0],
play_token.getPermanent());
event.getPermanent(),
play_token.getPermanent()
);
game.doAction(attach_equip);
}
}

View File

@ -4,7 +4,6 @@ import magic.model.MagicCounterType;
import magic.model.MagicGame;
import magic.model.MagicLocationType;
import magic.model.MagicPermanent;
import magic.model.MagicPlayer;
import magic.model.action.MagicChangeCountersAction;
import magic.model.action.MagicPermanentAction;
import magic.model.choice.MagicMayChoice;
@ -26,22 +25,22 @@ public class MagicModularTrigger extends MagicWhenPutIntoGraveyardTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicGraveyardTriggerData triggerData) {
if (MagicLocationType.Play == triggerData.fromLocation) {
final MagicPlayer player = permanent.getController();
final int amount = permanent.getCounters(MagicCounterType.PlusOne);
return new MagicEvent(
permanent,
player,
new MagicMayChoice(
amount > 1 ?
player + " may put " + amount + " +1/+1 counters on target artifact creature." :
player + " may put a +1/+1 counter on target artifact creature.",
MagicTargetChoice.POS_TARGET_ARTIFACT_CREATURE),
amount > 1 ?
"You may put " + amount + " +1/+1 counters on target artifact creature." :
"You may put a +1/+1 counter on target artifact creature.",
MagicTargetChoice.POS_TARGET_ARTIFACT_CREATURE
),
MagicPumpTargetPicker.create(),
new Object[]{amount},
this,
amount > 1 ?
player + " may$ put " + amount + " +1/+1 counters on target artifact creature$." :
player + " may$ put a +1/+1 counter on target artifact creature$.");
"PN may$ put " + amount + " +1/+1 counters on target artifact creature$." :
"PN may$ put a +1/+1 counter on target artifact creature$."
);
}
return MagicEvent.NONE;
}
@ -56,10 +55,11 @@ public class MagicModularTrigger extends MagicWhenPutIntoGraveyardTrigger {
event.processTargetPermanent(game,choiceResults,1,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicChangeCountersAction(
creature,
MagicCounterType.PlusOne,
(Integer)data[0],
true));
creature,
MagicCounterType.PlusOne,
(Integer)data[0],
true
));
}
});
}

View File

@ -17,18 +17,19 @@ public class MagicPersistTrigger extends MagicWhenPutIntoGraveyardTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicGraveyardTriggerData triggerData) {
if (triggerData.fromLocation==MagicLocationType.Play&&permanent.getCounters(MagicCounterType.MinusOne)==0) {
final MagicCard card=triggerData.card;
return new MagicEvent(permanent,permanent.getController(),new Object[]{card},this,
"Return "+card.getName()+" to play under its owner's control with a -1/-1 counter on it.");
}
return MagicEvent.NONE;
return (triggerData.fromLocation==MagicLocationType.Play &&
permanent.getCounters(MagicCounterType.MinusOne)==0) ?
new MagicEvent(
permanent,
this,
"Return SN to play under its owner's control with a -1/-1 counter on it."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
final MagicCard card=(MagicCard)data[0];
final MagicCard card = event.getPermanent().getCard();
game.doAction(new MagicReanimateAction(card.getOwner(),card,MagicPlayCardAction.PERSIST));
}

View File

@ -17,16 +17,15 @@ public class MagicRampageTrigger extends MagicWhenBecomesBlockedTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent creature) {
final MagicPlayer player = permanent.getController();
final MagicPermanentList plist = permanent.getBlockingCreatures();
final int amount = n * (plist.size() - 1);
return (creature == permanent && amount > 0) ?
new MagicEvent(
permanent,
player,
new Object[]{permanent,amount},
new Object[]{amount},
this,
permanent + " gets +" + amount + "/+" + amount + " until end of turn."):
"SN gets +" + amount + "/+" + amount + " until end of turn."
):
MagicEvent.NONE;
}
@ -36,9 +35,11 @@ public class MagicRampageTrigger extends MagicWhenBecomesBlockedTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final int amount = (Integer)data[0];
game.doAction(new MagicChangeTurnPTAction(
(MagicPermanent)data[0],
(Integer)data[1],
(Integer)data[1]));
event.getPermanent(),
amount,
amount
));
}
}

View File

@ -23,7 +23,6 @@ public class MagicSpecterTrigger extends MagicWhenDamageIsDealtTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicDamage damage) {
final MagicTarget target = damage.getTarget();
final String prefix = target + " discards a card";
return (damage.getSource() == permanent &&
target.isPlayer() &&
((MagicPlayer)target).getHandSize() > 0 &&
@ -31,19 +30,20 @@ public class MagicSpecterTrigger extends MagicWhenDamageIsDealtTrigger {
(!combat || damage.isCombat())) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent,target},
(MagicPlayer)target,
this,
random ? prefix + " at random." : prefix + "."):
"PN discards a card" + (random ? " at random." : ".")
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choices) {
game.addEvent(new MagicDiscardEvent(
(MagicPermanent)data[0],
(MagicPlayer)data[1],
1,
random));
event.getSource(),
event.getPlayer(),
1,
random
));
}
}

View File

@ -21,18 +21,17 @@ public class MagicStormTrigger extends MagicWhenSpellIsCastTrigger {
public MagicEvent executeTrigger(
final MagicGame game,
final MagicPermanent permanent,
final MagicCardOnStack data) {
final MagicPlayer player = data.getController();
final MagicCardOnStack spell) {
final int count = game.getSpellsPlayed();
return (count > 0) ?
new MagicEvent(
data.getSource(),
player,
new Object[]{player,data,count},
this,
"Copy " + data.getSource() + " " +
count + (count == 1 ? " time." : " times.")) :
MagicEvent.NONE;
new MagicEvent(
spell,
new Object[]{count},
this,
"Copy SN " + count +
(count == 1 ? " time." : " times.")
) :
MagicEvent.NONE;
}
@Override
@ -41,11 +40,12 @@ public class MagicStormTrigger extends MagicWhenSpellIsCastTrigger {
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
int count = (Integer)data[2];
int count = (Integer)data[0];
for (;count>0;count--) {
game.doAction(new MagicCopyCardOnStackAction(
(MagicPlayer)data[0],
(MagicCardOnStack)data[1]));
event.getPlayer(),
event.getCardOnStack()
));
}
}

View File

@ -19,16 +19,15 @@ public class MagicTappedIntoPlayTrigger extends MagicWhenComesIntoPlayTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer player) {
return new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent},
this,
permanent + " enters the battlefield tapped.");
permanent,
this,
"SN enters the battlefield tapped."
);
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicTapAction((MagicPermanent)data[0],false));
game.doAction(new MagicTapAction(event.getPermanent(),false));
}
@Override

View File

@ -19,20 +19,19 @@ public class MagicTappedIntoPlayUnlessTrigger extends MagicWhenComesIntoPlayTrig
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer player) {
return (!player.controlsPermanentWithSubType(subType1)&&
return (!player.controlsPermanentWithSubType(subType1) &&
!player.controlsPermanentWithSubType(subType2)) ?
new MagicEvent(
permanent,
player,
new Object[]{permanent},
this,
permanent+" enters the battlefield tapped."):
permanent,
this,
"SN enters the battlefield tapped."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicTapAction((MagicPermanent)data[0],false));
game.doAction(new MagicTapAction(event.getPermanent(),false));
}
@Override

View File

@ -22,16 +22,15 @@ public class MagicTappedIntoPlayUnlessTwoTrigger extends MagicWhenComesIntoPlayT
return (player.getNrOfPermanentsWithType(MagicType.Land) > 3) ?
new MagicEvent(
permanent,
player,
new Object[]{permanent},
this,
permanent+" enters the battlefield tapped."):
"SN enters the battlefield tapped."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
game.doAction(new MagicTapAction((MagicPermanent)data[0],false));
game.doAction(new MagicTapAction(event.getPermanent(),false));
}
@Override

View File

@ -20,18 +20,15 @@ public class MagicUndyingTrigger extends MagicWhenPutIntoGraveyardTrigger {
final MagicGame game,
final MagicPermanent permanent,
final MagicGraveyardTriggerData triggerData) {
if (triggerData.fromLocation == MagicLocationType.Play &&
permanent.getCounters(MagicCounterType.PlusOne) == 0) {
final MagicCard card = triggerData.card;
return new MagicEvent(
permanent,
permanent.getController(),
new Object[] {card},
this,
"Return " + card.getName() + " to play under its " +
"owner's control with a +1/+1 counter on it.");
}
return MagicEvent.NONE;
return (triggerData.fromLocation == MagicLocationType.Play &&
permanent.getCounters(MagicCounterType.PlusOne) == 0) ?
new MagicEvent(
permanent,
this,
"Return SN to play under its " +
"owner's control with a +1/+1 counter on it."
):
MagicEvent.NONE;
}
@Override
@ -40,11 +37,12 @@ public class MagicUndyingTrigger extends MagicWhenPutIntoGraveyardTrigger {
final MagicEvent event,
final Object[] data,
final Object[] choiceResults) {
final MagicCard card = (MagicCard)data[0];
final MagicCard card = event.getPermanent().getCard();
game.doAction(new MagicReanimateAction(
card.getOwner(),
card,
MagicPlayCardAction.UNDYING));
card.getOwner(),
card,
MagicPlayCardAction.UNDYING
));
}
public static final MagicUndyingTrigger getInstance() {

View File

@ -17,14 +17,14 @@ public class MagicWhenBlocksPumpTrigger extends MagicWhenBlocksTrigger {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent data) {
return (permanent == data ) ?
return (permanent == data) ?
new MagicEvent(
permanent,
permanent.getController(),
new Object[]{permanent},
this,
permanent + " gets " + getString(amountPower) +
"/" + getString(amountToughness) + " until end of turn.") :
permanent,
this,
"SN gets " +
getString(amountPower) + "/" + getString(amountToughness) +
" until end of turn."
):
MagicEvent.NONE;
}
@Override
@ -34,15 +34,13 @@ public class MagicWhenBlocksPumpTrigger extends MagicWhenBlocksTrigger {
final Object data[],
final Object[] choiceResults) {
game.doAction(new MagicChangeTurnPTAction(
(MagicPermanent)data[0],
amountPower,
amountToughness));
event.getPermanent(),
amountPower,
amountToughness
));
}
private String getString(final int pt) {
return pt >= 0 ?
"+" + pt :
Integer.toString(pt);
return pt >= 0 ? "+" + pt : Integer.toString(pt);
}
}