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

Indicator when a candy upgrade is available #1083

Merged
merged 35 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9a98b10
initial implementation
josericardo-fo May 18, 2024
db2b9aa
updated logic
josericardo-fo May 18, 2024
3aa4887
reverse retTint
josericardo-fo May 18, 2024
139f500
added candy overlays and colors
josericardo-fo May 18, 2024
9c5a470
added settings and minor fixes
josericardo-fo May 18, 2024
d748230
german changes
josericardo-fo May 18, 2024
e99dec4
logic fix
josericardo-fo May 18, 2024
e8ba3f7
german changes pt2
josericardo-fo May 18, 2024
4417599
german changes pt3
josericardo-fo May 18, 2024
8ff9d65
setting name changed
josericardo-fo May 18, 2024
182c4a0
Merge branch 'pagefaultgames:main' into candy-upgrade
josericardo-fo May 18, 2024
f0f5a85
Merge branch 'pagefaultgames:main' into candy-upgrade
josericardo-fo May 21, 2024
9ca017c
Merge branch 'main' into candy-upgrade
josericardo-fo May 23, 2024
5696d91
Update battle-scene.ts
josericardo-fo May 23, 2024
9327ec7
Merge branch 'pagefaultgames:main' into candy-upgrade
josericardo-fo May 23, 2024
269dbd4
initial animation implementation
josericardo-fo May 23, 2024
b18ca19
Merge branch 'candy-upgrade' of https://github.com/josericardo-fo/pok…
josericardo-fo May 23, 2024
da56ec1
minor fixes
josericardo-fo May 23, 2024
82f47b6
main compatibility
josericardo-fo May 23, 2024
b3897f0
minor fix
josericardo-fo May 23, 2024
705fe8c
logic for animations
josericardo-fo May 26, 2024
3f7feb5
Merge branch 'pagefaultgames:main' into candy-upgrade
josericardo-fo May 26, 2024
aeef9dd
eslint fixes
josericardo-fo May 26, 2024
2aab5d8
final generation logic
josericardo-fo May 26, 2024
6852084
Merge remote-tracking branch 'upstream/main' into pr/1083
bennybroseph May 26, 2024
4ae3d75
Pause Animation when Selected or Purchased
bennybroseph May 26, 2024
c7844a5
Disable Indicator if not Root Species
bennybroseph May 26, 2024
f291568
Merge branch 'pagefaultgames:main' into candy-upgrade
josericardo-fo May 27, 2024
d2dabf8
Add to Reload and Add Anchor
bennybroseph May 27, 2024
1655138
Merge branch 'candy-upgrade' of https://github.com/josericardo-fo/pok…
bennybroseph May 27, 2024
651e003
Fix Animation on Change
bennybroseph May 27, 2024
e6c9af7
Fix Icon on Change
bennybroseph May 27, 2024
7d54bdc
Merge branch 'main' into candy-upgrade
josericardo-fo May 28, 2024
6216694
Code Cleanup
bennybroseph May 28, 2024
d40133c
fix
josericardo-fo May 28, 2024
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
1 change: 1 addition & 0 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default class BattleScene extends SceneBase {
public showLevelUpStats: boolean = true;
public enableTutorials: boolean = import.meta.env.VITE_BYPASS_TUTORIAL === "1";
public enableRetries: boolean = false;
public candyUpgradeIconsMode: integer = 0;
public uiTheme: UiTheme = UiTheme.DEFAULT;
public windowType: integer = 0;
public experimentalSprites: boolean = false;
Expand Down
6 changes: 6 additions & 0 deletions src/system/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum Setting {
Window_Type = "WINDOW_TYPE",
Tutorials = "TUTORIALS",
Enable_Retries = "ENABLE_RETRIES",
Candy_Upgrade_Icon = "CANDY_UPGRADE_ICON",
Sprite_Set = "SPRITE_SET",
Move_Animations = "MOVE_ANIMATIONS",
Show_Stats_on_Level_Up = "SHOW_LEVEL_UP_STATS",
Expand Down Expand Up @@ -50,6 +51,7 @@ export const settingOptions: SettingOptions = {
[Setting.Window_Type]: new Array(5).fill(null).map((_, i) => (i + 1).toString()),
[Setting.Tutorials]: ['Off', 'On'],
[Setting.Enable_Retries]: ['Off', 'On'],
[Setting.Candy_Upgrade_Icon]: ['Off', 'Only Passive Unlocks', 'On'],
[Setting.Sprite_Set]: ['Consistent', 'Mixed Animated'],
[Setting.Move_Animations]: ['Off', 'On'],
[Setting.Show_Stats_on_Level_Up]: ['Off', 'On'],
Expand All @@ -75,6 +77,7 @@ export const settingDefaults: SettingDefaults = {
[Setting.Window_Type]: 0,
[Setting.Tutorials]: 1,
[Setting.Enable_Retries]: 0,
[Setting.Candy_Upgrade_Icon]: 0,
[Setting.Sprite_Set]: 0,
[Setting.Move_Animations]: 1,
[Setting.Show_Stats_on_Level_Up]: 1,
Expand Down Expand Up @@ -123,6 +126,9 @@ export function setSetting(scene: BattleScene, setting: Setting, value: integer)
case Setting.Enable_Retries:
scene.enableRetries = settingOptions[setting][value] === 'On';
break;
case Setting.Candy_Upgrade_Icon:
scene.candyUpgradeIconsMode = value;
break;
case Setting.Sprite_Set:
scene.experimentalSprites = !!value;
if (value)
Expand Down
67 changes: 67 additions & 0 deletions src/ui/starter-select-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private shinyIcons: Phaser.GameObjects.Image[][];
private hiddenAbilityIcons: Phaser.GameObjects.Image[];
private classicWinIcons: Phaser.GameObjects.Image[];
private candyUpgradeIcon: Phaser.GameObjects.Image[];
private candyUpgradeOverlayIcon: Phaser.GameObjects.Image[];

private iconAnimHandler: PokemonIconAnimHandler;

Expand Down Expand Up @@ -457,6 +459,28 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return ret;
});

this.candyUpgradeIcon = new Array(81).fill(null).map((_, i) => {
const x = (i % 9) * 18;
const y = Math.floor(i / 9) * 18;
const ret = this.scene.add.image(x + 163, y + 21, 'candy');
ret.setOrigin(0, 0);
ret.setScale(0.25);
ret.setVisible(false);
this.starterSelectContainer.add(ret);
return ret;
});

this.candyUpgradeOverlayIcon = new Array(81).fill(null).map((_, i) => {
const x = (i % 9) * 18;
const y = Math.floor(i / 9) * 18;
const ret = this.scene.add.image(x + 163, y + 21, 'candy_overlay');
ret.setOrigin(0, 0);
ret.setScale(0.25);
ret.setVisible(false);
this.starterSelectContainer.add(ret);
return ret;
});

this.pokemonSprite = this.scene.add.sprite(53, 63, `pkmn__sub`);
this.pokemonSprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], ignoreTimeTint: true });
this.starterSelectContainer.add(this.pokemonSprite);
Expand Down Expand Up @@ -960,6 +984,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (!success)
return this.scene.reset(true);
});
if (this.scene.candyUpgradeIconsMode !== 0) {this.updateCandyUpgradeIcon(this.cursor)} // If the setting is not set to 0, update the candy upgrade icon
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
return true;
Expand All @@ -984,6 +1009,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
if (!success)
return this.scene.reset(true);
});
if (this.scene.candyUpgradeIconsMode === 2) {this.updateCandyUpgradeIcon(this.cursor)} // If the setting is set to 2, update the candy upgrade icon
this.updateStarterValueLabel(this.cursor);
this.tryUpdateValue(0);
ui.setMode(Mode.STARTER_SELECT);
Expand Down Expand Up @@ -1274,6 +1300,31 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4));
this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0);

