mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-13 11:52:18 +02:00
Select simultaneously the item to transfer and the quantity
This commit is contained in:
parent
f1bedce28e
commit
ab08538a06
@ -29,7 +29,6 @@ export enum PartyUiMode {
|
|||||||
TM_MODIFIER,
|
TM_MODIFIER,
|
||||||
REMEMBER_MOVE_MODIFIER,
|
REMEMBER_MOVE_MODIFIER,
|
||||||
MODIFIER_TRANSFER,
|
MODIFIER_TRANSFER,
|
||||||
MODIFIER_TRANSFER_QUANTITY,
|
|
||||||
SPLICE,
|
SPLICE,
|
||||||
RELEASE
|
RELEASE
|
||||||
}
|
}
|
||||||
@ -41,7 +40,6 @@ export enum PartyOption {
|
|||||||
APPLY,
|
APPLY,
|
||||||
TEACH,
|
TEACH,
|
||||||
TRANSFER,
|
TRANSFER,
|
||||||
TRANSFER_QUANTITY,
|
|
||||||
SUMMARY,
|
SUMMARY,
|
||||||
UNPAUSE_EVOLUTION,
|
UNPAUSE_EVOLUTION,
|
||||||
SPLICE,
|
SPLICE,
|
||||||
@ -87,8 +85,8 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
private transferMode: boolean;
|
private transferMode: boolean;
|
||||||
private transferOptionCursor: integer;
|
private transferOptionCursor: integer;
|
||||||
private transferCursor: integer;
|
private transferCursor: integer;
|
||||||
private transferQuantity: integer;
|
private transferQuantities: integer[];
|
||||||
private transferQuantityMax: integer;
|
private transferQuantitiesMax: integer[];
|
||||||
|
|
||||||
private lastCursor: integer = 0;
|
private lastCursor: integer = 0;
|
||||||
private selectCallback: PartySelectCallback | PartyModifierTransferSelectCallback;
|
private selectCallback: PartySelectCallback | PartyModifierTransferSelectCallback;
|
||||||
@ -222,39 +220,18 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
if (this.optionsMode) {
|
if (this.optionsMode) {
|
||||||
|
const option = this.options[this.optionsCursor]
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
const option = this.options[this.optionsCursor];
|
|
||||||
const pokemon = this.scene.getParty()[this.cursor];
|
const pokemon = this.scene.getParty()[this.cursor];
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode && option !== PartyOption.CANCEL) {
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode && option !== PartyOption.CANCEL) {
|
||||||
const pokemon = this.scene.getParty()[this.cursor];
|
const pokemon = this.scene.getParty()[this.cursor];
|
||||||
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||||
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[];
|
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === pokemon.id) as PokemonHeldItemModifier[];
|
||||||
this.transferQuantityMax = itemModifiers[this.getOptionsCursorWithScroll()].stackCount
|
|
||||||
this.transferQuantity = this.transferQuantityMax
|
|
||||||
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
|
||||||
|
|
||||||
if (this.transferQuantityMax > 1) {
|
|
||||||
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER_QUANTITY;
|
|
||||||
this.showOptions();
|
|
||||||
this.eraseOptionsCursor();
|
|
||||||
ui.playSelect();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
|
||||||
this.startTransfer();
|
this.startTransfer();
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER && option !== PartyOption.CANCEL) {
|
||||||
|
|
||||||
} else if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER_QUANTITY && option !== PartyOption.CANCEL) {
|
|
||||||
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER
|
|
||||||
this.startTransfer();
|
|
||||||
this.clearOptions();
|
|
||||||
ui.playSelect();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER && option !== PartyOption.CANCEL) {
|
|
||||||
let filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
let filterResult = (this.selectFilter as PokemonSelectFilter)(pokemon);
|
||||||
if (filterResult === null) {
|
if (filterResult === null) {
|
||||||
this.selectCallback(this.cursor, option);
|
this.selectCallback(this.cursor, option);
|
||||||
@ -284,7 +261,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (this.selectCallback) {
|
if (this.selectCallback) {
|
||||||
if (option === PartyOption.TRANSFER) {
|
if (option === PartyOption.TRANSFER) {
|
||||||
if (this.transferCursor !== this.cursor) {
|
if (this.transferCursor !== this.cursor) {
|
||||||
(this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, this.transferOptionCursor, this.transferQuantity, this.cursor);
|
(this.selectCallback as PartyModifierTransferSelectCallback)(this.transferCursor, this.transferOptionCursor, this.transferQuantities[this.transferOptionCursor], this.cursor);
|
||||||
}
|
}
|
||||||
this.clearTransfer();
|
this.clearTransfer();
|
||||||
} else if (this.partyUiMode === PartyUiMode.SPLICE) {
|
} else if (this.partyUiMode === PartyUiMode.SPLICE) {
|
||||||
@ -292,7 +269,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
(this.selectCallback as PartyModifierSpliceSelectCallback)(this.transferCursor, this.cursor);
|
(this.selectCallback as PartyModifierSpliceSelectCallback)(this.transferCursor, this.cursor);
|
||||||
this.clearTransfer();
|
this.clearTransfer();
|
||||||
} else
|
} else
|
||||||
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
|
||||||
this.startTransfer();
|
this.startTransfer();
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
} else if (option === PartyOption.RELEASE)
|
} else if (option === PartyOption.RELEASE)
|
||||||
@ -374,25 +350,25 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
} else if (option === PartyOption.CANCEL)
|
} else if (option === PartyOption.CANCEL)
|
||||||
return this.processInput(Button.CANCEL);
|
return this.processInput(Button.CANCEL);
|
||||||
} else if (button === Button.CANCEL) {
|
} else if (button === Button.CANCEL) {
|
||||||
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER_QUANTITY) {
|
|
||||||
this.partyUiMode = PartyUiMode.MODIFIER_TRANSFER
|
|
||||||
}
|
|
||||||
this.clearOptions();
|
this.clearOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
return true;
|
return true;
|
||||||
} else if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER_QUANTITY) {
|
|
||||||
switch (button) {
|
|
||||||
case Button.LEFT:
|
|
||||||
this.transferQuantity = this.transferQuantity == 1 ? this.transferQuantityMax : this.transferQuantity - 1
|
|
||||||
this.updateOptions()
|
|
||||||
break;
|
|
||||||
case Button.RIGHT:
|
|
||||||
this.transferQuantity = this.transferQuantity == this.transferQuantityMax ? 1 : this.transferQuantity + 1
|
|
||||||
this.updateOptions()
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
|
case Button.LEFT:
|
||||||
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
this.transferQuantities[option] = this.transferQuantities[option] == 1 ? this.transferQuantitiesMax[option] : this.transferQuantities[option] - 1
|
||||||
|
this.updateOptions()
|
||||||
|
success = this.setCursor(this.optionsCursor)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Button.RIGHT:
|
||||||
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER) {
|
||||||
|
this.transferQuantities[option] = this.transferQuantities[option] == this.transferQuantitiesMax[option] ? 1 : this.transferQuantities[option] + 1
|
||||||
|
this.updateOptions()
|
||||||
|
success = this.setCursor(this.optionsCursor)
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Button.UP:
|
case Button.UP:
|
||||||
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1);
|
success = this.setCursor(this.optionsCursor ? this.optionsCursor - 1 : this.options.length - 1);
|
||||||
break;
|
break;
|
||||||
@ -404,6 +380,12 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
} else {
|
} else {
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
if (this.cursor < 6) {
|
if (this.cursor < 6) {
|
||||||
|
if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER && !this.transferMode) {
|
||||||
|
const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier
|
||||||
|
&& (m as PokemonHeldItemModifier).getTransferrable(true) && (m as PokemonHeldItemModifier).pokemonId === this.scene.getParty()[this.cursor].id) as PokemonHeldItemModifier[]
|
||||||
|
this.transferQuantities = itemModifiers.map(item => item.getStackCount())
|
||||||
|
this.transferQuantitiesMax = itemModifiers.map(item => item.getStackCount())
|
||||||
|
}
|
||||||
this.showOptions();
|
this.showOptions();
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
} else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH)
|
} else if (this.partyUiMode === PartyUiMode.FAINT_SWITCH)
|
||||||
@ -570,10 +552,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
if (!this.transferMode)
|
if (!this.transferMode)
|
||||||
optionsMessage = 'Select a held item to transfer.';
|
optionsMessage = 'Select a held item to transfer.';
|
||||||
break;
|
break;
|
||||||
case PartyUiMode.MODIFIER_TRANSFER_QUANTITY:
|
|
||||||
if (!this.transferMode)
|
|
||||||
optionsMessage = 'Select the quantity to transfer.';
|
|
||||||
break;
|
|
||||||
case PartyUiMode.SPLICE:
|
case PartyUiMode.SPLICE:
|
||||||
if (!this.transferMode)
|
if (!this.transferMode)
|
||||||
optionsMessage = 'Select another Pokémon to splice.';
|
optionsMessage = 'Select another Pokémon to splice.';
|
||||||
@ -609,7 +587,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
let formChangeItemModifiers: PokemonFormChangeItemModifier[];
|
let formChangeItemModifiers: PokemonFormChangeItemModifier[];
|
||||||
|
|
||||||
if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER_QUANTITY && (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER)) {
|
if (this.partyUiMode !== PartyUiMode.MOVE_MODIFIER && this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && (this.transferMode || this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER)) {
|
||||||
switch (this.partyUiMode) {
|
switch (this.partyUiMode) {
|
||||||
case PartyUiMode.SWITCH:
|
case PartyUiMode.SWITCH:
|
||||||
case PartyUiMode.FAINT_SWITCH:
|
case PartyUiMode.FAINT_SWITCH:
|
||||||
@ -668,8 +646,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
const learnableMoves = pokemon.getLearnableLevelMoves();
|
const learnableMoves = pokemon.getLearnableLevelMoves();
|
||||||
for (let m = 0; m < learnableMoves.length; m++)
|
for (let m = 0; m < learnableMoves.length; m++)
|
||||||
this.options.push(m);
|
this.options.push(m);
|
||||||
} else if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER_QUANTITY) {
|
|
||||||
this.options.push(PartyOption.TRANSFER_QUANTITY)
|
|
||||||
} else {
|
} else {
|
||||||
for (let im = 0; im < itemModifiers.length; im++)
|
for (let im = 0; im < itemModifiers.length; im++)
|
||||||
this.options.push(im);
|
this.options.push(im);
|
||||||
@ -690,9 +666,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
this.options.push(PartyOption.SCROLL_DOWN);
|
this.options.push(PartyOption.SCROLL_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER_QUANTITY) {
|
|
||||||
this.options.push(PartyOption.CANCEL);
|
this.options.push(PartyOption.CANCEL);
|
||||||
}
|
|
||||||
|
|
||||||
this.optionsBg = addWindow(this.scene, 0, 0, 0, 16 * this.options.length + 13);
|
this.optionsBg = addWindow(this.scene, 0, 0, 0, 16 * this.options.length + 13);
|
||||||
this.optionsBg.setOrigin(1, 1);
|
this.optionsBg.setOrigin(1, 1);
|
||||||
@ -713,7 +687,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
optionName = '↑';
|
optionName = '↑';
|
||||||
else if (option === PartyOption.SCROLL_DOWN)
|
else if (option === PartyOption.SCROLL_DOWN)
|
||||||
optionName = '↓';
|
optionName = '↓';
|
||||||
else if ((this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER_QUANTITY && (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) || option === PartyOption.CANCEL) {
|
else if ((this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) || option === PartyOption.CANCEL) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case PartyOption.MOVE_1:
|
case PartyOption.MOVE_1:
|
||||||
case PartyOption.MOVE_2:
|
case PartyOption.MOVE_2:
|
||||||
@ -740,13 +714,11 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
const move = learnableLevelMoves[option];
|
const move = learnableLevelMoves[option];
|
||||||
optionName = allMoves[move].name;
|
optionName = allMoves[move].name;
|
||||||
altText = !pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move);
|
altText = !pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move);
|
||||||
} else if (this.partyUiMode === PartyUiMode.MODIFIER_TRANSFER_QUANTITY) {
|
|
||||||
optionName = `< ${this.transferQuantity} >`
|
|
||||||
} else {
|
} else {
|
||||||
const itemModifier = itemModifiers[option];
|
const itemModifier = itemModifiers[option];
|
||||||
optionName = itemModifier.type.name;
|
optionName = itemModifier.type.name;
|
||||||
if (itemModifier.stackCount > 1)
|
if (this.transferQuantitiesMax[option] > 1)
|
||||||
optionName += ` (${itemModifier.stackCount})`;
|
optionName += ` (${this.transferQuantities[option]})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const yCoord = -6 - 16 * o;
|
const yCoord = -6 - 16 * o;
|
||||||
@ -772,6 +744,7 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
startTransfer(): void {
|
startTransfer(): void {
|
||||||
this.transferMode = true;
|
this.transferMode = true;
|
||||||
this.transferCursor = this.cursor;
|
this.transferCursor = this.cursor;
|
||||||
|
this.transferOptionCursor = this.getOptionsCursorWithScroll();
|
||||||
|
|
||||||
this.partySlots[this.transferCursor].setTransfer(true);
|
this.partySlots[this.transferCursor].setTransfer(true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user