mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Fixed a problem that Spell objects were not handled always correctly in game view.
This commit is contained in:
parent
925db89f31
commit
5925bdf259
1 changed files with 9 additions and 27 deletions
|
@ -27,18 +27,14 @@
|
||||||
*/
|
*/
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -60,8 +56,6 @@ import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -105,7 +99,12 @@ public class GameView implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (StackObject stackObject : state.getStack()) {
|
for (StackObject stackObject : state.getStack()) {
|
||||||
if (stackObject instanceof StackAbility) {
|
if (stackObject instanceof Spell) {
|
||||||
|
// Spell
|
||||||
|
CardView spellView = new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId));
|
||||||
|
spellView.paid = ((Spell) stackObject).getSpellAbility().getManaCostsToPay().isPaid();
|
||||||
|
stack.put(stackObject.getId(), spellView);
|
||||||
|
} else if (stackObject instanceof StackAbility) {
|
||||||
// Stack Ability
|
// Stack Ability
|
||||||
MageObject object = game.getObject(stackObject.getSourceId());
|
MageObject object = game.getObject(stackObject.getSourceId());
|
||||||
Card card = game.getCard(stackObject.getSourceId());
|
Card card = game.getCard(stackObject.getSourceId());
|
||||||
|
@ -161,9 +160,7 @@ public class GameView implements Serializable {
|
||||||
LOGGER.debug("Stack Object for stack ability not found: " + stackObject.getStackAbility().getRule());
|
LOGGER.debug("Stack Object for stack ability not found: " + stackObject.getStackAbility().getRule());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Spell
|
LOGGER.fatal("Unknown type of StackObject: " + stackObject.getName() + ' ' + stackObject.toString() + ' ' + stackObject.getClass().toString());
|
||||||
stack.put(stackObject.getId(), new CardView((Spell) stackObject, game, stackObject.getControllerId().equals(createdForPlayerId)));
|
|
||||||
checkPaid(stackObject.getId(), (Spell) stackObject);
|
|
||||||
}
|
}
|
||||||
//stackOrder.add(stackObject.getId());
|
//stackOrder.add(stackObject.getId());
|
||||||
}
|
}
|
||||||
|
@ -223,21 +220,6 @@ public class GameView implements Serializable {
|
||||||
cardView.paid = true;
|
cardView.paid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPaid(UUID uuid, Spell spell) {
|
|
||||||
for (Cost cost : spell.getSpellAbility().getManaCostsToPay()) {
|
|
||||||
if (!cost.isPaid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CardView cardView = stack.get(uuid);
|
|
||||||
cardView.paid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPaid(UUID uuid) {
|
|
||||||
CardView cardView = stack.get(uuid);
|
|
||||||
cardView.paid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLatestCardView(Game game, Card card, UUID stackId) {
|
private void updateLatestCardView(Game game, Card card, UUID stackId) {
|
||||||
if (!card.isTransformable()) {
|
if (!card.isTransformable()) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue