Skip to content

Commit bacfa1f

Browse files
committed
"fix" stuff
1 parent 7d8e97d commit bacfa1f

13 files changed

+130
-102
lines changed

calc/bundle

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const exports = {};
1313
`;
1414
bundled += bundler.read('util.js', 3, 1);
1515
const species = bundler.read('data/species.js').split('\n');
16-
bundled += species.slice(1, 64).join('\n'); // generator + iterator + spreadArray polyfill
16+
bundled += species.slice(1, 39).join('\n'); // generator + iterator polyfill
1717
bundled += '\nvar e_1, _a, e_2, _b;\nvar util_1 = exports;\n';
18-
bundled += species.slice(68, -2).join('\n');
18+
bundled += species.slice(43, -2).join('\n');
1919

2020
const types = bundler.read('data/types.js').split('\n');
2121
bundled += types.slice(1, 12).join('\n'); // __assign polyfill
@@ -25,7 +25,9 @@ bundled += natures.slice(28, 44).join('\n'); // __read polyfill
2525
bundled += natures.slice(47, -2).join('\n');
2626
bundled += bundler.read('data/abilities.js', 43, 1);
2727
bundled += bundler.read('data/moves.js', 43, 1);
28-
bundled += bundler.read('data/items.js', 68, 1);
28+
const items = bundler.read('data/items.js').split('\n');
29+
bundled += items.slice(44, 53).join('\n'); // __spreadArray polyfill
30+
bundled += items.slice(68, -2).join('\n');
2931
bundled += `
3032
var abilities_1 = exports;
3133
var items_1 = exports;

calc/src/data/interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export interface Specie extends Data<SpeciesName> {
146146
readonly nfe?: boolean;
147147
readonly gender?: GenderName;
148148
readonly otherFormes?: SpeciesName[];
149+
readonly canGigantamax?: MoveName;
149150
readonly baseSpecies?: SpeciesName;
150151
readonly abilities?: {0: AbilityName | ''};
151152
}

calc/src/data/moves.ts

+4
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,10 @@ const SV_PATCH: {[name: string]: DeepPartial<MoveData>} = {
47504750

47514751
const SV: {[name: string]: MoveData} = extend(true, {}, SS, SV_PATCH);
47524752

4753+
for (const moveName in SV) {
4754+
if (moveName.startsWith('G-Max')) delete SV[moveName];
4755+
}
4756+
47534757
export const MOVES = [{}, RBY, GSC, ADV, DPP, BW, XY, SM, SS, SV];
47544758

47554759
export class Moves implements I.Moves {

calc/src/data/species.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -7513,6 +7513,7 @@ const SS_PATCH: {[name: string]: DeepPartial<SpeciesData>} = {
75137513
Kingler: {canGigantamax: "G-Max Foam Burst"},
75147514
Lapras: {canGigantamax: "G-Max Resonance"},
75157515
Linoone: {otherFormes: ['Linoone-Galar']},
7516+
Machamp: {canGigantamax: "G-Max Chi-Strike"},
75167517
Magearna: {otherFormes: ["Magearna-Original"]},
75177518
Melmetal: {canGigantamax: "G-Max Meltdown"},
75187519
Meowth: {canGigantamax: "G-Max Gold Rush", otherFormes: ['Meowth-Alola', 'Meowth-Galar']},
@@ -8511,6 +8512,12 @@ const SS_PATCH: {[name: string]: DeepPartial<SpeciesData>} = {
85118512

85128513
const SS: {[name: string]: SpeciesData} = extend(true, {}, SM, SS_PATCH);
85138514

8515+
for (const speciesName in SS) {
8516+
if (SS[speciesName].canGigantamax) {
8517+
SS[speciesName + '-Gmax'] = SS[speciesName];
8518+
}
8519+
}
8520+
85148521
delete SS['Pikachu-Starter'];
85158522
delete SS['Eevee-Starter'];
85168523

@@ -9520,6 +9527,13 @@ const SV_PATCH: {[name: string]: DeepPartial<SpeciesData>} = {
95209527

95219528
const SV: {[name: string]: SpeciesData} = extend(true, {}, SS, SV_PATCH, PLA_PATCH);
95229529

9530+
for (const speciesName in SV) {
9531+
if (SV[speciesName].canGigantamax) {
9532+
// @ts-ignore readonly
9533+
delete SV[speciesName].canGigantamax;
9534+
}
9535+
}
9536+
95239537
export const SPECIES = [{}, RBY, GSC, ADV, DPP, BW, XY, SM, SS, SV];
95249538

95259539
export class Species implements I.Species {
@@ -9550,10 +9564,11 @@ class Specie implements I.Specie {
95509564
readonly nfe?: boolean;
95519565
readonly gender?: I.GenderName;
95529566
readonly otherFormes?: I.SpeciesName[];
9567+
readonly canGigantamax?: I.MoveName;
95539568
readonly baseSpecies?: I.SpeciesName;
95549569
readonly abilities?: {0: I.AbilityName}; // ability
95559570

9556-
private static readonly EXCLUDE = new Set(['bs', 'otherFormes']);
9571+
private static readonly EXCLUDE = new Set(['bs']);
95579572

95589573
constructor(name: string, data: SpeciesData) {
95599574
this.kind = 'Species';
@@ -9568,15 +9583,6 @@ class Specie implements I.Specie {
95689583
baseStats.spd = gen >= 2 ? data.bs.sd : data.bs.sl;
95699584
baseStats.spe = data.bs.sp;
95709585
this.baseStats = baseStats as I.StatsTable;
9571-
// Hack for getting Gmax pokemon out of existence in Gen 9+
9572-
if (data.otherFormes) {
9573-
this.otherFormes = data.otherFormes as I.SpeciesName[];
9574-
if (gen >= 9 && !['toxtricity', 'urshifu'].includes(this.id)) {
9575-
this.otherFormes = this.otherFormes.filter(f => !f.endsWith('-Gmax'));
9576-
if (!this.otherFormes.length) this.otherFormes = undefined;
9577-
if (this.otherFormes) this.otherFormes = [...new Set(this.otherFormes)];
9578-
}
9579-
}
95809586

95819587
assignWithout(this, data, Specie.EXCLUDE);
95829588
}

calc/src/move.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class Move implements State.Move {
1313
item?: I.ItemName;
1414
species?: I.SpeciesName;
1515
useZ?: boolean;
16-
useMax?: boolean;
16+
useMax?: 'gmax' | boolean;
1717
isGmax?: boolean;
1818
overrides?: Partial<I.Move>;
1919

@@ -64,7 +64,7 @@ export class Move implements State.Move {
6464
options.species,
6565
!!(data.category === 'Status'),
6666
options.ability,
67-
options.isGmax
67+
!!(options.useMax === 'gmax')
6868
);
6969
const maxMove = gen.moves.get(toID(maxMoveName));
7070
const maxPower = () => {
@@ -112,7 +112,6 @@ export class Move implements State.Move {
112112
this.item = options.item;
113113
this.useZ = options.useZ;
114114
this.useMax = options.useMax;
115-
this.isGmax = options.useMax;
116115
this.overrides = options.overrides;
117116
this.species = options.species;
118117

@@ -178,7 +177,6 @@ export class Move implements State.Move {
178177
species: this.species,
179178
useZ: this.useZ,
180179
useMax: this.useMax,
181-
isGmax: this.isGmax,
182180
isCrit: this.isCrit,
183181
hits: this.hits,
184182
timesUsed: this.timesUsed,
@@ -272,8 +270,7 @@ export function getMaxMoveName(
272270
}
273271
if (moveType === 'Electric') {
274272
if (pokemonSpecies === 'Pikachu' && isGmax) return 'G-Max Volt Crash';
275-
if (pokemonSpecies?.startsWith('Toxtricity') &&
276-
pokemonSpecies?.endsWith('Gmax')) return 'G-Max Stun Shock';
273+
if (pokemonSpecies?.startsWith('Toxtricity') && isGmax) return 'G-Max Stun Shock';
277274
}
278275
if (moveType === 'Grass') {
279276
if (pokemonSpecies === 'Appletun' && isGmax) return 'G-Max Sweetness';

calc/src/pokemon.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export class Pokemon implements State.Pokemon {
5353
this.gen = gen;
5454
this.name = options.name || name as I.SpeciesName;
5555
this.types = this.species.types;
56-
this.weightkg = this.species.weightkg;
5756

5857
this.level = options.level || 100;
5958
this.gender = options.gender || this.species.gender || 'M';
6059
this.ability = options.ability || this.species.abilities?.[0] || undefined;
6160
this.abilityOn = !!options.abilityOn;
6261

6362
this.isDynamaxed = !!options.isDynamaxed;
63+
this.weightkg = this.isDynamaxed ? 0 : this.species.weightkg;
6464
this.isSaltCure = !!options.isSaltCure;
6565
this.alliesFainted = options.alliesFainted;
6666
this.teraType = options.teraType;
@@ -70,12 +70,6 @@ export class Pokemon implements State.Pokemon {
7070
this.evs = Pokemon.withDefault(gen, options.evs, gen.num >= 3 ? 0 : 252);
7171
this.boosts = Pokemon.withDefault(gen, options.boosts, 0, false);
7272

73-
// Gigantamax 'forms' inherit weight from their base species when not dynamaxed
74-
// TODO: clean this up with proper Gigantamax support
75-
if (this.weightkg === 0 && !this.isDynamaxed && this.species.baseSpecies) {
76-
this.weightkg = gen.species.get(toID(this.species.baseSpecies))!.weightkg;
77-
}
78-
7973
if (gen.num < 3) {
8074
this.ivs.hp = Stats.DVToIV(
8175
Stats.getHPDV({

calc/src/state.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export namespace State {
2626
export interface Move {
2727
name: I.MoveName;
2828
useZ?: boolean;
29-
useMax?: boolean;
30-
isGmax?: boolean;
29+
useMax?: 'gmax' | boolean;
3130
isCrit?: boolean;
3231
hits?: number;
3332
timesUsed?: number;

calc/src/test/gen.ts

+2
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class Specie implements I.Specie {
301301
readonly weightkg: number;
302302
readonly nfe?: boolean;
303303
readonly gender?: I.GenderName;
304+
readonly canGigantamax?: I.MoveName;
304305
readonly otherFormes?: I.SpeciesName[];
305306
readonly baseSpecies?: I.SpeciesName;
306307
readonly abilities?: {0: I.AbilityName};
@@ -329,6 +330,7 @@ class Specie implements I.Specie {
329330
} else if (species.baseSpecies !== this.name) {
330331
this.baseSpecies = species.baseSpecies as I.SpeciesName;
331332
}
333+
if (species.canGigantamax) this.canGigantamax = species.canGigantamax;
332334

333335
if (dex.gen > 2) this.abilities = {0: species.abilities[0] as I.AbilityName};
334336
}

src/honkalculate.template.html

+14-9
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,20 @@
438438
<label>Current HP</label>
439439
<input class="current-hp" value="341" />/<span class="max-hp">341</span> (
440440
<input class="percent-hp" value="100" />%)
441-
<<<<<<< HEAD
442-
<input class="max calc-trigger btn-input" type="checkbox" id="maxL" /><label class="btn btn-wide gen-specific g8 g9" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
443-
=======
444-
<br />
445-
<input class="max calc-trigger btn-input" type="checkbox" id="maxL" />
446-
<label class="btn btn-wide gen-specific g8" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
447-
<input class="gmax calc-trigger btn-input" type="checkbox" id="gmaxL" />
448-
<label class="btn btn-xwide gen-specific g8" for="gmaxL" title="Use the G-Max forme instead?">Gigantamax</label>
449-
>>>>>>> Implement Gigantamaxing properly
441+
<div class="dynamaxOnly">
442+
<br />
443+
<br />
444+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxL" />
445+
<label class="btn btn-wide gen-specific g8 hide" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
446+
</div>
447+
<div class="dynamaxAndGigantamax">
448+
<br />
449+
<br />
450+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxL" />
451+
<label class="btn btn-wide gen-specific g8 hide" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
452+
<input class="gmax calc-trigger" type="checkbox" id="gmaxL" />
453+
<label class="gen-specific g8 hide" for="gmaxL" title="Use the G-Max forme instead?">Gigantamax</label>
454+
</div>
450455
<br />
451456
<br />
452457
Health <div class="hpbar"></div>

src/index.template.html

+28-26
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,20 @@
501501
<label for="currentHpL1">Current HP</label>
502502
<input class="current-hp calc-trigger" id="currentHpL1" value="341" />/<span class="max-hp">341</span> (
503503
<input class="percent-hp calc-trigger" value="100" />%)
504-
<<<<<<< HEAD
505-
<input class="visually-hidden max calc-trigger btn-input" type="checkbox" id="maxL" />
506-
<label class="btn btn-xwide gen-specific g8 hide" for="maxL"
507-
title="Use the corresponding Max Move?">Dynamax</label>
508-
<br />
509-
=======
510-
<br />
511-
<input class="visually-hidden max calc-trigger btn-input" type="checkbox" id="maxL" />
512-
<label class="btn btn-wide gen-specific g8" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
513-
<input class="visually-hidden gmax calc-trigger btn-input" type="checkbox" id="gmaxL" />
514-
<label class="btn btn-xwide gen-specific g8" for="gmaxL" title="Use the G-Max forme instead?">Gigantamax</label>
515-
<br />
516-
>>>>>>> Implement Gigantamaxing properly
504+
<div class="dynamaxOnly">
505+
<br />
506+
<br />
507+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxL" />
508+
<label class="btn btn-wide gen-specific g8 hide" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
509+
</div>
510+
<div class="dynamaxAndGigantamax">
511+
<br />
512+
<br />
513+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxL" />
514+
<label class="btn btn-wide gen-specific g8 hide" for="maxL" title="Use the corresponding Max Move?">Dynamax</label>
515+
<input class="gmax calc-trigger" type="checkbox" id="gmaxL" />
516+
<label class="gen-specific g8 hide" for="gmaxL" title="Use the G-Max forme instead?">Gigantamax</label>
517+
</div>
517518
<br />
518519
Health <div class="hpbar"></div>
519520
</div>
@@ -1389,19 +1390,20 @@
13891390
<label for="currentHpR1">Current HP</label>
13901391
<input class="current-hp calc-trigger" id="currentHpR1" value="341" />/<span class="max-hp">341</span> (
13911392
<input class="percent-hp calc-trigger" value="100" />%)
1392-
<<<<<<< HEAD
1393-
<input class="visually-hidden max calc-trigger btn-input" type="checkbox" id="maxR" />
1394-
<label class="btn btn-xwide gen-specific g8 hide" for="maxR"
1395-
title="Use the corresponding Max Move?">Dynamax</label>
1396-
<br />
1397-
=======
1398-
<br />
1399-
<input class="visually-hidden max calc-trigger btn-input" type="checkbox" id="maxR" />
1400-
<label class="btn btn-wide gen-specific g8" for="maxR" title="Use the corresponding Max Move?">Dynamax</label>
1401-
<input class="visually-hidden gmax calc-trigger btn-input" type="checkbox" id="gmaxR" />
1402-
<label class="btn btn-xwide gen-specific g8" for="gmaxR" title="Use the G-Max forme instead?">Gigantamax</label>
1403-
<br />
1404-
>>>>>>> Implement Gigantamaxing properly
1393+
<div class="dynamaxOnly">
1394+
<br />
1395+
<br />
1396+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxR" />
1397+
<label class="btn btn-wide gen-specific g8 hide" for="maxR" title="Use the corresponding Max Move?">Dynamax</label>
1398+
</div>
1399+
<div class="dynamaxAndGigantamax">
1400+
<br />
1401+
<br />
1402+
<input class="visually-hidden max calc-trigger" type="checkbox" id="maxR" />
1403+
<label class="btn btn-wide gen-specific g8 hide" for="maxR" title="Use the corresponding Max Move?">Dynamax</label>
1404+
<input class="gmax calc-trigger" type="checkbox" id="gmaxR" />
1405+
<label class="gen-specific g8 hide" for="gmaxR" title="Use the G-Max forme instead?">Gigantamax</label>
1406+
</div>
14051407
<br />
14061408
Health <div class="hpbar"></div>
14071409
</div>

src/js/moveset_import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function ExportPokemon(pokeInfo) {
1818
finalText += pokemon.nature && gen > 2 ? pokemon.nature + " Nature" + "\n" : "";
1919
finalText += pokemon.teraType && gen > 8 ? "Tera Type: " + pokemon.teraType : "";
2020
finalText += pokemon.ability ? "Ability: " + pokemon.ability + "\n" : "";
21-
finalText += pokemon.isGigantamaxed ? "Gigantamax: Yes\n" : "";
21+
finalText += pokemon.isDynamaxed === 'gmax' ? "Gigantamax: Yes\n" : "";
2222
if (gen > 2) {
2323
var EVs_Array = [];
2424
for (var stat in pokemon.evs) {

src/js/shared_controls.js

+26-12
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,18 @@ $(".set-selector").change(function () {
617617
} else {
618618
formeObj.hide();
619619
}
620+
if (gen === 8) {
621+
if (pokemon.canGigantamax) {
622+
$(this).closest('.poke-info').find('.dynamaxOnly').hide();
623+
$(this).closest('.poke-info').find('.dynamaxAndGigantamax').show();
624+
} else {
625+
$(this).closest('.poke-info').find('.dynamaxOnly').show();
626+
$(this).closest('.poke-info').find('.dynamaxAndGigantamax').hide();
627+
}
628+
} else {
629+
$(this).closest('.poke-info').find('.dynamaxOnly').hide();
630+
$(this).closest('.poke-info').find('.dynamaxAndGigantamax').hide();
631+
}
620632
calcHP(pokeObj);
621633
calcStats(pokeObj);
622634
abilityObj.change();
@@ -838,15 +850,17 @@ function createPokemon(pokeInfo) {
838850
var ability = pokeInfo.find(".ability").val();
839851
var item = pokeInfo.find(".item").val();
840852
var isDynamaxed = pokeInfo.find(".max").prop("checked");
841-
var isGigantamaxed = isDynamaxed && pokeInfo.find(".gmax").prop("checked");
853+
var isGigantamaxed = pokeInfo.find(".gmax").prop("checked");
854+
if (isGigantamaxed) {
855+
pokeInfo.find(".max").prop("checked", true);
856+
isDynamaxed = pokeInfo.find(".max").prop("checked");
857+
}
842858
var teraType = pokeInfo.find(".teraToggle").is(":checked") ? pokeInfo.find(".teraType").val() : undefined;
843-
pokeInfo.isDynamaxed = isDynamaxed;
844-
pokeInfo.isGigantamaxed = isGigantamaxed;
845-
if (pokeInfo.isGigantamaxed) pokeInfo.isDynamaxed = true;
859+
pokeInfo.isDynamaxed = isGigantamaxed ? 'gmax' : !!isDynamaxed;
846860
calcHP(pokeInfo);
847861
var curHP = ~~pokeInfo.find(".current-hp").val();
848862
// FIXME the Pokemon constructor expects non-dynamaxed HP
849-
if (isDynamaxed || isGigantamaxed) curHP = Math.floor(curHP / 2);
863+
if (pokeInfo.isDynamaxed) curHP = Math.floor(curHP / 2);
850864
var types = [pokeInfo.find(".type1").val(), pokeInfo.find(".type2").val()];
851865
return new calc.Pokemon(gen, name, {
852866
level: ~~pokeInfo.find(".level").val(),
@@ -866,10 +880,10 @@ function createPokemon(pokeInfo) {
866880
status: CALC_STATUS[pokeInfo.find(".status").val()],
867881
toxicCounter: status === 'Badly Poisoned' ? ~~pokeInfo.find(".toxic-counter").val() : 0,
868882
moves: [
869-
getMoveDetails(pokeInfo.find(".move1"), name, ability, item, isDynamaxed, isGigantamaxed),
870-
getMoveDetails(pokeInfo.find(".move2"), name, ability, item, isDynamaxed, isGigantamaxed),
871-
getMoveDetails(pokeInfo.find(".move3"), name, ability, item, isDynamaxed, isGigantamaxed),
872-
getMoveDetails(pokeInfo.find(".move4"), name, ability, item, isDynamaxed, isGigantamaxed)
883+
getMoveDetails(pokeInfo.find(".move1"), name, ability, item, isDynamaxed),
884+
getMoveDetails(pokeInfo.find(".move2"), name, ability, item, isDynamaxed),
885+
getMoveDetails(pokeInfo.find(".move3"), name, ability, item, isDynamaxed),
886+
getMoveDetails(pokeInfo.find(".move4"), name, ability, item, isDynamaxed)
873887
],
874888
overrides: {
875889
baseStats: baseStats,
@@ -885,7 +899,7 @@ function getGender(gender) {
885899
return 'F';
886900
}
887901

888-
function getMoveDetails(moveInfo, species, ability, item, useMax, isGmax) {
902+
function getMoveDetails(moveInfo, species, ability, item, useMax) {
889903
var moveName = moveInfo.find("select.move-selector").val();
890904
var isZMove = gen > 6 && moveInfo.find("input.move-z").prop("checked");
891905
var isCrit = moveInfo.find(".move-crit").prop("checked");
@@ -899,7 +913,7 @@ function getMoveDetails(moveInfo, species, ability, item, useMax, isGmax) {
899913
if (gen >= 4) overrides.category = moveInfo.find(".move-cat").val();
900914
return new calc.Move(gen, moveName, {
901915
ability: ability, item: item, useZ: isZMove, species: species, isCrit: isCrit, hits: hits, timesUsed: timesUsed,
902-
timesUsedWithMetronome: timesUsedWithMetronome, overrides: overrides, useMax: useMax, isGmax: isGmax
916+
timesUsedWithMetronome: timesUsedWithMetronome, overrides: overrides, useMax: useMax,
903917
});
904918
}
905919

@@ -996,7 +1010,7 @@ function calcStat(poke, StatID) {
9961010
}
9971011
// Shedinja still has 1 max HP during the effect even if its Dynamax Level is maxed (DaWoblefet)
9981012
var total = calc.calcStat(gen, legacyStatToStat(StatID), base, ivs, evs, level, nature);
999-
if (gen > 7 && StatID === "hp" && (poke.isDynamaxed || poke.isGigantamaxed) && total !== 1) {
1013+
if (gen > 7 && StatID === "hp" && poke.isDynamaxed && total !== 1) {
10001014
total *= 2;
10011015
}
10021016
stat.find(".total").text(total);

0 commit comments

Comments
 (0)