mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Added Tears of Rage.
This commit is contained in:
parent
3b99060617
commit
d7f82ad0c6
5 changed files with 214 additions and 3 deletions
|
|
@ -47,7 +47,7 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
private static final Logger logger = Logger.getLogger(MageObjectReference.class);
|
||||
|
||||
private final UUID sourceId;
|
||||
private final int zoneChangeCounter;
|
||||
private int zoneChangeCounter;
|
||||
|
||||
public MageObjectReference(MageObject mageObject, Game game) {
|
||||
this.sourceId = mageObject.getId();
|
||||
|
|
@ -67,6 +67,11 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
this.zoneChangeCounter = zoneChangeCounter;
|
||||
}
|
||||
|
||||
public MageObjectReference(UUID sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
this.zoneChangeCounter = -1;
|
||||
}
|
||||
|
||||
public MageObjectReference(UUID sourceId, Game game) {
|
||||
this.sourceId = sourceId;
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
|
|
@ -163,4 +168,7 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setZoneChangeCounter(int zoneChangeCounter) {
|
||||
this.zoneChangeCounter = zoneChangeCounter;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class CastOnlyDuringPhaseStepSourceAbility extends SimpleStaticAbility {
|
|||
}
|
||||
|
||||
public CastOnlyDuringPhaseStepSourceAbility(TurnPhase turnPhase, PhaseStep phaseStep, Condition condition, String effectText) {
|
||||
super(Zone.BATTLEFIELD, new CastOnlyDuringPhaseStepSourceEffect(turnPhase, phaseStep, condition));
|
||||
super(Zone.ALL, new CastOnlyDuringPhaseStepSourceEffect(turnPhase, phaseStep, condition));
|
||||
this.setRuleAtTheTop(true);
|
||||
if (effectText != null) {
|
||||
getEffects().get(0).setText(effectText);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class CastOnlyDuringPhaseStepSourceEffect extends ContinuousRuleModifying
|
|||
this.turnPhase = turnPhase;
|
||||
this.phaseStep = phaseStep;
|
||||
this.condition = condition;
|
||||
setText();
|
||||
staticText = setText();
|
||||
}
|
||||
|
||||
private CastOnlyDuringPhaseStepSourceEffect(final CastOnlyDuringPhaseStepSourceEffect effect) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.target.targetpointer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Cards;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FixedTargets implements TargetPointer {
|
||||
|
||||
final ArrayList<MageObjectReference> targets = new ArrayList<>();
|
||||
private boolean initialized;
|
||||
|
||||
public FixedTargets(UUID targetId) {
|
||||
targets.add(new MageObjectReference(targetId));
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
public FixedTargets(Cards cards, Game game) {
|
||||
for (UUID targetId : cards) {
|
||||
MageObjectReference mor = new MageObjectReference(targetId, game);
|
||||
targets.add(mor);
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public FixedTargets(List<Permanent> permanents, Game game) {
|
||||
for (Permanent permanent : permanents) {
|
||||
MageObjectReference mor = new MageObjectReference(permanent.getId(), permanent.getZoneChangeCounter(game), game);
|
||||
targets.add(mor);
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
private FixedTargets(final FixedTargets fixedTargets) {
|
||||
this.targets.addAll(fixedTargets.targets);
|
||||
this.initialized = fixedTargets.initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Game game, Ability source) {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (MageObjectReference mor : targets) {
|
||||
mor.setZoneChangeCounter(game.getState().getZoneChangeCounter(mor.getSourceId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
ArrayList<UUID> list = new ArrayList<>(1);
|
||||
for (MageObjectReference mor : targets) {
|
||||
if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) {
|
||||
list.add(mor.getSourceId());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getFirst(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
for (MageObjectReference mor : targets) {
|
||||
if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) {
|
||||
return mor.getSourceId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPointer copy() {
|
||||
return new FixedTargets(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue