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

Simulate Gen 1 Fight Button for Wrap #2327

Merged
merged 9 commits into from
Mar 12, 2025
24 changes: 19 additions & 5 deletions play.pokemonshowdown.com/js/client-battle.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@
var moveType = this.tooltips.getMoveType(move, typeValueTracker)[0];
var tooltipArgs = 'move|' + moveData.move + '|' + pos;
if (moveData.disabled) {
movebuttons += '<button disabled class="has-tooltip" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
movebuttons += '<button disabled class="movebutton has-tooltip" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
} else {
movebuttons += '<button class="type-' + moveType + ' has-tooltip" name="chooseMove" value="' + (i + 1) + '" data-move="' + BattleLog.escapeHTML(moveData.move) + '" data-target="' + BattleLog.escapeHTML(moveData.target) + '" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
movebuttons += '<button class="movebutton type-' + moveType + ' has-tooltip" name="chooseMove" value="' + (i + 1) + '" data-move="' + BattleLog.escapeHTML(moveData.move) + '" data-target="' + BattleLog.escapeHTML(moveData.target) + '" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
hasMoves = true;
}
movebuttons += name + '<br /><small class="type">' + (moveType ? Dex.types.get(moveType).name : "Unknown") + '</small> <small class="pp">' + pp + '</small>&nbsp;</button> ';
Expand Down Expand Up @@ -714,7 +714,7 @@
var tooltipArgs = classType + 'move|' + baseMove.id + '|' + pos;
if (specialMove.id.startsWith('gmax')) tooltipArgs += '|' + specialMove.id;
var isDisabled = specialMoves[i].disabled ? 'disabled="disabled"' : '';
movebuttons += '<button ' + isDisabled + ' class="type-' + moveType + ' has-tooltip" name="chooseMove" value="' + (i + 1) + '" data-move="' + BattleLog.escapeHTML(specialMoves[i].move) + '" data-target="' + BattleLog.escapeHTML(specialMoves[i].target) + '" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
movebuttons += '<button ' + isDisabled + ' class="movebutton type-' + moveType + ' has-tooltip" name="chooseMove" value="' + (i + 1) + '" data-move="' + BattleLog.escapeHTML(specialMoves[i].move) + '" data-target="' + BattleLog.escapeHTML(specialMoves[i].target) + '" data-tooltip="' + BattleLog.escapeHTML(tooltipArgs) + '">';
var pp = curActive.moves[i].pp + '/' + curActive.moves[i].maxpp;
if (canZMove) {
pp = '1/1';
Expand Down Expand Up @@ -749,7 +749,10 @@
moveMenu += '<br /><label class="megaevo"><input type="checkbox" name="terastallize" />&nbsp;Terastallize<br />' + Dex.getTypeIcon(canTerastallize) + '</label>';
}
if (this.finalDecisionMove) {
moveMenu += '<em style="display:block;clear:both">You <strong>might</strong> have some moves disabled, so you won\'t be able to cancel an attack!</em><br/>';
moveMenu += '<em class="movewarning">You <strong>might</strong> have some moves disabled, so you won\'t be able to cancel an attack!</em>';
}
if (curActive.maybeLocked) {
moveMenu += '<em class="movewarning">You <strong>might</strong> be locked into a move. <button class="button" name="chooseFight">Try Fight button</button> (prevents switching if you\'re locked)</em>';
}
moveMenu += '<div style="clear:left"></div>';

