-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
83 lines (71 loc) · 2.26 KB
/
Copy pathserver.js
File metadata and controls
83 lines (71 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import chalk from "chalk";
import figlet from "figlet";
import readlineSync from "readline-sync";
import { startGame } from "./game.js";
// 로비 화면을 출력하는 함수
function displayLobby() {
console.clear();
// 타이틀 텍스트
console.log(
chalk.cyan(
figlet.textSync("RL- Javascript", {
font: "Standard",
horizontalLayout: "default",
verticalLayout: "default",
})
)
);
// 상단 경계선
const line = chalk.magentaBright("=".repeat(50));
console.log(line);
// 게임 이름
console.log(chalk.yellowBright.bold("CLI 게임에 오신것을 환영합니다!"));
// 설명 텍스트
console.log(chalk.green("옵션을 선택해주세요."));
console.log();
// 옵션들
console.log(chalk.blue("1.") + chalk.white(" 새로운 게임 시작"));
console.log(chalk.blue("2.") + chalk.white(" 업적 확인하기"));
console.log(chalk.blue("3.") + chalk.white(" 옵션"));
console.log(chalk.blue("4.") + chalk.white(" 종료"));
// 하단 경계선
console.log(line);
// 하단 설명
console.log(chalk.gray("1-4 사이의 수를 입력한 뒤 엔터를 누르세요."));
}
// 유저 입력을 받아 처리하는 함수
function handleUserInput() {
const choice = readlineSync.question("입력: ");
switch (choice) {
case "1":
console.log(chalk.green("게임을 시작합니다."));
// 여기에서 새로운 게임 시작 로직을 구현
startGame();
break;
case "2":
console.log(chalk.yellow("구현 준비중입니다.. 게임을 시작하세요"));
// 업적 확인하기 로직을 구현
handleUserInput();
break;
case "3":
console.log(chalk.blue("구현 준비중입니다.. 게임을 시작하세요"));
// 옵션 메뉴 로직을 구현
handleUserInput();
break;
case "4":
console.log(chalk.red("게임을 종료합니다."));
// 게임 종료 로직을 구현
process.exit(0); // 게임 종료
break;
default:
console.log(chalk.red("올바른 선택을 하세요."));
handleUserInput(); // 유효하지 않은 입력일 경우 다시 입력 받음
}
}
// 게임 시작 함수
function start() {
displayLobby();
handleUserInput();
}
// 게임 실행
start();