com.megacrit.cardcrawl.powers.AbstractPower Java Examples

The following examples show how to use com.megacrit.cardcrawl.powers.AbstractPower. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NonStackablePowerPatch.java    From StSLib with MIT License 6 votes vote down vote up
@SpireInsertPatch(
        locator=Locator1.class,
        localvars={"powerToApply", "p"}
)
public static void AvoidStacking(ApplyPowerAction __instance, AbstractPower powerToApply, AbstractPower p)
{
    if (savedID != null) {
        powerToApply.ID = savedID;
        savedID = null;
    }

    if (p.ID.equals(powerToApply.ID)) {
        if (p instanceof NonStackablePower) {
            if (!((NonStackablePower) p).isStackable(powerToApply)) {
                savedID = powerToApply.ID;
                powerToApply.ID = NightmarePower.POWER_ID;
            }
        }
    }
}
 
Example #2
Source File: OnLoseBlockPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static SpireReturn<Integer> Prefix(AbstractCreature __instance, DamageInfo info, @ByRef int[] damageAmount)
{
    if (info.type != DamageInfo.DamageType.HP_LOSS && __instance.currentBlock > 0) {
        for (AbstractPower power : __instance.powers) {
            if (power instanceof OnLoseBlockPower) {
                damageAmount[0] = ((OnLoseBlockPower) power).onLoseBlock(info, damageAmount[0]);
            }
        }
        if (__instance.isPlayer) {
            for (AbstractRelic relic : AbstractDungeon.player.relics) {
                if (relic instanceof OnLoseBlockRelic) {
                    damageAmount[0] = ((OnLoseBlockRelic) relic).onLoseBlock(info, damageAmount[0]);
                }
            }
        }
    }

    return SpireReturn.Continue();
}
 
Example #3
Source File: OnPlayerHpLossSubscriberPatch.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
@SpireInsertPatch(
        locator = Locator.class,
        localvars = { "damageAmount" }
)
public static void patch(AbstractPlayer __this, DamageInfo info, @ByRef int[] damageAmount)
{
    // We order the power first somewhat arbitrarily, because we want Strange Pendant to happen before Mage Armor
    for (AbstractPower power : __this.powers) {
        if (power instanceof OnPlayerHpLossPowerSubscriber) {
            damageAmount[0] = ((OnPlayerHpLossPowerSubscriber) power).onPlayerHpLoss(damageAmount[0]);
        }
    }

    for (AbstractCard cardInHand : __this.hand.group) {
        if (cardInHand instanceof OnPlayerHpLossCardSubscriber) {
            damageAmount[0] = ((OnPlayerHpLossCardSubscriber) cardInHand).onPlayerHpLossWhileInHand(damageAmount[0]);
        }
    }
}
 
Example #4
Source File: TrueDamagePatch.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
public static ExprEditor Instrument() {
    return new ExprEditor() {
        @Override
        public void edit(MethodCall mc) throws CannotCompileException {
            String cls = mc.getClassName();
            String method = mc.getMethodName();

            // Clamp all the damage modifier hooks with first parameter of "float tmp"
            if ((
                    cls.equals(AbstractRelic.class.getName()) ||
                    cls.equals(AbstractPower.class.getName()) ||
                    cls.equals(AbstractStance.class.getName())
                ) && (
                    method.equals("atDamageModify") ||
                    method.equals("atDamageGive") ||
                    method.equals("atDamageReceive") ||
                    method.equals("atDamageFinalGive") ||
                    method.equals("atDamageFinalReceive")
            )) {
                mc.replace(String.format("{ $_ = %1$s.updateDamage(this, $1, $proceed($$)); }", TrueDamagePatchName));
            }
        }
    };
}
 
Example #5
Source File: RemovePowersMatchingPredicateAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void update() {
    for (AbstractPower power : target.powers) {
        if (removePowersPredicate.test(power)) {
            AbstractDungeon.actionManager.addToTop(new RemoveSpecificPowerAction(target, target, power.ID));
        }
    }
    this.isDone = true;
}
 
Example #6
Source File: CustomStackBehaviorPowerPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static boolean patchedStackPower(AbstractPower originalPower, AbstractPower newPower) {
    if (originalPower instanceof CustomStackBehaviorPower) {
        ((CustomStackBehaviorPower) originalPower).stackPower(newPower);
        return false;
    } else {
        return true;
    }
}
 
Example #7
Source File: AnomalyPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
@Override
public void onApplyPower(AbstractPower power, AbstractCreature target, AbstractCreature source) {
    if (target != this.owner && source == this.owner && (power.ID.equals("Weakened") || power.ID.equals("Vulnerable"))) {
        power.amount += this.amount;

        // when powers stack for some bizzare reason it uses the amount on the ApplyPowerAction
        // instead of the amount on the power being applied
        AbstractDungeon.actionManager.currentAction.amount += this.amount;
    }
}
 
Example #8
Source File: MultiplyBurningAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void update() {
    AbstractPower possibleExistingBurningPower = target.getPower(BurningPower.POWER_ID);
    if (possibleExistingBurningPower != null) {
        int stacksToAdd = possibleExistingBurningPower.amount * (multiplier - 1);
        AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(target, source, new BurningPower(target, source, stacksToAdd), stacksToAdd));
    }
    isDone = true;
}
 
Example #9
Source File: MagicMirrorOnPowerReceivedPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@SpirePrefixPatch
public static void patch(ApplyPowerAction __this) {
    if (__this.target != null && !__this.target.isDeadOrEscaped()) {
        float duration = ReflectionUtils.getPrivateField(__this, AbstractGameAction.class, "duration");
        float startingDuration = ReflectionUtils.getPrivateField(__this, ApplyPowerAction.class, "startingDuration");
        if (duration == startingDuration) {
            AbstractPower powerToApply = ReflectionUtils.getPrivateField(__this, ApplyPowerAction.class, "powerToApply");
            if (__this.target.hasPower(MagicMirrorPower.POWER_ID) && powerToApply.type == AbstractPower.PowerType.DEBUFF && __this.target != __this.source) {
                logger.info("Magic Mirror triggering to reflect a power");
                ((MagicMirrorPower)__this.target.getPower(MagicMirrorPower.POWER_ID)).onPowerReceived(powerToApply);
            }
        }
    }
}
 
Example #10
Source File: WitheringPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@SpireInsertPatch(locator = Locator.class, localvars = {"damageAmount"})
public static void patch(AbstractPlayer __instance, DamageInfo info, @ByRef int[] damageAmount) {
    AbstractPower maybeWithering = __instance.getPower(WitheringPower.POWER_ID);
    if(__instance.hasPower(IntangiblePlayerPower.POWER_ID) && maybeWithering != null)
    {
        damageAmount[0] = Math.min(maybeWithering.amount + 1, info.output);
    }
}
 
Example #11
Source File: TimeEddyAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
private static void forEachApplicablePlayerPower(Consumer<AbstractPower> callback) {
    for (AbstractPower power : AbstractDungeon.player.powers) {
        if (shouldAffectPower(power)) {
            callback.accept(power);
        }
    }
}
 
Example #12
Source File: OnHealedBySubscriberPatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static void applyAllHealedBySubscribers(HealAction action) {
    for (AbstractPower power : action.target.powers) {
        if (power instanceof OnHealedBySubscriber) {
            action.amount = ((OnHealedBySubscriber) power).onHealedBy(action.source, action.amount);
        }
    }
}
 
Example #13
Source File: FlickerPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public FlickerPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.description = DESCRIPTIONS[0];
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = true;
    this.priority = 4;
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #14
Source File: CoalescencePower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public CoalescencePower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #15
Source File: PotencyPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public PotencyPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    updateDescription();
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #16
Source File: TrueDamagePatch.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public static ExprEditor Instrument() {
    return new ExprEditor() {
        @Override
        public void edit(FieldAccess fa) throws CannotCompileException {
            // suppress the initial Intangible effect on info.output
            if (fa.getClassName().equals(DamageInfo.class.getName()) &&
                fa.getFieldName().equals("output") &&
                fa.isWriter())
            {
                fa.replace(String.format("{ if (!%1$s.isTrueDamage($0)) { $_ = $proceed($$); } }", TrueDamagePatchName));
            }
        }

        @Override
        public void edit(MethodCall mc) throws CannotCompileException {
            String cls = mc.getClassName();
            String method = mc.getMethodName();

            // clamp the onAttackToChangeDamage, onAttackedToChangeDamage, and onAttacked calls
            if ((cls.equals(AbstractPower.class.getName()) || cls.equals(AbstractRelic.class.getName())) &&
                (method.equals("onAttackToChangeDamage") || method.equals("onAttackedToChangeDamage") || method.equals("onAttacked")))
            {
                mc.replace(String.format("{ $_ = %1$s.updateDamage($1, $2, $proceed($$)); }", TrueDamagePatchName));
                return;
            }
        }
    };
}
 
Example #17
Source File: OnReceivePowerPatch.java    From StSLib with MIT License 5 votes vote down vote up
@SpireInsertPatch(
        locator = Locator.class,
        localvars = {"duration", "powerToApply"}
)
public static SpireReturn<Void> Insert(ApplyPowerAction __instance, @ByRef float[] duration, AbstractPower powerToApply)
{
    return CheckPower(__instance, __instance.target, __instance.source, duration, powerToApply);
}
 
