forked from smogon/pokemon-showdown-client
-
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.
This is the first step of moving the entire client over to TypeScript + Preact!!!! The main change here is that battledata.js has been split into three files: - `src/battle-dex.ts` - `src/battle-dex-data.ts` - `src/battle-dex-misc.js` These are concatenated back into `battledata.js` in the client, so third parties (and specifically, old replay files) should be unaffected. Also, this makes sure that we don't have more than two dependencies right now. The compilation is done with Babel 7 beta, because no stable version of Babel supports TypeScript. We're not using `tsc` because it can't compile to ES3 and it doesn't support preserving line numbers. `toRoomid` has been moved from client.js to battle-dex.ts.
- Loading branch information
Showing
10 changed files
with
632 additions
and
477 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,28 @@ | ||
{ | ||
"presets": [ | ||
"@babel/typescript" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-transform-member-expression-literals", | ||
"@babel/plugin-transform-property-literals", | ||
"@babel/plugin-transform-arrow-functions", | ||
["@babel/plugin-transform-block-scoping", {"throwIfClosureRequired": true}], | ||
["@babel/plugin-transform-classes", {"loose": true}], | ||
["@babel/plugin-transform-computed-properties", {"loose": true}], | ||
"@babel/plugin-transform-destructuring", | ||
["@babel/plugin-transform-for-of", {"assumeArray": true}], | ||
"@babel/plugin-transform-literals", | ||
"@babel/plugin-transform-parameters", | ||
"@babel/plugin-transform-shorthand-properties", | ||
["@babel/plugin-transform-spread", {"loose": true}], | ||
["@babel/plugin-transform-template-literals", {"loose": true}], | ||
"@babel/plugin-transform-exponentiation-operator", | ||
["@babel/plugin-proposal-class-properties", {"loose": true}], | ||
["@babel/plugin-proposal-object-rest-spread", {"useBuiltIns": true}], | ||
["@babel/plugin-transform-react-jsx", {"pragma": "Preact.h", "useBuiltIns": true}] | ||
], | ||
"ignore": [ | ||
"src/globals.d.ts" | ||
], | ||
"retainLines": true | ||
} |
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 |
---|---|---|
|
@@ -12,3 +12,7 @@ eslint-cache/ | |
Thumbs.db | ||
npm-debug.log | ||
/vendor/ | ||
|
||
/js/battledata.js | ||
/js/battle-dex.js | ||
/js/battle-dex-data.js |
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,225 @@ | ||
/** | ||
* Pokemon Showdown Dex Data | ||
* | ||
* A collection of data and definitions for src/battle-dex.ts. | ||
* | ||
* Larger data has their own files in data/, so this is just for small | ||
* miscellaneous data that doesn't need its own file. | ||
* | ||
* @author Guangcong Luo <[email protected]> | ||
* @license MIT | ||
*/ | ||
|
||
const BattleNatures = { | ||
Adamant: { | ||
plus: 'atk', | ||
minus: 'spa' | ||
}, | ||
Bashful: {}, | ||
Bold: { | ||
plus: 'def', | ||
minus: 'atk' | ||
}, | ||
Brave: { | ||
plus: 'atk', | ||
minus: 'spe' | ||
}, | ||
Calm: { | ||
plus: 'spd', | ||
minus: 'atk' | ||
}, | ||
Careful: { | ||
plus: 'spd', | ||
minus: 'spa' | ||
}, | ||
Docile: {}, | ||
Gentle: { | ||
plus: 'spd', | ||
minus: 'def' | ||
}, | ||
Hardy: {}, | ||
Hasty: { | ||
plus: 'spe', | ||
minus: 'def' | ||
}, | ||
Impish: { | ||
plus: 'def', | ||
minus: 'spa' | ||
}, | ||
Jolly: { | ||
plus: 'spe', | ||
minus: 'spa' | ||
}, | ||
Lax: { | ||
plus: 'def', | ||
minus: 'spd' | ||
}, | ||
Lonely: { | ||
plus: 'atk', | ||
minus: 'def' | ||
}, | ||
Mild: { | ||
plus: 'spa', | ||
minus: 'def' | ||
}, | ||
Modest: { | ||
plus: 'spa', | ||
minus: 'atk' | ||
}, | ||
Naive: { | ||
plus: 'spe', | ||
minus: 'spd' | ||
}, | ||
Naughty: { | ||
plus: 'atk', | ||
minus: 'spd' | ||
}, | ||
Quiet: { | ||
plus: 'spa', | ||
minus: 'spe' | ||
}, | ||
Quirky: {}, | ||
Rash: { | ||
plus: 'spa', | ||
minus: 'spd' | ||
}, | ||
Relaxed: { | ||
plus: 'def', | ||
minus: 'spe' | ||
}, | ||
Sassy: { | ||
plus: 'spd', | ||
minus: 'spe' | ||
}, | ||
Serious: {}, | ||
Timid: { | ||
plus: 'spe', | ||
minus: 'atk' | ||
} | ||
}; | ||
const BattleStatIDs = { | ||
HP: 'hp', | ||
hp: 'hp', | ||
Atk: 'atk', | ||
atk: 'atk', | ||
Def: 'def', | ||
def: 'def', | ||
SpA: 'spa', | ||
SAtk: 'spa', | ||
SpAtk: 'spa', | ||
spa: 'spa', | ||
spc: 'spa', | ||
Spc: 'spa', | ||
SpD: 'spd', | ||
SDef: 'spd', | ||
SpDef: 'spd', | ||
spd: 'spd', | ||
Spe: 'spe', | ||
Spd: 'spe', | ||
spe: 'spe' | ||
}; | ||
const BattlePOStatNames = { // only used for interacting with PO | ||
hp: 'HP', | ||
atk: 'Atk', | ||
def: 'Def', | ||
spa: 'SAtk', | ||
spd: 'SDef', | ||
spe: 'Spd' | ||
}; | ||
const BattleStatNames = { // proper style | ||
hp: 'HP', | ||
atk: 'Atk', | ||
def: 'Def', | ||
spa: 'SpA', | ||
spd: 'SpD', | ||
spe: 'Spe' | ||
}; | ||
|
||
const baseSpeciesChart = [ | ||
'pikachu', | ||
'pichu', | ||
'unown', | ||
'castform', | ||
'deoxys', | ||
'burmy', | ||
'wormadam', | ||
'cherrim', | ||
'shellos', | ||
'gastrodon', | ||
'rotom', | ||
'giratina', | ||
'shaymin', | ||
'arceus', | ||
'basculin', | ||
'darmanitan', | ||
'deerling', | ||
'sawsbuck', | ||
'tornadus', | ||
'thundurus', | ||
'landorus', | ||
'kyurem', | ||
'keldeo', | ||
'meloetta', | ||
'genesect', | ||
'vivillon', | ||
'flabebe', | ||
'floette', | ||
'florges', | ||
'furfrou', | ||
'aegislash', | ||
'pumpkaboo', | ||
'gourgeist', | ||
'meowstic', | ||
'hoopa', | ||
'zygarde', | ||
'lycanroc', | ||
'wishiwashi', | ||
'minior', | ||
'mimikyu', | ||
'greninja', | ||
'oricorio', | ||
'silvally', | ||
'necrozma', | ||
|
||
// alola totems | ||
'raticate', | ||
'marowak', | ||
'kommoo', | ||
|
||
// mega evolutions | ||
'charizard', | ||
'mewtwo' | ||
// others are hardcoded by ending with 'mega' | ||
]; | ||
|
||
type StatName = 'hp' | 'atk' | 'def' | 'spa' | 'spd' | 'spe'; | ||
interface Effect { | ||
readonly id: string; | ||
readonly name: string; | ||
readonly gen: number; | ||
readonly effectType: 'Item' | 'Move' | 'Ability' | 'Template'; | ||
readonly exists: boolean; | ||
} | ||
interface Item extends Effect { | ||
readonly effectType: 'Item'; | ||
} | ||
interface Move extends Effect { | ||
readonly effectType: 'Move'; | ||
readonly type: string; | ||
readonly category: string; | ||
} | ||
interface Ability extends Effect { | ||
readonly effectType: 'Ability'; | ||
} | ||
interface Template extends Effect { | ||
readonly effectType: 'Template'; | ||
readonly species: string; | ||
readonly baseSpecies: string; | ||
readonly spriteid: string; | ||
readonly types: string[]; | ||
readonly abilities: {0: string, 1?: string, H?: string, S?: string}; | ||
readonly baseStats: {hp: number, atk: number, def: number, spa: number, spd: number, spe: number} | ||
readonly unreleasedHidden: boolean; | ||
readonly tier: string; | ||
readonly isNonstandard: boolean; | ||
} |
Oops, something went wrong.