mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
fixed life total exchanging to allow for rules 118.7, 118.8
This commit is contained in:
parent
c66fb996b8
commit
d2aeabc374
4 changed files with 68 additions and 24 deletions
|
|
@ -31,17 +31,21 @@ package mage.sets.magic2011;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
|
import mage.Constants.Layer;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.SubLayer;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.ReplacementEffectImpl;
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
import mage.abilities.keyword.LeylineAbility;
|
import mage.abilities.keyword.LeylineAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -69,10 +73,10 @@ public class LeylineOfPunishment extends CardImpl<LeylineOfPunishment> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LeylineOfPunishmentEffect1 extends ReplacementEffectImpl<LeylineOfPunishmentEffect1> {
|
class LeylineOfPunishmentEffect1 extends ContinuousEffectImpl<LeylineOfPunishmentEffect1> {
|
||||||
|
|
||||||
public LeylineOfPunishmentEffect1() {
|
public LeylineOfPunishmentEffect1() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
super(Duration.WhileOnBattlefield, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
|
||||||
staticText = "Players can't gain life";
|
staticText = "Players can't gain life";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,19 +91,15 @@ class LeylineOfPunishmentEffect1 extends ReplacementEffectImpl<LeylineOfPunishme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
return true;
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
}
|
if (controller != null) {
|
||||||
|
for (UUID playerId: controller.getInRange()) {
|
||||||
@Override
|
Player player = game.getPlayer(playerId);
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
if (player != null)
|
||||||
return true;
|
player.setCanGainLife(false);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
|
||||||
if (event.getType() == EventType.GAIN_LIFE) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,22 @@ class SoulConduitEffect extends OneShotEffect<SoulConduitEffect> {
|
||||||
int lifePlayer1 = player1.getLife();
|
int lifePlayer1 = player1.getLife();
|
||||||
int lifePlayer2 = player2.getLife();
|
int lifePlayer2 = player2.getLife();
|
||||||
|
|
||||||
|
if (lifePlayer1 == lifePlayer2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!player1.isLifeTotalCanChange() || !player2.isLifeTotalCanChange())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 20110930 - 118.7, 118.8
|
||||||
|
if (lifePlayer1 < lifePlayer2 && (!player1.isCanGainLife() || !player2.isCanLoseLife()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (lifePlayer1 > lifePlayer2 && (!player1.isCanLoseLife() || !player2.isCanGainLife()))
|
||||||
|
return false;
|
||||||
|
|
||||||
player1.setLife(lifePlayer2, game);
|
player1.setLife(lifePlayer2, game);
|
||||||
player2.setLife(lifePlayer1, game);
|
player2.setLife(lifePlayer1, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
public int getLife();
|
public int getLife();
|
||||||
public void setLife(int life, Game game);
|
public void setLife(int life, Game game);
|
||||||
public int loseLife(int amount, Game game);
|
public int loseLife(int amount, Game game);
|
||||||
public void gainLife(int amount, Game game);
|
public boolean isCanLoseLife();
|
||||||
|
public void setCanLoseLife(boolean canLoseLife);
|
||||||
|
public int gainLife(int amount, Game game);
|
||||||
|
public boolean isCanGainLife();
|
||||||
|
public void setCanGainLife(boolean canGainLife);
|
||||||
public boolean isLifeTotalCanChange();
|
public boolean isLifeTotalCanChange();
|
||||||
public void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
public void setLifeTotalCanChange(boolean lifeTotalCanChange);
|
||||||
public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
|
public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
protected RangeOfInfluence range;
|
protected RangeOfInfluence range;
|
||||||
protected Set<UUID> inRange = new HashSet<UUID>();
|
protected Set<UUID> inRange = new HashSet<UUID>();
|
||||||
protected boolean isTestMode = false;
|
protected boolean isTestMode = false;
|
||||||
protected boolean lifeTotalCanChange = true;
|
|
||||||
protected boolean canGainLife = true;
|
protected boolean canGainLife = true;
|
||||||
protected boolean canLoseLife = true;
|
protected boolean canLoseLife = true;
|
||||||
protected boolean isGameUnderControl = true;
|
protected boolean isGameUnderControl = true;
|
||||||
|
|
@ -154,7 +153,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.passedTurn = player.passedTurn;
|
this.passedTurn = player.passedTurn;
|
||||||
this.left = player.left;
|
this.left = player.left;
|
||||||
this.range = player.range;
|
this.range = player.range;
|
||||||
this.lifeTotalCanChange = player.lifeTotalCanChange;
|
this.canGainLife = player.canGainLife;
|
||||||
|
this.canLoseLife = player.canLoseLife;
|
||||||
for (UUID id: player.inRange) {
|
for (UUID id: player.inRange) {
|
||||||
this.inRange.add(id);
|
this.inRange.add(id);
|
||||||
}
|
}
|
||||||
|
|
@ -186,6 +186,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.left = false;
|
this.left = false;
|
||||||
this.passed = false;
|
this.passed = false;
|
||||||
this.passedTurn = false;
|
this.passedTurn = false;
|
||||||
|
this.canGainLife = true;
|
||||||
|
this.canLoseLife = true;
|
||||||
Watcher bloodthirst = new BloodthirstWatcher();
|
Watcher bloodthirst = new BloodthirstWatcher();
|
||||||
bloodthirst.setControllerId(playerId);
|
bloodthirst.setControllerId(playerId);
|
||||||
game.getState().getWatchers().add(bloodthirst);
|
game.getState().getWatchers().add(bloodthirst);
|
||||||
|
|
@ -196,7 +198,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.abilities.clear();
|
this.abilities.clear();
|
||||||
this.landsPerTurn = 1;
|
this.landsPerTurn = 1;
|
||||||
this.maxHandSize = 7;
|
this.maxHandSize = 7;
|
||||||
this.lifeTotalCanChange = true;
|
this.canGainLife = true;
|
||||||
|
this.canLoseLife = true;
|
||||||
this.topCardRevealed = false;
|
this.topCardRevealed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -808,17 +811,28 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLifeTotalCanChange(boolean lifeTotalCanChange) {
|
public void setLifeTotalCanChange(boolean lifeTotalCanChange) {
|
||||||
this.lifeTotalCanChange = lifeTotalCanChange;
|
this.canGainLife = lifeTotalCanChange;
|
||||||
|
this.canLoseLife = lifeTotalCanChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLifeTotalCanChange() {
|
public boolean isLifeTotalCanChange() {
|
||||||
return this.lifeTotalCanChange;
|
return canGainLife | canLoseLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCanLoseLife() {
|
||||||
|
return canLoseLife;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCanLoseLife(boolean canLoseLife) {
|
||||||
|
this.canLoseLife = canLoseLife;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int loseLife(int amount, Game game) {
|
public int loseLife(int amount, Game game) {
|
||||||
if (!lifeTotalCanChange) return 0;
|
if (!canLoseLife) return 0;
|
||||||
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, false);
|
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, false);
|
||||||
if (!game.replaceEvent(event)) {
|
if (!game.replaceEvent(event)) {
|
||||||
this.life -= amount;
|
this.life -= amount;
|
||||||
|
|
@ -828,14 +842,26 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCanGainLife() {
|
||||||
|
return canGainLife;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCanGainLife(boolean canGainLife) {
|
||||||
|
this.canGainLife = canGainLife;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void gainLife(int amount, Game game) {
|
public int gainLife(int amount, Game game) {
|
||||||
if (!lifeTotalCanChange) return;
|
if (!canGainLife) return 0;
|
||||||
GameEvent event = new GameEvent(GameEvent.EventType.GAIN_LIFE, playerId, playerId, playerId, amount, false);
|
GameEvent event = new GameEvent(GameEvent.EventType.GAIN_LIFE, playerId, playerId, playerId, amount, false);
|
||||||
if (!game.replaceEvent(event)) {
|
if (!game.replaceEvent(event)) {
|
||||||
this.life += amount;
|
this.life += amount;
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, playerId, playerId, amount));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, playerId, playerId, amount));
|
||||||
|
return amount;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue