cheats: fixed broken emblem commands (example: emblem:Human:ElspethSunsChampionEmblem:1)

This commit is contained in:
Oleg Agafonov 2023-12-16 02:25:03 +04:00
parent 150d76dcf9
commit d97b034711
4 changed files with 11 additions and 4 deletions

View file

@ -764,7 +764,7 @@ public final class SystemUtil {
feedbackPlayer.getName(), errorsList.size()); feedbackPlayer.getName(), errorsList.size());
mes += String.join("\n", errorsList); mes += String.join("\n", errorsList);
mes += "\n"; mes += "\n";
game.fireErrorEvent("Cheat command errors", new IllegalArgumentException(mes)); game.fireErrorEvent("Cheat command errors, see server logs for details", new IllegalArgumentException(mes));
} }
game.informPlayers(String.format("%s: tried to apply cheat commands", feedbackPlayer.getLogName())); game.informPlayers(String.format("%s: tried to apply cheat commands", feedbackPlayer.getLogName()));
} }

View file

@ -1870,7 +1870,7 @@ public abstract class GameImpl implements Game {
/** /**
* @param emblem * @param emblem
* @param sourceObject * @param sourceObject can be null
* @param toPlayerId controller and owner of the emblem * @param toPlayerId controller and owner of the emblem
*/ */
@Override @Override

View file

@ -33,7 +33,7 @@ public abstract class Emblem extends CommandObjectImpl {
private static final ManaCosts emptyCost = new ManaCostsImpl<>(); private static final ManaCosts emptyCost = new ManaCostsImpl<>();
private UUID controllerId; private UUID controllerId;
protected MageObject sourceObject; protected MageObject sourceObject; // can be null
private boolean copy; private boolean copy;
private MageObject copyFrom; // copied card INFO (used to call original adjusters) private MageObject copyFrom; // copied card INFO (used to call original adjusters)
private FrameStyle frameStyle; private FrameStyle frameStyle;
@ -62,7 +62,10 @@ public abstract class Emblem extends CommandObjectImpl {
this.sourceObject = sourceObject; this.sourceObject = sourceObject;
// choose set code due source // choose set code due source
TokenInfo foundInfo = TokenRepository.instance.findPreferredTokenInfoForClass(this.getClass().getName(), sourceObject.getExpansionSetCode()); TokenInfo foundInfo = TokenRepository.instance.findPreferredTokenInfoForClass(
this.getClass().getName(),
this.sourceObject == null ? null : this.sourceObject.getExpansionSetCode()
);
if (foundInfo != null) { if (foundInfo != null) {
this.setExpansionSetCode(foundInfo.getSetCode()); this.setExpansionSetCode(foundInfo.getSetCode());
this.setCardNumber(""); this.setCardNumber("");

View file

@ -72,6 +72,10 @@ public class Spell extends StackObjectImpl implements Card {
} }
private Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone, Game game, boolean isCopy) { private Spell(Card card, SpellAbility ability, UUID controllerId, Zone fromZone, Game game, boolean isCopy) {
if (card == null) {
throw new IllegalArgumentException("Wrong code usage: can't create spell without card: " + ability, new Throwable());
}
Card affectedCard = card; Card affectedCard = card;
// TODO: must be removed after transform cards (one side) migrated to MDF engine (multiple sides) // TODO: must be removed after transform cards (one side) migrated to MDF engine (multiple sides)