Skip to content

Commit b01c150

Browse files
authored
Let's Go: Support itemless megas (#2233)
1 parent 946f699 commit b01c150

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

play.pokemonshowdown.com/js/client-battle.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
},
5454
events: {
5555
'click .replayDownloadButton': 'clickReplayDownloadButton',
56+
'change input[name=megaevox]': 'uncheckMegaEvoY',
57+
'change input[name=megaevoy]': 'uncheckMegaEvoX',
5658
'change input[name=zmove]': 'updateZMove',
5759
'change input[name=dynamax]': 'updateMaxMove'
5860
},
@@ -510,6 +512,12 @@
510512
}
511513
return '<button name="openTimer" class="button timerbutton' + timerTicking + '"><i class="fa fa-hourglass-start"></i> ' + time + '</button>';
512514
},
515+
uncheckMegaEvoX: function () {
516+
this.$('input[name=megaevox]').prop('checked', false);
517+
},
518+
uncheckMegaEvoY: function () {
519+
this.$('input[name=megaevoy]').prop('checked', false);
520+
},
513521
updateMaxMove: function () {
514522
var dynaChecked = this.$('input[name=dynamax]')[0].checked;
515523
if (dynaChecked) {
@@ -559,6 +567,8 @@
559567
if (!curActive) return;
560568
var trapped = curActive.trapped;
561569
var canMegaEvo = curActive.canMegaEvo || switchables[pos].canMegaEvo;
570+
var canMegaEvoX = curActive.canMegaEvoX || switchables[pos].canMegaEvoX;
571+
var canMegaEvoY = curActive.canMegaEvoY || switchables[pos].canMegaEvoY;
562572
var canZMove = curActive.canZMove || switchables[pos].canZMove;
563573
var canUltraBurst = curActive.canUltraBurst || switchables[pos].canUltraBurst;
564574
var canDynamax = curActive.canDynamax || switchables[pos].canDynamax;
@@ -721,6 +731,13 @@
721731
}
722732
if (canMegaEvo) {
723733
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevo" />&nbsp;Mega&nbsp;Evolution</label>';
734+
} else if (canMegaEvoX && canMegaEvoY) {
735+
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevox" />&nbsp;Mega&nbsp;Evolution X</label>';
736+
moveMenu += '<label class="megaevo"><input type="checkbox" name="megaevoy" />&nbsp;Mega&nbsp;Evolution Y</label>';
737+
} else if (canMegaEvoX) {
738+
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevox" />&nbsp;Mega&nbsp;Evolution X</label>';
739+
} else if (canMegaEvoY) {
740+
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="megaevoy" />&nbsp;Mega&nbsp;Evolution Y</label>';
724741
} else if (canZMove) {
725742
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="zmove" />&nbsp;Z-Power</label>';
726743
} else if (canUltraBurst) {
@@ -983,6 +1000,14 @@
9831000
buf += 'Mega Evolve, then ';
9841001
targetPos = parts[3];
9851002
}
1003+
if (targetPos === 'megax') {
1004+
buf += 'Mega Evolve X, then ';
1005+
targetPos = parts[3];
1006+
}
1007+
if (targetPos === 'megay') {
1008+
buf += 'Mega Evolve Y, then ';
1009+
targetPos = parts[3];
1010+
}
9861011
if (targetPos === 'zmove') {
9871012
move = this.request.active[i].canZMove[parseInt(parts[1], 10) - 1].move;
9881013
targetPos = parts[3];
@@ -1232,6 +1257,8 @@
12321257
if (pos !== undefined) { // pos === undefined if called by chooseMoveTarget()
12331258
var nearActive = this.battle.nearSide.active;
12341259
var isMega = !!(this.$('input[name=megaevo]')[0] || '').checked;
1260+
var isMegaX = !!(this.$('input[name=megaevox]')[0] || '').checked;
1261+
var isMegaY = !!(this.$('input[name=megaevoy]')[0] || '').checked;
12351262
var isZMove = !!(this.$('input[name=zmove]')[0] || '').checked;
12361263
var isUltraBurst = !!(this.$('input[name=ultraburst]')[0] || '').checked;
12371264
var isDynamax = !!(this.$('input[name=dynamax]')[0] || '').checked;
@@ -1240,7 +1267,7 @@
12401267
var target = e.getAttribute('data-target');
12411268
var choosableTargets = {normal: 1, any: 1, adjacentAlly: 1, adjacentAllyOrSelf: 1, adjacentFoe: 1};
12421269

1243-
this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '') + (isDynamax ? ' dynamax' : '') + (isTerastal ? ' terastallize' : ''));
1270+
this.choice.choices.push('move ' + pos + (isMega ? ' mega' : '') + (isMegaX ? ' megax' : isMegaY ? ' megay' : '') + (isZMove ? ' zmove' : '') + (isUltraBurst ? ' ultra' : '') + (isDynamax ? ' dynamax' : '') + (isTerastal ? ' terastallize' : ''));
12441271
if (nearActive.length > 1 && target in choosableTargets) {
12451272
this.choice.type = 'movetarget';
12461273
this.choice.moveTarget = target;

play.pokemonshowdown.com/js/client-teambuilder.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,7 @@
13641364
buf += '</div></div>';
13651365

13661366
buf += '<div class="setrow">';
1367-
// 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>';
1368-
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>';
1367+
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>';
13691368
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>';
13701369
buf += '</div></div>';
13711370

play.pokemonshowdown.com/src/battle-choices.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface BattleRequestActivePokemon {
4141
canDynamax?: boolean;
4242
canGigantamax?: boolean;
4343
canMegaEvo?: boolean;
44+
canMegaEvoX?: boolean;
45+
canMegaEvoY?: boolean;
4446
canUltraBurst?: boolean;
4547
canTerastallize?: boolean;
4648
trapped?: boolean;
@@ -82,6 +84,8 @@ interface BattleMoveChoice {
8284
move: number;
8385
targetLoc: number;
8486
mega: boolean;
87+
megax: boolean;
88+
megay: boolean;
8589
ultra: boolean;
8690
max: boolean;
8791
z: boolean;
@@ -114,6 +118,8 @@ class BattleChoiceBuilder {
114118
move: 0,
115119
targetLoc: 0, // should always be 0: is not partial if `targetLoc` is known
116120
mega: false,
121+
megax: false,
122+
megay: false,
117123
ultra: false,
118124
z: false,
119125
max: false,
@@ -194,7 +200,7 @@ class BattleChoiceBuilder {
194200
return null;
195201
}
196202
}
197-
if (choice.mega) this.alreadyMega = true;
203+
if (choice.mega || choice.megax || choice.megay) this.alreadyMega = true;
198204
if (choice.z) this.alreadyZ = true;
199205
if (choice.max) this.alreadyMax = true;
200206
if (choice.tera) this.alreadyTera = true;
@@ -285,6 +291,8 @@ class BattleChoiceBuilder {
285291
move: 0,
286292
targetLoc: 0,
287293
mega: false,
294+
megax: false,
295+
megay: false,
288296
ultra: false,
289297
z: false,
290298
max: false,
@@ -302,6 +310,12 @@ class BattleChoiceBuilder {
302310
} else if (choice.endsWith(' mega')) {
303311
current.mega = true;
304312
choice = choice.slice(0, -5);
313+
} else if (choice.endsWith(' megax')) {
314+
current.megax = true;
315+
choice = choice.slice(0, -6);
316+
} else if (choice.endsWith(' megay')) {
317+
current.megay = true;
318+
choice = choice.slice(0, -6);
305319
} else if (choice.endsWith(' zmove')) {
306320
current.z = true;
307321
choice = choice.slice(0, -6);

play.pokemonshowdown.com/src/panel-battle.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
245245
case 'mega':
246246
choices.current.mega = checkbox.checked;
247247
break;
248+
case 'megax':
249+
choices.current.megax = checkbox.checked;
250+
choices.current.megay = false;
251+
break;
252+
case 'megay':
253+
choices.current.megay = checkbox.checked;
254+
choices.current.megax = false;
255+
break;
248256
case 'ultra':
249257
choices.current.ultra = checkbox.checked;
250258
break;
@@ -549,6 +557,8 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
549557

550558
const canDynamax = moveRequest.canDynamax && !choices.alreadyMax;
551559
const canMegaEvo = moveRequest.canMegaEvo && !choices.alreadyMega;
560+
const canMegaEvoX = moveRequest.canMegaEvoX && !choices.alreadyMega;
561+
const canMegaEvoY = moveRequest.canMegaEvoY && !choices.alreadyMega;
552562
const canZMove = moveRequest.zMoves && !choices.alreadyZ;
553563

554564
if (choices.current.move) {
@@ -588,6 +598,14 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
588598
<input type="checkbox" name="mega" checked={choices.current.mega} onChange={this.toggleBoostedMove} /> {}
589599
Mega Evolution
590600
</label>}
601+
{canMegaEvoX && <label class={`megaevo${choices.current.mega ? ' cur' : ''}`}>
602+
<input type="checkbox" name="megax" checked={choices.current.megax} onChange={this.toggleBoostedMove} /> {}
603+
Mega Evolution X
604+
</label>}
605+
{canMegaEvoY && <label class={`megaevo${choices.current.mega ? ' cur' : ''}`}>
606+
<input type="checkbox" name="megay" checked={choices.current.megay} onChange={this.toggleBoostedMove} /> {}
607+
Mega Evolution Y
608+
</label>}
591609
{moveRequest.canUltraBurst && <label class={`megaevo${choices.current.ultra ? ' cur' : ''}`}>
592610
<input type="checkbox" name="ultra" checked={choices.current.ultra} onChange={this.toggleBoostedMove} /> {}
593611
Ultra Burst

0 commit comments

Comments
 (0)