mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-09-12 03:05:36 -05:00
TypeScript 4.8+ supports Lowercase for lowercase strings, which isn't exactly what ID is, but can be used to type IDs in object keys and data entries that previously required string. I'm calling it IDEntry in places where it should be an ID but TypeScript doesn't support that. Very conveniently, no additional casts will be needed when using ID where IDEntry is expected. It's caught at least a few bugs, which is also why I'm PRing: I didn't write the code for the bugs it found, and don't know if it's the right way to fix them. This ballooned into several other type refactors.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
export const Items: import('../../../sim/dex-items').ModdedItemDataTable = {
|
|
airballoon: {
|
|
inherit: true,
|
|
// airborneness implemented in sim/pokemon.js:Pokemon#isGrounded
|
|
onDamagingHit(damage, target, source, move) {
|
|
this.add('-enditem', target, 'Air Balloon');
|
|
if (target.item === 'airballoon') {
|
|
target.item = '';
|
|
target.itemState = {id: '', target};
|
|
} else {
|
|
delete target.volatiles['item:airballoon'];
|
|
target.m.sharedItemsUsed.push('airballoon');
|
|
}
|
|
this.runEvent('AfterUseItem', target, null, null, this.dex.items.get('airballoon'));
|
|
},
|
|
onAfterSubDamage(damage, target, source, effect) {
|
|
this.debug('effect: ' + effect.id);
|
|
if (effect.effectType === 'Move') {
|
|
this.add('-enditem', target, 'Air Balloon');
|
|
if (target.item === 'airballoon') {
|
|
target.item = '';
|
|
target.itemState = {id: '', target};
|
|
} else {
|
|
delete target.volatiles['item:airballoon'];
|
|
target.m.sharedItemsUsed.push('airballoon');
|
|
}
|
|
this.runEvent('AfterUseItem', target, null, null, this.dex.items.get('airballoon'));
|
|
}
|
|
},
|
|
},
|
|
};
|