From 1eaa7057e3eb862b48375f4d4c4b475e65921129 Mon Sep 17 00:00:00 2001 From: anapple96 <62083669+anapple96@users.noreply.github.com> Date: Thu, 3 Jun 2021 11:17:08 +0700 Subject: [PATCH 1/2] Simple rework --- src/modules/data.ts | 44 +++--- src/modules/routes.ts | 334 ++++++++++++++++++------------------------ 2 files changed, 164 insertions(+), 214 deletions(-) diff --git a/src/modules/data.ts b/src/modules/data.ts index c0a17c5a..17e6d5d8 100644 --- a/src/modules/data.ts +++ b/src/modules/data.ts @@ -8,30 +8,30 @@ EXP_TABLE['Fast'] = [1, 2, 6, 21, 51, 100, 172, 274, 409, 583, 800, 1064, 1382, export type PokemonGrowthRate = keyof typeof EXP_TABLE; -export const COLORS: Record> = {}; -COLORS['route'] = {}; -COLORS['route']['locked'] = 'rgb(255, 0, 0)'; -COLORS['route']['unlocked'] = 'rgb(255, 255, 255)'; -COLORS['route']['current'] = 'rgb(139, 69, 19)'; - -export const POKEDEXFLAGS: Record = {}; -POKEDEXFLAGS['unseen'] = 0; -POKEDEXFLAGS['seenNormal'] = 1; -POKEDEXFLAGS['seenShiny'] = 2; -POKEDEXFLAGS['releasedNormal'] = 3; // from releasing into wild -POKEDEXFLAGS['releasedShiny'] = 4; // from releasing into wild -POKEDEXFLAGS['ownedNormal'] = 5; // from evolution -POKEDEXFLAGS['ownNormal'] = 6; // in current rosta -POKEDEXFLAGS['ownedShiny'] = 7; // from evolution -POKEDEXFLAGS['ownShiny'] = 8; // in current rosta +export enum COLORS { + 'locked' = 'rgb(255, 0, 0)', + 'unlocked' = 'rgb(255, 255, 255)', + 'current' = 'rgb(139, 69, 19)', +} +export enum POKEDEXFLAGS { + 'unseen' = 0, + 'seenNormal', + 'seenShiny', + 'releasedNormal', + 'releasedShiny', + 'ownedNormal', + 'ownNormal', + 'ownedShiny', + 'ownShiny', +} export type PokedexFlagName = keyof typeof POKEDEXFLAGS; -export const BALLRNG: Record = { - pokeball: 1, - greatball: 1.5, - ultraball: 2, - masterball: 100, +export enum BALLRNG { + pokeball = 1, + greatball = 1.5, + ultraball = 2, + masterball = 100, }; export type PokemonType = 'Normal' | 'Fighting' | 'Flying' | 'Poison' | 'Ground' | 'Rock' | 'Bug' | 'Ghost' | 'Steel' | 'Fire' | 'Water' | 'Grass' | 'Electric' | 'Psychic' | 'Ice' | 'Dragon' | 'Dark' | 'Fairy'; @@ -43,7 +43,7 @@ interface VitaminData { stat: PokemonStatType, } -export const VITAMINS: Record = { +export const VITAMIN: Record = { hpUp: { display: 'HP Up', stat: 'hp', diff --git a/src/modules/routes.ts b/src/modules/routes.ts index 8f61bdf7..c8e08353 100644 --- a/src/modules/routes.ts +++ b/src/modules/routes.ts @@ -3,17 +3,18 @@ import { PokemonNameType } from './db'; interface UnlockData { badges: Record, } - -interface GymLeader { +interface Trainer { name: string, poke: Array<[PokemonNameType, number]>, - badge?: string, win?: string, reward?: string, event?: string, + req?: string, +} +interface GymLeader extends Trainer { + badge?: string, megaStone?: string, megaStones?: string[], - req?: string, } type ItemSpecialRequirement = { @@ -39,97 +40,19 @@ interface SpecialPokemon { pokemon: PokemonNameType[], } -interface GymTrainer1 { - name: string, - poke: Array<[PokemonNameType, number]>, - win?: string, - reward?: string, - event?: string, - req?: string, -} - -interface GymTrainer2 { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, -} - -interface GymTrainer3 { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, -} - -interface EliteFour1 { - name: string, - poke: Array<[PokemonNameType, number]>, - win?: string, - reward?: string, - event?: string, +interface EliteFour extends Trainer { megaStone?: string, megaStones?: string[], } -interface EliteFour2 { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, - megaStone?: string, - megaStones?: string[], -} -interface EliteFour3 { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, - megaStone?: string, - megaStones?: string[], -} - -interface EliteFour4 { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, - megaStone?: string, - megaStones?: string[], -} - -interface EliteFourChampion { - name: string, - poke: Array<[PokemonNameType, number]>, - req?: string, - win?: string, - reward?: string, - event?: string, - megaStone?: string, - megaStones?: string[], -} +interface EliteFourChampion extends EliteFour {} interface Gym { name: string, gymLeader?: GymLeader, - gymTrainer1?: GymTrainer1, - gymTrainer2?: GymTrainer2, - gymTrainer3?: GymTrainer3, - eliteFour1?: EliteFour1, - eliteFour2?: EliteFour2, - eliteFour3?: EliteFour3, - eliteFour4?: EliteFour4, + gymTrainer?: Trainer[], + eliteFour?: EliteFour[] eliteFourChampion?: EliteFourChampion, } @@ -256,7 +179,8 @@ const ROUTES: Routes = { }, gym: { name: 'Viridian Gym', - gymTrainer1: { + gymTrainer: [ + { name: 'Lass', poke: [ ['Bellsprout', 21], @@ -265,7 +189,7 @@ const ROUTES: Routes = { win: 'viridianGym1', req: 'volcano1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -276,7 +200,7 @@ const ROUTES: Routes = { win: 'viridianGym2', req: 'viridianGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -286,6 +210,7 @@ const ROUTES: Routes = { win: 'viridianGym3', req: 'viridianGym2', }, + ], gymLeader: { name: 'Giovanni', badge: 'Earth Badge', @@ -328,7 +253,8 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Pewter Gym', - gymTrainer1: { + gymTrainer: [ + { name: 'Jr. Trainer', poke: [ ['Diglett', 11], @@ -336,6 +262,7 @@ const ROUTES: Routes = { ], win: 'pewterGym1', }, + ], gymLeader: { name: 'Brock', badge: 'Boulder Badge', @@ -409,7 +336,8 @@ const ROUTES: Routes = { }, gym: { name: 'Cerulean Gym', - gymTrainer1: { + gymTrainer: [ + { name: 'Swimmer', poke: [ ['Horsea', 16], @@ -417,7 +345,7 @@ const ROUTES: Routes = { ], win: 'ceruleanGym1', }, - gymTrainer2: { + { name: 'Jr. Trainer', poke: [ ['Goldeen', 19], @@ -425,6 +353,7 @@ const ROUTES: Routes = { req: 'ceruleanGym1', win: 'ceruleanGym2', }, + ], gymLeader: { name: 'Misty', badge: 'Cascade Badge', @@ -515,32 +444,34 @@ const ROUTES: Routes = { }, gym: { name: 'Vermilion Gym', - gymTrainer1: { - name: 'Sailor', - poke: [ - ['Pikachu', 21], - ['Pikachu', 21], - ], - win: 'vermilionGym1', - }, - gymTrainer2: { - name: 'Rocker', - poke: [ - ['Voltorb', 20], - ['Magnemite', 20], - ['Voltorb', 20], - ], - win: 'vermilionGym2', - req: 'vermilionGym1', - }, - gymTrainer3: { - name: 'Gentleman', - poke: [ - ['Pikachu', 23], - ], - win: 'vermilionGym3', - req: 'vermilionGym2', - }, + gymTrainer: [ + { + name: 'Sailor', + poke: [ + ['Pikachu', 21], + ['Pikachu', 21], + ], + win: 'vermilionGym1', + }, + { + name: 'Rocker', + poke: [ + ['Voltorb', 20], + ['Magnemite', 20], + ['Voltorb', 20], + ], + win: 'vermilionGym2', + req: 'vermilionGym1', + }, + { + name: 'Gentleman', + poke: [ + ['Pikachu', 23], + ], + win: 'vermilionGym3', + req: 'vermilionGym2', + }, + ], gymLeader: { name: 'Lt. Surge', badge: 'Thunder Badge', @@ -683,35 +614,37 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Celadon Gym', - gymTrainer1: { - name: 'Lass', - poke: [ - ['Bellsprout', 21], - ['Weepinbell', 23], - ], - win: 'celadonGym1', - }, - gymTrainer2: { - name: 'Beauty', - poke: [ - ['Oddish', 21], - ['Bellsprout', 21], - ['Oddish', 21], - ['Bellsprout', 21], - ], - win: 'celadonGym2', - req: 'celadonGym1', - }, - gymTrainer3: { - name: 'Cooltrainer', - poke: [ - ['Weepinbell', 24], - ['Gloom', 24], - ['Ivysaur', 24], - ], - win: 'celadonGym3', - req: 'celadonGym2', - }, + gymTrainer: [ + { + name: 'Lass', + poke: [ + ['Bellsprout', 21], + ['Weepinbell', 23], + ], + win: 'celadonGym1', + }, + { + name: 'Beauty', + poke: [ + ['Oddish', 21], + ['Bellsprout', 21], + ['Oddish', 21], + ['Bellsprout', 21], + ], + win: 'celadonGym2', + req: 'celadonGym1', + }, + { + name: 'Cooltrainer', + poke: [ + ['Weepinbell', 24], + ['Gloom', 24], + ['Ivysaur', 24], + ], + win: 'celadonGym3', + req: 'celadonGym2', + }, + ], gymLeader: { name: 'Erika', badge: 'Rainbow Badge', @@ -740,7 +673,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Saffron Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Psychic', poke: [ ['Mr. Mime', 34], @@ -748,7 +681,7 @@ const ROUTES: Routes = { ], win: 'saffronGym1', }, - gymTrainer2: { + { name: 'Psychic', poke: [ ['Kadabra', 34], @@ -759,6 +692,7 @@ const ROUTES: Routes = { win: 'saffronGym2', req: 'saffronGym1', }, + ], gymLeader: { name: 'Sabrina', badge: 'Marsh Badge', @@ -832,7 +766,8 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Fuchsia Gym', - gymTrainer1: { + gymTrainer: [ + { name: 'Juggler', poke: [ ['Drowzee', 32], @@ -840,7 +775,7 @@ const ROUTES: Routes = { ], win: 'fuchsiaGym1', }, - gymTrainer2: { + { name: 'Tamer', poke: [ ['Arbok', 32], @@ -850,7 +785,7 @@ const ROUTES: Routes = { win: 'fuchsiaGym2', req: 'fuchsiaGym1', }, - gymTrainer3: { + { name: 'Juggler', poke: [ ['Hypno', 35], @@ -860,6 +795,7 @@ const ROUTES: Routes = { win: 'fuchsiaGym3', req: 'fuchsiaGym2', }, + ], gymLeader: { name: 'Koga', badge: 'Soul Badge', @@ -980,7 +916,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Cinnabar Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Burgler', poke: [ ['Growlithe', 36], @@ -989,7 +925,7 @@ const ROUTES: Routes = { ], win: 'cinnabarGym1', }, - gymTrainer2: { + { name: 'Super Nerd', poke: [ ['Ponyta', 36], @@ -1000,7 +936,7 @@ const ROUTES: Routes = { win: 'cinnabarGym2', req: 'cinnabarGym1', }, - gymTrainer3: { + { name: 'Burgler', poke: [ ['Growlithe', 36], @@ -1010,6 +946,7 @@ const ROUTES: Routes = { win: 'cinnabarGym3', req: 'cinnabarGym2', }, + ], gymLeader: { name: 'Blaine', badge: 'Volcano Badge', @@ -1194,7 +1131,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Violet Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1202,7 +1139,7 @@ const ROUTES: Routes = { ], win: 'violetGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1213,7 +1150,7 @@ const ROUTES: Routes = { win: 'violetGym2', req: 'violetGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1223,6 +1160,7 @@ const ROUTES: Routes = { win: 'violetGym3', req: 'violetGym2', }, + ], gymLeader: { name: 'Falkner', win: 'falkner1', @@ -1326,7 +1264,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Azalea Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1334,7 +1272,7 @@ const ROUTES: Routes = { ], win: 'azaleaGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1345,7 +1283,7 @@ const ROUTES: Routes = { win: 'azaleaGym2', req: 'azaleaGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1355,6 +1293,7 @@ const ROUTES: Routes = { win: 'azaleaGym3', req: 'azaleaGym2', }, + ], gymLeader: { name: 'Bugsy', win: 'bugsy1', @@ -1415,7 +1354,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Goldenrod Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1423,7 +1362,7 @@ const ROUTES: Routes = { ], win: 'goldenrodGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1434,7 +1373,7 @@ const ROUTES: Routes = { win: 'goldenrodGym2', req: 'goldenrodGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1444,6 +1383,7 @@ const ROUTES: Routes = { win: 'goldenrodGym3', req: 'goldenrodGym2', }, + ], gymLeader: { name: 'Whitney', win: 'whitney1', @@ -1515,7 +1455,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Ecruteak Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1523,7 +1463,7 @@ const ROUTES: Routes = { ], win: 'ecruteakGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1534,7 +1474,7 @@ const ROUTES: Routes = { win: 'ecruteakGym2', req: 'ecruteakGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1544,6 +1484,7 @@ const ROUTES: Routes = { win: 'ecruteakGym3', req: 'ecruteakGym2', }, + ], gymLeader: { name: 'Morty', badge: 'Fog Badge', @@ -1616,7 +1557,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Olivine Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1624,7 +1565,7 @@ const ROUTES: Routes = { ], win: 'olivineGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1635,7 +1576,7 @@ const ROUTES: Routes = { win: 'olivineGym2', req: 'olivineGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1645,6 +1586,7 @@ const ROUTES: Routes = { win: 'olivineGym3', req: 'olivineGym2', }, + ], gymLeader: { name: 'Jasmine', win: 'jasmine1', @@ -1705,7 +1647,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Cianwood Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1713,7 +1655,7 @@ const ROUTES: Routes = { ], win: 'cianwoodGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1724,7 +1666,7 @@ const ROUTES: Routes = { win: 'cianwoodGym2', req: 'cianwoodGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1734,6 +1676,7 @@ const ROUTES: Routes = { win: 'cianwoodGym3', req: 'cianwoodGym2', }, + ], gymLeader: { name: 'Chuck', badge: 'Storm Badge', @@ -1816,7 +1759,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Mahogany Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1824,7 +1767,7 @@ const ROUTES: Routes = { ], win: 'mahoganyGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1835,7 +1778,7 @@ const ROUTES: Routes = { win: 'mahoganyGym2', req: 'mahoganyGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1845,6 +1788,7 @@ const ROUTES: Routes = { win: 'mahoganyGym3', req: 'mahoganyGym2', }, + ], gymLeader: { name: 'Pryce', badge: 'Glacier Badge', @@ -1928,7 +1872,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Blackthorn Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Lass', poke: [ ['Bellsprout', 21], @@ -1936,7 +1880,7 @@ const ROUTES: Routes = { ], win: 'blackthornGym1', }, - gymTrainer2: { + { name: 'Beauty', poke: [ ['Oddish', 21], @@ -1947,7 +1891,7 @@ const ROUTES: Routes = { win: 'blackthornGym2', req: 'blackthornGym1', }, - gymTrainer3: { + { name: 'Cooltrainer', poke: [ ['Weepinbell', 24], @@ -1957,6 +1901,7 @@ const ROUTES: Routes = { win: 'blackthornGym3', req: 'blackthornGym2', }, + ], gymLeader: { name: 'Clair', badge: 'Rising Badge', @@ -3054,7 +2999,7 @@ const ROUTES: Routes = { town: true, gym: { name: 'Elite 4', - gymTrainer1: { + eliteFour: [{ name: 'Sidney', poke: [ ['Mightyena', 46], @@ -3064,7 +3009,7 @@ const ROUTES: Routes = { ['Absol', 49], ], }, - gymTrainer2: { + { name: 'Phoebe', poke: [ ['Dusclops', 58], @@ -3074,7 +3019,7 @@ const ROUTES: Routes = { ['Dusclops', 61], ], }, - gymTrainer3: { + { name: 'Glacia', poke: [ ['Glalie', 60], @@ -3084,8 +3029,10 @@ const ROUTES: Routes = { ['Walrein', 63], ], }, + ], }, - }, /* + }, + /* elite4Drake: { name: 'Elite 4 Drake', town: true, @@ -4099,7 +4046,7 @@ const ROUTES: Routes = { town: true, gym: { name: 'Elite 4', - gymTrainer1: { + gymTrainer: [{ name: 'Aaron', poke: [ ['Dustox', 53], @@ -4109,7 +4056,7 @@ const ROUTES: Routes = { ['Drapion', 57], ], }, - gymTrainer2: { + { name: 'Bertha', poke: [ ['Quagsire', 55], @@ -4119,7 +4066,7 @@ const ROUTES: Routes = { ['Golem', 56], ], }, - gymTrainer3: { + { name: 'Flint', poke: [ ['Houndoom', 58], @@ -4129,6 +4076,7 @@ const ROUTES: Routes = { ['Magmortar', 57], ], }, + ], gymLeader: { name: 'Lucian', poke: [ @@ -6464,7 +6412,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Kali Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Surfer', poke: [ ['Poliwrath', 63], @@ -6473,7 +6421,7 @@ const ROUTES: Routes = { ], win: 'kaliGym1', }, - gymTrainer2: { + { name: 'Tech Genius', poke: [ ['Oranguru', 62], @@ -6484,7 +6432,7 @@ const ROUTES: Routes = { win: 'kaliGym2', req: 'kaliGym1', }, - gymTrainer3: { + { name: 'Liberal', poke: [ ['Glaceon', 67], @@ -6494,6 +6442,7 @@ const ROUTES: Routes = { win: 'kaliGym3', req: 'kaliGym2', }, + ], gymLeader: { name: 'Krush', win: 'power1', @@ -6590,7 +6539,7 @@ const ROUTES: Routes = { pokeMart: true, gym: { name: 'Freezing Gym', - gymTrainer1: { + gymTrainer: [{ name: 'Miner', poke: [ ['Excadrill', 50], @@ -6600,7 +6549,7 @@ const ROUTES: Routes = { ], win: 'freezingGym1', }, - gymTrainer2: { + { name: 'Ace Trainer', poke: [ ['Manectric', 52], @@ -6611,7 +6560,7 @@ const ROUTES: Routes = { win: 'freezingGym2', req: 'freezingGym1', }, - gymTrainer3: { + { name: 'Hiker', poke: [ ['Weavile', 55], @@ -6621,6 +6570,7 @@ const ROUTES: Routes = { win: 'freezingGym3', req: 'freezingGym2', }, + ], gymLeader: { name: 'ColdOre', req: 'freezingGym3', From b23b8d078e7a5f9df8322434a45613b3ea7d4501 Mon Sep 17 00:00:00 2001 From: anapple96 <62083669+anapple96@users.noreply.github.com> Date: Thu, 3 Jun 2021 11:44:49 +0700 Subject: [PATCH 2/2] Fix --- src/modules/actions.js | 241 ++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 134 deletions(-) diff --git a/src/modules/actions.js b/src/modules/actions.js index 3a0ddbad..cae084c9 100644 --- a/src/modules/actions.js +++ b/src/modules/actions.js @@ -16,7 +16,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { const UserActions = { - changeRoute: function (newRouteId, force = false) { + changeRoute: function(newRouteId, force = false) { if (!force && player.alivePokeIndexes().length == 0) { notify('It is too dangerous to travel without a POKEMON.'); return false; @@ -45,11 +45,11 @@ export default (player, combatLoop, enemy, town, story, appModel) => { return true; }, - changePokemon: function (newActiveIndex) { + changePokemon: function(newActiveIndex) { player.setActive(newActiveIndex); renderView(dom, enemy, player); }, - goToKanto: function () { + goToKanto: function() { if (player.regionUnlocked('Kanto')) { player.settings.currentRegionId = 'Kanto'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -63,7 +63,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToJohto: function () { + goToJohto: function() { if (player.regionUnlocked('Johto')) { player.settings.currentRegionId = 'Johto'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -77,7 +77,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToHoenn: function () { + goToHoenn: function() { if (player.regionUnlocked('Hoenn')) { player.settings.currentRegionId = 'Hoenn'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -91,7 +91,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToSinnoh: function () { + goToSinnoh: function() { if (player.regionUnlocked('Sinnoh')) { player.settings.currentRegionId = 'Sinnoh'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -105,7 +105,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToUnova: function () { + goToUnova: function() { if (player.regionUnlocked('Unova')) { player.settings.currentRegionId = 'Unova'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -119,7 +119,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToKalos: function () { + goToKalos: function() { if (player.regionUnlocked('Kalos')) { player.settings.currentRegionId = 'Kalos'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -133,7 +133,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToAlola: function () { + goToAlola: function() { if (player.regionUnlocked('Alola')) { player.settings.currentRegionId = 'Alola'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -147,7 +147,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToGalar: function () { + goToGalar: function() { if (player.regionUnlocked('Galar')) { player.settings.currentRegionId = 'Galar'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -161,7 +161,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToFandom: function () { + goToFandom: function() { if (player.regionUnlocked('Fandom')) { player.settings.currentRegionId = 'Fandom'; if (Object.keys(ROUTES[player.settings.currentRegionId])[0].charAt(0) !== '_') { @@ -175,65 +175,65 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have not unlocked this region yet'); } }, - goToNone: function () { + goToNone: function() { notify('This region is not implemented yet'); }, - enablePokeListAutoSort: function () { + enablePokeListAutoSort: function() { player.settings.autoSort = $('#autoSort').checked; // hide or show sort dropdowns dom.renderPokeSort(); }, - changeCatchOption: function (newCatchOption) { + changeCatchOption: function(newCatchOption) { combatLoop.changeCatch(newCatchOption); }, - changeListView: function (view) { + changeListView: function(view) { player.settings.listView = view; }, - clearGameData: function () { + clearGameData: function() { if (dom.checkConfirmed('#confirmClearData')) { localStorage.clear(); player.purgeData = true; window.location.reload(true); } }, - changeSelectedBall: function (newBall) { + changeSelectedBall: function(newBall) { player.changeSelectedBall(newBall); }, - pokemonToFirst: function (pokemonIndex, from = 'roster') { + pokemonToFirst: function(pokemonIndex, from = 'roster') { appModel.$store.commit('pokemon/moveToFirst', { pokemonIndex, from }); player.savePokes(); }, - pokemonToDown: function (pokemonIndex, from = 'roster') { + pokemonToDown: function(pokemonIndex, from = 'roster') { appModel.$store.commit('pokemon/moveDown', { pokemonIndex, from }); player.savePokes(); }, - pokemonToUp: function (pokemonIndex, from = 'roster') { + pokemonToUp: function(pokemonIndex, from = 'roster') { appModel.$store.commit('pokemon/moveUp', { pokemonIndex, from }); player.savePokes(); }, - evolvePokemon: function (pokemonIndex) { + evolvePokemon: function(pokemonIndex) { player.getPokemon()[pokemonIndex].tryEvolve(player.getPokemon()[pokemonIndex].shiny(), player); renderView(dom, enemy, player); }, - prestigePokemon: function (pokemonIndex) { + prestigePokemon: function(pokemonIndex) { player.getPokemon()[pokemonIndex].tryPrestige(player.getPokemon()[pokemonIndex].shiny()); renderView(dom, enemy, player); }, - moveToStorage: function (pokemonIndex) { + moveToStorage: function(pokemonIndex) { appModel.$store.commit('pokemon/deposit', pokemonIndex); }, - moveToRoster: function (pokemonIndex) { + moveToRoster: function(pokemonIndex) { appModel.$store.commit('pokemon/withdraw', pokemonIndex); }, - openPokeDex: function () { + openPokeDex: function() { openModal($('#pokedexModal')); }, - forceSave: function () { + forceSave: function() { player.savePokes(); $('#forceSave').style.display = 'inline'; setTimeout(() => { $('#forceSave').style.display = 'none'; }, 5000); }, - exportSaveDialog: function () { + exportSaveDialog: function() { $('#savetextDialog .modal-card-title').innerHTML = 'Export your save'; if (document.queryCommandSupported('copy')) { document.getElementById('copySaveText').style.display = 'initial'; @@ -243,7 +243,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { openModal(document.getElementById('savetextModal')); closeModal($('#settingsModal')); }, - importSaveDialog: function () { + importSaveDialog: function() { $('#savetextDialog .modal-card-title').innerHTML = 'Import a save'; document.getElementById('copySaveText').style.display = 'none'; document.getElementById('saveText').value = ''; @@ -251,7 +251,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { openModal(document.getElementById('savetextModal')); closeModal($('#settingsModal')); }, - importSave: async function () { + importSave: async function() { if (window.confirm('Loading a save will overwrite your current progress, are you sure you wish to continue?')) { await appModel.$store.dispatch('setLoading', true); player.loadFromString(document.getElementById('saveText').value.trim()); @@ -264,12 +264,12 @@ export default (player, combatLoop, enemy, town, story, appModel) => { dom.renderPokeCoins(); } }, - copySaveText: function () { + copySaveText: function() { document.getElementById('saveText').select(); document.execCommand('copy'); window.getSelection().removeAllRanges(); }, - changeSpriteChoice: function () { + changeSpriteChoice: function() { if (document.getElementById('spriteChoiceFront').checked) { player.settings.spriteChoice = 'front'; } else { @@ -278,7 +278,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.savePokes(); renderView(dom, enemy, player); }, - viewStatistics: function () { + viewStatistics: function() { const statisticStrings = { 'fireBeaten': 'Fire POKEMON Beaten', 'waterBeaten': 'Water POKEMON Beaten', @@ -348,7 +348,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { document.getElementById('statisticsList').innerHTML = statList; openModal(document.getElementById('statisticsModal')); }, - viewInventory: function () { + viewInventory: function() { let inventoryHTML = ''; const vitamins = Object.keys(VITAMINS); for (let i = 0; i < vitamins.length; i++) { @@ -361,34 +361,34 @@ export default (player, combatLoop, enemy, town, story, appModel) => { document.getElementById('inventoryList').innerHTML = inventoryHTML; openModal(document.getElementById('inventoryModal')); }, - renderBeatenAchievement: function () { + renderBeatenAchievement: function() { const beatenReq = player.statisticsRequirements.beaten; const beaten1Req = player.statisticsRequirements.beaten1; if (player.statistics.beaten > beatenReq) { return beaten1Req; } else { return beatenReq; } }, - renderCaughtAchievement: function () { + renderCaughtAchievement: function() { const caughtReq = player.statisticsRequirements.caught; const caught1Req = player.statisticsRequirements.caught1; if (player.statistics.caught > caughtReq) { return caught1Req; } else { return caughtReq; } }, - renderOwnedAchievement: function () { + renderOwnedAchievement: function() { const ownedReq = player.statisticsRequirements.owned; const owned1Req = player.statisticsRequirements.owned1; if (player.countPokedex(5) + player.countPokedex(7) > ownedReq) { return owned1Req; } else { return ownedReq; } }, - renderPokemonDefeated: function () { + renderPokemonDefeated: function() { const pokemonDefeatedElement = $('#pokemonDefeated'); pokemonDefeatedElement.innerHTML = `${player.statistics.beaten}/${this.renderBeatenAchievement()}`; }, - renderPokemonCaught: function () { + renderPokemonCaught: function() { const pokemonCaughtElement = $('#pokemonCaught'); pokemonCaughtElement.innerHTML = `${player.statistics.caught}/${this.renderCaughtAchievement()}`; }, - renderPokemonOwned: function () { + renderPokemonOwned: function() { const pokemonOwnedElement = $('#pokemonOwned'); pokemonOwnedElement.innerHTML = `${player.countPokedex(5) + player.countPokedex(7)}/${this.renderOwnedAchievement()}`; }, - checkPokemonDefeated: function () { + checkPokemonDefeated: function() { if (player.statistics.beaten > 49 && !player.events.beaten) { player.ballsAmount.masterball += 50; dom.renderBalls(); @@ -402,7 +402,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.events.beaten1 = true; } else { notify('Defeat more Pokemon and try again'); } }, - checkPokemonCaught: function () { + checkPokemonCaught: function() { if (player.statistics.caught > 49 && !player.events.caught) { player.ballsAmount.masterball += 99; dom.renderBalls(); @@ -416,7 +416,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.events.caught1 = true; } else { notify('catch more Pokemon and try again'); } }, - checkPokemonOwned: function () { + checkPokemonOwned: function() { if (player.countPokedex(5) + player.countPokedex(7) > 100 && !player.events.owned) { player.ballsAmount.masterball += 99; dom.renderBalls(); @@ -430,13 +430,13 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.events.owned1 = true; } else { notify('catch more varied Pokemon and try again'); } }, - viewAchievements: function () { + viewAchievements: function() { this.renderPokemonDefeated(); this.renderPokemonCaught(); this.renderPokemonOwned(); openModal(document.getElementById('achievementsModal')); }, - enterCode: function () { + enterCode: function() { // eslint-disable-next-line prefer-const let secretCode = prompt('Please enter your secret code', 'Secret Code'); const rando = Math.round(Math.random() * 898); @@ -462,7 +462,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { alert('Code Invalid or Already Claimed'); } }, - viewBadgeCase: function () { + viewBadgeCase: function() { if (!isEmpty(player.badges)) { if (player.badges['Boulder Badge'] === true) { document.getElementById('boulderBadge').style.visibility = 'visible'; @@ -518,17 +518,17 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have no Badges'); } }, - renderBoulderBadge: function () { + renderBoulderBadge: function() { openModal(document.getElementById('brockModal')); }, - viewSettings: function () { + viewSettings: function() { openModal(document.getElementById('settingsModal')); closeModal(document.getElementById('bagModal')); }, - viewPokeDex: function () { + viewPokeDex: function() { openModal(document.getElementById('pokedexModal')); }, - viewEvoStones: function () { + viewEvoStones: function() { if (!isEmpty(player.evoStones)) { let evoStonesHTML = ''; for (const evoStones in player.evoStones) { @@ -541,7 +541,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have no Evolution Stones'); } }, - viewKeyItems: function () { + viewKeyItems: function() { if (!isEmpty(player.unlocked)) { let keyItemsHTML = ''; for (const keyItems in player.unlocked) { @@ -554,14 +554,14 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You have no Key Items'); } }, - viewBag: function () { + viewBag: function() { openModal(document.getElementById('bagModal')); }, - viewTown: function () { + viewTown: function() { this.renderTown(); openModal(document.getElementById('townModal')); }, - renderTown: function () { + renderTown: function() { const pokeMart = $('#pokeMartButton'); const npc = $('#npcButton'); const prof = $('#profButton'); @@ -576,7 +576,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { prof.style.display = (route.prof) ? '' : 'none'; prof.innerHTML = (route.prof) ? route.prof.name : ''; }, - viewShop: function () { + viewShop: function() { closeModal(document.getElementById('townModal')); const region = player.settings.currentRegionId.toLowerCase(); town.renderPokeCoinShop(region); @@ -584,29 +584,24 @@ export default (player, combatLoop, enemy, town, story, appModel) => { town.renderCatchCoinShop(region); openModal(document.getElementById('shopModal')); }, - renderGym: function () { - const gymTrainer1 = $('#gymTrainer1'); - const gymTrainer2 = $('#gymTrainer2'); - const gymTrainer3 = $('#gymTrainer3'); + renderGym: function() { const gymLeader = $('#gymLeader'); const fanBoy = $('#fanBoy'); const route = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; - gymTrainer1.style.display = (route.gym.gymTrainer1) ? '' : 'none'; - gymTrainer1.innerHTML = (route.gym.gymTrainer1) ? route.gym.gymTrainer1.name : ''; - gymTrainer2.style.display = (route.gym.gymTrainer2) ? '' : 'none'; - gymTrainer2.innerHTML = (route.gym.gymTrainer2) ? route.gym.gymTrainer2.name : ''; - gymTrainer3.style.display = (route.gym.gymTrainer3) ? '' : 'none'; - gymTrainer3.innerHTML = (route.gym.gymTrainer3) ? route.gym.gymTrainer3.name : ''; gymLeader.style.display = (route.gym.gymLeader) ? '' : 'none'; gymLeader.innerHTML = (route.gym.gymLeader) ? route.gym.gymLeader.name : ''; + for (let i = 1; i < 4; i++) { + $(`#gymTrainer${i}`).style.display = (route.gym.gymTrainer1) ? '' : 'none'; + $(`#gymTrainer${i}`).innerHTML = (route.gym.gymTrainer[i - 1]) ? route.gym.gymTrainer[i - 1].name : ''; + } fanBoy.style.display = (route.gym.fanBoy) ? '' : 'none'; fanBoy.innerHTML = (route.gym.fanBoy) ? route.gym.fanBoy.name : ''; }, - viewGym: function () { + viewGym: function() { this.renderGym(); openModal(document.getElementById('gymModal')); }, - openVitaminModal: function (vitamin) { + openVitaminModal: function(vitamin) { if (!VITAMINS[vitamin]) { return notify(`Invalid vitamin '${vitamin}'`); } @@ -621,7 +616,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { this.updateVitaminModal(); openModal(vitaminModal); }, - updateVitaminModal: function () { + updateVitaminModal: function() { const vitaminModal = document.getElementById('vitaminModal'); const vitamin = vitaminModal.getAttribute('data-vitamin'); const data = VITAMINS[vitamin]; @@ -636,7 +631,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { } document.getElementById('vitaminPokemon').innerHTML = vitaminPokemonHTML; }, - useVitamin: function (vitamin, pokemonIndex) { + useVitamin: function(vitamin, pokemonIndex) { const vitaminData = VITAMINS[vitamin]; const count = player.vitamins[vitamin]; const poke = player.pokemons[pokemonIndex]; @@ -648,7 +643,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { this.updateVitaminModal(); } }, - checkGymLeaderBattle: function () { + checkGymLeaderBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (!player.wins[routeData.gymLeader.win]) { this.gymLeaderBattle(); @@ -666,13 +661,13 @@ export default (player, combatLoop, enemy, town, story, appModel) => { this.gymLeader3ABattle(); } }, - checkNPCBattle: function () { + checkNPCBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (routeData.npc.name === 'Nugget 5') { this.npcBattle(); } }, - checkNPC: function () { + checkNPC: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId].npc.name; if (routeData === 'Pewter Museum') { this.pewterMuseumEvent(); @@ -702,50 +697,50 @@ export default (player, combatLoop, enemy, town, story, appModel) => { alert('GoodJob!'); } }, - checkProf: function () { + checkProf: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (routeData.prof.name === 'Prof. Oak\'s Lab') { this.oakLab(); } }, - checkStory: function () { + checkStory: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (routeData.story.name === 'Burgled House') { alert('Good Job'); } }, - vFisherman: function () { + vFisherman: function() { if (!player.unlocked.kantoOldRod) { alert('You seem like a good kid. Take this Fishing Rod.'); player.unlocked.kantoOldRod = 1; dom.renderRouteList(); } else { alert('How do you like fishing?'); } }, - renderGameTokens: function () { + renderGameTokens: function() { const gameTokensElement = $('#gameTokens'); gameTokensElement.innerHTML = player.currencyAmount.gametokens; }, - renderPrizeTokens: function () { + renderPrizeTokens: function() { const gameTokensElement = $('#prizeTokens'); gameTokensElement.innerHTML = player.currencyAmount.gametokens; }, - gameCorner: function () { + gameCorner: function() { closeModal(document.getElementById('townModal')); this.renderGameTokens(); openModal(document.getElementById('gameCornerModal')); }, - prizeCorner: function () { + prizeCorner: function() { closeModal(document.getElementById('gameCornerModal')); openModal(document.getElementById('prizeCornerModal')); this.renderPrizeTokens(); }, - freebie: function () { + freebie: function() { if (player.currencyAmount.gametokens === 0) { player.currencyAmount.gametokens += 100; this.renderGameTokens(); } else alert('You have enough tokens to play'); }, - buyAbra: function () { + buyAbra: function() { let gametokens = player.currencyAmount.gametokens; const abra = 'Abra'; if (player.hasPokemon(abra)) { @@ -760,7 +755,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { alert('Idk honestly'); } }, - betAllGameTokens: function () { + betAllGameTokens: function() { const heads = Math.random(); const totalAmount = player.currencyAmount.gametokens; if (totalAmount === 0) { @@ -775,7 +770,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { this.renderGameTokens(); } }, - betHalfGameTokens: function () { + betHalfGameTokens: function() { const heads = Math.random(); const totalAmount = player.currencyAmount.gametokens; if (totalAmount === 0) { @@ -790,10 +785,10 @@ export default (player, combatLoop, enemy, town, story, appModel) => { this.renderGameTokens(); } }, - oakLab: function () { + oakLab: function() { openModal(document.getElementById('oaklabModal')); }, - oakAide1: function () { + oakAide1: function() { if (player.events.oakAide1 != true) { alert('I am just a simple aide. No need to talk to me again'); player.events.oakAide1 = true; @@ -811,13 +806,13 @@ export default (player, combatLoop, enemy, town, story, appModel) => { dom.renderBalls(); } }, - oakAide2: function () { + oakAide2: function() { alert('Have you talked to the other aide? They get a little overwhelmed sometimes, I would be careful if I were you.'); }, - oakLabOak: function () { + oakLabOak: function() { alert('How is your POKEDEX coming along?'); }, - pewterMuseumEvent: function () { + pewterMuseumEvent: function() { if (player.events.pewterMuseum1 === true) { alert('Did you take that fossil to Cinnabar Island?'); } @@ -830,7 +825,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.events.pewterMuseum1 = true; } }, - nuggetBridgeEvent: function () { + nuggetBridgeEvent: function() { if (player.events.nugget5 === true && !player.hasPokemon('Charmander')) { notify('I think you would do great in Team Rocket. Here is a Charmander as a bribe.'); player.addPoke(new Poke(POKEDEX[4], 25)); @@ -844,7 +839,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('You feel like joining us yet?'); } }, - billEvent: function () { + billEvent: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (!player.events[routeData.npc.event]) { notify('Hi! Thanks for stopping by. Show me a Haunter, Machoke, Graveler, or Kadabra and I will give you their evolved forms'); @@ -873,7 +868,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('No trades right now. Sorry'); } }, - cinnabarLabEvent: function () { + cinnabarLabEvent: function() { if (!player.events.cinnabarLab1) { notify('Welcome, if you have any fossils we can restore them to the Pokemon they were.'); player.events.cinnabarLab1 = true; @@ -884,7 +879,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { player.addPokedex('Aerodactyl', POKEDEXFLAGS.ownNormal); } }, - beldumEvent: function () { + beldumEvent: function() { if (!player.events.beldum1) { notify('Congrats on being dope. Take this Beldum'); player.addPoke(new Poke(pokeByName('Beldum'), 5)); @@ -894,7 +889,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('No one is home'); } }, - abundantOldManEvent: function () { + abundantOldManEvent: function() { if (!player.events.abundantShrineEvent && player.hasPokemon('Thundurus') && player.hasPokemon('Landorus') && player.hasPokemon('Tornadus')) { notify('Amazing that you\'ve tamed the Forces of Nature. Take this item to take them to the next level'); player.evoStones.revealGlass = 1; @@ -907,7 +902,7 @@ export default (player, combatLoop, enemy, town, story, appModel) => { notify('Come back to me when you\'ve master the Forces of Nature'); } }, - profBattle: function () { + profBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (routeData.prof && routeData.prof.poke.length > 0) { combatLoop.prof = { @@ -916,72 +911,50 @@ export default (player, combatLoop, enemy, town, story, appModel) => { win: routeData.prof.win, reward: routeData.prof.reward, }; - combatLoop.profPoke = Object.values({ ...routeData.prof.poke }); + combatLoop.profPoke = Object.values({...routeData.prof.poke }); combatLoop.unpause(); combatLoop.refresh(); } }, - gymLeaderBattle: function () { + gymLeaderBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId].gym; closeModal(document.getElementById('gymModal')); if (routeData.gymLeader && routeData.gymLeader.poke.length > 0 && (!routeData.gymLeader.req || player.wins[routeData.gymLeader.req])) { combatLoop.gymLeader = { name: routeData.gymLeader.name, badge: routeData.gymLeader.badge, win: routeData.gymLeader.win }; - combatLoop.gymLeaderPoke = Object.values({ ...routeData.gymLeader.poke }); + combatLoop.gymLeaderPoke = Object.values({...routeData.gymLeader.poke }); combatLoop.unpause(); combatLoop.refresh(); } else { notify('Defeat the previous trainers and try again.'); } }, - gymTrainer1Battle: function () { - const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId].gym; - closeModal(document.getElementById('gymModal')); - if (routeData.gymTrainer1.req && !player.wins[routeData.gymTrainer1.req]) { - notify('Defeat more GYM LEADERS and try again'); - } else if (routeData.gymTrainer1 && routeData.gymTrainer1.poke.length > 0) { - combatLoop.gymLeader = { name: routeData.gymTrainer1.name, win: routeData.gymTrainer1.win }; - combatLoop.gymLeaderPoke = Object.values({ ...routeData.gymTrainer1.poke }); - combatLoop.unpause(); - combatLoop.refresh(); - } else { notify('Something is broken :/'); } - }, - gymTrainer2Battle: function () { - const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId].gym; - closeModal(document.getElementById('gymModal')); - if (routeData.gymTrainer2 && routeData.gymTrainer2.poke.length > 0 && player.wins[routeData.gymTrainer2.req]) { - combatLoop.gymLeader = { name: routeData.gymTrainer2.name, win: routeData.gymTrainer2.win }; - combatLoop.gymLeaderPoke = Object.values({ ...routeData.gymTrainer2.poke }); - combatLoop.unpause(); - combatLoop.refresh(); - } else { - notify('Defeat the previous trainer and try again.'); - } - }, - gymTrainer3Battle: function () { + gymTrainerBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId].gym; closeModal(document.getElementById('gymModal')); - if (routeData.gymTrainer3 && routeData.gymTrainer3.poke.length > 0 && player.wins[routeData.gymTrainer3.req]) { - combatLoop.gymLeader = { name: routeData.gymTrainer3.name, win: routeData.gymTrainer3.win }; - combatLoop.gymLeaderPoke = Object.values({ ...routeData.gymTrainer3.poke }); - combatLoop.unpause(); - combatLoop.refresh(); - } else { - notify('Defeat the previous trainer and try again.'); - } - }, - npcBattle: function () { + for (let i = 1; i < 4; i++) { + if (routeData.gymTrainer[i - 1].req && !player.wins[routeData.gymTrainer[i - 1].req]) { + notify('Defeat more GYM LEADERS and try again'); + } else if (routeData.gymTrainer[i - 1] && routeData.gymTrainer[i - 1].poke.length > 0) { + combatLoop.gymLeader = { name: routeData.gymTrainer[i - 1].name, win: routeData.gymTrainer[i - 1].win }; + combatLoop.gymLeaderPoke = Object.values({...routeData.gymTrainer[i - 1].poke }); + combatLoop.unpause(); + combatLoop.refresh(); + } else { notify('Something is broken :/'); } + } + }, + npcBattle: function() { const routeData = ROUTES[player.settings.currentRegionId][player.settings.currentRouteId]; if (routeData.npc && routeData.npc.poke.length > 0) { combatLoop.npc = { name: routeData.npc.name, event: routeData.npc.event, }; - combatLoop.npcPoke = Object.values({ ...routeData.npc.poke }); + combatLoop.npcPoke = Object.values({...routeData.npc.poke }); combatLoop.unpause(); combatLoop.refresh(); } }, - closeStory: function () { + closeStory: function() { if (story.canClose) { $('#storyContainer').style.display = 'none'; } @@ -998,4 +971,4 @@ export const dummy = new Proxy({}, { get(target, prop) { return () => {}; }, -}); +}); \ No newline at end of file