style: reformat card-events.ts with 2-space indentation
This commit is contained in:
parent
2f2e4e56b5
commit
dda8f4cfe9
|
|
@ -9,9 +9,14 @@ export function addCardEventTriggers(triggers: Triggers) {
|
||||||
const effects = getEffects();
|
const effects = getEffects();
|
||||||
|
|
||||||
function findEffect(id: string): EffectData {
|
function findEffect(id: string): EffectData {
|
||||||
const found = effects.find(e => e.id === id);
|
const found = effects.find((e) => e.id === id);
|
||||||
if (found) return found;
|
if (found) return found;
|
||||||
return { id, name: id, description: "", lifecycle: "instant" } as EffectData;
|
return {
|
||||||
|
id,
|
||||||
|
name: id,
|
||||||
|
description: "",
|
||||||
|
lifecycle: "instant",
|
||||||
|
} as EffectData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// storm: give static card to player when storm enemy attacks
|
// storm: give static card to player when storm enemy attacks
|
||||||
|
|
@ -62,14 +67,17 @@ export function addCardEventTriggers(triggers: Triggers) {
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
const playedItemId = card.itemId;
|
const playedItemId = card.itemId;
|
||||||
|
|
||||||
const adjacent = getAdjacentItems<GameItemMeta>(ctx.game.value.inventory, playedItemId);
|
const adjacent = getAdjacentItems<GameItemMeta>(
|
||||||
|
ctx.game.value.inventory,
|
||||||
|
playedItemId,
|
||||||
|
);
|
||||||
for (const [adjItemId] of adjacent) {
|
for (const [adjItemId] of adjacent) {
|
||||||
const adjEffects = ctx.game.value.player.itemEffects[adjItemId];
|
const adjEffects = ctx.game.value.player.itemEffects[adjItemId];
|
||||||
if (!adjEffects) continue;
|
if (!adjEffects) continue;
|
||||||
const burn = adjEffects.burnForEnergy;
|
const burn = adjEffects.burnForEnergy;
|
||||||
if (!burn || burn.stacks <= 0) continue;
|
if (!burn || burn.stacks <= 0) continue;
|
||||||
|
|
||||||
await ctx.game.produceAsync(draft => {
|
await ctx.game.produceAsync((draft) => {
|
||||||
const item = draft.inventory.items.get(adjItemId);
|
const item = draft.inventory.items.get(adjItemId);
|
||||||
if (item) {
|
if (item) {
|
||||||
draft.inventory.items.delete(adjItemId);
|
draft.inventory.items.delete(adjItemId);
|
||||||
|
|
@ -89,12 +97,12 @@ export function addCardEventTriggers(triggers: Triggers) {
|
||||||
if (!card || card.cardData.id !== "fatigue") return;
|
if (!card || card.cardData.id !== "fatigue") return;
|
||||||
|
|
||||||
const sandwormKing = ctx.game.value.enemies.find(
|
const sandwormKing = ctx.game.value.enemies.find(
|
||||||
e => e.enemy.id === "沙虫王" && e.isAlive
|
(e) => e.enemy.id === "沙虫王" && e.isAlive,
|
||||||
);
|
);
|
||||||
if (!sandwormKing) return;
|
if (!sandwormKing) return;
|
||||||
|
|
||||||
await ctx.game.produceAsync(draft => {
|
await ctx.game.produceAsync((draft) => {
|
||||||
const king = draft.enemies.find(e => e.id === sandwormKing.id);
|
const king = draft.enemies.find((e) => e.id === sandwormKing.id);
|
||||||
if (king) {
|
if (king) {
|
||||||
king.hp = Math.min(king.hp + 10, king.maxHp);
|
king.hp = Math.min(king.hp + 10, king.maxHp);
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +117,8 @@ export function addCardEventTriggers(triggers: Triggers) {
|
||||||
if (dealt <= 0 || !ctx.sourceEntityKey) return;
|
if (dealt <= 0 || !ctx.sourceEntityKey) return;
|
||||||
|
|
||||||
const attacker = getCombatEntity(ctx.game.value, ctx.sourceEntityKey);
|
const attacker = getCombatEntity(ctx.game.value, ctx.sourceEntityKey);
|
||||||
if (!attacker || !("enemy" in attacker) || attacker.enemy.id !== "秃鹫") return;
|
if (!attacker || !("enemy" in attacker) || attacker.enemy.id !== "秃鹫")
|
||||||
|
return;
|
||||||
|
|
||||||
await triggers.onEffectApplied.execute(ctx.game, {
|
await triggers.onEffectApplied.execute(ctx.game, {
|
||||||
effect: findEffect("vultureEye"),
|
effect: findEffect("vultureEye"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue