add-held-item
Add held items to the battle system. Use when creating items Pokemon can hold for passive or triggered effects.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add held items to the battle system. Use when creating items Pokemon can hold for passive or triggered effects.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Add new moves to the battle system. Use when implementing attack, status, or support moves for Pokemon.
Add a Pokemon (real or fake) to src/config/pokemonConfig.js with its moves, abilities, rarity, and evolution data. Use when the user asks to add, register, implement, or create a new Pokemon, Pokemon form, or fake/custom Pokemon in the battle system.
Find a Pokemon's Discord emoji string — canonical (e.g. `<:25:1100282072003772457>`) from `pokestar-pk-{n}`, form variants (e.g. `<:483origin:1404654211324448848>`) from `pokestar-forms-1`, or fakemon (e.g. `<:ashpikachu:1109522092283658250>`) from `pokestar-pk-extra` — via Playwright CLI. Use when the user asks for a Pokemon's emoji, emoji ID, form emoji, fakemon emoji, or needs an `<:name:snowflake>` string.
Create an implementation plan before adding one or more Pokemon via the `add-pokemon` skill. Builds Pokemon, moves, and abilities tables with all required inputs, flags unimplemented moves/abilities, and produces step-by-step implementation instructions. Use when the user asks to plan adding a Pokemon, plan a Pokemon batch, or invokes this skill before `add-pokemon`.
Verify Discord bot changes by running the bot and testing commands in Discord via Playwright CLI. Use when the user asks to test, verify, or check bot commands in Discord.
Verify a Pokemon's configuration in pokemonConfig.js by testing its moves and abilities in Discord via Playwright CLI. Use when validating a Pokemon's battle behavior after configuration changes.
| name | add-held-item |
| description | Add held items to the battle system. Use when creating items Pokemon can hold for passive or triggered effects. |
Files to modify:
src/enums/battleEnums.js - Add heldItemIdEnum.YOUR_ITEM entry (ONLY if not exists)src/config/backpackConfig.js - Add item metadata (name, description) if not existssrc/battle/data/heldItems.js - Add the held item implementationDO NOT modify other held items or battleConfig.js unless explicitly asked.
[heldItemIdEnum.ITEM_NAME]: new HeldItem({
id: heldItemIdEnum.ITEM_NAME,
itemAdd({ battle, target }) {
// Called when item is applied to Pokemon
return {
// Properties to store for later use in itemRemove
listenerId: this.registerListenerFunction({...}),
};
},
itemRemove({ battle, target, properties }) {
// Called when item is removed
battle.unregisterListener(properties.listenerId);
},
itemUse({ battle, target }) {
// Optional: Logic for when the item is consumed
// Only required for items with the "usable" tag
},
tags: ["berry", "usable"], // Optional tags for item categorization
}),
Return state from itemAdd that you'll need in itemRemove:
itemAdd({ battle, target }) {
return {
listenerId: this.registerListenerFunction({...}),
originalStat: target.getStat("atk"),
triggered: false,
};
},
itemRemove({ battle, target, properties }) {
battle.unregisterListener(properties.listenerId);
}
Held items have a class-level registerListenerFunction method that automatically includes the held item instance:
itemAdd({ battle, target }) {
return {
listenerId: this.registerListenerFunction({
battle,
target,
eventName: battleEventEnum.AFTER_DAMAGE_DEALT,
callback: ({ damage, heldItemInstance }) => {
// heldItemInstance.data contains the properties
// Perform item logic
},
conditionCallback: getIsTargetPokemonCallback(target),
}),
};
},
| Tag | Description |
|---|---|
berry | Berry item, consumed after use |
usable | Item can be consumed, requires itemUse method |
Always Clean Up Listeners: Failing to unregister listeners causes memory leaks.
Item Data: Name and description come from backpackHeldItemConfig[id], not the HeldItem constructor.
Event Argument Modification: Return modified values from callbacks:
callback: (args) => {
return { damage: Math.floor(args.damage * 0.5) };
};
usable Tag: Items with the usable tag MUST implement itemUse.
heldItemInstance: Access stored properties via heldItemInstance.data in callbacks.
After implementing a held item, run the held item test suite to validate the implementation:
npm test -- src/battle/data/__tests__/heldItems.test.js
This runs an e2e test that verifies all held items can be applied and removed without throwing errors. For items with the usable tag, it also verifies that itemUse can be called. If your new held item causes a test failure, fix the implementation and re-run until tests pass.
See the unit-test skill for more details on testing.
references/pattern-*.md - Common held item implementation patternsadd-event-listener skill - Common event types and condition callbacks