mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
added CREATE_TOKEN event
This commit is contained in:
parent
1b84072fa7
commit
9327d525c4
23 changed files with 43 additions and 45 deletions
|
|
@ -90,9 +90,7 @@ class MartialCoupEffect extends OneShotEffect<MartialCoupEffect> {
|
|||
permanent.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < amount; i++) {
|
||||
token.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
}
|
||||
token.putOntoBattlefield(amount, game, source.getId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class BackFromTheBrinkEffect extends OneShotEffect<BackFromTheBrinkEffect> {
|
|||
if (card != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(card);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class CacklingCounterpartEffect extends OneShotEffect<CacklingCounterpartEffect>
|
|||
if (card != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(card);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class CellarDoorEffect extends OneShotEffect<CellarDoorEffect> {
|
|||
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, true);
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
ZombieToken token = new ZombieToken();
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class GeistOfSaintTraftEffect extends OneShotEffect<GeistOfSaintTraftEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
AngelToken token = new AngelToken();
|
||||
if (token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId())) {
|
||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||
Permanent p = game.getPermanent(token.getLastAddedToken());
|
||||
game.getCombat().declareAttacker(p.getId(), game.getCombat().getDefendingPlayer(source.getSourceId()), game);
|
||||
Effect effect = new ExileTargetEffect();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class DruidicSatchelEffect extends OneShotEffect<DruidicSatchelEffect> {
|
|||
if (card != null) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
Token token = new SaprolingToken();
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
player.getLibrary().remove(card.getId(), game);
|
||||
|
|
|
|||
|
|
@ -93,9 +93,7 @@ class ThroneOfEmpiresEffect extends OneShotEffect<ThroneOfEmpiresEffect> {
|
|||
}
|
||||
Token soldier = new SoldierToken();
|
||||
int count = scepter && crown ? 5 : 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
soldier.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
soldier.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,12 +87,10 @@ class HeroOfBladeholdEffect extends OneShotEffect<HeroOfBladeholdEffect> {
|
|||
SoldierToken token = new SoldierToken();
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
token.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
Permanent p = game.getPermanent(token.getLastAddedToken());
|
||||
game.getCombat().declareAttacker(p.getId(), game.getCombat().getDefendingPlayer(source.getSourceId()), game);
|
||||
p.setTapped(true);
|
||||
}
|
||||
token.putOntoBattlefield(2, game, source.getId(), source.getControllerId());
|
||||
Permanent p = game.getPermanent(token.getLastAddedToken());
|
||||
game.getCombat().declareAttacker(p.getId(), game.getCombat().getDefendingPlayer(source.getSourceId()), game);
|
||||
p.setTapped(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class MirrorworksEffect extends OneShotEffect<MirrorworksEffect> {
|
|||
if (target != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(target);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class PhyrexianRebirth extends CardImpl<PhyrexianRebirth> {
|
|||
HorrorToken horrorToken = new HorrorToken();
|
||||
horrorToken.getPower().setValue(count);
|
||||
horrorToken.getToughness().setValue(count);
|
||||
horrorToken.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
horrorToken.putOntoBattlefield(1, game, source.getId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class BeastWithinEffect extends OneShotEffect<BeastWithinEffect> {
|
|||
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(source), Constants.Zone.BATTLEFIELD);
|
||||
if (permanent != null) {
|
||||
BeastToken token = new BeastToken();
|
||||
token.putOntoBattlefield(game, source.getId(), permanent.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getId(), permanent.getControllerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,9 +132,7 @@ class FreshMeatEffect extends OneShotEffect<FreshMeatEffect> {
|
|||
FreshMeatWatcher watcher = (FreshMeatWatcher) game.getState().getWatchers().get(source.getControllerId(), "CreaturesDiedFreshMeat");
|
||||
int count = watcher.getCreaturesCount();
|
||||
BeastToken token = new BeastToken();
|
||||
for (int i = 0; i < count; i++) {
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ class BroodBirthingEffect extends OneShotEffect<BroodBirthingEffect> {
|
|||
|
||||
EldraziSpawnToken token = new EldraziSpawnToken();
|
||||
int count = game.getBattlefield().countAll(filter, source.getControllerId()) > 0 ? 3 : 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
token.putOntoBattlefield(count, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class SarkhanTheMadSacEffect extends OneShotEffect<SarkhanTheMadSacEffect> {
|
|||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
permanent.sacrifice(this.getId(), game);
|
||||
Token dragonToken = new DragonToken();
|
||||
dragonToken.putOntoBattlefield(game, this.getId(), player.getId());
|
||||
dragonToken.putOntoBattlefield(1, game, this.getId(), player.getId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class SplinterTwinEffect extends OneShotEffect<SplinterTwinEffect> {
|
|||
CardUtil.copyTo(token).from(card);
|
||||
|
||||
token.addAbility(HasteAbility.getInstance());
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
|
||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class MimicVatCreateTokenEffect extends OneShotEffect<MimicVatCreateTokenEffect>
|
|||
CardUtil.copyTo(token).from(card);
|
||||
|
||||
token.addAbility(HasteAbility.getInstance());
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
|
||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
||||
|
|
|
|||
|
|
@ -97,14 +97,14 @@ class MyrPropagatorCreateTokenEffect extends OneShotEffect<MyrPropagatorCreateTo
|
|||
if (thisCard != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(thisCard);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
} else { // maybe it's token
|
||||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(permanent);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class MyrsmithEffect extends OneShotEffect<MyrsmithEffect> {
|
|||
Cost cost = new GenericManaCost(1);
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getId(), source.getControllerId(), false)) {
|
||||
new MyrToken().putOntoBattlefield(game, source.getControllerId(), source.getControllerId());
|
||||
new MyrToken().putOntoBattlefield(1, game, source.getControllerId(), source.getControllerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class PrototypePortalCreateTokenEffect extends OneShotEffect<PrototypePortalCrea
|
|||
if (card != null) {
|
||||
EmptyToken token = new EmptyToken();
|
||||
CardUtil.copyTo(token).from(card);
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,7 @@ public class CreateTokenEffect extends OneShotEffect<CreateTokenEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int value = amount.calculate(game, source);
|
||||
for (int i = 0; i < value; i++) {
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
token.putOntoBattlefield(value, game, source.getSourceId(), source.getControllerId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class LivingWeaponEffect extends OneShotEffect<LivingWeaponEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
GermToken token = new GermToken();
|
||||
token.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
token.putOntoBattlefield(1, game, source.getId(), source.getControllerId());
|
||||
Permanent p = game.getPermanent(token.getLastAddedToken());
|
||||
if (p != null) {
|
||||
p.addAttachment(source.getSourceId(), game);
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ public class GameEvent {
|
|||
COUNTER_REMOVED,
|
||||
LOSE_CONTROL, LOST_CONTROL,
|
||||
GAIN_CONTROL, GAINED_CONTROL,
|
||||
CREATE_TOKEN,
|
||||
|
||||
//combat events
|
||||
COMBAT_DAMAGE_APPLIED,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import mage.abilities.Abilities;
|
|||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
|
||||
|
|
@ -86,16 +88,23 @@ public class Token extends MageObjectImpl<Token> {
|
|||
return new Token(this);
|
||||
}
|
||||
|
||||
public boolean putOntoBattlefield(Game game, UUID sourceId, UUID controllerId) {
|
||||
public boolean putOntoBattlefield(int amount, Game game, UUID sourceId, UUID 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();
|
||||
permanent.entersBattlefield(sourceId, game);
|
||||
game.applyEffects();
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));
|
||||
return true;
|
||||
GameEvent event = GameEvent.getEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount);
|
||||
if (!game.replaceEvent(event)) {
|
||||
amount = event.getAmount();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
PermanentToken permanent = new PermanentToken(this, controllerId, setCode);
|
||||
game.getBattlefield().addPermanent(permanent);
|
||||
this.lastAddedTokenId = permanent.getId();
|
||||
permanent.entersBattlefield(sourceId, game);
|
||||
game.applyEffects();
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue