* Minds Aglow - Fixed that payed mana can be undone if X was set to a too high value.

This commit is contained in:
LevelX2 2017-07-30 18:50:36 +02:00
parent 12f094e854
commit 7b168a9d5e
3 changed files with 22 additions and 16 deletions

View file

@ -1281,7 +1281,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
hideTables();
SessionHandler.disconnect(false);
if (errorCall) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + '?');
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);

View file

@ -47,8 +47,7 @@ import mage.players.Player;
public class MindsAglow extends CardImpl {
public MindsAglow(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}");
// Join forces - Starting with you, each player may pay any amount of mana. Each player draws X cards, where X is the total amount of mana paid this way.
this.getSpellAbility().addEffect(new MindsAglowEffect());
@ -66,44 +65,44 @@ public class MindsAglow extends CardImpl {
}
class MindsAglowEffect extends OneShotEffect {
public MindsAglowEffect() {
super(Outcome.Detriment);
this.staticText = "<i>Join forces</i> - Starting with you, each player may pay any amount of mana. Each player draws X cards, where X is the total amount of mana paid this way";
}
public MindsAglowEffect(final MindsAglowEffect effect) {
super(effect);
}
@Override
public MindsAglowEffect copy() {
return new MindsAglowEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int xSum = 0;
xSum += playerPaysXGenericMana(controller, source, game);
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (!Objects.equals(playerId, controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
xSum += playerPaysXGenericMana(player, source, game);
}
}
}
if (xSum > 0) {
for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(xSum, game);
}
}
}
// prevent undo
controller.resetStoredBookmark(game);
@ -120,6 +119,9 @@ class MindsAglowEffect extends OneShotEffect {
if (xValue > 0) {
Cost cost = new GenericManaCost(xValue);
payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
if (!payed) {
game.undo(player.getId());
}
} else {
payed = true;
}

View file

@ -69,8 +69,8 @@ import mage.util.SubTypeList;
*/
public class Spell extends StackObjImpl implements Card {
private final List<Card> spellCards = new ArrayList<>();
private final List<SpellAbility> spellAbilities = new ArrayList<>();
private final List<Card> spellCards = new ArrayList<>();
private final Card card;
private final ObjectColor color;
@ -108,7 +108,6 @@ public class Spell extends StackObjImpl implements Card {
this.controllerId = controllerId;
this.fromZone = fromZone;
this.countered = false;
this.doneActivatingManaAbilities = false;
}
public Spell(final Spell spell) {
@ -129,13 +128,18 @@ public class Spell extends StackObjImpl implements Card {
} else {
this.card = spell.card.copy();
}
this.controllerId = spell.controllerId;
this.fromZone = spell.fromZone;
this.copiedSpell = spell.copiedSpell;
this.faceDown = spell.faceDown;
this.color = spell.color.copy();
this.frameColor = spell.color.copy();
this.frameStyle = spell.frameStyle;
this.controllerId = spell.controllerId;
this.copiedSpell = spell.copiedSpell;
this.faceDown = spell.faceDown;
this.countered = spell.countered;
this.resolving = spell.resolving;
this.doneActivatingManaAbilities = spell.doneActivatingManaAbilities;
}