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());
mes += String.join("\n", errorsList);
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()));
}

View file

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

View file

@ -33,7 +33,7 @@ public abstract class Emblem extends CommandObjectImpl {
private static final ManaCosts emptyCost = new ManaCostsImpl<>();
private UUID controllerId;
protected MageObject sourceObject;
protected MageObject sourceObject; // can be null
private boolean copy;
private MageObject copyFrom; // copied card INFO (used to call original adjusters)
private FrameStyle frameStyle;
@ -62,7 +62,10 @@ public abstract class Emblem extends CommandObjectImpl {
this.sourceObject = sourceObject;
// 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) {
this.setExpansionSetCode(foundInfo.getSetCode());
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) {
if (card == null) {
throw new IllegalArgumentException("Wrong code usage: can't create spell without card: " + ability, new Throwable());
}
Card affectedCard = card;
// TODO: must be removed after transform cards (one side) migrated to MDF engine (multiple sides)