Skip to content

Instantly share code, notes, and snippets.

@Tarmean
Created January 13, 2018 21:56
Show Gist options
  • Select an option

  • Save Tarmean/833e18eaaf70c687af2396f4ec6b55d3 to your computer and use it in GitHub Desktop.

Select an option

Save Tarmean/833e18eaaf70c687af2396f4ec6b55d3 to your computer and use it in GitHub Desktop.
diff --git c/src/com/megacrit/cardcrawl/actions/unique/NightTerrorAction.java w/src/com/megacrit/cardcrawl/actions/unique/NightTerrorAction.java
index bb05c1d..d5d6704 100644
--- c/src/com/megacrit/cardcrawl/actions/unique/NightTerrorAction.java
+++ w/src/com/megacrit/cardcrawl/actions/unique/NightTerrorAction.java
@@ -42,7 +42,7 @@ extends AbstractGameAction {
return;
}
if (this.p.hand.size() == 1) {
- AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(this.p, this.p, new NightTerrorPower(this.p, this.amount, this.p.hand.getBottomCard())));
+ this.setupPower(this.p.hand.getBottomCard());
this.isDone = true;
return;
}
@@ -52,7 +52,7 @@ extends AbstractGameAction {
}
if (!AbstractDungeon.handCardSelectScreen.wereCardsRetrieved) {
AbstractCard tmpCard = AbstractDungeon.handCardSelectScreen.selectedCards.getBottomCard();
- AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(this.p, this.p, new NightTerrorPower(this.p, this.amount, tmpCard)));
+ this.setupPower(tmpCard);
AbstractDungeon.player.hand.addToHand(tmpCard);
AbstractDungeon.handCardSelectScreen.selectedCards.clear();
AbstractDungeon.handCardSelectScreen.wereCardsRetrieved = true;
@@ -60,6 +60,14 @@ extends AbstractGameAction {
this.tickDuration();
}
+ private void setupPower(AbstractCard card) {
+ NightTerrorPower power = (NightTerrorPower)this.p.getPower("Night Terror");
+ if (power != null) {
+ power.pushCard(this.amount, card);
+ }
+ AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(this.p, this.p, new NightTerrorPower(this.p, this.amount, card)));
+ }
+
static {
DURATION = Settings.ACTION_DUR_XFAST;
}
diff --git c/src/com/megacrit/cardcrawl/powers/NightTerrorPower.java w/src/com/megacrit/cardcrawl/powers/NightTerrorPower.java
index e9fa649..7106b96 100644
--- c/src/com/megacrit/cardcrawl/powers/NightTerrorPower.java
+++ w/src/com/megacrit/cardcrawl/powers/NightTerrorPower.java
@@ -3,9 +3,6 @@
*/
package com.megacrit.cardcrawl.powers;
-import com.badlogic.gdx.graphics.Texture;
-import com.megacrit.cardcrawl.actions.AbstractGameAction;
-import com.megacrit.cardcrawl.actions.GameActionManager;
import com.megacrit.cardcrawl.actions.common.MakeTempCardInHandAction;
import com.megacrit.cardcrawl.actions.common.RemoveSpecificPowerAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
@@ -14,9 +11,15 @@ import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.FontHelper;
import com.megacrit.cardcrawl.helpers.ImageMaster;
-import com.megacrit.cardcrawl.localization.LocalizedStrings;
import com.megacrit.cardcrawl.localization.PowerStrings;
-import com.megacrit.cardcrawl.powers.AbstractPower;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static java.util.stream.Collectors.*;
public class NightTerrorPower
extends AbstractPower {
@@ -24,27 +27,55 @@ extends AbstractPower {
private static final PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings("Night Terror");
public static final String NAME = NightTerrorPower.powerStrings.NAME;
public static final String[] DESCRIPTIONS = NightTerrorPower.powerStrings.DESCRIPTIONS;
- private AbstractCard card;
+ private List<AbstractCard> cards;
+ private List<Integer> amounts;
public NightTerrorPower(AbstractCreature owner, int cardAmt, AbstractCard copyMe) {
this.name = NAME;
this.ID = "Night Terror";
this.owner = owner;
- this.amount = cardAmt;
this.img = ImageMaster.loadImage("images/powers/32/nightTerror.png");
- this.card = copyMe.makeStatEquivalentCopy();
+ this.cards = new ArrayList<>();
+ this.amounts = new ArrayList<>();
+ this.pushCard(cardAmt, copyMe);
this.updateDescription();
}
@Override
public void updateDescription() {
- this.description = DESCRIPTIONS[0] + this.amount + " " + FontHelper.colorString(this.card.name, "y") + DESCRIPTIONS[1];
+ // Group duplicated cards by card name
+ Map<String, Integer> dupedCards = IntStream.range(0, cards.size()).boxed()
+ .collect(groupingBy(
+ i -> cards.get(i).name,
+ summingInt(amounts::get)
+ ));
+
+ if (dupedCards.size() == 1) {
+ String onlyCard = cards.get(0).name;
+ int count = dupedCards.getOrDefault(onlyCard, 0);
+ String coloredName = FontHelper.colorString(onlyCard, "y");
+ this.description = DESCRIPTIONS[0] + " " + count + " " + coloredName + " " + DESCRIPTIONS[1];
+ } else {
+ Function<Map.Entry<String, Integer>, String> formatCard =
+ entry -> "- " + entry.getValue() + " " + FontHelper.colorString(entry.getKey(), "y") + " NL ";
+ this.description = dupedCards.entrySet().stream()
+ .map(formatCard)
+ .collect(joining("", DESCRIPTIONS[0] + " NL ", DESCRIPTIONS[1]));
+ }
}
@Override
public void atStartOfTurn() {
- AbstractDungeon.actionManager.addToBottom(new MakeTempCardInHandAction(this.card, this.amount));
+ for (int i = 0; i < this.cards.size(); ++i) {
+ AbstractDungeon.actionManager.addToBottom(new MakeTempCardInHandAction(this.cards.get(i), this.amounts.get(i)));
+ }
AbstractDungeon.actionManager.addToBottom(new RemoveSpecificPowerAction(this.owner, this.owner, "Night Terror"));
}
+
+ public void pushCard(int amount, AbstractCard card) {
+ this.cards.add(card.makeStatEquivalentCopy());
+ this.amounts.add(amount);
+ this.updateDescription();
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment