mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-04-26 18:18:46 -05:00
Preact: Show ally side pokemon in multi battles (#2602)
This commit is contained in:
parent
403fc61f2d
commit
028fb74cf0
|
|
@ -20,6 +20,11 @@ export interface BattleRequestSideInfo {
|
||||||
id: 'p1' | 'p2' | 'p3' | 'p4';
|
id: 'p1' | 'p2' | 'p3' | 'p4';
|
||||||
pokemon: ServerPokemon[];
|
pokemon: ServerPokemon[];
|
||||||
}
|
}
|
||||||
|
export interface BattleRequestAllyInfo {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
pokemon: ServerPokemon[];
|
||||||
|
}
|
||||||
export interface BattleRequestActivePokemon {
|
export interface BattleRequestActivePokemon {
|
||||||
moves: {
|
moves: {
|
||||||
name: string,
|
name: string,
|
||||||
|
|
@ -60,6 +65,7 @@ export interface BattleMoveRequest {
|
||||||
requestType: 'move';
|
requestType: 'move';
|
||||||
rqid: number;
|
rqid: number;
|
||||||
side: BattleRequestSideInfo;
|
side: BattleRequestSideInfo;
|
||||||
|
ally?: BattleRequestAllyInfo;
|
||||||
active: (BattleRequestActivePokemon | null)[];
|
active: (BattleRequestActivePokemon | null)[];
|
||||||
noCancel?: boolean;
|
noCancel?: boolean;
|
||||||
targetable?: boolean;
|
targetable?: boolean;
|
||||||
|
|
@ -67,6 +73,7 @@ export interface BattleMoveRequest {
|
||||||
export interface BattleSwitchRequest {
|
export interface BattleSwitchRequest {
|
||||||
requestType: 'switch';
|
requestType: 'switch';
|
||||||
rqid: number;
|
rqid: number;
|
||||||
|
ally?: BattleRequestAllyInfo;
|
||||||
side: BattleRequestSideInfo;
|
side: BattleRequestSideInfo;
|
||||||
forceSwitch: boolean[];
|
forceSwitch: boolean[];
|
||||||
noCancel?: boolean;
|
noCancel?: boolean;
|
||||||
|
|
@ -75,6 +82,7 @@ export interface BattleTeamRequest {
|
||||||
requestType: 'team';
|
requestType: 'team';
|
||||||
rqid: number;
|
rqid: number;
|
||||||
side: BattleRequestSideInfo;
|
side: BattleRequestSideInfo;
|
||||||
|
ally?: BattleRequestAllyInfo;
|
||||||
maxTeamSize?: number;
|
maxTeamSize?: number;
|
||||||
maxChosenTeamSize?: number;
|
maxChosenTeamSize?: number;
|
||||||
chosenTeamSize?: number;
|
chosenTeamSize?: number;
|
||||||
|
|
@ -84,6 +92,7 @@ export interface BattleWaitRequest {
|
||||||
requestType: 'wait';
|
requestType: 'wait';
|
||||||
rqid: number;
|
rqid: number;
|
||||||
side: undefined;
|
side: undefined;
|
||||||
|
ally: undefined;
|
||||||
noCancel?: boolean;
|
noCancel?: boolean;
|
||||||
}
|
}
|
||||||
export type BattleRequest = BattleMoveRequest | BattleSwitchRequest | BattleTeamRequest | BattleWaitRequest;
|
export type BattleRequest = BattleMoveRequest | BattleSwitchRequest | BattleTeamRequest | BattleWaitRequest;
|
||||||
|
|
@ -449,6 +458,7 @@ export class BattleChoiceBuilder {
|
||||||
choiceType: isTeamPreview ? 'team' : 'switch',
|
choiceType: isTeamPreview ? 'team' : 'switch',
|
||||||
targetPokemon: 0,
|
targetPokemon: 0,
|
||||||
};
|
};
|
||||||
|
if (choice === 'notMine') throw new Error(`You cannot decide for your partner!`);
|
||||||
if (/^[0-9]+$/.test(choice)) {
|
if (/^[0-9]+$/.test(choice)) {
|
||||||
// Parse a one-based move index.
|
// Parse a one-based move index.
|
||||||
current.targetPokemon = parseInt(choice, 10);
|
current.targetPokemon = parseInt(choice, 10);
|
||||||
|
|
@ -562,6 +572,12 @@ export class BattleChoiceBuilder {
|
||||||
battle.parseHealth(serverPokemon.condition, serverPokemon);
|
battle.parseHealth(serverPokemon.condition, serverPokemon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (request.ally) {
|
||||||
|
for (const serverPokemon of request.ally.pokemon) {
|
||||||
|
battle.parseDetails(serverPokemon.ident.substr(4), serverPokemon.ident, serverPokemon.details, serverPokemon);
|
||||||
|
battle.parseHealth(serverPokemon.condition, serverPokemon);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (request.requestType === 'team' && !request.chosenTeamSize) {
|
if (request.requestType === 'team' && !request.chosenTeamSize) {
|
||||||
request.chosenTeamSize = 1;
|
request.chosenTeamSize = 1;
|
||||||
if (battle.gameType === 'doubles') {
|
if (battle.gameType === 'doubles') {
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,9 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
|
||||||
room.battle.setViewpoint(request.side.id);
|
room.battle.setViewpoint(request.side.id);
|
||||||
room.side = request.side;
|
room.side = request.side;
|
||||||
}
|
}
|
||||||
|
if (request.ally) {
|
||||||
|
room.battle.myAllyPokemon = request.ally.pokemon;
|
||||||
|
}
|
||||||
|
|
||||||
room.request = request;
|
room.request = request;
|
||||||
room.choices = new BattleChoiceBuilder(request);
|
room.choices = new BattleChoiceBuilder(request);
|
||||||
|
|
@ -753,6 +756,14 @@ class BattlePanel extends PSRoomPanel<BattleRoom> {
|
||||||
tooltip: `switchpokemon|${i}`,
|
tooltip: `switchpokemon|${i}`,
|
||||||
});
|
});
|
||||||
})}
|
})}
|
||||||
|
{request.ally?.pokemon?.map((serverPokemon, i) => {
|
||||||
|
return this.renderPokemonButton({
|
||||||
|
pokemon: serverPokemon,
|
||||||
|
cmd: `/switch notMine`,
|
||||||
|
disabled: true,
|
||||||
|
tooltip: `allypokemon|${i}`,
|
||||||
|
});
|
||||||
|
})}
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
renderTeamPreviewChooser(request: | BattleTeamRequest, choices: BattleChoiceBuilder) {
|
renderTeamPreviewChooser(request: | BattleTeamRequest, choices: BattleChoiceBuilder) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user