Expand Down Expand Up @@ -777,7 +780,7 @@
} else {
switchMenu += this.displayParty(switchables, trapped);
if (this.finalDecisionSwitch && this.battle.gen > 2) {
switchMenu += '<em style="display:block;clear:both">You <strong>might</strong> be trapped, so you won\'t be able to cancel a switch!</em><br/>';
switchMenu += '<em class="movewarning">You <strong>might</strong> be trapped, so you won\'t be able to cancel a switch!</em>';
}
}
var switchControls = (
Expand Down Expand Up @@ -1060,6 +1063,9 @@
case 'shift':
buf += myPokemon[i].speciesForme + ' will shift position.<br />';
break;
case 'testfight':
buf += myPokemon[i].speciesForme + ' is locked into a move.<br />';
break;
}
}
}
Expand Down Expand Up @@ -1296,6 +1302,14 @@
this.choice.choices[this.choice.choices.length - 1] += ' ' + posString;
this.chooseMove();
},
chooseFight: function () {
if (!this.choice) return;
this.tooltips.hideTooltip();

// TODO?: change this action
this.choice.choices.push('testfight');
this.endChoice();
},
chooseShift: function () {
if (!this.choice) return;
this.tooltips.hideTooltip();
Expand Down
4 changes: 3 additions & 1 deletion play.pokemonshowdown.com/src/panel-battle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ class BattleDiv extends preact.Component {
function MoveButton(props: {
children: string, cmd: string, moveData: { pp: number, maxpp: number }, type: Dex.TypeName, tooltip: string,
}) {
return <button name="cmd" value={props.cmd} class={`type-${props.type} has-tooltip`} data-tooltip={props.tooltip}>
return <button
name="cmd" value={props.cmd} class={`movebutton type-${props.type} has-tooltip`} data-tooltip={props.tooltip}
>
{props.children}<br />
<small class="type">{props.type}</small> <small class="pp">{props.moveData.pp}/{props.moveData.maxpp}</small>&nbsp;
</button>;
Expand Down
24 changes: 15 additions & 9 deletions play.pokemonshowdown.com/style/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ a.ilink.yours {
background: #009AA4;
}

.movemenu button {
.movebutton {
float: left;
display: block;
width: 155px;
Expand All @@ -1812,15 +1812,15 @@ a.ilink.yours {
position: relative;
padding: 6px 4px 0 4px;
}
.movemenu button small {
.movebutton small {
color: #777777;
}
.movemenu button small.type {
.movebutton small.type {
padding-top: 3px;
float: left;
font-size: 8pt;
}
.movemenu button small.pp {
.movebutton small.pp {
padding-top: 2px;
float: right;
font-size: 8pt;
Expand Down Expand Up @@ -1849,6 +1849,12 @@ a.ilink.yours {
background: #E5E5E5;
color: black;
}
.movewarning {
clear: both;
display: block;
font-size: 10pt;
padding: 8px 0 5px;
}
.allyparty,
.switchmenu,
.movemenu {
Expand All @@ -1858,7 +1864,7 @@ a.ilink.yours {
}
.allyparty button,
.switchmenu button,
.movemenu button {
.movebutton {
position: relative;
outline: none;
text-align: center;
Expand All @@ -1876,24 +1882,24 @@ a.ilink.yours {
}
.allyparty button:hover,
.switchmenu button:hover,
.movemenu button:hover {
.movebutton:hover {
background: #cfcfcf;
background: linear-gradient(to bottom, #f2f2f2, #cfcfcf);
border-color: #606060;
}
.allyparty button:active,
.switchmenu button:active,
.movemenu button:active,
.movebutton:active,
.switchmenu button.pressed,
.movemenu button.pressed {
.movebutton.pressed {
background: linear-gradient(to bottom, #cfcfcf, #f2f2f2);
}

.allyparty button.disabled,
.allyparty button:disabled,
.switchmenu button.disabled,
.switchmenu button:disabled,
.movemenu button:disabled {
.movebutton:disabled {
cursor: default;
background: #F3F3F3 !important;
border-color: #CCCCCC !important;
Expand Down
18 changes: 9 additions & 9 deletions play.pokemonshowdown.com/style/client2.css
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ a.ilink.yours {
background: #009AA4;
}

.movemenu button {
.movebutton {
float: left;
display: block;
width: 155px;
Expand All @@ -1706,15 +1706,15 @@ a.ilink.yours {
position: relative;
padding: 6px 4px 0 4px;
}
.movemenu button small {
.movebutton small {
color: #777777;
}
.movemenu button small.type {
.movebutton small.type {
padding-top: 3px;
float: left;
font-size: 8pt;
}
.movemenu button small.pp {
.movebutton small.pp {
padding-top: 2px;
float: right;
font-size: 8pt;
Expand Down Expand Up @@ -1757,7 +1757,7 @@ a.ilink.yours {
padding-left: 4px;
}
.switchmenu button,
.movemenu button {
.movebutton {
position: relative;
outline: none;
text-align: center;
Expand All @@ -1774,21 +1774,21 @@ a.ilink.yours {
background: linear-gradient(to bottom, #f6f6f6, #e3e3e3);
}
.switchmenu button:hover,
.movemenu button:hover {
.movebutton:hover {
background: #cfcfcf;
background: linear-gradient(to bottom, #f2f2f2, #cfcfcf);
border-color: #606060;
}
.switchmenu button:active,
.movemenu button:active,
.movebutton:active,
.switchmenu button.pressed,
.movemenu button.pressed {
.movebutton.pressed {
background: linear-gradient(to bottom, #cfcfcf, #f2f2f2);
}

.switchmenu button.disabled,
.switchmenu button:disabled,
.movemenu button:disabled {
.movebutton:disabled {
cursor: default;
background: #F3F3F3 !important;
border-color: #CCCCCC !important;
Expand Down