Advertisement
Guest User

Untitled

a guest
May 25th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.57 KB | None | 0 0
  1. package theSenshi.cards;
  2.  
  3. import com.megacrit.cardcrawl.characters.AbstractPlayer;
  4. import com.megacrit.cardcrawl.core.CardCrawlGame;
  5. import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
  6. import com.megacrit.cardcrawl.localization.UIStrings;
  7. import com.megacrit.cardcrawl.monsters.AbstractMonster;
  8. import com.megacrit.cardcrawl.vfx.ThoughtBubble;
  9. import theSenshi.SenshiMod;
  10. import theSenshi.powers.MagicPower;
  11. import theSenshi.relics.EternalTiareRelic;
  12.  
  13. import static com.megacrit.cardcrawl.core.CardCrawlGame.languagePack;
  14.  
  15. public abstract class AbstractMagicCard extends AbstractDefaultCard {
  16.  
  17.     // "How come DefaultCommonAttack extends CustomCard and not DynamicCard like all the rest?"
  18.  
  19.     // Well every card, at the end of the day, extends CustomCard.
  20.     // Abstract Default Card extends CustomCard and builds up on it, adding a second magic number. Your card can extend it and
  21.     // bam - you can have a second magic number in that card (Learn Java inheritance if you want to know how that works).
  22.     // Abstract Dynamic Card builds up on Abstract Default Card even more and makes it so that you don't need to add
  23.     // the NAME and the DESCRIPTION into your card - it'll get it automatically. Of course, this functionality could have easily
  24.     // Been added to the default card rather than creating a new Dynamic one, but was done so to deliberately.
  25.  
  26.     public int magical;        // Just like magic number, or any number for that matter, we want our regular, modifiable stat
  27.     public int baseMagical;    // And our base stat - the number in it's base state. It will reset to that by default.
  28.     public boolean upgradedMagical; // A boolean to check whether the number has been upgraded or not.
  29.     public boolean isMagicalModified; // A boolean to check whether the number has been modified or not, for coloring purposes. (red/green)
  30.  
  31.     protected int cardBaseDamage;
  32.  
  33.     protected String currentDescription;
  34.     protected String handDescription;
  35.  
  36.     private boolean doDamage = false;
  37.  
  38.     private static final UIStrings uiStrings;
  39.     public static final String[] TEXT;
  40.  
  41.     public AbstractMagicCard(final String id,
  42.                              final String img,
  43.                              final int cost,
  44.                              final CardType type,
  45.                              final CardColor color,
  46.                              final CardRarity rarity,
  47.                              final CardTarget target) {
  48.  
  49.         super(id, languagePack.getCardStrings(id).NAME, img, cost, languagePack.getCardStrings(id).DESCRIPTION, type, color, rarity, target);
  50.         isMagicalModified = false;
  51.  
  52.     }
  53.  
  54.     private void adjustDamage() {
  55.         AbstractPlayer p =AbstractDungeon.player;
  56.         int additional = 0;
  57.         if (p.hasPower(MagicPower.POWER_ID)) {
  58.             additional = p.getPower(MagicPower.POWER_ID).amount;
  59.             if (magical != -1) {
  60.                 int cap = magical;
  61.                 if (p.hasRelic(EternalTiareRelic.ID)) {
  62.                     EternalTiareRelic relic = (EternalTiareRelic) (p.getRelic(EternalTiareRelic.ID));
  63.                     relic.trigger(cap);
  64.                 }
  65.                 if (additional > cap)
  66.                     additional = cap;
  67.             }
  68.         }
  69.         this.baseDamage = cardBaseDamage + additional;
  70.         isDamageModified = additional > 0;
  71.         doDamage = baseDamage > 0;
  72.     }
  73.  
  74.     public void displayUpgrades() { // Display the upgrade - when you click a card to upgrade it
  75.         super.displayUpgrades();
  76.         if (upgradedMagical) { // If we set upgradedSecondMagicNumber = true in our card.
  77.             magical = baseMagical; // Show how the number changes, as out of combat, the base number of a card is shown.
  78.             isMagicalModified = true; // Modified = true, color it green to highlight that the number is being changed.
  79.         }
  80.     }
  81.  
  82.     public void upgradeMagical(int amount) { // If we're upgrading (read: changing) the number. Note "upgrade" and NOT "upgraded" - 2 different things. One is a boolean, and then this one is what you will usually use - change the integer by how much you want to upgrade.
  83.         baseMagical += amount; // Upgrade the number by the amount you provide in your card.
  84.         magical = baseMagical; // Set the number to be equal to the base value.
  85.         upgradedMagical = true; // Upgraded = true - which does what the above method does.
  86.     }
  87.  
  88.     @Override
  89.     public void use(AbstractPlayer p, AbstractMonster m) {
  90.         if (!doDamage)
  91.             AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F, TEXT[0], true));
  92.         else{
  93.             if (p.hasRelic(EternalTiareRelic.ID)) {
  94.                 p.getRelic(EternalTiareRelic.ID).flash();
  95.             }
  96.         }
  97.     }
  98.  
  99.     @Override
  100.     public void applyPowers() {
  101.         adjustDamage();
  102.         super.applyPowers();
  103.         rawDescription = handDescription;
  104.         initializeDescription();
  105.         baseDamage = cardBaseDamage;
  106.     }
  107.  
  108.     @Override
  109.     public void calculateCardDamage(AbstractMonster mo) {
  110.         adjustDamage();
  111.         super.calculateCardDamage(mo);
  112.         rawDescription = handDescription;
  113.         initializeDescription();
  114.         baseDamage = cardBaseDamage;
  115.     }
  116.  
  117.     @Override
  118.     public void onMoveToDiscard() {
  119.         rawDescription = currentDescription;
  120.         initializeDescription();
  121.     }
  122.  
  123.     static {
  124.         uiStrings = CardCrawlGame.languagePack.getUIString(SenshiMod.makeID(AbstractMagicCard.class.getSimpleName()));
  125.         TEXT = uiStrings.TEXT;
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement