moved computation of dynamic cost into MagicCard so that it will show corrected in the UI
parent
af844e58b7
commit
2b7cb18534
|
@ -97,6 +97,15 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable<MagicCard>
|
|||
return token;
|
||||
}
|
||||
|
||||
public MagicManaCost getCost() {
|
||||
final MagicManaCost cost = getCardDefinition().getCost();
|
||||
final MagicGame game = getGame();
|
||||
|
||||
//cost modifications due to continous effects
|
||||
|
||||
return cost;
|
||||
}
|
||||
|
||||
public static MagicCard createTokenCard(final MagicCardDefinition cardDefinition,final MagicPlayer owner) {
|
||||
final MagicCard card=new MagicCard(cardDefinition,owner,MagicCard.TOKEN_ID);
|
||||
card.setToken();
|
||||
|
|
|
@ -12,14 +12,12 @@ public class MagicPayDelayedCostAction extends MagicAction {
|
|||
private MagicBuilderManaCost oldBuilderCost;
|
||||
|
||||
public MagicPayDelayedCostAction(final MagicPlayer player,final MagicDelayedPayManaCostResult result) {
|
||||
|
||||
this.player=player;
|
||||
this.result=result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final MagicGame game) {
|
||||
|
||||
oldBuilderCost=player.getBuilderCost();
|
||||
final MagicBuilderManaCost builderCost=new MagicBuilderManaCost(oldBuilderCost);
|
||||
result.getCost().addTo(builderCost,result.getX());
|
||||
|
@ -28,7 +26,6 @@ public class MagicPayDelayedCostAction extends MagicAction {
|
|||
|
||||
@Override
|
||||
public void undoAction(final MagicGame game) {
|
||||
|
||||
player.setBuilderCost(oldBuilderCost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class MagicCardActivation extends MagicActivation {
|
|||
|
||||
@Override
|
||||
protected MagicEvent[] getCostEvent(final MagicSource source) {
|
||||
final MagicManaCost cost = MagicLayer.getManaCost(source);
|
||||
final MagicManaCost cost = ((MagicCard)source).getCost();
|
||||
|
||||
if (cost!=MagicManaCost.ZERO) {
|
||||
return new MagicEvent[]{new MagicPayManaCostEvent(source,source.getController(),cost)};
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package magic.model.mstatic;
|
||||
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicSource;
|
||||
import magic.model.MagicManaCost;
|
||||
|
||||
public enum MagicLayer {
|
||||
Card, //0. properties from the card, not formally defined in rules
|
||||
Copy, //1. copy
|
||||
|
@ -22,13 +18,4 @@ public enum MagicLayer {
|
|||
Player, //8. affect player, not objects
|
||||
Game, //9. affect game rules, not objects
|
||||
;
|
||||
|
||||
public static MagicManaCost getManaCost(final MagicSource source) {
|
||||
final MagicManaCost cost = source.getCardDefinition().getCost();
|
||||
final MagicGame game = source.getGame();
|
||||
|
||||
//cost modifications due to continous effects
|
||||
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public abstract class CardListViewer extends JPanel implements ChoiceViewer {
|
|||
|
||||
final MagicCardDefinition cardDefinition=card.getCardDefinition();
|
||||
|
||||
final CostPanel costPanel=new CostPanel(graveyard||cardDefinition.isLand()?null:cardDefinition.getCost());
|
||||
final CostPanel costPanel=new CostPanel(graveyard||cardDefinition.isLand()?null:card.getCost());
|
||||
|
||||
nameLabel=new JLabel(cardDefinition.getName());
|
||||
nameLabel.setForeground(cardDefinition.getRarityColor());
|
||||
|
|
|
@ -163,7 +163,7 @@ public class ImageCardListViewer extends JPanel implements ChoiceViewer {
|
|||
if (cardDefinition.isLand()) {
|
||||
ImageDrawingUtils.drawManaInfo(g,this,cardDefinition,x1+1,y2-17);
|
||||
} else {
|
||||
ImageDrawingUtils.drawCostInfo(g,this,cardDefinition.getCost(),x1,x2-1,y1+2);
|
||||
ImageDrawingUtils.drawCostInfo(g,this,card.getCost(),x1,x2-1,y1+2);
|
||||
}
|
||||
if (cardDefinition.isCreature()) {
|
||||
ImageDrawingUtils.drawAbilityInfo(g,this,cardDefinition.getAbilityFlags(),x1+2,y2-18);
|
||||
|
|
Loading…
Reference in New Issue