if (!starterColors[speciesId]) {
starterColors[speciesId] = [ 'ffffff', 'ffffff' ]; // Default to white if no colors are found
}

// Set the candy colors
this.candyUpgradeIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][0])));
this.candyUpgradeOverlayIcon[s].setTint(argbFromRgba(Utils.rgbHexToRgba(starterColors[speciesId][1])));

if (this.scene.candyUpgradeIconsMode == 1) { // 'Only Passive Unlocks' mode
this.candyUpgradeIcon[s].setVisible(
slotVisible && (
this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) &&
!(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)));
this.candyUpgradeOverlayIcon[s].setVisible(slotVisible && this.candyUpgradeIcon[s].visible);

} else if (this.scene.candyUpgradeIconsMode == 2) { // 'On' mode
this.candyUpgradeIcon[s].setVisible(
slotVisible && (
(this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) &&
!(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)) ||
(this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction] &&
this.scene.gameData.starterData[speciesId].valueReduction < 2)));
this.candyUpgradeOverlayIcon[s].setVisible(slotVisible && this.candyUpgradeIcon[s].visible);
}
}
} else {
changed = super.setCursor(cursor);
Expand Down Expand Up @@ -1758,6 +1809,22 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.starterValueLabels[cursor].setShadowColor(this.getTextColor(textStyle, true));
}

updateCandyUpgradeIcon(cursor: integer): void {
const speciesId = this.genSpecies[this.getGenCursorWithScroll()][cursor].speciesId;

if (this.scene.candyUpgradeIconsMode === 1) { // 'Only Passive Unlocks' mode:
this.candyUpgradeIcon[cursor].setVisible(this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED));
this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible);

} else if (this.scene.candyUpgradeIconsMode === 2) { // 'On' mode
this.candyUpgradeIcon[cursor].setVisible(
(this.scene.gameData.starterData[speciesId].candyCount >= getPassiveCandyCount(speciesStarters[speciesId]) && !(this.scene.gameData.starterData[speciesId].passiveAttr & PassiveAttr.UNLOCKED)) ||
(this.scene.gameData.starterData[speciesId].candyCount >= getValueReductionCandyCounts(speciesStarters[speciesId])[this.scene.gameData.starterData[speciesId].valueReduction]) &&
this.scene.gameData.starterData[speciesId].valueReduction < 2);
this.candyUpgradeOverlayIcon[cursor].setVisible(this.candyUpgradeIcon[cursor].visible);
}
}

tryUpdateValue(add?: integer): boolean {
const value = this.starterGens.reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.genSpecies[gen][this.starterCursors[i]].speciesId), 0);
const newValue = value + (add || 0);
Expand Down