Example #18
Source File: BurningLoseHpAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
public void update() {
    if (AbstractDungeon.getCurrRoom().phase != AbstractRoom.RoomPhase.COMBAT) {
        this.isDone = true;
    } else {
        if (this.duration == DURATION && this.target.currentHealth > 0) {
            AbstractDungeon.effectList.add(new FlashAtkImgEffect(this.target.hb.cX, this.target.hb.cY, this.attackEffect));
        }

        this.tickDuration();
        if (this.isDone) {
            if (this.target.currentHealth > 0) {
                this.target.tint.color = Color.ORANGE.cpy();
                this.target.tint.changeColor(Color.WHITE.cpy());
                this.target.damage(new DamageInfo(this.source, this.amount, DamageInfo.DamageType.THORNS));
            }

            AbstractPower p = this.target.getPower(BurningPower.POWER_ID);
            if (p != null) {
                p.amount = BurningUtils.calculateNextBurningAmount(source, p.amount);

                p.updateDescription();
            }

            if (AbstractDungeon.getCurrRoom().monsters.areMonstersBasicallyDead()) {
                AbstractDungeon.actionManager.clearPostCombatActions();
            }

            AbstractDungeon.actionManager.addToTop(new WaitAction(0.1F));
        }
    }
}
 
Example #19
Source File: ThirstingSwordBurningVampireAction.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void update() {
    AbstractPower possibleExistingBurningPower = target.getPower(BurningPower.POWER_ID);
    if (possibleExistingBurningPower != null) {
        int healAmount = possibleExistingBurningPower.amount;
        AbstractDungeon.actionManager.addToTop(new HealAction(source, source, healAmount));
    }

    source.decreaseMaxHealth(maxHealthReduction);
    isDone = true;
}
 
Example #20
Source File: AnomalyPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public AnomalyPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    updateDescription();
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #21
Source File: NonStackablePowerPatch.java    From StSLib with MIT License 5 votes vote down vote up
@SpireInsertPatch(
        locator=Locator2.class,
        localvars={"powerToApply"}
)
public static void RestorePowerID(ApplyPowerAction __instance, AbstractPower powerToApply)
{
    if (savedID != null) {
        powerToApply.ID = savedID;
        savedID = null;
    }
}
 
Example #22
Source File: PyromancyPower.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void onApplyPower(AbstractPower power, AbstractCreature target, AbstractCreature source) {
    if (source == owner && power.ID.equals(BurningPower.POWER_ID) && !((BurningPower)power).generatedByPyromancy) {
        for (int i = 0; i < amount; ++i) {
            AbstractDungeon.actionManager.addToTop(new ApplyPowerAction(target, source, new BurningPower(target, source, power.amount, true)));
        }
    }
}
 
Example #23
Source File: EnigmaPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public EnigmaPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #24
Source File: BlackTentaclesPower.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void onInitialApplication() {
    // only 1 target can have this power at a time; subsequent uses of the card will overwrite the old effect
    for(AbstractMonster m : AbstractDungeon.getMonsters().monsters) {
        for (AbstractPower p : m.powers) {
            if (p.ID.equals(this.ID) && p != this) {
                AbstractDungeon.actionManager.addToTop(new RemoveSpecificPowerAction(m, source, p));
            }
        }
    }
}
 
Example #25
Source File: CoalescencePower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public CoalescencePower(AbstractCreature owner, int weakAmount, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    this.weakAmount = weakAmount;
    updateDescription();
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #26
Source File: CelerityPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public CelerityPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    updateDescription();
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #27
Source File: PhantasmPower.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public boolean onReceivePowerToCancel(AbstractPower power, AbstractCreature source) {
    if (power.ID.equals(IntangiblePlayerPower.POWER_ID) && power.owner == this.owner) {
        this.flash();
        AbstractDungeon.actionManager.addToBottom(new DamageAllEnemiesAction(this.owner, DamageInfo.createDamageMatrix(this.amount, true), DamageInfo.DamageType.THORNS, AbstractGameAction.AttackEffect.POISON, true));
    }
    return false;
}
 
Example #28
Source File: VigorPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public VigorPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    updateDescription();
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = false;
    this.priority = 90;
    this.img = new Texture(SeekerMod.makePowerImagePath(POWER_ID));
}
 
Example #29
Source File: FlowPower.java    From FruityMod-StS with MIT License 5 votes vote down vote up
public FlowPower(AbstractCreature owner, int amount) {
    this.name = NAME;
    this.ID = POWER_ID;
    this.owner = owner;
    this.amount = amount;
    this.description = DESCRIPTIONS[0];
    this.type = AbstractPower.PowerType.BUFF;
    this.isTurnBased = true;
    this.img = new Texture(SeekerMod.makePowerImagePath(AstralHazePower.POWER_ID)); // Replace with a different image
}
 
Example #30
Source File: PrestidigitationPower.java    From jorbs-spire-mod with MIT License 5 votes vote down vote up
@Override
public void atStartOfTurn() {
    AbstractCreature target = AbstractDungeon.getRandomMonster();
    if (target != null) {
        this.flash();
        AbstractPower effect = AbstractDungeon.cardRandomRng.randomBoolean() ?
                new WeakPower(target, amount, !owner.isPlayer) :
                new VulnerablePower(target, amount, !owner.isPlayer);

        AbstractDungeon.actionManager.addToBottom(new ApplyPowerAction(target, owner, effect, amount));
    }
}