forked from External/mage
Reworked emblems
This commit is contained in:
parent
2a5ceefe94
commit
c22f0cf503
8 changed files with 56 additions and 16 deletions
|
|
@ -8,6 +8,7 @@ import mage.cards.Card;
|
|||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.players.Player;
|
||||
|
|
@ -388,6 +389,23 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
Assert.assertEquals("(Battlefield) Card counts are not equal (" + cardName + ")", count, actualCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert emblem count under player's control
|
||||
*
|
||||
* @param player
|
||||
* @param count
|
||||
* @throws AssertionError
|
||||
*/
|
||||
public void assertEmblemCount(Player player, int count) throws AssertionError {
|
||||
int actualCount = 0;
|
||||
for (CommandObject commandObject : currentGame.getState().getCommand()) {
|
||||
if (commandObject.getControllerId().equals(player.getId())) {
|
||||
actualCount++;
|
||||
}
|
||||
}
|
||||
Assert.assertEquals("Emblem counts are not equal", count, actualCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert counter count on a permanent
|
||||
*
|
||||
|
|
|
|||
|
|
@ -60,13 +60,7 @@ public class GetEmblemEffect extends OneShotEffect<GetEmblemEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Emblem newEmblem = this.emblem.copy();
|
||||
newEmblem.setSourceId(source.getSourceId());
|
||||
newEmblem.setControllerId(source.getControllerId());
|
||||
game.getState().getCommand().add(newEmblem);
|
||||
for (Ability ability: newEmblem.getAbilities()) {
|
||||
ability.resolve(game);
|
||||
}
|
||||
game.addEmblem(emblem, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import mage.cards.Cards;
|
|||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
|
|
@ -162,6 +163,7 @@ public interface Game extends MageItem, Serializable {
|
|||
public void concede(UUID playerId);
|
||||
public void emptyManaPools();
|
||||
public void addEffect(ContinuousEffect continuousEffect, Ability source);
|
||||
public void addEmblem(Emblem emblem, Ability source);
|
||||
|
||||
/**
|
||||
* This version supports copying of copies of any depth.
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import mage.filter.Filter;
|
|||
import mage.filter.Filter.ComparisonScope;
|
||||
import mage.filter.common.*;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.*;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.permanent.Battlefield;
|
||||
|
|
@ -740,6 +741,16 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
state.addEffect(newEffect, newAbility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEmblem(Emblem emblem, Ability source) {
|
||||
Emblem newEmblem = emblem.copy();
|
||||
newEmblem.setSourceId(source.getSourceId());
|
||||
newEmblem.setControllerId(source.getControllerId());
|
||||
newEmblem.assignNewId();
|
||||
newEmblem.getAbilities().newId();
|
||||
state.addEmblem(newEmblem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier) {
|
||||
Permanent permanent = copyFromPermanent.copy();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import mage.choices.Choice;
|
|||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.Command;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Battlefield;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -448,10 +449,17 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
}
|
||||
else if (ability instanceof TriggeredAbility) {
|
||||
triggers.add((TriggeredAbility)ability);
|
||||
addTriggeredAbility((TriggeredAbility)ability);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEmblem(Emblem emblem) {
|
||||
getCommand().add(emblem);
|
||||
for (Ability ability: emblem.getAbilities()) {
|
||||
addAbility(ability);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTriggeredAbility(TriggeredAbility ability) {
|
||||
this.triggered.add(ability);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ public class Command extends ArrayList<CommandObject> {
|
|||
public Command () {}
|
||||
|
||||
public Command(final Command command) {
|
||||
//
|
||||
addAll(command);
|
||||
}
|
||||
|
||||
// public void checkTriggers(GameEvent event, Game game) {
|
||||
// for (CommandObject commandObject: this) {
|
||||
// commandObject.checkTriggers(event, game);
|
||||
// }
|
||||
// }
|
||||
/*public void checkTriggers(GameEvent event, Game game) {
|
||||
for (CommandObject commandObject: this) {
|
||||
commandObject.checkTriggers(event, game);
|
||||
}
|
||||
}*/
|
||||
|
||||
public Command copy() {
|
||||
return new Command(this);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@
|
|||
|
||||
package mage.game.command;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Viserion, nantuko
|
||||
|
|
@ -39,6 +40,7 @@ public interface CommandObject extends MageObject {
|
|||
|
||||
public UUID getSourceId();
|
||||
public UUID getControllerId();
|
||||
public void assignNewId();
|
||||
// public void checkTriggers(GameEvent event, Game game);
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ public class Emblem implements CommandObject {
|
|||
this.abilites = emblem.abilites.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignNewId() {
|
||||
this.id = UUID.randomUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return this.sourceId;
|
||||
|
|
@ -78,7 +83,7 @@ public class Emblem implements CommandObject {
|
|||
return this.controllerId;
|
||||
}
|
||||
|
||||
public void setControllerId(UUID controllerId) {
|
||||
public void setControllerId(UUID controllerId) {
|
||||
this.controllerId = controllerId;
|
||||
this.abilites.setControllerId(controllerId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue