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

chore: dev-be -> main #235

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions be/gameServer/src/common/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export enum ErrorMessages {
ALL_PLAYERS_MUST_BE_READY = 'AllPlayersMustBeReady',
NOT_ENOUGH_PLAYERS = 'NotEnoughPlayers',
VALIDATION_FAILED = 'ValidationFailed',
GAME_ALREADY_IN_PROGRESS = 'GameAlreadyInProgress',
}

export enum RedisKeys {
Expand Down
3 changes: 3 additions & 0 deletions be/gameServer/src/modules/games/dto/game-data.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { PlayerDataDto } from '../../players/dto/player-data.dto';

export class GameDataDto {
gameId: string;
players: PlayerDataDto[];
alivePlayers: string[];
currentTurn: number;
currentPlayer: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,19 @@ export class VoiceProcessingResultDto {
description: '결과',
})
result: string;

@ApiProperty({
example: '3옥도#',
type: String,
description: '음계',
required: false,
})
note?: string;

@ApiProperty({
example: 99,
type: Number,
description: '발음 게임 점수',
})
procounceScore?: number;
}
81 changes: 36 additions & 45 deletions be/gameServer/src/modules/games/games-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ const SAMPLE_DATA = [
timeLimit: 6,
lyrics: '중앙청 창살은 쌍창살이고 시청의 창살은 외창살이다.',
},
{
timeLimit: 4,
lyrics: '페페페페페페페페페페',
},
];

export function createTurnData(
Expand All @@ -38,8 +34,9 @@ export function createTurnData(
const gameModes = [
GameMode.PRONUNCIATION,
GameMode.CLEOPATRA,
// GameMode.CLEOPATRA,
// GameMode.CLEOPATRA,
GameMode.CLEOPATRA,
GameMode.CLEOPATRA,
GameMode.CLEOPATRA,
];
const gameMode = gameModes[Math.floor(Math.random() * gameModes.length)];

Expand Down Expand Up @@ -94,11 +91,15 @@ export function removePlayerFromGame(
gameData: GameDataDto,
playerNickname: string,
): void {
gameData.alivePlayers = gameData.alivePlayers.filter(
(player: string) => player !== playerNickname,
);

gameData.rank.unshift(playerNickname);
if (gameData.alivePlayers.includes(playerNickname)) {
gameData.alivePlayers = gameData.alivePlayers.filter(
(player: string) => player !== playerNickname,
);

if (!gameData.rank.includes(playerNickname)) {
gameData.rank.unshift(playerNickname);
}
}
}

export function noteToNumber(note: string): number {
Expand All @@ -125,23 +126,29 @@ export function noteToNumber(note: string): number {
}

export function numberToNote(number: number): string {
const notes = [
'C',
'C#',
'D',
'D#',
'E',
'F',
'F#',
'G',
'G#',
'A',
'A#',
'B',
];
const koreanNoteNames = {
C: '도',
'C#': '도#',
D: '레',
'D#': '레#',
E: '미',
F: '파',
'F#': '파#',
G: '솔',
'G#': '솔#',
A: '라',
'A#': '라#',
B: '시',
};

const noteNames = Object.keys(koreanNoteNames);
const noteBase = number % 12;
const octave = Math.floor(number / 12) - 1;
const noteIndex = Math.round(number) % 12;
return `${notes[noteIndex]}${octave}`;

const noteName = noteNames[noteBase];
const koreanNote = koreanNoteNames[noteName];

return `${octave}옥${koreanNote}`;
}

export function updatePreviousPlayers(
Expand All @@ -154,22 +161,6 @@ export function updatePreviousPlayers(
gameData.previousPlayers.push(playerNickname);
}

const PRONOUNCE_SCORE_ORIGINAL_THRESOLHD = 50;
const PRONOUNCE_SCORE_THRESOLHD = 90;
const INCREMENT = 2 / 7;
const DECREMENT = 3;

export function transformScore(originalScore) {
let transformed;
if (originalScore >= PRONOUNCE_SCORE_ORIGINAL_THRESOLHD) {
transformed =
PRONOUNCE_SCORE_THRESOLHD +
(originalScore - PRONOUNCE_SCORE_ORIGINAL_THRESOLHD) * INCREMENT;
} else {
transformed =
PRONOUNCE_SCORE_THRESOLHD -
(PRONOUNCE_SCORE_ORIGINAL_THRESOLHD - originalScore) * DECREMENT;
}

return Math.max(Math.min(Math.round(transformed), 100), 0);
export function transformScore(originalScore: number) {
return Math.min(originalScore + 50, 100);
}
131 changes: 0 additions & 131 deletions be/gameServer/src/modules/games/games.gateway.spec.ts

This file was deleted.

Loading
Loading