mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Merge origin/master
This commit is contained in:
commit
a4e1c7aefd
41 changed files with 1395 additions and 640 deletions
|
|
@ -32,12 +32,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.util.Copyable;
|
||||
import mage.util.ThreadLocalStringBuilder;
|
||||
|
||||
public class ObjectColor implements Serializable, Copyable<ObjectColor>, Comparable<ObjectColor> {
|
||||
|
||||
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(10);
|
||||
|
||||
public static final ObjectColor WHITE = new ObjectColor("W");
|
||||
public static final ObjectColor BLUE = new ObjectColor("U");
|
||||
public static final ObjectColor BLACK = new ObjectColor("B");
|
||||
|
|
@ -232,7 +229,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = threadLocalBuilder.get();
|
||||
StringBuilder sb = new StringBuilder(5);
|
||||
if (white) {
|
||||
sb.append("W");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
|
@ -56,8 +57,12 @@ public class CommanderInPlayCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent commander = game.getPermanent(controller.getCommanderId());
|
||||
return commander != null && commander.getControllerId().equals(source.getControllerId());
|
||||
for (UUID commanderId : controller.getCommandersIds()) {
|
||||
Permanent commander = game.getPermanent(commanderId);
|
||||
if (commander != null && commander.getControllerId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
|
@ -49,20 +50,16 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl {
|
||||
|
||||
private FilterMana commanderMana;
|
||||
|
||||
public CommanderColorIdentityManaAbility() {
|
||||
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), new TapSourceCost());
|
||||
}
|
||||
|
||||
public CommanderColorIdentityManaAbility(Cost cost) {
|
||||
super(Zone.BATTLEFIELD, new CommanderIdentityManaEffect(), cost);
|
||||
commanderMana = null;
|
||||
}
|
||||
|
||||
public CommanderColorIdentityManaAbility(final CommanderColorIdentityManaAbility ability) {
|
||||
super(ability);
|
||||
this.commanderMana = ability.commanderMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -75,30 +72,27 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
|
|||
if (netMana.isEmpty() && game != null) {
|
||||
Player controller = game.getPlayer(getControllerId());
|
||||
if (controller != null) {
|
||||
if (commanderMana == null) {
|
||||
Card commander = game.getCard(controller.getCommanderId());
|
||||
for (UUID commanderId : controller.getCommandersIds()) {
|
||||
Card commander = game.getCard(commanderId);
|
||||
if (commander != null) {
|
||||
commanderMana = CardUtil.getColorIdentity(commander);
|
||||
} else {
|
||||
// In formats other than Commander, Command Tower's ability produces no mana.
|
||||
commanderMana = new FilterMana();
|
||||
FilterMana commanderMana = CardUtil.getColorIdentity(commander);
|
||||
if (commanderMana.isBlack()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.B));
|
||||
}
|
||||
if (commanderMana.isBlue()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.U));
|
||||
}
|
||||
if (commanderMana.isGreen()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.G));
|
||||
}
|
||||
if (commanderMana.isRed()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.R));
|
||||
}
|
||||
if (commanderMana.isWhite()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.W));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commanderMana.isBlack()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.B));
|
||||
}
|
||||
if (commanderMana.isBlue()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.U));
|
||||
}
|
||||
if (commanderMana.isGreen()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.G));
|
||||
}
|
||||
if (commanderMana.isRed()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.R));
|
||||
}
|
||||
if (commanderMana.isWhite()) {
|
||||
netMana.add(new Mana(ColoredManaSymbol.W));
|
||||
}
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
|
|
@ -113,17 +107,13 @@ public class CommanderColorIdentityManaAbility extends ActivatedManaAbilityImpl
|
|||
|
||||
class CommanderIdentityManaEffect extends ManaEffect {
|
||||
|
||||
private FilterMana commanderMana;
|
||||
|
||||
public CommanderIdentityManaEffect() {
|
||||
super();
|
||||
this.staticText = "Add to your mana pool one mana of any color in your commander's color identity";
|
||||
commanderMana = null;
|
||||
}
|
||||
|
||||
public CommanderIdentityManaEffect(final CommanderIdentityManaEffect effect) {
|
||||
super(effect);
|
||||
this.commanderMana = effect.commanderMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -135,31 +125,28 @@ class CommanderIdentityManaEffect extends ManaEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (commanderMana == null) {
|
||||
Card commander = game.getCard(controller.getCommanderId());
|
||||
if (commander != null) {
|
||||
commanderMana = CardUtil.getColorIdentity(commander);
|
||||
} else {
|
||||
// In formats other than Commander, Command Tower's ability produces no mana.
|
||||
commanderMana = new FilterMana();
|
||||
}
|
||||
}
|
||||
Choice choice = new ChoiceImpl();
|
||||
choice.setMessage("Pick a mana color");
|
||||
if (commanderMana.isBlack()) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (commanderMana.isRed()) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (commanderMana.isBlue()) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (commanderMana.isGreen()) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
if (commanderMana.isWhite()) {
|
||||
choice.getChoices().add("White");
|
||||
for (UUID commanderId : controller.getCommandersIds()) {
|
||||
Card commander = game.getCard(commanderId);
|
||||
if (commander != null) {
|
||||
FilterMana commanderMana = CardUtil.getColorIdentity(commander);
|
||||
if (commanderMana.isWhite()) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
if (commanderMana.isBlue()) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (commanderMana.isBlack()) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (commanderMana.isRed()) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (commanderMana.isGreen()) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice.getChoices().size() > 0) {
|
||||
if (choice.getChoices().size() == 1) {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public enum CounterType {
|
|||
FATE("fate"),
|
||||
FEATHER("feather"),
|
||||
FLOOD("flood"),
|
||||
FURY("fury"),
|
||||
FUSE("fuse"),
|
||||
GOLD("gold"),
|
||||
HATCHLING("hatchling"),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class CommanderPredicate implements Predicate<Permanent> {
|
|||
Player owner = game.getPlayer(input.getOwnerId());
|
||||
return input.getCardType().contains(CardType.CREATURE)
|
||||
&& owner != null
|
||||
&& input.getId().equals(owner.getCommanderId());
|
||||
&& input.getId().equals(owner.getCommandersIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -76,16 +76,14 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
|
||||
Player player = getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.getSideboard().size() > 0) {
|
||||
Card commander = getCard((UUID) player.getSideboard().toArray()[0]);
|
||||
while (player.getSideboard().size() > 0) {
|
||||
Card commander = this.getCard(player.getSideboard().iterator().next());
|
||||
if (commander != null) {
|
||||
player.setCommanderId(commander.getId());
|
||||
player.addCommanderId(commander.getId());
|
||||
commander.moveToZone(Zone.COMMAND, null, this, true);
|
||||
commander.getAbilities().setControllerId(player.getId());
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
|
||||
ability.addEffect(new CommanderCostModification(commander.getId()));
|
||||
// Commander rule #4 was removed Jan. 18, 2016
|
||||
// ability.addEffect(new CommanderManaReplacementEffect(player.getId(), CardUtil.getColorIdentity(commander)));
|
||||
getState().setValue(commander.getId() + "_castCount", 0);
|
||||
CommanderInfoWatcher watcher = new CommanderInfoWatcher(commander.getId(), CHECK_COMMANDER_DAMAGE);
|
||||
getState().getWatchers().add(watcher);
|
||||
|
|
@ -93,7 +91,6 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this.getState().addAbility(ability, null);
|
||||
super.init(choosingPlayerId);
|
||||
|
|
@ -189,15 +186,17 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
@Override
|
||||
protected boolean checkStateBasedActions() {
|
||||
for (Player player : getPlayers().values()) {
|
||||
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get("CommanderCombatDamageWatcher", player.getCommanderId());
|
||||
if (damageWatcher == null) {
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<UUID, Integer> entrySet : damageWatcher.getDamageToPlayer().entrySet()) {
|
||||
if (entrySet.getValue() > 20) {
|
||||
Player opponent = getPlayer(entrySet.getKey());
|
||||
if (opponent != null && !opponent.hasLost() && player.isInGame()) {
|
||||
opponent.lost(this);
|
||||
for (UUID commanderId : player.getCommandersIds()) {
|
||||
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get("CommanderCombatDamageWatcher", commanderId);
|
||||
if (damageWatcher == null) {
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<UUID, Integer> entrySet : damageWatcher.getDamageToPlayer().entrySet()) {
|
||||
if (entrySet.getValue() > 20) {
|
||||
Player opponent = getPlayer(entrySet.getKey());
|
||||
if (opponent != null && !opponent.hasLost() && player.isInGame()) {
|
||||
opponent.lost(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl {
|
|||
Set<Card> cards = new HashSet<>();
|
||||
cards.add(commander);
|
||||
this.loadCards(cards, playerId);
|
||||
player.setCommanderId(commander.getId());
|
||||
player.addCommanderId(commander.getId());
|
||||
commander.moveToZone(Zone.COMMAND, null, this, true);
|
||||
ability.addEffect(new CommanderReplacementEffect(commander.getId(), alsoHand, alsoLibrary));
|
||||
ability.addEffect(new CommanderCostModification(commander.getId()));
|
||||
|
|
|
|||
|
|
@ -161,9 +161,6 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
String getValue(GameState state);
|
||||
|
||||
@Deprecated
|
||||
void addAbility(Ability ability);
|
||||
|
||||
@Deprecated
|
||||
void addAbility(Ability ability, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -265,12 +265,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return abilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addAbility(Ability ability) {
|
||||
throw new UnsupportedOperationException("Unsupported operation: use addAbility(Ability ability, Game game) instead");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ability
|
||||
|
|
|
|||
|
|
@ -645,16 +645,16 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
/**
|
||||
* Set the commanderId of the player
|
||||
*
|
||||
* @param commanderId
|
||||
* @param commandersIds
|
||||
*/
|
||||
void setCommanderId(UUID commanderId);
|
||||
void addCommanderId(UUID commanderId);
|
||||
|
||||
/**
|
||||
* Get the commanderId of the player
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
UUID getCommanderId();
|
||||
Set<UUID> getCommandersIds();
|
||||
|
||||
/**
|
||||
* Moves cards from one zone to another
|
||||
|
|
|
|||
|
|
@ -105,7 +105,12 @@ import mage.filter.common.FilterCreatureForCombat;
|
|||
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.*;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.Graveyard;
|
||||
import mage.game.Table;
|
||||
import mage.game.ZoneChangeInfo;
|
||||
import mage.game.ZonesHandler;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.events.DamagePlayerEvent;
|
||||
|
|
@ -153,7 +158,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
protected Cards sideboard;
|
||||
protected Cards hand;
|
||||
protected Graveyard graveyard;
|
||||
protected UUID commanderId;
|
||||
protected Set<UUID> commandersIds = new HashSet<>(0);
|
||||
protected Abilities<Ability> abilities;
|
||||
protected Counters counters;
|
||||
protected int landsPlayed;
|
||||
|
|
@ -273,7 +278,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.sideboard = player.sideboard.copy();
|
||||
this.hand = player.hand.copy();
|
||||
this.graveyard = player.graveyard.copy();
|
||||
this.commanderId = player.commanderId;
|
||||
this.commandersIds = player.commandersIds;
|
||||
this.abilities = player.abilities.copy();
|
||||
this.counters = player.counters.copy();
|
||||
|
||||
|
|
@ -359,7 +364,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.sideboard = player.getSideboard().copy();
|
||||
this.hand = player.getHand().copy();
|
||||
this.graveyard = player.getGraveyard().copy();
|
||||
this.commanderId = player.getCommanderId();
|
||||
this.commandersIds = player.getCommandersIds();
|
||||
this.abilities = player.getAbilities().copy();
|
||||
this.counters = player.getCounters().copy();
|
||||
|
||||
|
|
@ -3124,13 +3129,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCommanderId(UUID commanderId) {
|
||||
this.commanderId = commanderId;
|
||||
public void addCommanderId(UUID commanderId) {
|
||||
this.commandersIds.add(commanderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getCommanderId() {
|
||||
return this.commanderId;
|
||||
public Set<UUID> getCommandersIds() {
|
||||
return this.commandersIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue