forked from External/mage
Some changes to userData handling. Added country flag to some dialogs. Saved and restored some more table columns width and order information.
This commit is contained in:
parent
cb3b5f895b
commit
87f3978589
32 changed files with 1982 additions and 1699 deletions
|
|
@ -227,6 +227,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
protected UserData userData;
|
||||
protected MatchPlayer matchPlayer;
|
||||
|
||||
protected String flagName;
|
||||
|
||||
/**
|
||||
* During some steps we can't play anything
|
||||
*/
|
||||
|
|
@ -571,7 +573,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns true if the player has the control itself - false if the player is controlled by another player
|
||||
* returns true if the player has the control itself - false if the player
|
||||
* is controlled by another player
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -701,7 +705,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (random) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Card card = this.getHand().getRandom(game);
|
||||
if(card != null) {
|
||||
if (card != null) {
|
||||
discardedCards.add(card);
|
||||
discard(card, source, game);
|
||||
}
|
||||
|
|
@ -917,7 +921,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return castSourceIdManaCosts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInPayManaMode() {
|
||||
return payManaMode;
|
||||
|
|
@ -939,7 +942,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// some effects set sourceId to cast without paying mana costs
|
||||
if (ability.getSourceId().equals(getCastSourceIdWithAlternateMana())) {
|
||||
ManaCosts alternateCosts = getCastSourceIdManaCosts();
|
||||
Ability spellAbility = spell.getSpellAbility();
|
||||
Ability spellAbility = spell.getSpellAbility();
|
||||
if (alternateCosts == null) {
|
||||
noMana = true;
|
||||
} else {
|
||||
|
|
@ -1096,7 +1099,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
if (ability instanceof PlayLandAbility) {
|
||||
|
||||
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
result = playLand(card, game);
|
||||
} else {
|
||||
|
|
@ -1338,7 +1340,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
game.getState().getLookedAt(this.playerId).add(name, card);
|
||||
game.fireUpdatePlayersEvent();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void lookAtCards(String name, Cards cards, Game game) {
|
||||
game.getState().getLookedAt(this.playerId).add(name, cards);
|
||||
|
|
@ -1679,7 +1681,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
} else if (source instanceof Card) {
|
||||
sourceAbilities = ((Card) source).getAbilities(game);
|
||||
sourceControllerId = ((Card) source).getOwnerId();
|
||||
} else if (source instanceof CommandObject){
|
||||
} else if (source instanceof CommandObject) {
|
||||
sourceControllerId = ((CommandObject) source).getControllerId();
|
||||
sourceAbilities = ((CommandObject) source).getAbilities();
|
||||
}
|
||||
|
|
@ -2033,7 +2035,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
Permanent attacker = game.getPermanent(attackerId);
|
||||
if (attacker != null && attacker.canAttack(defenderId, game) && attacker.getControllerId().equals(playerId)) {
|
||||
if(!game.getCombat().declareAttacker(attackerId, defenderId, playerId, game)) {
|
||||
if (!game.getCombat().declareAttacker(attackerId, defenderId, playerId, game)) {
|
||||
game.undo(playerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -2285,64 +2287,64 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
protected boolean canPlayCardByAlternateCost(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
||||
if (sourceObject != null && !(sourceObject instanceof Permanent)) {
|
||||
for (Ability alternateSourceCostsAbility : sourceObject.getAbilities()) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (alternateSourceCostsAbility instanceof AlternativeSourceCosts) {
|
||||
if (((AlternativeSourceCosts) alternateSourceCostsAbility).isAvailable(ability, game)) {
|
||||
if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) {
|
||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||
for (Cost cost : alternateSourceCostsAbility.getCosts()) {
|
||||
if (cost instanceof ManaCost) {
|
||||
manaCosts.add((ManaCost) cost);
|
||||
}
|
||||
}
|
||||
if (sourceObject != null && !(sourceObject instanceof Permanent)) {
|
||||
for (Ability alternateSourceCostsAbility : sourceObject.getAbilities()) {
|
||||
// if cast for noMana no Alternative costs are allowed
|
||||
if (alternateSourceCostsAbility instanceof AlternativeSourceCosts) {
|
||||
if (((AlternativeSourceCosts) alternateSourceCostsAbility).isAvailable(ability, game)) {
|
||||
if (alternateSourceCostsAbility.getCosts().canPay(ability, playerId, playerId, game)) {
|
||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||
for (Cost cost : alternateSourceCostsAbility.getCosts()) {
|
||||
if (cost instanceof ManaCost) {
|
||||
manaCosts.add((ManaCost) cost);
|
||||
}
|
||||
}
|
||||
|
||||
if (manaCosts.size() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
for (Mana mana : manaCosts.getOptions()) {
|
||||
for (Mana avail : available) {
|
||||
if (mana.enough(avail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (manaCosts.size() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
for (Mana mana : manaCosts.getOptions()) {
|
||||
for (Mana avail : available) {
|
||||
if (mana.enough(avail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// controller specific alternate spell costs
|
||||
for (AlternativeSourceCosts alternateSourceCosts: getAlternativeSourceCosts()) {
|
||||
if (alternateSourceCosts instanceof Ability) {
|
||||
if (alternateSourceCosts.isAvailable(ability, game)) {
|
||||
if (((Ability) alternateSourceCosts).getCosts().canPay(ability, playerId, playerId, game)) {
|
||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||
for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) {
|
||||
if (cost instanceof ManaCost) {
|
||||
manaCosts.add((ManaCost) cost);
|
||||
}
|
||||
}
|
||||
// controller specific alternate spell costs
|
||||
for (AlternativeSourceCosts alternateSourceCosts : getAlternativeSourceCosts()) {
|
||||
if (alternateSourceCosts instanceof Ability) {
|
||||
if (alternateSourceCosts.isAvailable(ability, game)) {
|
||||
if (((Ability) alternateSourceCosts).getCosts().canPay(ability, playerId, playerId, game)) {
|
||||
ManaCostsImpl manaCosts = new ManaCostsImpl();
|
||||
for (Cost cost : ((Ability) alternateSourceCosts).getCosts()) {
|
||||
if (cost instanceof ManaCost) {
|
||||
manaCosts.add((ManaCost) cost);
|
||||
}
|
||||
}
|
||||
|
||||
if (manaCosts.size() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
for (Mana mana : manaCosts.getOptions()) {
|
||||
for (Mana avail : available) {
|
||||
if (mana.enough(avail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (manaCosts.size() == 0) {
|
||||
return true;
|
||||
} else {
|
||||
for (Mana mana : manaCosts.getOptions()) {
|
||||
for (Mana avail : available) {
|
||||
if (mana.enough(avail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canLandPlayAlternateSourceCostsAbility(Card sourceObject, ManaOptions available, Ability ability, Game game) {
|
||||
|
|
@ -2847,7 +2849,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game) {
|
||||
ArrayList<Card> cardList = new ArrayList<>();
|
||||
for (UUID cardId: cards) {
|
||||
for (UUID cardId : cards) {
|
||||
if (fromZone.equals(Zone.BATTLEFIELD)) {
|
||||
Permanent permanent = game.getPermanent(cardId);
|
||||
if (permanent != null) {
|
||||
|
|
@ -2857,7 +2859,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
cardList.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return moveCards(cardList, fromZone, toZone, source, game);
|
||||
|
|
@ -2878,10 +2880,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return true;
|
||||
}
|
||||
game.fireEvent(new ZoneChangeGroupEvent(cards, source == null ? null : source.getSourceId(), this.getId(), fromZone, toZone));
|
||||
switch(toZone) {
|
||||
switch (toZone) {
|
||||
case EXILED:
|
||||
boolean result = false;
|
||||
for(Card card: cards) {
|
||||
for (Card card : cards) {
|
||||
result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, true);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -2889,7 +2891,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return moveCardsToGraveyardWithInfo(cards, source, game, fromZone);
|
||||
case HAND:
|
||||
result = false;
|
||||
for(Card card: cards) {
|
||||
for (Card card : cards) {
|
||||
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -2912,7 +2914,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
if (!game.isSimulation()) {
|
||||
StringBuilder sb = new StringBuilder(this.getLogName()).append(" puts ").append(withName ? card.getLogName() : "a face down card");
|
||||
switch(fromZone) {
|
||||
switch (fromZone) {
|
||||
case EXILED:
|
||||
sb.append(" from exile zone ");
|
||||
break;
|
||||
|
|
@ -3051,8 +3053,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (card instanceof PermanentCard) {
|
||||
card = game.getCard(card.getId());
|
||||
}
|
||||
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() : "a card face down") + " " +
|
||||
(fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "") + "to the exile zone");
|
||||
game.informPlayers(this.getLogName() + " moves " + (withName ? card.getLogName() : "a card face down") + " "
|
||||
+ (fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "") + "to the exile zone");
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
|
|
@ -3075,7 +3077,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(this.getLogName())
|
||||
.append(" puts ").append(facedown ? "a card face down ":card.getLogName())
|
||||
.append(" puts ").append(facedown ? "a card face down " : card.getLogName())
|
||||
.append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")
|
||||
.append("onto the Battlefield").toString());
|
||||
}
|
||||
|
|
@ -3129,7 +3131,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
usersAllowedToSeeHandCards.add(watcherUserId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRequestToShowHandCardsAllowed() {
|
||||
return userData.isAllowRequestShowHandCards();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue