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 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could still default Trump Card to 0 unless overridden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple implementation on the client side only would be to automatically set a move slot's PP Ups to 0 if Trump Card is selected. Otherwise, the import format would have to be edited to make an exception for Trump Card.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could modify noPPBoosts to PPBoosts, allowing it to accept either a number or false, with false indicating things that can't be PP boosted. The default value would be 3.

Copy link
Contributor

@andrebastosdias andrebastosdias Mar 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although that is not really move data, so it's probably better to just add a condition for Trump Card.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added exceptions for Trump Card on the server and client-side. It should be backwards-compatible for all regular teambuilder usage, but it wouldn't be for direct usage of packed format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't think it would be backwards-compatible in general.

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone puts 3 PP Ups on Trump Card, it's not gonna get exported properly here, unfortunately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed this by changing the unpack format. Old teams will need to adjust Trump Card's PP Ups to be 0, but newly created teams will automatically set this; is this something that you're fine with? (Trump Card hasn't been usable since Gen 7, and it's otherwise an unviable move, so I doubt it will have much impact anyway.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with making tradeoffs if they're necessary, but this doesn't seem necessary to me...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made it so that the default PP Ups for Trump Card is 0, and I've also made changes to the client PR to match the code here.

PPUps = ` (PP Ups: ${set.movePPUps[i]})`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. How do I feel about this...

}
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