Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow PP Ups to be edited #10167

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data/moves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20869,7 +20869,6 @@ export const Moves: import('../sim/dex-moves').MoveDataTable = {
isNonstandard: "Past",
name: "Trump Card",
pp: 5,
noPPBoosts: true,
priority: 0,
flags: {contact: 1, protect: 1, mirror: 1, metronome: 1},
secondary: null,
Expand Down
5 changes: 4 additions & 1 deletion sim/TEAMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Armaldo||leftovers|swiftswim|xscissor,stoneedge,aquatail,rapidspin|Adamant|128,2
The format is a list of pokemon delimited by `]`, where every Pokémon is:

```
NICKNAME|SPECIES|ITEM|ABILITY|MOVES|NATURE|EVS|GENDER|IVS|SHINY|LEVEL|HAPPINESS,POKEBALL,HIDDENPOWERTYPE,GIGANTAMAX,DYNAMAXLEVEL,TERATYPE
NICKNAME|SPECIES|ITEM|ABILITY|MOVES;PPUPS|NATURE|EVS|GENDER|IVS|SHINY|LEVEL|HAPPINESS,POKEBALL,HIDDENPOWERTYPE,GIGANTAMAX,DYNAMAXLEVEL,TERATYPE
```

- `SPECIES` is left blank if it's identical to `NICKNAME`
Expand All @@ -180,6 +180,9 @@ NICKNAME|SPECIES|ITEM|ABILITY|MOVES|NATURE|EVS|GENDER|IVS|SHINY|LEVEL|HAPPINESS,

- `MOVES` is a comma-separated list of move IDs.

- `PPUPS` correspond to the moves as specified in `MOVES`. A blank value is for
3 PP Ups, and if all values are blank, the semicolon and commas can be removed.

- `NATURE` left blank means Serious, except in Gen 1-2, where it means no Nature.

- `EVS` and `IVS` are comma-separated in standard order:
Expand Down
4 changes: 3 additions & 1 deletion sim/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ export class Pokemon {
if (!set.hpType) set.hpType = move.type;
move = this.battle.dex.moves.get('hiddenpower');
}
let basepp = (move.noPPBoosts || move.isZ) ? move.pp : move.pp * 8 / 5;
let PPUps = this.set.movePPUps ? this.set.movePPUps[this.set.moves.indexOf(moveid)] : 3;
PPUps = this.battle.clampIntRange(PPUps, 0, 3);
let basepp = (move.noPPBoosts || move.isZ) ? move.pp : move.pp * (5 + PPUps) / 5;
if (this.battle.gen < 3) basepp = Math.min(61, basepp);
this.baseMoveSlots.push({
move: move.name,
Expand Down
52 changes: 43 additions & 9 deletions sim/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface PokemonSet {
* These should always be converted to ids before use.
*/
moves: string[];
movePPUps?: number[];
/**
* This can be an id, e.g. "adamant" or a full name, e.g. "Adamant".
* This should always be converted to an id before use.
Expand Down Expand Up @@ -138,6 +139,15 @@ export const Teams = new class Teams {
// moves
buf += '|' + set.moves.map(this.packName).join(',');

// move PP
if (set.movePPUps && set.movePPUps.some(n => n < 3)) {
const PPUps = set.movePPUps.map(n => {
if (n === 3) return '';
return n.toString();
});
buf += ';' + PPUps.join(',');
}

// nature
buf += '|' + (set.nature || '');

Expand Down Expand Up @@ -219,6 +229,7 @@ export const Teams = new class Teams {
const team = [];
let i = 0;
let j = 0;
let k = 0;

// limit to 24
for (let count = 0; count < 24; count++) {
Expand Down Expand Up @@ -254,11 +265,26 @@ export const Teams = new class Teams {
i = j + 1;

// moves
j = buf.indexOf('|', i);
if (j < 0) return null;
j = buf.indexOf(';', i);
k = buf.indexOf('|', i);
if (j < 0 || j > k) {
j = k;
if (j < 0) return null;
}
set.moves = buf.substring(i, j).split(',', 24).map(name => this.unpackName(name, Dex.moves));
i = j + 1;

// move PP ups
if (buf.charAt(j) === ';') {
j = buf.indexOf('|', i);
if (j < 0) return null;
set.movePPUps = buf.substring(i, j).split(',', 24).map(n => {
if (!n) return 3;
return parseInt(n);
});
i = j + 1;
}

// nature
j = buf.indexOf('|', i);
if (j < 0) return null;
Expand Down Expand Up @@ -435,11 +461,16 @@ export const Teams = new class Teams {
}

// moves
for (let move of set.moves) {
for (let i = 0; i < set.moves.length; i++) {
let move = set.moves[i];
let PPUps = ``;
if (move.startsWith(`Hidden Power `) && move.charAt(13) !== '[') {
move = `Hidden Power [${move.slice(13)}]`;
}
out += `- ${move} \n`;
if (set.movePPUps && !isNaN(set.movePPUps[i]) && set.movePPUps[i] < 3) {
PPUps = ` (PP Ups: ${set.movePPUps[i]})`;
}
out += `- ${move}${PPUps} \n`;
}

return out;
Expand Down Expand Up @@ -525,9 +556,10 @@ export const Teams = new class Teams {
if (line !== 'undefined') set.nature = aggressive ? toID(line) : line;
} else if (line.startsWith('-') || line.startsWith('~')) {
line = line.slice(line.charAt(1) === ' ' ? 2 : 1);
if (line.startsWith('Hidden Power [')) {
const hpType = line.slice(14, -1);
line = 'Hidden Power ' + hpType;
let [move, PPUps] = line.split(' (PP Ups: ');
if (move.startsWith('Hidden Power [')) {
const hpType = move.slice(14, -1);
move = 'Hidden Power ' + hpType;
if (!set.ivs && Dex.types.isName(hpType)) {
set.ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};
const hpIVs = Dex.types.get(hpType).HPivs || {};
Expand All @@ -536,10 +568,12 @@ export const Teams = new class Teams {
}
}
}
if (line === 'Frustration' && set.happiness === undefined) {
if (!set.movePPUps) set.movePPUps = [];
set.movePPUps.push(parseInt(PPUps?.charAt(0)) || 3);
if (move === 'Frustration' && set.happiness === undefined) {
set.happiness = 0;
}
set.moves.push(line);
set.moves.push(move);
}
}
/** Accepts a team in any format (JSON, packed, or exported) */
Expand Down
4 changes: 2 additions & 2 deletions test/sim/moves/trumpcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Trump Card', function () {

it('should power-up the less PP the move has', function () {
battle = common.createBattle([
[{species: 'Eevee', ability: 'runaway', moves: ['trumpcard']}],
[{species: 'Eevee', ability: 'runaway', moves: ['trumpcard'], movePPUps: [0]}],
[{species: 'Lugia', ability: 'multiscale', moves: ['recover']}],
]);

Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Trump Card', function () {

it('should work if called via Custap Berry in Gen 4', function () {
battle = common.gen(4).createBattle([
[{species: 'Eevee', level: 1, ability: 'runaway', item: 'custapberry', moves: ['trumpcard']}],
[{species: 'Eevee', level: 1, ability: 'runaway', item: 'custapberry', moves: ['trumpcard'], movePPUps: [0]}],
[{species: 'Scizor', ability: 'technician', moves: ['falseswipe']}],
]);

Expand Down
Loading