Added "available image set codes" functionality to emblems (#9150)

* Added pulling image from list of available image set codes functionality to emblems

* Provided available image set codes for Daretti, Scrap Savant emblem

* Fixed typo in a comment
This commit is contained in:
PurpleCrowbar 2022-06-24 07:32:07 +01:00 committed by GitHub
parent 144ba0e97b
commit 494fc39dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -19,6 +19,7 @@ import mage.constants.SuperType;
import mage.game.Game;
import mage.game.events.ZoneChangeEvent;
import mage.util.GameLog;
import mage.util.RandomUtil;
import mage.util.SubTypes;
import java.util.ArrayList;
@ -45,6 +46,9 @@ public class Emblem implements CommandObject {
private Abilities<Ability> abilites = new AbilitiesImpl<>();
private String expansionSetCodeForImage = "";
// list of set codes emblem images are available for
protected List<String> availableImageSetCodes = new ArrayList<>();
public Emblem() {
this.id = UUID.randomUUID();
}
@ -59,6 +63,7 @@ public class Emblem implements CommandObject {
this.copyFrom = (emblem.copyFrom != null ? emblem.copyFrom : null);
this.abilites = emblem.abilites.copy();
this.expansionSetCodeForImage = emblem.expansionSetCodeForImage;
this.availableImageSetCodes = emblem.availableImageSetCodes;
}
@Override
@ -80,6 +85,11 @@ public class Emblem implements CommandObject {
if (expansionSetCodeForImage.isEmpty()) {
expansionSetCodeForImage = ((Card) sourceObject).getExpansionSetCode();
}
if (!availableImageSetCodes.isEmpty()) {
if (expansionSetCodeForImage.equals("") || !availableImageSetCodes.contains(expansionSetCodeForImage)) {
expansionSetCodeForImage = availableImageSetCodes.get(RandomUtil.nextInt(availableImageSetCodes.size()));
}
}
}
}

View file

@ -17,6 +17,8 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.target.targetpointer.FixedTarget;
import java.util.Arrays;
/**
*
* @author spjspj
@ -26,6 +28,7 @@ public final class DarettiScrapSavantEmblem extends Emblem {
public DarettiScrapSavantEmblem() {
setName("Emblem Daretti");
availableImageSetCodes = Arrays.asList("C14", "C16", "CM2");
this.getAbilities().add(new DarettiScrapSavantTriggeredAbility());
}