-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
base: master
Are you sure you want to change the base?
Allow PP Ups to be edited #10167
Changes from 7 commits
0dafd30
c777c20
0e2b91b
65f8ed6
ac69b4b
b5a51ce
abc0116
8725d3e
f95a7dc
86a003a
abf10f4
ad0dac2
1071da2
81a1a2e
cddcad4
c748050
ad8e07a
f170206
d7560e3
b19e8b1
bad76e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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 || ''); | ||
|
||
|
@@ -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++) { | ||
|
@@ -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; | ||
|
@@ -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]; | ||
Zarel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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) { | ||
dot-Comfey marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]})`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. How do I feel about this...
dot-Comfey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
out += `- ${move}${PPUps} \n`; | ||
} | ||
|
||
return out; | ||
|
@@ -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 || {}; | ||
|
@@ -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) */ | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could modify
noPPBoosts
toPPBoosts
, 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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.