Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package theSenshi.cards;
- import com.megacrit.cardcrawl.characters.AbstractPlayer;
- import com.megacrit.cardcrawl.core.CardCrawlGame;
- import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
- import com.megacrit.cardcrawl.localization.UIStrings;
- import com.megacrit.cardcrawl.monsters.AbstractMonster;
- import com.megacrit.cardcrawl.vfx.ThoughtBubble;
- import theSenshi.SenshiMod;
- import theSenshi.powers.MagicPower;
- import theSenshi.relics.EternalTiareRelic;
- import static com.megacrit.cardcrawl.core.CardCrawlGame.languagePack;
- public abstract class AbstractMagicCard extends AbstractDefaultCard {
- // "How come DefaultCommonAttack extends CustomCard and not DynamicCard like all the rest?"
- // Well every card, at the end of the day, extends CustomCard.
- // Abstract Default Card extends CustomCard and builds up on it, adding a second magic number. Your card can extend it and
- // bam - you can have a second magic number in that card (Learn Java inheritance if you want to know how that works).
- // Abstract Dynamic Card builds up on Abstract Default Card even more and makes it so that you don't need to add
- // the NAME and the DESCRIPTION into your card - it'll get it automatically. Of course, this functionality could have easily
- // Been added to the default card rather than creating a new Dynamic one, but was done so to deliberately.
- public int magical; // Just like magic number, or any number for that matter, we want our regular, modifiable stat
- public int baseMagical; // And our base stat - the number in it's base state. It will reset to that by default.
- public boolean upgradedMagical; // A boolean to check whether the number has been upgraded or not.
- public boolean isMagicalModified; // A boolean to check whether the number has been modified or not, for coloring purposes. (red/green)
- protected int cardBaseDamage;
- protected String currentDescription;
- protected String handDescription;
- private boolean doDamage = false;
- private static final UIStrings uiStrings;
- public static final String[] TEXT;
- public AbstractMagicCard(final String id,
- final String img,
- final int cost,
- final CardType type,
- final CardColor color,
- final CardRarity rarity,
- final CardTarget target) {
- super(id, languagePack.getCardStrings(id).NAME, img, cost, languagePack.getCardStrings(id).DESCRIPTION, type, color, rarity, target);
- isMagicalModified = false;
- }
- private void adjustDamage() {
- AbstractPlayer p =AbstractDungeon.player;
- int additional = 0;
- if (p.hasPower(MagicPower.POWER_ID)) {
- additional = p.getPower(MagicPower.POWER_ID).amount;
- if (magical != -1) {
- int cap = magical;
- if (p.hasRelic(EternalTiareRelic.ID)) {
- EternalTiareRelic relic = (EternalTiareRelic) (p.getRelic(EternalTiareRelic.ID));
- relic.trigger(cap);
- }
- if (additional > cap)
- additional = cap;
- }
- }
- this.baseDamage = cardBaseDamage + additional;
- isDamageModified = additional > 0;
- doDamage = baseDamage > 0;
- }
- public void displayUpgrades() { // Display the upgrade - when you click a card to upgrade it
- super.displayUpgrades();
- if (upgradedMagical) { // If we set upgradedSecondMagicNumber = true in our card.
- magical = baseMagical; // Show how the number changes, as out of combat, the base number of a card is shown.
- isMagicalModified = true; // Modified = true, color it green to highlight that the number is being changed.
- }
- }
- 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.
- baseMagical += amount; // Upgrade the number by the amount you provide in your card.
- magical = baseMagical; // Set the number to be equal to the base value.
- upgradedMagical = true; // Upgraded = true - which does what the above method does.
- }
- @Override
- public void use(AbstractPlayer p, AbstractMonster m) {
- if (!doDamage)
- AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F, TEXT[0], true));
- else{
- if (p.hasRelic(EternalTiareRelic.ID)) {
- p.getRelic(EternalTiareRelic.ID).flash();
- }
- }
- }
- @Override
- public void applyPowers() {
- adjustDamage();
- super.applyPowers();
- rawDescription = handDescription;
- initializeDescription();
- baseDamage = cardBaseDamage;
- }
- @Override
- public void calculateCardDamage(AbstractMonster mo) {
- adjustDamage();
- super.calculateCardDamage(mo);
- rawDescription = handDescription;
- initializeDescription();
- baseDamage = cardBaseDamage;
- }
- @Override
- public void onMoveToDiscard() {
- rawDescription = currentDescription;
- initializeDescription();
- }
- static {
- uiStrings = CardCrawlGame.languagePack.getUIString(SenshiMod.makeID(AbstractMagicCard.class.getSimpleName()));
- TEXT = uiStrings.TEXT;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement