mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Fixed a problem that Emblems created by permanents where its owner left the game caused errors in clients. Some handling cganges of emblems.
This commit is contained in:
parent
81caed134f
commit
8075ea2e50
56 changed files with 894 additions and 850 deletions
|
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -37,7 +36,7 @@ import mage.game.command.Emblem;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
* @author nantuko
|
||||
*/
|
||||
public class GetEmblemEffect extends OneShotEffect {
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ public class GetEmblemEffect extends OneShotEffect {
|
|||
if (sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
game.addEmblem(emblem, source);
|
||||
game.addEmblem(emblem, sourceObject, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -71,7 +70,7 @@ public class GetEmblemTargetPlayerEffect extends OneShotEffect {
|
|||
if (toPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
game.addEmblem(emblem, source, toPlayer.getId());
|
||||
game.addEmblem(emblem, sourceObject, toPlayer.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -43,11 +42,11 @@ import mage.players.Player;
|
|||
public class RevealHandTargetEffect extends OneShotEffect {
|
||||
|
||||
private final TargetController targetController;
|
||||
|
||||
|
||||
public RevealHandTargetEffect() {
|
||||
this(TargetController.OPPONENT);
|
||||
}
|
||||
|
||||
|
||||
public RevealHandTargetEffect(TargetController targetController) {
|
||||
super(Outcome.Discard);
|
||||
this.targetController = targetController;
|
||||
|
|
@ -64,7 +63,7 @@ public class RevealHandTargetEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (player != null && sourceObject != null) {
|
||||
player.revealCards(sourceObject.getName(), player.getHand(), game);
|
||||
player.revealCards(sourceObject.getIdName(), player.getHand(), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -74,7 +73,7 @@ public class RevealHandTargetEffect extends OneShotEffect {
|
|||
public RevealHandTargetEffect copy() {
|
||||
return new RevealHandTargetEffect(this);
|
||||
}
|
||||
|
||||
|
||||
private String getText() {
|
||||
StringBuilder sb = new StringBuilder("Target ");
|
||||
switch (targetController) {
|
||||
|
|
|
|||
|
|
@ -364,9 +364,9 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
void addEffect(ContinuousEffect continuousEffect, Ability source);
|
||||
|
||||
void addEmblem(Emblem emblem, Ability source);
|
||||
void addEmblem(Emblem emblem, MageObject sourceObject, Ability source);
|
||||
|
||||
void addEmblem(Emblem emblem, Ability source, UUID toPlayerId);
|
||||
void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId);
|
||||
|
||||
void addCommander(Commander commander);
|
||||
|
||||
|
|
|
|||
|
|
@ -1426,19 +1426,21 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addEmblem(Emblem emblem, Ability source) {
|
||||
addEmblem(emblem, source, null);
|
||||
public void addEmblem(Emblem emblem, MageObject sourceObject, Ability source) {
|
||||
addEmblem(emblem, sourceObject, source.getControllerId());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param emblem
|
||||
* @param sourceObject
|
||||
* @param toPlayerId controller and owner of the emblem
|
||||
*/
|
||||
@Override
|
||||
public void addEmblem(Emblem emblem, Ability source, UUID toPlayerId) {
|
||||
public void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId) {
|
||||
Emblem newEmblem = emblem.copy();
|
||||
newEmblem.setSourceId(source.getSourceId());
|
||||
if (toPlayerId == null) {
|
||||
newEmblem.setControllerId(source.getControllerId());
|
||||
} else {
|
||||
newEmblem.setControllerId(toPlayerId);
|
||||
}
|
||||
newEmblem.setSourceObject(sourceObject);
|
||||
newEmblem.setControllerId(toPlayerId);
|
||||
newEmblem.assignNewId();
|
||||
newEmblem.getAbilities().newId();
|
||||
for (Ability ability : newEmblem.getAbilities()) {
|
||||
|
|
|
|||
|
|
@ -24,24 +24,26 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.game.command;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Viserion, nantuko
|
||||
*/
|
||||
*
|
||||
* @author Viserion, nantuko
|
||||
*/
|
||||
public interface CommandObject extends MageObject {
|
||||
|
||||
UUID getSourceId();
|
||||
|
||||
UUID getControllerId();
|
||||
|
||||
void assignNewId();
|
||||
|
||||
MageObject getSourceObject();
|
||||
|
||||
@Override
|
||||
CommandObject copy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ import mage.util.GameLog;
|
|||
|
||||
public class Commander implements CommandObject {
|
||||
|
||||
private final Card card;
|
||||
private final Card sourceObject;
|
||||
private final Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||
|
||||
public Commander(Card card) {
|
||||
this.card = card;
|
||||
this.sourceObject = card;
|
||||
abilites.add(new CastCommanderAbility(card));
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (!(ability instanceof SpellAbility)) {
|
||||
|
|
@ -62,21 +62,22 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
private Commander(Commander copy) {
|
||||
this.card = copy.card;
|
||||
this.sourceObject = copy.sourceObject;
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
return card;
|
||||
@Override
|
||||
public Card getSourceObject() {
|
||||
return sourceObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return card.getId();
|
||||
return sourceObject.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getControllerId() {
|
||||
return card.getOwnerId();
|
||||
return sourceObject.getOwnerId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -90,12 +91,12 @@ public class Commander implements CommandObject {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return card.getName();
|
||||
return sourceObject.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdName() {
|
||||
return card.getName() + " [" + card.getId().toString().substring(0, 3) + "]";
|
||||
return sourceObject.getName() + " [" + sourceObject.getId().toString().substring(0, 3) + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -110,22 +111,22 @@ public class Commander implements CommandObject {
|
|||
|
||||
@Override
|
||||
public List<CardType> getCardType() {
|
||||
return card.getCardType();
|
||||
return sourceObject.getCardType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubtype(Game game) {
|
||||
return card.getSubtype(game);
|
||||
return sourceObject.getSubtype(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSubtype(String subtype, Game game) {
|
||||
return card.hasSubtype(subtype, game);
|
||||
return sourceObject.hasSubtype(subtype, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return card.getSupertype();
|
||||
return sourceObject.getSupertype();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -144,42 +145,42 @@ public class Commander implements CommandObject {
|
|||
|
||||
@Override
|
||||
public ObjectColor getColor(Game game) {
|
||||
return card.getColor(game);
|
||||
return sourceObject.getColor(game);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ObjectColor getFrameColor(Game game) {
|
||||
return card.getFrameColor(game);
|
||||
return sourceObject.getFrameColor(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrameStyle getFrameStyle() {
|
||||
return card.getFrameStyle();
|
||||
return sourceObject.getFrameStyle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaCosts<ManaCost> getManaCost() {
|
||||
return card.getManaCost();
|
||||
return sourceObject.getManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConvertedManaCost() {
|
||||
return card.getConvertedManaCost();
|
||||
return sourceObject.getConvertedManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getPower() {
|
||||
return card.getPower();
|
||||
return sourceObject.getPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getToughness() {
|
||||
return card.getToughness();
|
||||
return sourceObject.getToughness();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStartingLoyalty() {
|
||||
return card.getStartingLoyalty();
|
||||
return sourceObject.getStartingLoyalty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -201,27 +202,27 @@ public class Commander implements CommandObject {
|
|||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return card.getId();
|
||||
return sourceObject.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return card.getImageName();
|
||||
return sourceObject.getImageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZoneChangeCounter(Game game) {
|
||||
return card.getZoneChangeCounter(game);
|
||||
return sourceObject.getZoneChangeCounter(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) {
|
||||
card.updateZoneChangeCounter(game, event);
|
||||
sourceObject.updateZoneChangeCounter(game, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoneChangeCounter(int value, Game game) {
|
||||
card.setZoneChangeCounter(value, game);
|
||||
sourceObject.setZoneChangeCounter(value, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
|
|
@ -38,6 +39,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
|
|
@ -53,13 +55,13 @@ public class Emblem implements CommandObject {
|
|||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts emptyCost = new ManaCostsImpl();
|
||||
|
||||
private String name;
|
||||
private String name = "";
|
||||
private UUID id;
|
||||
private UUID controllerId;
|
||||
private UUID sourceId;
|
||||
private MageObject sourceObject;
|
||||
private FrameStyle frameStyle;
|
||||
private Abilities<Ability> abilites = new AbilitiesImpl<>();
|
||||
private String expansionSetCodeForImage = null;
|
||||
private String expansionSetCodeForImage = "";
|
||||
|
||||
public Emblem() {
|
||||
this.id = UUID.randomUUID();
|
||||
|
|
@ -70,8 +72,9 @@ public class Emblem implements CommandObject {
|
|||
this.name = emblem.name;
|
||||
this.frameStyle = emblem.frameStyle;
|
||||
this.controllerId = emblem.controllerId;
|
||||
this.sourceId = emblem.sourceId;
|
||||
this.sourceObject = emblem.sourceObject;
|
||||
this.abilites = emblem.abilites.copy();
|
||||
this.expansionSetCodeForImage = emblem.expansionSetCodeForImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -84,9 +87,29 @@ public class Emblem implements CommandObject {
|
|||
this.id = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public void setSourceObject(MageObject sourceObject) {
|
||||
this.sourceObject = sourceObject;
|
||||
if (sourceObject instanceof Card) {
|
||||
if (name.isEmpty()) {
|
||||
name = ((Card) sourceObject).getSubtype(null).toString();
|
||||
}
|
||||
if (expansionSetCodeForImage.isEmpty()) {
|
||||
expansionSetCodeForImage = ((Card) sourceObject).getExpansionSetCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObject getSourceObject() {
|
||||
return sourceObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return this.sourceId;
|
||||
if (sourceObject != null) {
|
||||
return sourceObject.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -99,10 +122,6 @@ public class Emblem implements CommandObject {
|
|||
this.abilites.setControllerId(controllerId);
|
||||
}
|
||||
|
||||
public void setSourceId(UUID sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
@ -162,8 +181,8 @@ public class Emblem implements CommandObject {
|
|||
public ObjectColor getColor(Game game) {
|
||||
return emptyColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public ObjectColor getFrameColor(Game game) {
|
||||
return emptyColor;
|
||||
}
|
||||
|
|
@ -187,7 +206,7 @@ public class Emblem implements CommandObject {
|
|||
public MageInt getToughness() {
|
||||
return MageInt.EmptyMageInt;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStartingLoyalty() {
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue