generated from Alorel/basic-library-template-repo
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
190 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const enum EqNeq { | ||
EQ = '=', | ||
NEQ = '!=', | ||
} | ||
|
||
type EqNeqFn<T> = (a: T, b: T) => boolean; | ||
|
||
const compareFns = new Map<EqNeq, EqNeqFn<any>>([ | ||
[EqNeq.EQ, (a, b) => a === b], | ||
[EqNeq.NEQ, (a, b) => a !== b], | ||
]); | ||
|
||
/** Get the comparison function for {@link EqNeq} */ | ||
export function getEqNeqFn<T>(eqNeq: EqNeq): EqNeqFn<T> { | ||
return compareFns.get(eqNeq)!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type {SpecialAttack as TSpecialAttack} from 'melvor'; | ||
import {Fragment} from 'preact'; | ||
import {InternalCategory} from '../../lib/registries/action-registry.mjs'; | ||
import {defineLocalTrigger} from '../../lib/util/define-local.mjs'; | ||
import {EqNeq, getEqNeqFn} from '../../lib/util/eqneq.mjs'; | ||
|
||
interface Data { | ||
atk: TSpecialAttack; | ||
|
||
match: EqNeq; | ||
} | ||
|
||
const triggerCtx = defineLocalTrigger<Data>({ | ||
category: InternalCategory.COMBAT, | ||
check: d => game.combat.isActive && getEqNeqFn(d.match)(game.combat.enemy.nextAttack.id, d.atk.id), | ||
init() { | ||
ctx.patch(Enemy, 'queueNextAction').after(() => { | ||
const atk = game.combat.enemy.nextAttack.id; | ||
triggerCtx.notifyListeners(d => getEqNeqFn(d.match)(atk, d.atk.id)); | ||
}); | ||
}, | ||
initOptions: () => ({match: EqNeq.EQ}), | ||
label: 'Monster attack', | ||
localID: 'enemyAtk', | ||
media: cdnMedia('assets/media/bank/Mask_of_Torment.png'), | ||
options: [ | ||
{ | ||
icon: false, | ||
itemRender: ({item}: {item: TSpecialAttack}) => ( | ||
<Fragment> | ||
<span class={'font-w600'}>{`${item.name} `}</span> | ||
<small>{item.description}</small> | ||
</Fragment> | ||
), | ||
label: 'Attack', | ||
localID: 'atk', | ||
registry: 'specialAttacks', | ||
required: true, | ||
type: 'MediaItem', | ||
}, | ||
{ | ||
enum: { | ||
[EqNeq.EQ]: 'Casting attack', | ||
[EqNeq.NEQ]: 'Not casting attack', | ||
}, | ||
label: 'Match', | ||
localID: 'match', | ||
required: true, | ||
type: String, | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './enemy-id-trigger.mjs'; | ||
import './enemy-special-attack-trigger'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './and-or-trigger.mjs'; | ||
import './item-quantity-trigger.mjs'; | ||
import './level-gained-trigger.mjs'; | ||
import './mastery-level-trigger.mjs'; | ||
import './mastery-pool-xp-trigger.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
import '../option-types/option-types.mjs'; | ||
import './combat/enemy-id-trigger.mjs'; | ||
import './core/and-or-trigger.mjs'; | ||
import './core/item-quantity-trigger.mjs'; | ||
import './core/level-gained-trigger.mjs'; | ||
import './core/mastery-level-trigger.mts'; | ||
import './core/mastery-pool-xp-trigger.mts'; | ||
import './combat/index.mjs'; | ||
import './core/index.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.