This commit is contained in:
dtookey 2020-08-16 15:12:38 -04:00
parent e334d1cb8d
commit 77dd7f4409
9 changed files with 133 additions and 25 deletions

View File

@ -3,7 +3,9 @@ package constructTheArena;
import basemod.BaseMod; import basemod.BaseMod;
import basemod.ModLabeledToggleButton; import basemod.ModLabeledToggleButton;
import basemod.ModPanel; import basemod.ModPanel;
import basemod.helpers.RelicType;
import basemod.interfaces.AddCustomModeModsSubscriber; import basemod.interfaces.AddCustomModeModsSubscriber;
import basemod.interfaces.EditRelicsSubscriber;
import basemod.interfaces.EditStringsSubscriber; import basemod.interfaces.EditStringsSubscriber;
import basemod.interfaces.PostInitializeSubscriber; import basemod.interfaces.PostInitializeSubscriber;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
@ -16,8 +18,11 @@ import com.google.gson.Gson;
import com.megacrit.cardcrawl.core.Settings; import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.helpers.CardHelper; import com.megacrit.cardcrawl.helpers.CardHelper;
import com.megacrit.cardcrawl.helpers.FontHelper; import com.megacrit.cardcrawl.helpers.FontHelper;
import com.megacrit.cardcrawl.localization.RelicStrings;
import com.megacrit.cardcrawl.localization.RunModStrings; import com.megacrit.cardcrawl.localization.RunModStrings;
import com.megacrit.cardcrawl.localization.UIStrings;
import com.megacrit.cardcrawl.screens.custom.CustomMod; import com.megacrit.cardcrawl.screens.custom.CustomMod;
import constructTheArena.relics.ConstructorsBurden;
import constructTheArena.util.IDCheckDontTouchPls; import constructTheArena.util.IDCheckDontTouchPls;
import constructTheArena.util.ResUtil; import constructTheArena.util.ResUtil;
import constructTheArena.util.TextureLoader; import constructTheArena.util.TextureLoader;
@ -60,6 +65,7 @@ import java.util.Properties;
public class ConstructTheArena implements public class ConstructTheArena implements
AddCustomModeModsSubscriber, AddCustomModeModsSubscriber,
EditStringsSubscriber, EditStringsSubscriber,
EditRelicsSubscriber,
PostInitializeSubscriber { PostInitializeSubscriber {
// Make sure to implement the subscribers *you* are using (read basemod wiki). Editing cards? EditCardsSubscriber. // Make sure to implement the subscribers *you* are using (read basemod wiki). Editing cards? EditCardsSubscriber.
// Making relics? EditRelicsSubscriber. etc., etc., for a full list and how to make your own, visit the basemod wiki. // Making relics? EditRelicsSubscriber. etc., etc., for a full list and how to make your own, visit the basemod wiki.
@ -90,12 +96,7 @@ public class ConstructTheArena implements
// =============== SUBSCRIBE, CREATE THE COLOR_GRAY, INITIALIZE ================= // =============== SUBSCRIBE, CREATE THE COLOR_GRAY, INITIALIZE =================
public ConstructTheArena() { public ConstructTheArena() {
logger.info("Subscribe to BaseMod hooks");
setModID("constructTheArena"); setModID("constructTheArena");
logger.info("Adding mod settings");
constructTheArenaSettings.setProperty(ENABLE_PLACEHOLDER_SETTINGS, "FALSE"); // This is the default setting. It's actually set... constructTheArenaSettings.setProperty(ENABLE_PLACEHOLDER_SETTINGS, "FALSE"); // This is the default setting. It's actually set...
try { try {
@ -118,7 +119,6 @@ public class ConstructTheArena implements
// String IDjson = Gdx.files.internal("IDCheckStringsDONT-EDIT-AT-ALL.json").readString(String.valueOf(StandardCharsets.UTF_8)); // i hate u Gdx.files // String IDjson = Gdx.files.internal("IDCheckStringsDONT-EDIT-AT-ALL.json").readString(String.valueOf(StandardCharsets.UTF_8)); // i hate u Gdx.files
InputStream in = ConstructTheArena.class.getResourceAsStream("/IDCheckStringsDONT-EDIT-AT-ALL.json"); // DON'T EDIT THIS ETHER InputStream in = ConstructTheArena.class.getResourceAsStream("/IDCheckStringsDONT-EDIT-AT-ALL.json"); // DON'T EDIT THIS ETHER
IDCheckDontTouchPls EXCEPTION_STRINGS = coolG.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), IDCheckDontTouchPls.class); // OR THIS, DON'T EDIT IT IDCheckDontTouchPls EXCEPTION_STRINGS = coolG.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), IDCheckDontTouchPls.class); // OR THIS, DON'T EDIT IT
logger.info("You are attempting to set your mod ID as: " + ID); // NO WHY
if (ID.equals(EXCEPTION_STRINGS.DEFAULTID)) { // DO *NOT* CHANGE THIS ESPECIALLY, TO EDIT YOUR MOD ID, SCROLL UP JUST A LITTLE, IT'S JUST ABOVE if (ID.equals(EXCEPTION_STRINGS.DEFAULTID)) { // DO *NOT* CHANGE THIS ESPECIALLY, TO EDIT YOUR MOD ID, SCROLL UP JUST A LITTLE, IT'S JUST ABOVE
throw new RuntimeException(EXCEPTION_STRINGS.EXCEPTION); // THIS ALSO DON'T EDIT throw new RuntimeException(EXCEPTION_STRINGS.EXCEPTION); // THIS ALSO DON'T EDIT
} else if (ID.equals(EXCEPTION_STRINGS.DEVID)) { // NO } else if (ID.equals(EXCEPTION_STRINGS.DEVID)) { // NO
@ -126,7 +126,6 @@ public class ConstructTheArena implements
} else { // NO EDIT AREA } else { // NO EDIT AREA
modID = ID; // DON'T WRITE OR CHANGE THINGS HERE NOT EVEN A LITTLE modID = ID; // DON'T WRITE OR CHANGE THINGS HERE NOT EVEN A LITTLE
} // NO } // NO
logger.info("Success! ID is " + modID); // WHY WOULD U WANT IT NOT TO LOG?? DON'T EDIT THIS.
} // NO } // NO
public static String getModID() { // NO public static String getModID() { // NO
@ -232,8 +231,26 @@ public class ConstructTheArena implements
@Override @Override
public void receiveEditStrings() { public void receiveEditStrings() {
BaseMod.loadCustomStringsFile(RunModStrings.class, ResUtil.getLocRes("eng", "constructTheArena-RunModStrings.json")); BaseMod.loadCustomStringsFile(RunModStrings.class, ResUtil.getLocRes("eng", "constructTheArena-RunModStrings.json"));
BaseMod.loadCustomStringsFile(RelicStrings.class, ResUtil.getLocRes("eng", "constructTheArena-RelicStrings.json"));
BaseMod.loadCustomStringsFile(UIStrings.class, ResUtil.getLocRes("eng", "constructTheArena-UIStrings.json"));
} }
//<editor-fold name="Add Relics">
/*======================================================================================
Add Relics
======================================================================================*/
@Override
public void receiveEditRelics() {
BaseMod.addRelic(new ConstructorsBurden(), RelicType.SHARED);
}
//</editor-fold>
//</editor-fold> //</editor-fold>
} }

View File

@ -27,7 +27,6 @@ public class CArenaPatch {
public static void Insert(CustomModeScreen __instance, CustomTrial trial, ArrayList<String> modIds, String modId) { public static void Insert(CustomModeScreen __instance, CustomTrial trial, ArrayList<String> modIds, String modId) {
if (modId.equals("constructTheArena:constructTheArena")) { if (modId.equals("constructTheArena:constructTheArena")) {
//do nothing for now //do nothing for now
logger.info("Patched dailymods insert");
enabled = true; enabled = true;
ArrayList<String> mods = ModHelper.getEnabledModIDs(); ArrayList<String> mods = ModHelper.getEnabledModIDs();
mods.add("SealedDeck"); mods.add("SealedDeck");

View File

@ -11,9 +11,7 @@ import org.apache.logging.log4j.Logger;
clz = AbstractPlayer.class, clz = AbstractPlayer.class,
method = "initializeStarterDeck" method = "initializeStarterDeck"
) )
public class CArenaStartingDeckPatch { public class CArenaSkipMasterDeckPatch {
private final static Logger logger = LogManager.getLogger(CArenaStartingDeckPatch.class.getName());
@SpireInsertPatch( @SpireInsertPatch(
loc = 409, loc = 409,
localvars = {"addBaseCards"} localvars = {"addBaseCards"}

View File

@ -4,18 +4,22 @@ import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.evacipated.cardcrawl.modthespire.lib.SpirePrefixPatch; import com.evacipated.cardcrawl.modthespire.lib.SpirePrefixPatch;
import com.megacrit.cardcrawl.cards.AbstractCard; import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.CardGroup; import com.megacrit.cardcrawl.cards.CardGroup;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon; import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.CardLibrary;
import com.megacrit.cardcrawl.helpers.ModHelper; import com.megacrit.cardcrawl.helpers.ModHelper;
import com.megacrit.cardcrawl.localization.UIStrings;
import com.megacrit.cardcrawl.neow.NeowEvent; import com.megacrit.cardcrawl.neow.NeowEvent;
import com.megacrit.cardcrawl.screens.custom.CustomModeScreen;
import com.megacrit.cardcrawl.trials.CustomTrial;
import com.megacrit.cardcrawl.unlock.UnlockTracker; import com.megacrit.cardcrawl.unlock.UnlockTracker;
import constructTheArena.relics.ConstructorsBurden;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.TreeSet;
@SpirePatch( @SpirePatch(
clz = NeowEvent.class, clz = NeowEvent.class,
@ -24,31 +28,53 @@ import java.util.List;
public class ConstructDraftPatch { public class ConstructDraftPatch {
private final static Logger logger = LogManager.getLogger(ConstructDraftPatch.class.getName()); private final static Logger logger = LogManager.getLogger(ConstructDraftPatch.class.getName());
private final static int CardLimit = 40;
private static final UIStrings uiStrings = CardCrawlGame.languagePack.getUIString("ConstructModeInstructions");
@SpirePrefixPatch @SpirePrefixPatch
public static void Prefix() { public static void Prefix() {
logger.info("Hit dailymods prefix");
if (CArenaPatch.isEnabled()) { if (CArenaPatch.isEnabled()) {
ArrayList<String> mods = ModHelper.getEnabledModIDs(); ArrayList<String> mods = ModHelper.getEnabledModIDs();
mods.remove("SealedDeck"); mods.remove("SealedDeck");
ModHelper.setMods(mods); ModHelper.setMods(mods);
CardGroup sealedGroup = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED); CardGroup constructGroup = new CardGroup(CardGroup.CardGroupType.UNSPECIFIED);
AbstractCard card;
for (int i = 0; i < 30; ++i) {
card = AbstractDungeon.getCard(AbstractDungeon.rollRarity());
sealedGroup.addToBottom(card.makeCopy()); //add master deck to draw pool
TreeSet<String> dedupedMasterDeck = new TreeSet<>(AbstractDungeon.player.getStartingDeck());
for (String cardName : dedupedMasterDeck) {
AbstractCard card = CardLibrary.getCard(AbstractDungeon.player.chosenClass, cardName);
for (int i = 0; i < 4; i++) {
constructGroup.addToTop(card.makeCopy());
}
} }
Iterator<AbstractCard> cards = sealedGroup.group.iterator();
//add all other eligible cards to the draw pool
ArrayList<AbstractCard> cardPool = new ArrayList<>();
AbstractDungeon.player.getCardPool(cardPool);
//sort it so it's all pretty
cardPool.sort(Comparator.comparing(card -> card.name));
for (AbstractCard card : cardPool) {
for (int i = 0; i < 4; i++) {
constructGroup.addToTop(card.makeCopy());
}
}
Iterator<AbstractCard> cards = constructGroup.group.iterator();
AbstractCard c;
while (cards.hasNext()) { while (cards.hasNext()) {
AbstractCard c = cards.next(); c = cards.next();
UnlockTracker.markCardAsSeen(c.cardID); UnlockTracker.markCardAsSeen(c.cardID);
} }
AbstractDungeon.gridSelectScreen.open(sealedGroup, 10, "Whatever", false); AbstractDungeon.gridSelectScreen.open(constructGroup, 40, true, uiStrings.TEXT[0]+CardLimit+uiStrings.TEXT[1]);
AbstractDungeon.getCurrRoom().spawnRelicAndObtain(Settings.WIDTH / 2.0F, Settings.HEIGHT / 2.0F, new ConstructorsBurden());
} }
} }

View File

@ -0,0 +1,45 @@
package constructTheArena.relics;
import com.fasterxml.jackson.core.type.ResolvedType;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import constructTheArena.util.ResUtil;
public class ConstructorsBurden extends AbstractRelic {
private final static String imgPathLarge = ResUtil.getImageRes("relics", "constructorsBurdenLarge.png");
private final static String imgPath = ResUtil.getImageRes("relics", "constructorsBurden.png");
public ConstructorsBurden() {
super("constructTheArena:ConstructorsBurden", "", RelicTier.SPECIAL, LandingSound.HEAVY);
imgUrl = imgPath;
img = ImageMaster.loadImage(imgPath);
largeImg = ImageMaster.loadImage(imgPathLarge);
outlineImg = ImageMaster.loadImage(imgPath);
}
@Override
public AbstractRelic makeCopy() {
return new ConstructorsBurden();
}
@Override
public int changeNumberOfCardsInReward(int NumberOfCards) {
return -10;
}
@Override
public String getUpdatedDescription() {
if (AbstractDungeon.player != null) {
return setDescription(AbstractDungeon.player.chosenClass);
}
return setDescription((AbstractPlayer.PlayerClass) null);
}
private String setDescription(AbstractPlayer.PlayerClass c) {
return this.DESCRIPTIONS[0];
}
}

View File

@ -34,4 +34,10 @@ public class ResUtil {
return getResource(localization, resourceName); return getResource(localization, resourceName);
} }
public static String getImageRes(String category, String resourceName) {
String localization = "images/" + category;
return getResource(localization, resourceName);
}
} }

View File

@ -15,7 +15,7 @@ import java.util.HashMap;
public class TextureLoader { public class TextureLoader {
private static HashMap<String, Texture> textures = new HashMap<String, Texture>(); private final static HashMap<String, Texture> textures = new HashMap<>();
public static final Logger logger = LogManager.getLogger(TextureLoader.class.getName()); public static final Logger logger = LogManager.getLogger(TextureLoader.class.getName());
/** /**
@ -43,7 +43,6 @@ public class TextureLoader {
* @throws GdxRuntimeException * @throws GdxRuntimeException
*/ */
private static void loadTexture(final String textureString) throws GdxRuntimeException { private static void loadTexture(final String textureString) throws GdxRuntimeException {
logger.info("DefaultMod | Loading Texture: " + textureString);
Texture texture = new Texture(textureString); Texture texture = new Texture(textureString);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
textures.put(textureString, texture); textures.put(textureString, texture);

View File

@ -0,0 +1,9 @@
{
"constructTheArena:ConstructorsBurden": {
"NAME": "Constructor's Burden",
"FLAVOR": "You no longer receive card rewards.",
"DESCRIPTIONS": [
"Number of card rewards set to 0."
]
}
}

View File

@ -0,0 +1,9 @@
{
"ConstructModeInstructions": {
"TEXT": [
"Select up to ",
" cards."
]
}
}