mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
Sheoldred, Whispering One and refactoring and make more generic BeginningOfCntrolledUpkeepTriggeredAbility
This commit is contained in:
parent
61ce0ffb6b
commit
b9f4f7abf4
9 changed files with 152 additions and 55 deletions
|
|
@ -1,36 +0,0 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class BeginningOfControllerUpkeepTriggeredAbility extends TriggeredAbilityImpl<BeginningOfControllerUpkeepTriggeredAbility> {
|
||||
|
||||
public BeginningOfControllerUpkeepTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
super(Constants.Zone.BATTLEFIELD, effect, isOptional);
|
||||
}
|
||||
|
||||
public BeginningOfControllerUpkeepTriggeredAbility(final BeginningOfControllerUpkeepTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeginningOfControllerUpkeepTriggeredAbility copy() {
|
||||
return new BeginningOfControllerUpkeepTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At the beginning of your upkeep, " + effects.getText(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.CASTORE;
|
||||
import mage.Constants;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<BeginningOfUpkeepTriggeredAbility> {
|
||||
private Constants.TargetController targetController;
|
||||
|
||||
public BeginningOfUpkeepTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) {
|
||||
super(Constants.Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
||||
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.targetController = ability.targetController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeginningOfUpkeepTriggeredAbility copy() {
|
||||
return new BeginningOfUpkeepTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
|
||||
switch (targetController) {
|
||||
case YOU:
|
||||
return event.getPlayerId().equals(this.controllerId);
|
||||
case OPPONENT:
|
||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
||||
this.getTargets().get(0).add(event.getPlayerId(), game); //TODO add target pushing checking to constructor
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
switch (targetController) {
|
||||
case YOU:
|
||||
return "At the beginning of your upkeep, " + effects.getText(this);
|
||||
case OPPONENT:
|
||||
return "At the beginning of each opponent's upkeep, " + effects.getText(this);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue