mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Merge pull request #5351 from magefree/plane-and-emblem-implements-controllable
Refactor: make plane and emblem implement Controllable
This commit is contained in:
commit
08e88b8a65
8 changed files with 13 additions and 11 deletions
|
|
@ -219,9 +219,9 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
} else {
|
||||
MageObject mageObject = game.getObject(this.sourceId);
|
||||
if (mageObject instanceof Emblem) {
|
||||
return ((Emblem) mageObject).getControllerId().equals(playerId);
|
||||
return ((Emblem) mageObject).isControlledBy(playerId);
|
||||
} else if (mageObject instanceof Plane) {
|
||||
return ((Plane) mageObject).getControllerId().equals(playerId);
|
||||
return ((Plane) mageObject).isControlledBy(playerId);
|
||||
} else if (game.getState().getZone(this.sourceId) != Zone.BATTLEFIELD) {
|
||||
return ((Card) mageObject).isOwnedBy(playerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ public interface Controllable {
|
|||
UUID getId();
|
||||
|
||||
default boolean isControlledBy(UUID controllerID){
|
||||
if(getControllerId() == null){
|
||||
return false;
|
||||
}
|
||||
return getControllerId().equals(controllerID);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2600,7 +2600,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
boolean addPlaneAgain = false;
|
||||
for (Iterator<CommandObject> it = this.getState().getCommand().iterator(); it.hasNext();) {
|
||||
CommandObject obj = it.next();
|
||||
if (obj.getControllerId().equals(playerId)) {
|
||||
if (obj.isControlledBy(playerId)) {
|
||||
if (obj instanceof Emblem) {
|
||||
((Emblem) obj).discardEffects();// This may not be the best fix but it works
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,16 @@ package mage.game.command;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.game.Controllable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Viserion, nantuko
|
||||
*/
|
||||
public interface CommandObject extends MageObject {
|
||||
public interface CommandObject extends MageObject, Controllable {
|
||||
|
||||
UUID getSourceId();
|
||||
|
||||
UUID getControllerId();
|
||||
|
||||
void assignNewId();
|
||||
|
||||
MageObject getSourceObject();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue