Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/restore-apple…
Browse files Browse the repository at this point in the history
…-game
  • Loading branch information
0chil committed Feb 11, 2025
2 parents 8353cb9 + 1845873 commit 833b4fa
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 36 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Vercel CLI
run: npm install -g [email protected]

- name: Deploy to Vercel Action
uses: BetaHuhn/deploy-to-vercel-action@latest
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/develop-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ jobs:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 8
version: 9

- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- name: ⎔ Install pnpm
run: npm install -g pnpm

- name: ⎔ Install dependencies
run: pnpm install

- name: ⎔ Build
run: pnpm run build
1 change: 1 addition & 0 deletions src/constants/localStorage.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export const KEY_HAPTIC_ENABLED = 'haptic-enabled';
export const KEY_PREFIX_STATS = 'stats-';
export const KEY_PREFIX_BEST_SCORE = 'stats-best-score-';
export const KEY_GAME_MODE = 'game-mode';
export const KEY_GAME_SETTINGS = 'game-settings';
4 changes: 3 additions & 1 deletion src/pages/games/SnackGame/game/util/audio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PlayOptions, Sound, sound } from '@pixi/sound';
import { Sound, sound } from '@pixi/sound';
import gsap from 'gsap';

import type { PlayOptions } from '@pixi/sound';

/**
* 배경 음악을 관리하며, 한 번에 하나의 오디오 파일만 루프로 재생하고,
* 새로운 음악이 요청될 때 이전 음악을 페이드 아웃하거나 정지합니다.
Expand Down
5 changes: 3 additions & 2 deletions src/pages/games/SnackGame/game/util/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class StorageWrapper {
this.setString(key, String(value));
}

/** 저장소에서 Boolean 값을 가져오거나, 값이 'true'가 아닌 경우 false를 반환합니다. */
/** 저장소에서 Boolean 값을 가져오거나, 값을 가져올 수 없는 경우 undefined를 반환합니다. */
public getBoolean(key: string) {
const str = this.getString(key) ?? '';
const str = this.getString(key);
if (!str) return undefined;
return str === 'true';
}
}
Expand Down
63 changes: 34 additions & 29 deletions src/pages/games/SnackGame/game/util/userSetting.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,85 @@
import {
KEY_GAME_MODE,
KEY_VOLUME_MASTER,
KEY_VOLUME_BGM,
KEY_VOLUME_SFX,
KEY_HAPTIC_ENABLED,
} from '@constants/localStorage.constant';
import { KEY_GAME_SETTINGS } from '@constants/localStorage.constant';

import { bgm, setMasterVolume, sfx } from './audio';
import { storage } from './storage';
import { SnackGameMode, snackGameModes } from '../snackGame/SnackGameUtil';

/**
* 볼륨 및 게임 모드의 지속적인 사용자 설정.
*/
class UserSettings {
private settings: {
hapticEnabled: boolean;
volumeMaster: number;
volumeBGM: number;
volumeSFX: number;
};

constructor() {
this.settings = this.loadSettings();
setMasterVolume(this.getMasterVolume());
bgm.setVolume(this.getBgmVolume());
sfx.setVolume(this.getSfxVolume());
}

/** Get current game mode */
public getGameMode() {
const mode = storage.getString(KEY_GAME_MODE) as SnackGameMode;
return snackGameModes.includes(mode) ? mode : 'default';
private loadSettings() {
return storage.getObject(KEY_GAME_SETTINGS) ?? this.getDefaultSettings();
}

private getDefaultSettings() {
return {
hapticEnabled: true,
volumeMaster: 0.5,
volumeBGM: 1,
volumeSFX: 1,
};
}

/** Set current game mode */
public setGameMode(mode: SnackGameMode) {
if (!snackGameModes.includes(mode)) {
throw new Error('Invalid game mode: ' + mode);
}
return storage.setString(KEY_GAME_MODE, mode);
private saveSettings() {
storage.setObject(KEY_GAME_SETTINGS, this.settings);
}

/** 전체 사운드 볼륨을 가져옵니다. */
public getMasterVolume() {
return storage.getNumber(KEY_VOLUME_MASTER) ?? 0.5;
return this.settings.volumeMaster;
}

/** 전체 사운드 볼륨을 설정합니다. */
public setMasterVolume(value: number) {
setMasterVolume(value);
storage.setNumber(KEY_VOLUME_MASTER, value);
this.settings.volumeMaster = value;
this.saveSettings();
}

/** 배경 음악 볼륨을 가져옵니다. */
public getBgmVolume() {
return storage.getNumber(KEY_VOLUME_BGM) ?? 1;
return this.settings.volumeBGM;
}

/** 배경 음악 볼륨을 설정합니다. */
public setBgmVolume(value: number) {
bgm.setVolume(value);
storage.setNumber(KEY_VOLUME_BGM, value);
this.settings.volumeBGM = value;
this.saveSettings();
}

/** 효과음 볼륨을 가져옵니다. */
public getSfxVolume() {
return storage.getNumber(KEY_VOLUME_SFX) ?? 1;
return this.settings.volumeSFX;
}

/** 효과음 볼륨을 설정합니다. */
public setSfxVolume(value: number) {
sfx.setVolume(value);
storage.setNumber(KEY_VOLUME_SFX, value);
this.settings.volumeSFX = value;
this.saveSettings();
}

/** 햅틱 활성화 여부를 설정합니다. */
public setHapticEnabled(value: boolean) {
storage.setBoolean(KEY_HAPTIC_ENABLED, value);
this.settings.hapticEnabled = value;
this.saveSettings();
}

/** 햅틱 활성화 여부를 가져옵니다. */
public getHapticEnabled() {
return storage.getBoolean(KEY_HAPTIC_ENABLED) ?? true;
return this.settings.hapticEnabled;
}
}

Expand Down

0 comments on commit 833b4fa

Please sign in to comment.