override change method in triggers with specialize addTrigger methods

master
melvin 2012-10-14 20:41:47 +08:00
parent 0d0f0bf98c
commit ed4d60cb34
5 changed files with 28 additions and 0 deletions

View File

@ -630,18 +630,22 @@ public class MagicCardDefinition {
public void addTrigger(final MagicWhenSpellIsCastTrigger trigger) {
spellIsCastTriggers.add(trigger);
numTriggers++;
}
public void addTrigger(final MagicWhenComesIntoPlayTrigger trigger) {
comeIntoPlayTriggers.add(trigger);
numTriggers++;
}
public void addTrigger(final MagicWhenPutIntoGraveyardTrigger trigger) {
putIntoGraveyardTriggers.add(trigger);
numTriggers++;
}
public void addTrigger(final MagicWhenDrawnTrigger trigger) {
drawnTriggers.add(trigger);
numTriggers++;
}
public void addTrigger(final MagicTrigger<?> trigger) {

View File

@ -1,6 +1,7 @@
package magic.model.trigger;
import magic.model.MagicPlayer;
import magic.model.MagicCardDefinition;
public abstract class MagicWhenComesIntoPlayTrigger extends MagicTrigger<MagicPlayer> {
public MagicWhenComesIntoPlayTrigger(final int priority) {
@ -12,4 +13,9 @@ public abstract class MagicWhenComesIntoPlayTrigger extends MagicTrigger<MagicPl
public MagicTriggerType getType() {
return MagicTriggerType.WhenComesIntoPlay;
}
@Override
public void change(final MagicCardDefinition cdef) {
cdef.addTrigger(this);
}
}

View File

@ -1,6 +1,7 @@
package magic.model.trigger;
import magic.model.MagicCard;
import magic.model.MagicCardDefinition;
public abstract class MagicWhenDrawnTrigger extends MagicTrigger<MagicCard> {
public MagicWhenDrawnTrigger(final int priority) {
@ -12,4 +13,9 @@ public abstract class MagicWhenDrawnTrigger extends MagicTrigger<MagicCard> {
public MagicTriggerType getType() {
return MagicTriggerType.WhenDrawn;
}
@Override
public void change(final MagicCardDefinition cdef) {
cdef.addTrigger(this);
}
}

View File

@ -1,5 +1,6 @@
package magic.model.trigger;
import magic.model.MagicCardDefinition;
public abstract class MagicWhenPutIntoGraveyardTrigger extends MagicTrigger<MagicGraveyardTriggerData> {
public MagicWhenPutIntoGraveyardTrigger(final int priority) {
@ -11,4 +12,9 @@ public abstract class MagicWhenPutIntoGraveyardTrigger extends MagicTrigger<Magi
public MagicTriggerType getType() {
return MagicTriggerType.WhenPutIntoGraveyard;
}
@Override
public void change(final MagicCardDefinition cdef) {
cdef.addTrigger(this);
}
}

View File

@ -1,5 +1,6 @@
package magic.model.trigger;
import magic.model.MagicCardDefinition;
import magic.model.stack.MagicCardOnStack;
public abstract class MagicWhenSpellIsCastTrigger extends MagicTrigger<MagicCardOnStack> {
@ -12,4 +13,9 @@ public abstract class MagicWhenSpellIsCastTrigger extends MagicTrigger<MagicCard
public MagicTriggerType getType() {
return MagicTriggerType.WhenSpellIsCast;
}
@Override
public void change(final MagicCardDefinition cdef) {
cdef.addTrigger(this);
}
}