mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Some rework of Keeper of the Light.
This commit is contained in:
parent
458b207d2f
commit
d66d8d47fb
3 changed files with 45 additions and 61 deletions
|
@ -83,7 +83,7 @@ public class KeeperOfTheDead extends CardImpl {
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// {B}, {tap}: Choose target opponent who had at least two fewer creature cards in his or her graveyard than you did as you activated this ability. Destroy target nonblack creature he or she controls.
|
// {B}, {T}: Choose target opponent who had at least two fewer creature cards in his or her graveyard than you did as you activated this ability. Destroy target nonblack creature he or she controls.
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new KeeperOfTheDeadEffect(), new TapSourceCost());
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new KeeperOfTheDeadEffect(), new TapSourceCost());
|
||||||
ability.addCost(new ManaCostsImpl("{B}"));
|
ability.addCost(new ManaCostsImpl("{B}"));
|
||||||
ability.addTarget(new TargetPlayer(1, 1, false, filter));
|
ability.addTarget(new TargetPlayer(1, 1, false, filter));
|
||||||
|
@ -136,10 +136,10 @@ class KeeperOfDeadPredicate implements ObjectSourcePlayerPredicate<ObjectSourceP
|
||||||
|
|
||||||
class KeeperOfTheDeadCreatureTarget extends TargetPermanent {
|
class KeeperOfTheDeadCreatureTarget extends TargetPermanent {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("nonblack creature");
|
private static final FilterCreaturePermanent nonblackCreaturefilter = new FilterCreaturePermanent("nonblack creature");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
|
nonblackCreaturefilter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeeperOfTheDeadCreatureTarget() {
|
public KeeperOfTheDeadCreatureTarget() {
|
||||||
|
@ -179,7 +179,7 @@ class KeeperOfTheDeadCreatureTarget extends TargetPermanent {
|
||||||
UUID playerId = ((StackObject) object).getStackAbility().getFirstTarget();
|
UUID playerId = ((StackObject) object).getStackAbility().getFirstTarget();
|
||||||
for (UUID targetId : availablePossibleTargets) {
|
for (UUID targetId : availablePossibleTargets) {
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if (permanent != null && filter.match(permanent, game) && permanent.getControllerId().equals(playerId)) {
|
if (permanent != null && nonblackCreaturefilter.match(permanent, game) && permanent.getControllerId().equals(playerId)) {
|
||||||
possibleTargets.add(targetId);
|
possibleTargets.add(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,28 +27,24 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.constants.SubType;
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.common.GainLifeEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.filter.FilterOpponent;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
|
||||||
import mage.abilities.condition.Condition;
|
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
|
||||||
import mage.abilities.decorator.ConditionalActivatedAbility;
|
|
||||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
|
||||||
import mage.abilities.effects.common.GainLifeEffect;
|
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.filter.FilterOpponent;
|
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,20 +55,20 @@ public class KeeperOfTheLight extends CardImpl {
|
||||||
|
|
||||||
public KeeperOfTheLight(UUID ownerId, CardSetInfo setInfo) {
|
public KeeperOfTheLight(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{W}");
|
||||||
|
|
||||||
this.subtype.add(SubType.HUMAN);
|
this.subtype.add(SubType.HUMAN);
|
||||||
this.subtype.add(SubType.WIZARD);
|
this.subtype.add(SubType.WIZARD);
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// {W}, {tap}: Choose target opponent who had more life than you did as you activated this ability. You gain 3 life.
|
// {W}, {T}: Choose target opponent who had more life than you did as you activated this ability. You gain 3 life.
|
||||||
Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD,
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||||
new GainLifeEffect(new StaticValue(3), "Choose target opponent who had more life than you did as you activated this ability. You gain 3 life."),
|
new GainLifeEffect(3).setText("Choose target opponent who had more life than you did as you activated this ability. You gain 3 life."),
|
||||||
new TapSourceCost(), KeeperOfTheLightCondition.instance);
|
new ManaCostsImpl("{W}"));
|
||||||
ability.addCost(new ManaCostsImpl("{W}"));
|
ability.addCost(new TapSourceCost());
|
||||||
ability.addTarget(new KeeperOfTheLightTarget());
|
ability.addTarget(new KeeperOfTheLightTarget());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeeperOfTheLight(final KeeperOfTheLight card) {
|
public KeeperOfTheLight(final KeeperOfTheLight card) {
|
||||||
|
@ -88,15 +84,7 @@ public class KeeperOfTheLight extends CardImpl {
|
||||||
class KeeperOfTheLightTarget extends TargetPlayer {
|
class KeeperOfTheLightTarget extends TargetPlayer {
|
||||||
|
|
||||||
public KeeperOfTheLightTarget() {
|
public KeeperOfTheLightTarget() {
|
||||||
this(false);
|
super(1, 1, false, new FilterOpponent("opponent that has more life than you"));
|
||||||
}
|
|
||||||
|
|
||||||
public KeeperOfTheLightTarget(boolean notTarget) {
|
|
||||||
this(new FilterOpponent("opponent who had more life than you did as you activated this ability"), notTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeeperOfTheLightTarget(FilterOpponent filter, boolean notTarget) {
|
|
||||||
super(1, 1, notTarget, filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeeperOfTheLightTarget(final KeeperOfTheLightTarget target) {
|
public KeeperOfTheLightTarget(final KeeperOfTheLightTarget target) {
|
||||||
|
@ -108,43 +96,36 @@ class KeeperOfTheLightTarget extends TargetPlayer {
|
||||||
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
int lifeController = game.getPlayer(sourceControllerId).getLife();
|
int lifeController = game.getPlayer(sourceControllerId).getLife();
|
||||||
|
|
||||||
for (UUID targetId : availablePossibleTargets) {
|
for (UUID targetId : availablePossibleTargets) {
|
||||||
Player opponent = game.getPlayer(targetId);
|
Player opponent = game.getPlayer(targetId);
|
||||||
if (opponent != null){
|
if (opponent != null) {
|
||||||
int lifeOpponent = opponent.getLife();
|
int lifeOpponent = opponent.getLife();
|
||||||
if (lifeOpponent > lifeController){
|
if (lifeOpponent > lifeController) {
|
||||||
possibleTargets.add(targetId);
|
possibleTargets.add(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeeperOfTheLightTarget copy() {
|
|
||||||
return new KeeperOfTheLightTarget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "opponent who had more life than you did as you activated this ability";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum KeeperOfTheLightCondition implements Condition {
|
|
||||||
|
|
||||||
instance;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
int count = 0;
|
||||||
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int controllerLife = controller.getLife();
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
for (UUID playerId : game.getPlayerList()){
|
if (player != null
|
||||||
if (controllerLife < game.getPlayer(playerId).getLife()){
|
&& controller.getLife() < player.getLife()
|
||||||
return true;
|
&& !player.hasLeft()
|
||||||
|
&& filter.match(player, sourceId, sourceControllerId, game)
|
||||||
|
&& player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,9 +133,7 @@ enum KeeperOfTheLightCondition implements Condition {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public KeeperOfTheLightTarget copy() {
|
||||||
return "you have less life than an opponent";
|
return new KeeperOfTheLightTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2272,6 +2272,11 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
return state.getPlayers();
|
return state.getPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of all players ignoring the range of visible players
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlayerList getPlayerList() {
|
public PlayerList getPlayerList() {
|
||||||
return state.getPlayerList();
|
return state.getPlayerList();
|
||||||
|
|
Loading…
Reference in a new issue