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

Let's Go: Support itemless megas #2233

Merged
merged 2 commits into from
Mar 25, 2024
Merged
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
29 changes: 28 additions & 1 deletion play.pokemonshowdown.com/js/client-battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
},
events: {
'click .replayDownloadButton': 'clickReplayDownloadButton',
'change input[name=megaevox]': 'uncheckMegaEvoY',
'change input[name=megaevoy]': 'uncheckMegaEvoX',
'change input[name=zmove]': 'updateZMove',
'change input[name=dynamax]': 'updateMaxMove'
},
Expand Down Expand Up @@ -510,6 +512,12 @@
}
return '<button name="openTimer" class="button timerbutton' + timerTicking + '"><i class="fa fa-hourglass-start"></i> ' + time + '</button>';
},
uncheckMegaEvoX: function () {
this.$('input[name=megaevox]').prop('checked', false);
},
uncheckMegaEvoY: function () {
this.$('input[name=megaevoy]').prop('checked', false);
},
updateMaxMove: function () {
var dynaChecked = this.$('input[name=dynamax]')[0].checked;
if (dynaChecked) {
Expand Down Expand Up @@ -559,6 +567,8 @@
if (!curActive) return;
var trapped = curActive.trapped;
var canMegaEvo = curActive.canMegaEvo || switchables[pos].canMegaEvo;
var canMegaEvoX = curActive.canMegaEvoX || switchables[pos].canMegaEvoX;
var canMegaEvoY = curActive.canMegaEvoY || switchables[pos].canMegaEvoY;
var canZMove = curActive.canZMove || switchables[pos].canZMove;
var canUltraBurst = curActive.canUltraBurst || switchables[pos].canUltraBurst;
var canDynamax = curActive.canDynamax || switchables[pos].canDynamax;
Expand Down Expand Up @@ -721,6 +731,13 @@
}
if (canMegaEvo) {
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevo" />&nbsp;Mega&nbsp;Evolution</label>';
} else if (canMegaEvoX && canMegaEvoY) {
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevox" />&nbsp;Mega&nbsp;Evolution X</label>';
moveMenu += '<label class="megaevo"><input type="checkbox" name="megaevoy" />&nbsp;Mega&nbsp;Evolution Y</label>';
} else if (canMegaEvoX) {
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevox" />&nbsp;Mega&nbsp;Evolution X</label>';
} else if (canMegaEvoY) {
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevoy" />&nbsp;Mega&nbsp;Evolution Y</label>';
} else if (canZMove) {
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="zmove" />&nbsp;Z-Power</label>';
} else if (canUltraBurst) {
Expand Down Expand Up @@ -983,6 +1000,14 @@
buf += 'Mega Evolve, then ';
targetPos = parts[3];
}
if (targetPos === 'megax') {
buf += 'Mega Evolve X, then ';
targetPos = parts[3];
}
if (targetPos === 'megay') {
buf += 'Mega Evolve Y, then ';
targetPos = parts[3];
}
if (targetPos === 'zmove') {
move = this.request.active[i].canZMove[parseInt(parts[1], 10) - 1].move;
targetPos = parts[3];
Expand Down Expand Up @@ -1232,6 +1257,8 @@
if (pos !== undefined) { // pos === undefined if called by chooseMoveTarget()
var nearActive = this.battle.nearSide.active;
var isMega = !!(this.$('input[name=megaevo]')[0] || '').checked;
var isMegaX = !!(this.$('input[name=megaevox]')[0] || '').checked;
var isMegaY = !!(this.$('input[name=megaevoy]')[0] || '').checked;
var isZMove = !!(this.$('input[name=zmove]')[0] || '').checked;
var isUltraBurst = !!(this.$('input[name=ultraburst]')[0] || '').checked;
var isDynamax = !!(this.$('input[name=dynamax]')[0] || '').checked;
Expand All @@ -1240,7 +1267,7 @@
var target = e.getAttribute('data-target');
var choosableTargets = {normal: 1, any: 1, adjacentAlly: 1, adjacentAllyOrSelf: 1, adjacentFoe: 1};

this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '') + (isDynamax ? ' dynamax' : '') + (isTerastal ? ' terastallize' : ''));
this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isMegaX ? ' megax' : isMegaY ? ' megay' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '') + (isDynamax ? ' dynamax' : '') + (isTerastal ? ' terastallize' : ''));
if (nearActive.length > 1 && target in choosableTargets) {
this.choice.type = 'movetarget';
this.choice.moveTarget = target;
Expand Down
3 changes: 1 addition & 2 deletions play.pokemonshowdown.com/js/client-teambuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1364,8 +1364,7 @@
buf += '</div></div>';

buf += '<div class="setrow">';
// if (this.curTeam.gen > 1 && !isLetsGo) buf += '<div class="setcell setcell-item"><label>Item</label><input type="text" name="item" class="textbox chartinput" value="' + BattleLog.escapeHTML(set.item) + '" /></div>';
if (this.curTeam.gen > 1) buf += '<div class="setcell setcell-item"><label>Item</label><input type="text" name="item" class="textbox chartinput" value="' + BattleLog.escapeHTML(set.item) + '" autocomplete="off" /></div>';
if (this.curTeam.gen > 1 && !isLetsGo) buf += '<div class="setcell setcell-item"><label>Item</label><input type="text" name="item" class="textbox chartinput" value="' + BattleLog.escapeHTML(set.item) + '" autocomplete="off" /></div>';
if (this.curTeam.gen > 2 && !isLetsGo) buf += '<div class="setcell setcell-ability"><label>Ability</label><input type="text" name="ability" class="textbox chartinput" value="' + BattleLog.escapeHTML(set.ability) + '" autocomplete="off" /></div>';
buf += '</div></div>';

Expand Down
16 changes: 15 additions & 1 deletion play.pokemonshowdown.com/src/battle-choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface BattleRequestActivePokemon {
canDynamax?: boolean;
canGigantamax?: boolean;
canMegaEvo?: boolean;
canMegaEvoX?: boolean;
canMegaEvoY?: boolean;
canUltraBurst?: boolean;
canTerastallize?: boolean;
trapped?: boolean;
Expand Down Expand Up @@ -82,6 +84,8 @@ interface BattleMoveChoice {
move: number;
targetLoc: number;
mega: boolean;
megax: boolean;
megay: boolean;
ultra: boolean;
max: boolean;
z: boolean;
Expand Down Expand Up @@ -114,6 +118,8 @@ class BattleChoiceBuilder {
move: 0,
targetLoc: 0, // should always be 0: is not partial if `targetLoc` is known
mega: false,
megax: false,
megay: false,
ultra: false,
z: false,
max: false,
Expand Down Expand Up @@ -194,7 +200,7 @@ class BattleChoiceBuilder {
return null;
}
}
if (choice.mega) this.alreadyMega = true;
if (choice.mega || choice.megax || choice.megay) this.alreadyMega = true;
if (choice.z) this.alreadyZ = true;
if (choice.max) this.alreadyMax = true;
if (choice.tera) this.alreadyTera = true;
Expand Down Expand Up @@ -285,6 +291,8 @@ class BattleChoiceBuilder {
move: 0,
targetLoc: 0,
mega: false,
megax: false,
megay: false,
ultra: false,
z: false,
max: false,
Expand All @@ -302,6 +310,12 @@ class BattleChoiceBuilder {
} else if (choice.endsWith(' mega')) {
current.mega = true;
choice = choice.slice(0, -5);
} else if (choice.endsWith(' megax')) {
current.megax = true;
choice = choice.slice(0, -6);
} else if (choice.endsWith(' megay')) {
current.megay = true;
choice = choice.slice(0, -6);
} else if (choice.endsWith(' zmove')) {
current.z = true;
choice = choice.slice(0, -6);
Expand Down
18 changes: 18 additions & 0 deletions play.pokemonshowdown.com/src/panel-battle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
case 'mega':
choices.current.mega = checkbox.checked;
break;
case 'megax':
choices.current.megax = checkbox.checked;
choices.current.megay = false;
break;
case 'megay':
choices.current.megay = checkbox.checked;
choices.current.megax = false;
break;
case 'ultra':
choices.current.ultra = checkbox.checked;
break;
Expand Down Expand Up @@ -549,6 +557,8 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {

const canDynamax = moveRequest.canDynamax && !choices.alreadyMax;
const canMegaEvo = moveRequest.canMegaEvo && !choices.alreadyMega;
const canMegaEvoX = moveRequest.canMegaEvoX && !choices.alreadyMega;
const canMegaEvoY = moveRequest.canMegaEvoY && !choices.alreadyMega;
const canZMove = moveRequest.zMoves && !choices.alreadyZ;

if (choices.current.move) {
Expand Down Expand Up @@ -588,6 +598,14 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
<input type="checkbox" name="mega" checked={choices.current.mega} onChange={this.toggleBoostedMove} /> {}
Mega Evolution
</label>}
{canMegaEvoX && <label class={`megaevo${choices.current.mega ? ' cur' : ''}`}>
<input type="checkbox" name="megax" checked={choices.current.megax} onChange={this.toggleBoostedMove} /> {}
Mega Evolution X
</label>}
{canMegaEvoY && <label class={`megaevo${choices.current.mega ? ' cur' : ''}`}>
<input type="checkbox" name="megay" checked={choices.current.megay} onChange={this.toggleBoostedMove} /> {}
Mega Evolution Y
</label>}
{moveRequest.canUltraBurst && <label class={`megaevo${choices.current.ultra ? ' cur' : ''}`}>
<input type="checkbox" name="ultra" checked={choices.current.ultra} onChange={this.toggleBoostedMove} /> {}
Ultra Burst
Expand Down
Loading