Skip to content

Commit

Permalink
remove daily mode for avoid stuggle at loading
Browse files Browse the repository at this point in the history
  • Loading branch information
daidaiJ committed Dec 12, 2024
1 parent 0e1017b commit e4402a9
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 72 deletions.
15 changes: 15 additions & 0 deletions build/windows/wails.exe.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="com.wails.{{.Name}}" version="{{.Info.ProductVersion}}.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
11 changes: 6 additions & 5 deletions frontend/src/field/pokemon-sprite-sparkle-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class PokemonSpriteSparkleHandler {
}

onLapse(): void {
console.log("what 1111")
Array.from(this.sprites.values()).filter(s => !s.scene).map(s => this.sprites.delete(s));
for (const s of this.sprites.values()) {
if (!s.pipelineData["teraColor"] || !(s.pipelineData["teraColor"] as number[]).find(c => c)) {
Expand All @@ -30,13 +31,13 @@ export default class PokemonSpriteSparkleHandler {
const pokemon = s.parentContainer instanceof Pokemon ? s.parentContainer as Pokemon : null;
const parent = (pokemon || s).parentContainer;
const texture = s.texture;
const [ width, height ] = [ texture.source[0].width, texture.source[0].height ];
const [ pixelX, pixelY ] = [ Utils.randInt(width), Utils.randInt(height) ];
const [width, height] = [texture.source[0].width, texture.source[0].height];
const [pixelX, pixelY] = [Utils.randInt(width), Utils.randInt(height)];
const ratioX = s.width / width;
const ratioY = s.height / height;
const pixel = texture.manager.getPixel(pixelX, pixelY, texture.key, "__BASE");
if (pixel?.alpha) {
const [ xOffset, yOffset ] = [ -s.originX * s.width, -s.originY * s.height ];
const [xOffset, yOffset] = [-s.originX * s.width, -s.originY * s.height];
const sparkle = (s.scene as BattleScene).addFieldSprite(((pokemon?.x || 0) + s.x + pixelX * ratioX + xOffset), ((pokemon?.y || 0) + s.y + pixelY * ratioY + yOffset), "tera_sparkle");
sparkle.pipelineData["ignoreTimeTint"] = s.pipelineData["ignoreTimeTint"];
sparkle.setName("sprite-tera-sparkle");
Expand All @@ -49,7 +50,7 @@ export default class PokemonSpriteSparkleHandler {

add(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void {
if (!Array.isArray(sprites)) {
sprites = [ sprites ];
sprites = [sprites];
}
for (const s of sprites) {
if (this.sprites.has(s)) {
Expand All @@ -61,7 +62,7 @@ export default class PokemonSpriteSparkleHandler {

remove(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void {
if (!Array.isArray(sprites)) {
sprites = [ sprites ];
sprites = [sprites];
}
for (const s of sprites) {
this.sprites.delete(s);
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const startGame = async (manifest?: any) => {
createContainer: true
},
pixelArt: true,
pipeline: [ InvertPostFX ] as unknown as Phaser.Types.Core.PipelineConfig,
scene: [ LoadingScene, BattleScene ],
pipeline: [InvertPostFX] as unknown as Phaser.Types.Core.PipelineConfig,
scene: [LoadingScene, BattleScene],
version: version
});
game.sound.pauseOnBlur = false;
Expand All @@ -99,13 +99,8 @@ const startGame = async (manifest?: any) => {
}
};

fetch("/manifest.json")
.then(res => res.json())
.then(jsonResponse => {
startGame(jsonResponse.manifest);
}).catch(() => {
// Manifest not found (likely local build)
startGame();
});

// Manifest not found (likely local build)
startGame();

export default game;
6 changes: 3 additions & 3 deletions frontend/src/modifier/modifier-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1562,9 +1562,9 @@ export const modifierTypes = {

MINI_BLACK_HOLE: () => new TurnHeldItemTransferModifierType("modifierType:ModifierType.MINI_BLACK_HOLE", "mini_black_hole"),

VOUCHER: () => new AddVoucherModifierType(VoucherType.REGULAR, 1),
VOUCHER_PLUS: () => new AddVoucherModifierType(VoucherType.PLUS, 1),
VOUCHER_PREMIUM: () => new AddVoucherModifierType(VoucherType.PREMIUM, 1),
VOUCHER: () => new AddVoucherModifierType(VoucherType.REGULAR, 10),
VOUCHER_PLUS: () => new AddVoucherModifierType(VoucherType.PLUS, 10),
VOUCHER_PREMIUM: () => new AddVoucherModifierType(VoucherType.PREMIUM, 10),

GOLDEN_POKEBALL: () => new ModifierType("modifierType:ModifierType.GOLDEN_POKEBALL", "pb_gold", (type, _args) => new ExtraModifierModifier(type), undefined, "se/pb_bounce_1"),
SILVER_POKEBALL: () => new ModifierType("modifierType:ModifierType.SILVER_POKEBALL", "pb_silver", (type, _args) => new TempExtraModifierModifier(type, 100), undefined, "se/pb_bounce_1"),
Expand Down
1 change: 1 addition & 0 deletions frontend/src/phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Phase {
if (this.scene.abilityBar.shown) {
this.scene.abilityBar.resetAutoHideTimer();
}

}

end() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/phases/attempt-run-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class AttemptRunPhase extends PokemonPhase {
this.scene.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500);

this.scene.tweens.add({
targets: [ this.scene.arenaEnemy, enemyField ].flat(),
targets: [this.scene.arenaEnemy, enemyField].flat(),
alpha: 0,
duration: 250,
ease: "Sine.easeIn",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/phases/battle-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class BattlePhase extends Phase {
const tintSprites = this.scene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct?
for (let i = 0; i < sprites.length; i++) {
const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2;
[ sprites[i], tintSprites[i] ].map(sprite => {
[sprites[i], tintSprites[i]].map(sprite => {
if (visible) {
sprite.x = trainerSlot || sprites.length < 2 ? 0 : i ? 16 : -16;
}
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/phases/command-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class CommandPhase extends FieldPhase {

// If the Pokemon has applied Commander's effects to its ally, skip this command
if (this.scene.currentBattle?.double && this.getPokemon().getAlly()?.getTag(BattlerTagType.COMMANDED)?.getSourcePokemon(this.scene) === this.getPokemon()) {
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.FIGHT, move: { move: Moves.NONE, targets: []}, skip: true };
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.FIGHT, move: { move: Moves.NONE, targets: [] }, skip: true };
}

// Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP.
Expand All @@ -76,8 +76,8 @@ export class CommandPhase extends FieldPhase {
const moveQueue = playerPokemon.getMoveQueue();

while (moveQueue.length && moveQueue[0]
&& moveQueue[0].move && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move)
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct?
&& moveQueue[0].move && (!playerPokemon.getMoveset().find(m => m?.moveId === moveQueue[0].move)
|| !playerPokemon.getMoveset()[playerPokemon.getMoveset().findIndex(m => m?.moveId === moveQueue[0].move)]!.isUsable(playerPokemon, moveQueue[0].ignorePP))) { // TODO: is the bang correct?
moveQueue.shift();
}

Expand Down Expand Up @@ -111,13 +111,13 @@ export class CommandPhase extends FieldPhase {
case Command.FIGHT:
let useStruggle = false;
if (cursor === -1 ||
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) {
playerPokemon.trySelectMove(cursor, args[0] as boolean) ||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m?.isUsable(playerPokemon)).length)) {
const moveId = !useStruggle ? cursor > -1 ? playerPokemon.getMoveset()[cursor]!.moveId : Moves.NONE : Moves.STRUGGLE; // TODO: is the bang correct?
const turnCommand: TurnCommand = { command: Command.FIGHT, cursor: cursor, move: { move: moveId, targets: [], ignorePP: args[0] }, args: args };
const moveTargets: MoveTargetSet = args.length < 3 ? getMoveTargets(playerPokemon, moveId) : args[2];
if (!moveId) {
turnCommand.targets = [ this.fieldIndex ];
turnCommand.targets = [this.fieldIndex];
}
console.log(moveTargets, getPokemonNameWithAffix(playerPokemon));
if (moveTargets.targets.length > 1 && moveTargets.multiple) {
Expand All @@ -138,9 +138,9 @@ export class CommandPhase extends FieldPhase {

// Decides between a Disabled, Not Implemented, or No PP translation message
const errorMessage =
playerPokemon.isMoveRestricted(move.moveId, playerPokemon)
? playerPokemon.getRestrictingTag(move.moveId, playerPokemon)!.selectionDeniedText(playerPokemon, move.moveId)
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
playerPokemon.isMoveRestricted(move.moveId, playerPokemon)
? playerPokemon.getRestrictingTag(move.moveId, playerPokemon)!.selectionDeniedText(playerPokemon, move.moveId)
: move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP";
const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator

this.scene.ui.showText(i18next.t(errorMessage, { moveName: moveName }), null, () => {
Expand All @@ -151,7 +151,7 @@ export class CommandPhase extends FieldPhase {
break;
case Command.BALL:
const notInDex = (this.scene.getEnemyField().filter(p => p.isActive(true)).some(p => !p.scene.gameData.dexData[p.species.speciesId].caughtAttr) && this.scene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarterCosts).length - 1);
if (this.scene.arena.biomeType === Biome.END && (!this.scene.gameMode.isClassic || this.scene.gameMode.isFreshStartChallenge() || notInDex )) {
if (this.scene.arena.biomeType === Biome.END && (!this.scene.gameMode.isClassic || this.scene.gameMode.isFreshStartChallenge() || notInDex)) {
this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex);
this.scene.ui.setMode(Mode.MESSAGE);
this.scene.ui.showText(i18next.t("battle:noPokeballForce"), null, () => {
Expand Down Expand Up @@ -229,7 +229,7 @@ export class CommandPhase extends FieldPhase {
: { command: Command.RUN };
success = true;
if (!isSwitch && this.fieldIndex) {
currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true;
currentBattle.turnCommands[this.fieldIndex - 1]!.skip = true;
}
} else if (trappedAbMessages.length > 0) {
if (!isSwitch) {
Expand Down
58 changes: 28 additions & 30 deletions frontend/src/phases/title-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,35 +129,27 @@ export class TitlePhase extends Phase {
return true;
}
},
{
label: i18next.t("menu:loadGame"),
handler: () => {
this.scene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD,
(slotId: integer) => {
if (slotId === -1) {
return this.showOptions();
}
this.loadSaveSlot(slotId);
});
return true;
}
},
{
label: i18next.t("menu:dailyRun"),
handler: () => {
this.initDailyRun();
return true;
},
keepOpen: true
},
{
label: i18next.t("menu:settings"),
handler: () => {
this.scene.ui.setOverlayMode(Mode.SETTINGS);
return true;
{
label: i18next.t("menu:loadGame"),
handler: () => {
this.scene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD,
(slotId: integer) => {
if (slotId === -1) {
return this.showOptions();
}
this.loadSaveSlot(slotId);
});
return true;
}
},
keepOpen: true
});
{
label: i18next.t("menu:settings"),
handler: () => {
this.scene.ui.setOverlayMode(Mode.SETTINGS);
return true;
},
keepOpen: true
});
const config: OptionSelectConfig = {
options: options,
noCancel: true,
Expand Down Expand Up @@ -221,7 +213,7 @@ export class TitlePhase extends Phase {

const modifiers: Modifier[] = Array(3).fill(null).map(() => modifierTypes.EXP_SHARE().withIdFromFunc(modifierTypes.EXP_SHARE).newModifier())
.concat(Array(3).fill(null).map(() => modifierTypes.GOLDEN_EXP_CHARM().withIdFromFunc(modifierTypes.GOLDEN_EXP_CHARM).newModifier()))
.concat([ modifierTypes.MAP().withIdFromFunc(modifierTypes.MAP).newModifier() ])
.concat([modifierTypes.MAP().withIdFromFunc(modifierTypes.MAP).newModifier()])
.concat(getDailyRunStarterModifiers(party))
.filter((m) => m !== null);

Expand All @@ -243,7 +235,9 @@ export class TitlePhase extends Phase {
};

// If Online, calls seed fetch from db to generate daily run. If Offline, generates a daily run based on current date.
if (!Utils.isLocal || Utils.isLocalServerConnected) {
if (false) {
console.log(!Utils.isLocal)
console.log(Utils.isLocalServerConnected)
fetchDailyRunSeed().then(seed => {
if (seed) {
generateDaily(seed);
Expand All @@ -257,6 +251,7 @@ export class TitlePhase extends Phase {
generateDaily(btoa(new Date().toISOString().substring(0, 10)));
}
});
console.log("init daily run ")
}

end(): void {
Expand Down Expand Up @@ -299,6 +294,9 @@ export class TitlePhase extends Phase {
this.scene.validateVoucher(vouchers[achv]);
}
}
console.log("stop here")



super.end();
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/plugins/api/pokerogue-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ export class PokerogueApi extends ApiBase {
*/
public async getGameTitleStats() {
try {
const response = await this.doGet("/game/titlestats");
return (await response.json()) as TitleStatsResponse;
return {
playerCount: 1,
battleCount: 1
};
} catch (err) {
console.warn("Could not get game title stats!", err);
return null;
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function randSeedShuffle<T>(items: T[]): T[] {
const newArray = items.slice(0);
for (let i = items.length - 1; i > 0; i--) {
const j = Phaser.Math.RND.integerInRange(0, i);
[ newArray[i], newArray[j] ] = [ newArray[j], newArray[i] ];
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
}
return newArray;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ export function formatLargeNumber(count: integer, threshold: integer): string {
}

// Abbreviations from 10^0 to 10^33
const AbbreviationsLargeNumber: string[] = [ "", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d" ];
const AbbreviationsLargeNumber: string[] = ["", "K", "M", "B", "t", "q", "Q", "s", "S", "o", "n", "d"];

export function formatFancyLargeNumber(number: number, rounded: number = 3): string {
let exponent: number;
Expand Down Expand Up @@ -256,7 +256,7 @@ export const sessionIdKey = "pokerogue_sessionId";
// Check if the current hostname is 'localhost' or an IP address, and ensure a port is specified
export const isLocal = (
(window.location.hostname === "localhost" ||
/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) &&
/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) &&
window.location.port !== "") || window.location.hostname === "";

/**
Expand All @@ -271,7 +271,7 @@ export const localServerUrl = import.meta.env.VITE_SERVER_URL ?? `http://${windo
*/
export const apiUrl = localServerUrl ?? "https://api.pokerogue.net";
// used to disable api calls when isLocal is true and a server is not found
export let isLocalServerConnected = true;
export let isLocalServerConnected = false;

export const isBeta = import.meta.env.MODE === "beta"; // this checks to see if the env mode is development. Technically this gives the same value for beta AND for dev envs

Expand Down Expand Up @@ -324,7 +324,7 @@ export async function localPing() {
}

/** Alias for the constructor of a class */
export type Constructor<T> = new(...args: unknown[]) => T;
export type Constructor<T> = new (...args: unknown[]) => T;

export class BooleanHolder {
public value: boolean;
Expand Down Expand Up @@ -386,7 +386,7 @@ export function rgbToHsv(r: integer, g: integer, b: integer) {
const v = Math.max(r, g, b);
const c = v - Math.min(r, g, b);
const h = c && ((v === r) ? (g - b) / c : ((v === g) ? 2 + (b - r) / c : 4 + (r - g) / c));
return [ 60 * (h < 0 ? h + 6 : h), v && c / v, v ];
return [60 * (h < 0 ? h + 6 : h), v && c / v, v];
}

/**
Expand All @@ -395,8 +395,8 @@ export function rgbToHsv(r: integer, g: integer, b: integer) {
* @param {Array} rgb2 Second RGB color in array
*/
export function deltaRgb(rgb1: integer[], rgb2: integer[]): integer {
const [ r1, g1, b1 ] = rgb1;
const [ r2, g2, b2 ] = rgb2;
const [r1, g1, b1] = rgb1;
const [r2, g2, b2] = rgb2;
const drp2 = Math.pow(r1 - r2, 2);
const dgp2 = Math.pow(g1 - g2, 2);
const dbp2 = Math.pow(b1 - b2, 2);
Expand All @@ -406,7 +406,7 @@ export function deltaRgb(rgb1: integer[], rgb2: integer[]): integer {
}

export function rgbHexToRgba(hex: string) {
const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i) ?? [ "000000", "00", "00", "00" ];
const color = hex.match(/^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i) ?? ["000000", "00", "00", "00"];
return {
r: parseInt(color[1], 16),
g: parseInt(color[2], 16),
Expand Down
7 changes: 7 additions & 0 deletions wails.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@
"author": {
"name": "pandazhangs",
"email": "[email protected]"
},
"Info": {
"companyName": "ForFunnyDemo",
"productName": "Wails Vite",
"productVersion": "1.0.0",
"copyright": "Copyright©2024PandaZhangs",
"comments": "Built using Wails (https://wails.io)"
}
}

0 comments on commit e4402a9

Please sign in to comment.