mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Now tokens connected to the source by expansionSetCode - results in token image displayed.
This commit is contained in:
parent
278a52941f
commit
611c4b7b2f
5 changed files with 17 additions and 9 deletions
|
@ -94,12 +94,10 @@ public class CardView implements Serializable {
|
|||
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
||||
if (card instanceof PermanentToken) {
|
||||
this.rarity = Rarity.NA;
|
||||
this.expansionSetCode = "";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.rarity = card.getRarity();
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
}
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
this.cardNumber = card.getCardNumber();
|
||||
|
||||
if (card instanceof Spell) {
|
||||
|
@ -127,7 +125,7 @@ public class CardView implements Serializable {
|
|||
this.color = token.getColor();
|
||||
this.manaCost = token.getManaCost().getSymbols();
|
||||
this.rarity = Rarity.NA;
|
||||
this.expansionSetCode = "";
|
||||
//this.expansionSetCode = "";
|
||||
}
|
||||
|
||||
protected void setTargets(Targets targets) {
|
||||
|
|
|
@ -74,6 +74,7 @@ public class PermanentView extends CardView {
|
|||
}
|
||||
if (permanent instanceof PermanentToken) {
|
||||
original = new CardView(((PermanentToken)permanent).getToken());
|
||||
original.expansionSetCode = permanent.getExpansionSetCode();
|
||||
}
|
||||
else {
|
||||
original = new CardView(card);
|
||||
|
|
|
@ -73,7 +73,10 @@ public class CreateTokenEffect extends OneShotEffect<CreateTokenEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (int i = 0; i < amount.calculate(game, source); i++) {
|
||||
token.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
// we need to specify source.getSourceId(), not source.getId()
|
||||
// as we most interested in the game object that created effect,
|
||||
// not in ability uuid
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -43,15 +43,17 @@ public class PermanentToken extends PermanentImpl<PermanentToken> {
|
|||
|
||||
protected Token token;
|
||||
|
||||
public PermanentToken(Token token, UUID controllerId) {
|
||||
public PermanentToken(Token token, UUID controllerId, String expansionSetCode) {
|
||||
super(controllerId, controllerId, token.getName());
|
||||
this.token = token;
|
||||
this.expansionSetCode = expansionSetCode;
|
||||
copyFromToken(token);
|
||||
}
|
||||
|
||||
public PermanentToken(final PermanentToken permanent) {
|
||||
super(permanent);
|
||||
this.token = permanent.token.copy();
|
||||
this.expansionSetCode = permanent.expansionSetCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,8 +36,10 @@ import mage.MageObjectImpl;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
|
||||
public class Token extends MageObjectImpl<Token> {
|
||||
|
@ -86,9 +88,11 @@ public class Token extends MageObjectImpl<Token> {
|
|||
}
|
||||
|
||||
public boolean putOntoBattlefield(Game game, UUID sourceId, UUID controllerId) {
|
||||
PermanentToken permanent = new PermanentToken(this, controllerId);
|
||||
Card source = game.getCard(sourceId);
|
||||
String setCode = source != null ? source.getExpansionSetCode() : null;
|
||||
PermanentToken permanent = new PermanentToken(this, controllerId, setCode);
|
||||
game.getBattlefield().addPermanent(permanent);
|
||||
this.lastAddedTokenId = permanent.getId();
|
||||
this.lastAddedTokenId = permanent.getId();
|
||||
permanent.entersBattlefield(sourceId, game);
|
||||
game.applyEffects();
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));
|
||||
|
|
Loading…
Reference in a new issue