Skip to content

Commit

Permalink
Merge pull request #306 from JohnnyDevo/FixCustomModeModsPersisting
Browse files Browse the repository at this point in the history
fix custom mode mods sometimes persisting between runs (issue #271)
  • Loading branch information
kiooeht authored Jun 17, 2021
2 parents dc1da88 + aefc8c5 commit 299a2ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 10 additions & 0 deletions mod/src/main/java/basemod/BaseMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.daily.mods.AbstractDailyMod;
import com.megacrit.cardcrawl.daily.mods.RedCards;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.events.AbstractEvent;
Expand Down Expand Up @@ -2649,6 +2650,10 @@ public static void publishPostDeath() {
public static void publishAddCustomModeMods(List<CustomMod> modList) {
logger.info("publishAddCustomModeMods");

String modType = "legacy"; //if community consensus thinks character card mods should be available on the daily, change this to "generic"
//maybe make this into a config? Idk that's out of this fix's scope.
HashMap<String, AbstractDailyMod> map = ReflectionHacks.getPrivateStatic(ModHelper.class, modType + "Mods");

CustomMod charMod = new CustomMod("Modded Character Cards", "p", false);
for (AbstractPlayer character : getModdedCharacters()) {
CustomMod mod = new CustomMod(RedCards.ID, "g", true);
Expand All @@ -2661,6 +2666,11 @@ public static void publishAddCustomModeMods(List<CustomMod> modList) {
ReflectionHacks.setPrivate(mod, CustomMod.class, "height", height);

insertCustomMod(modList, mod);

if (map != null) {
AbstractDailyMod dailyMod = new AbstractDailyMod(mod.ID, mod.name, mod.description, "diverse.png", true, character.chosenClass);
map.put(dailyMod.modID, dailyMod);
}
}

for (AddCustomModeModsSubscriber sub : addCustomModeModsSubscribers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,23 @@ public static void Insert(AbstractDungeon __instance, ArrayList<AbstractCard> tm
AbstractPlayer player = AbstractDungeon.player;
AbstractPlayer.PlayerClass chosenClass = player.chosenClass;

if (AbstractPlayer.customMods == null) {
AbstractPlayer.customMods = new ArrayList<>();
}

// Diverse
if (ModHelper.isModEnabled(Diverse.ID)) {
for (AbstractPlayer character : BaseMod.getModdedCharacters()) {
character.getCardPool(tmpPool);
}
} else if (!BaseMod.isBaseGameCharacter(chosenClass)) {
// Red/Green/Blue/Purple Cards modifiers for modded characters
if (AbstractPlayer.customMods.contains(RedCards.ID)) {
if (ModHelper.isModEnabled(RedCards.ID)) {
CardLibrary.addRedCards(tmpPool);
}
if (AbstractPlayer.customMods.contains(GreenCards.ID)) {
if (ModHelper.isModEnabled(GreenCards.ID)) {
CardLibrary.addGreenCards(tmpPool);
}
if (AbstractPlayer.customMods.contains(BlueCards.ID)) {
if (ModHelper.isModEnabled(BlueCards.ID)) {
CardLibrary.addBlueCards(tmpPool);
}
if (AbstractPlayer.customMods.contains(PurpleCards.ID)) {
if (ModHelper.isModEnabled(PurpleCards.ID)) {
CardLibrary.addPurpleCards(tmpPool);
}
}
Expand All @@ -67,7 +63,7 @@ public static void Insert(AbstractDungeon __instance, ArrayList<AbstractCard> tm
continue;
}
String ID = character.chosenClass.name() + charMod.name;
if (AbstractPlayer.customMods.contains(ID)) {
if (ModHelper.isModEnabled(ID)) {
BaseMod.logger.info("[INFO] Adding " + character.getLocalizedCharacterName() + " cards into card pool.");
AbstractCard.CardColor color = character.getCardColor();
for (AbstractCard c : CardLibrary.cards.values()) {
Expand Down

0 comments on commit 299a2ca

Please sign in to comment.