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

[UI/UX] Spend all button for gacha #5136

Open
wants to merge 5 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion public/locales
DayKev marked this conversation as resolved.
Show resolved Hide resolved
Submodule locales updated 1 files
+4 −1 en/egg.json
51 changes: 43 additions & 8 deletions src/ui/egg-gacha-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ export default class EggGachaUiHandler extends MessageUiHandler {
this.updateGachaInfo(g);
});

this.eggGachaOptionsContainer = globalScene.add.container();

this.eggGachaOptionsContainer = globalScene.add.container((globalScene.game.canvas.width / 6), 148);
this.eggGachaContainer.add(this.eggGachaOptionsContainer);

Expand All @@ -211,12 +209,14 @@ export default class EggGachaUiHandler extends MessageUiHandler {

const multiplierOne = "x1";
const multiplierTen = "x10";
const multiplierNone = "";
const pullOptions = [
{ multiplier: multiplierOne, description: `1 ${i18next.t("egg:pull")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) },
{ multiplier: multiplierTen, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.REGULAR) },
{ multiplier: multiplierOne, description: `5 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PLUS) },
{ multiplier: multiplierOne, description: `10 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.PREMIUM) },
{ multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) }
{ multiplier: multiplierOne, description: `25 ${i18next.t("egg:pulls")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) },
{ multiplier: multiplierNone, description: `${i18next.t("egg:all")}`, icon: getVoucherTypeIcon(VoucherType.GOLDEN) }
];

const resolvedLanguage = i18next.resolvedLanguage ?? "en";
Expand All @@ -238,7 +238,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
TextStyle.WINDOW,
);

optionText.setLineSpacing(28);
optionText.setLineSpacing(13);
optionText.setFontSize("80px");

this.eggGachaOptionsContainer.add(optionText);
Expand All @@ -248,7 +248,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
pullOptions.forEach((option, i) => {
const icon = globalScene.add.sprite(0, 0, "items", option.icon);
icon.setScale(3 * this.scale);
icon.setPositionRelative(this.eggGachaOptionSelectBg, 20, 9 + (48 + i * 96) * this.scale);
icon.setPositionRelative(this.eggGachaOptionSelectBg, 20, 9 + (48 + i * 81) * this.scale);
this.eggGachaOptionsContainer.add(icon);
});

Expand Down Expand Up @@ -496,7 +496,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
ease: "Sine.easeOut",
duration: overlayEaseInDuration,
onComplete: () => {
const rowItems = 5;
const rowItems = Math.max(Math.ceil(eggs.length / 11), 5);
const rows = Math.ceil(eggs.length / rowItems);
const cols = Math.min(eggs.length, rowItems);
const height = this.eggGachaOverlay.displayHeight - this.eggGachaMessageBox.displayHeight;
Expand Down Expand Up @@ -709,6 +709,41 @@ export default class EggGachaUiHandler extends MessageUiHandler {
}
break;
case 5:
if (!globalScene.gameData.voucherCounts[VoucherType.REGULAR] && !globalScene.gameData.voucherCounts[VoucherType.PLUS]
&& !globalScene.gameData.voucherCounts[VoucherType.PREMIUM] && !globalScene.gameData.voucherCounts[VoucherType.GOLDEN] &&
!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
Davidy22 marked this conversation as resolved.
Show resolved Hide resolved
error = true;
this.showError(i18next.t("egg:noVouchers"));
} else if (globalScene.gameData.eggs.length < 99 || Overrides.UNLIMITED_EGG_COUNT_OVERRIDE) {
let pulls = 0;
let eggSpace = 99 - globalScene.gameData.eggs.length;

if (!Overrides.EGG_FREE_GACHA_PULLS_OVERRIDE) {
const voucherTypes = [[ VoucherType.GOLDEN, 25 ], [ VoucherType.PREMIUM, 10 ], [ VoucherType.PLUS, 5 ], [ VoucherType.REGULAR, 1 ]];
voucherTypes.forEach(voucherType => {
const vouchersUsed = Math.min(globalScene.gameData.voucherCounts[voucherType[0]], ~~(eggSpace / voucherType[1]));
Davidy22 marked this conversation as resolved.
Show resolved Hide resolved
this.consumeVouchers(voucherType[0], vouchersUsed);
const pullsUsed = vouchersUsed * voucherType[1];
pulls += pullsUsed;
eggSpace -= pullsUsed;
});
} else {
pulls = eggSpace;
}

if (pulls === 0) {
error = true;
this.showError(i18next.t("egg:vouchersExceedEggCap"));
} else {
this.pull(pulls);
success = true;
}
} else {
error = true;
this.showError(i18next.t("egg:tooManyEggs"));
}
break;
case 6:
ui.revertMode();
success = true;
break;
Expand All @@ -724,7 +759,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
}
break;
case Button.DOWN:
if (this.cursor < 5) {
if (this.cursor < 6) {
success = this.setCursor(this.cursor + 1);
}
break;
Expand Down Expand Up @@ -760,7 +795,7 @@ export default class EggGachaUiHandler extends MessageUiHandler {
}

this.cursorObj.setScale(this.scale * 6);
this.cursorObj.setPositionRelative(this.eggGachaOptionSelectBg, 10, 9 + (48 + this.cursor * 96) * this.scale);
this.cursorObj.setPositionRelative(this.eggGachaOptionSelectBg, 10, 9 + (48 + this.cursor * 81) * this.scale);

return ret;
}
Expand Down
Loading