diff --git a/src/main/kotlin/marisa/Utils.kt b/src/main/kotlin/marisa/Utils.kt index ef8d5c5..5ce0406 100644 --- a/src/main/kotlin/marisa/Utils.kt +++ b/src/main/kotlin/marisa/Utils.kt @@ -12,7 +12,27 @@ fun countRelic(id: String): Int { return 1 } -fun Iterable.exhaustBurns(): Int = - this.filterIsInstance() - .apply { forEach { p.hand.moveToExhaustPile(it) } } - .size +inline fun Iterable.partitionByType(): Pair, List> { + val first = ArrayList() + val second = ArrayList() + for (element in this) { + if (element is U) second.add(element) + else first.add(element) + } + return Pair(first, second) +} + +/** + * Exhaust all [Burn] cards in the [Iterable] and return the number of [Burn] cards exhausted. + */ +fun Iterable.exhaustBurns() = onEach { p.hand.moveToExhaustPile(it) } + +/** + * Partition the [Iterable] into two lists, one containing all [AbstractCard]s and the other containing all [Burn]s. + * Burns are automatically exhausted. + */ +fun Iterable.withCardsBurned(): Pair, List> { + val (regular, burns) = this.partitionByType() + burns.exhaustBurns() + return Pair(regular, burns) +} diff --git a/src/main/kotlin/marisa/action/MeteoricShowerAction.kt b/src/main/kotlin/marisa/action/MeteoricShowerAction.kt index c0d05d5..57d17c1 100644 --- a/src/main/kotlin/marisa/action/MeteoricShowerAction.kt +++ b/src/main/kotlin/marisa/action/MeteoricShowerAction.kt @@ -7,10 +7,9 @@ import com.megacrit.cardcrawl.dungeons.AbstractDungeon import com.megacrit.cardcrawl.relics.ChemicalX import com.megacrit.cardcrawl.ui.panels.EnergyPanel import marisa.countRelic -import marisa.exhaustBurns import marisa.fx.MeteoricShowerEffect import marisa.p - +import marisa.withCardsBurned class MeteoricShowerAction(val energyOnUse: Int, val dmg: Int, val freeToPlay: Boolean) : AbstractGameAction() { @@ -32,8 +31,9 @@ class MeteoricShowerAction(val energyOnUse: Int, val dmg: Int, val freeToPlay: B return } if (!AbstractDungeon.handCardSelectScreen.wereCardsRetrieved) { - val cnt = - 2 * AbstractDungeon.handCardSelectScreen.selectedCards.group.exhaustBurns() + val (regular, burns) = AbstractDungeon.handCardSelectScreen.selectedCards.group.withCardsBurned() + val cnt = regular.size * 3 + burns.size * 2 + AbstractDungeon.handCardSelectScreen.wereCardsRetrieved = true AbstractDungeon.handCardSelectScreen.selectedCards.group.clear() addToBot(MeteoricShowerEffect.toVfx(cnt))