diff --git a/src/main/java/str_exporter/DeckJSONBuilder.java b/src/main/java/str_exporter/DeckJSONBuilder.java index aa56359..8f6f274 100644 --- a/src/main/java/str_exporter/DeckJSONBuilder.java +++ b/src/main/java/str_exporter/DeckJSONBuilder.java @@ -7,6 +7,7 @@ import com.megacrit.cardcrawl.cards.CardGroup; import com.megacrit.cardcrawl.cards.DescriptionLine; import com.megacrit.cardcrawl.core.CardCrawlGame; +import com.megacrit.cardcrawl.core.Settings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -165,12 +166,12 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { String desc = sanitizeEmpty(parseDescription(card)); String keywords = sanitizeEmpty(encodeKeywords(card)); - AbstractCard copy = card.makeStatEquivalentCopy(); - copy.upgrade(); - copy.displayUpgrades(); - String upgradedDesc = sanitizeEmpty(parseDescription(copy)); - String upgradedName = sanitizeEmpty(sanitize(copy.name)); - String upgradedKeywords = sanitizeEmpty(encodeKeywords(copy)); + AbstractCard cardUpg = card.makeStatEquivalentCopy(); + cardUpg.upgrade(); + cardUpg.displayUpgrades(); + String upgradedDesc = sanitizeEmpty(parseDescription(cardUpg)); + String upgradedName = sanitizeEmpty(sanitize(cardUpg.name)); + String upgradedKeywords = sanitizeEmpty(encodeKeywords(cardUpg)); int timesUpgraded = card.timesUpgraded; int cost = card.cost; @@ -192,6 +193,10 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { upgradedKeywords = "_"; } + // this odd ordering of properties is supposed to maximize the compression ratio of the custom compression + // algorithm implemented here. It's supposed to cluster features that often change together or don't change + // at all + // for a regular card: // name ; bottleStatus ; modName ; cardToPreview ; cardToPreview upgraded ; nameUpgraded ; upgrades ; keyword upgraded ; descriptionUpgraded ; keywords ; cost ; cost upgraded ; type ; rarity ; color ; description @@ -204,7 +209,7 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { if (!repr) { sb.append(encodeCardToPreview(card)); sb.append(';'); - sb.append(encodeCardToPreview(copy)); + sb.append(encodeCardToPreview(cardUpg)); sb.append(';'); } sb.append(upgradedName); @@ -219,7 +224,7 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { sb.append(';'); sb.append(cost); sb.append(";"); - sb.append(copy.cost); + sb.append(cardUpg.cost); sb.append(";"); sb.append(encodeCardType(card)); sb.append(";"); @@ -323,7 +328,17 @@ private String parseDescription(AbstractCard card) { sb.append(" NL "); } - String[] parts = sb.toString().split(" "); + String description = sb.toString(); + + if(Settings.lineBreakViaCharacter) { //CN or Japanese localization + description = description.replaceAll("D", "!D!") + .replaceAll("!B!!", "!B!") + .replaceAll("!M!!", "!M!"); + } + +// logger.info("first description: " + sb.toString()); + + String[] parts = description.split(" "); sb.setLength(0); Pattern patternDynVar = Pattern.compile("!(.+)!(.*)"); diff --git a/src/main/resources/ModTheSpire.json b/src/main/resources/ModTheSpire.json index f6f9a00..6888ffb 100644 --- a/src/main/resources/ModTheSpire.json +++ b/src/main/resources/ModTheSpire.json @@ -3,7 +3,7 @@ "name": "Slay the Relics Exporter", "author_list": ["LordAddy"], "description": "This mod exports data to Slay the Relics Twitch extension. \n\nThis mod in combination with the extension displays deck view and tooltips for viewers on stream for relics, potions, player/monster powers, orbs, even some custom tooltips from some mods. \nThe viewers just need to hover over the respective item just as if they were in the game themselves.\n\nSee the extension config on Twitch for setup instructions (search 'Slay the Relics').", - "version": "1.2.2", + "version": "1.2.4", "sts_version": "07-30-2020", "mts_version": "3.15.0", "dependencies": ["basemod"]