@Override public String getValue(GameState state) { StringBuilder sb = threadLocalBuilder.get(); sb.append(controllerId).append(getName()).append(tapped).append(damage); sb.append(subtype).append(supertype).append(power.getValue()).append(toughness.getValue()); sb.append(abilities.getValue()); for (Counter counter : getCounters(state).values()) { sb.append(counter.getName()).append(counter.getCount()); } return sb.toString(); }
@Override public boolean turnFaceUp(Game game, UUID playerId) { if (super.turnFaceUp(game, playerId)) { power.modifyBaseValue(power.getBaseValue()); toughness.modifyBaseValue(toughness.getBaseValue()); setManifested(false); setMorphed(false); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (target != null) { int power = target.getPower().getValue(); target.getPower().setValue(target.getToughness().getValue()); target.getToughness().setValue(power); return true; } return false; }
public PermanentToken(Token token, UUID controllerId, String expansionSetCode, Game game) { super(controllerId, controllerId, token.getName()); this.expansionSetCode = expansionSetCode; this.token = token.copy(); this.token.getAbilities().newOriginalId(); // neccessary if token has ability like DevourAbility() this.token.getAbilities().setSourceId(objectId); this.power.modifyBaseValue(token.getPower().getBaseValueModified()); this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified()); this.copyFromToken(this.token, game, false); // needed to have at this time (e.g. for subtypes for entersTheBattlefield replacement effects) }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURES, player.getId(), game); int amount = 0; for (Permanent creature : creatures) { int power = creature.getPower().getValue(); if (amount < power) { amount = power; } } OozeToken oozeToken = new OozeToken(); oozeToken.getPower().modifyBaseValue(amount); oozeToken.getToughness().modifyBaseValue(amount); oozeToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); return true; } return false; } }
@Override public void setPower(int power) { this.power.setValue(power); }
public TokenImpl(String name, String description, int power, int toughness) { this(name, description); this.power.modifyBaseValue(power); this.toughness.modifyBaseValue(toughness); }
if (object instanceof Permanent) { this.mageObjectType = MageObjectType.PERMANENT; this.power = Integer.toString(object.getPower().getValue()); this.toughness = Integer.toString(object.getToughness().getValue()); this.loyalty = Integer.toString(((Permanent) object).getCounters((Game) null).getCount(CounterType.LOYALTY)); } else { this.power = object.getPower().toString(); this.toughness = object.getToughness().toString(); this.loyalty = "";
@Override public void reset(Game game) { copyFromToken(token, game, true); super.reset(game); // Because the P/T objects have there own base value for reset we have to take it from there instead of from the basic token object this.power.resetToBaseValue(); this.toughness.resetToBaseValue(); }
@Override public boolean apply(Game game, Ability source) { Permanent targetCreature = game.getPermanent(source.getFirstTarget()); if (targetCreature != null) { int toughness = targetCreature.getToughness().getBaseValueModified(); game.addEffect(new SetPowerToughnessTargetEffect(0, toughness, Duration.EndOfTurn), source); return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Permanent sourcePermanent = game.getPermanent(getSourceId()); MageObject mageObject = game.getObject(getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell == null || sourcePermanent == null || mageObject == null) { return false; } Integer doomNumber = (Integer) game.getState().getValue(mageObject.getId() + "_doom"); if (doomNumber == null || doomNumber == 0) { return false; } if (!spell.isFaceDown(game)) { String doomString = doomNumber.toString(); if (spell.getCard().getManaCost().getText().contains(doomString) || String.valueOf(spell.getPower().getBaseValue()).contains(doomString) || String.valueOf(spell.getToughness().getBaseValue()).contains(doomString)) { return true; } else { for (String string : spell.getCard().getRules()) { if (string.contains(doomString)) { return true; } } } } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); if (sourcePermanent != null) { int power = sourcePermanent.getPower().getValue(); sourcePermanent.getPower().setValue(sourcePermanent.getToughness().getValue()); sourcePermanent.getToughness().setValue(power); return true; } else { if (duration.isOnlyValidIfNoZoneChange()) { discard(); } } return false; }
@Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(source.getFirstTarget()); if (opponent != null && opponent.isLifeTotalCanChange()) { Permanent perm = game.getPermanent(source.getSourceId()); if (perm != null) { int amount = perm.getToughness().getValue(); int life = opponent.getLife(); if (life == amount) { return false; } if (life < amount && !opponent.isCanGainLife()) { return false; } if (life > amount && !opponent.isCanLoseLife()) { return false; } opponent.setLife(amount, game, source); perm.getToughness().modifyBaseValue(life); // game.addEffect(new SetPowerToughnessSourceEffect(Integer.MIN_VALUE, life, Duration.Custom, SubLayer.SetPT_7b), source); return true; } } return false; }
@Override public void setToughness(int toughness) { this.toughness.setValue(toughness); }
@Override public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { permanent.removePTCDA(); permanent.getPower().modifyBaseValue(7); permanent.getToughness().modifyBaseValue(7); return true; }
target.getPower().modifyBaseValue(sourceObj.getPower().getBaseValueModified()); target.getToughness().modifyBaseValue(sourceObj.getToughness().getBaseValueModified());
@Override public void reset(Game game) { // when the permanent is reset, copy all original values from the card // must copy card each reset so that the original values don't get modified copyFromCard(card, game); power.resetToBaseValue(); toughness.resetToBaseValue(); super.reset(game); }