labag 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +141 -0
- package/dist/json/PDatas.json +38 -0
- package/dist/types/JsonLaBaG.d.ts +10 -0
- package/dist/types/JsonLaBaG.js +63 -0
- package/dist/types/LaBaG.d.ts +47 -0
- package/dist/types/LaBaG.js +174 -0
- package/dist/types/Mode.d.ts +11 -0
- package/dist/types/Mode.js +2 -0
- package/dist/types/P.d.ts +14 -0
- package/dist/types/P.js +23 -0
- package/dist/types/PlayLaBaG.d.ts +9 -0
- package/dist/types/PlayLaBaG.js +77 -0
- package/dist/utils/RandInt.d.ts +1 -0
- package/dist/utils/RandInt.js +8 -0
- package/package.json +18 -0
- package/src/index.ts +143 -0
- package/src/json/PDatas.json +38 -0
- package/src/types/JsonLaBaG.ts +70 -0
- package/src/types/LaBaG.ts +221 -0
- package/src/types/Mode.ts +13 -0
- package/src/types/P.ts +34 -0
- package/src/types/PlayLaBaG.ts +80 -0
- package/src/types/declaration.d.ts +5 -0
- package/src/utils/RandInt.ts +5 -0
- package/tsconfig.json +115 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import PDatas from "@/json/PDatas.json";
|
|
2
|
+
import { P, PData } from "@/types/P";
|
|
3
|
+
import { LaBaG } from "./types/LaBaG";
|
|
4
|
+
import { Mode, ModeNames } from "./types/Mode";
|
|
5
|
+
import { RandInt } from "./utils/RandInt";
|
|
6
|
+
import { PlayLaBaG } from "./types/PlayLaBaG";
|
|
7
|
+
import { JsonLaBaG } from "./types/JsonLaBaG";
|
|
8
|
+
|
|
9
|
+
Object.values(PDatas).forEach((Pdata: PData) => {
|
|
10
|
+
new P(Pdata.code, Pdata.scores, Pdata.rates);
|
|
11
|
+
});
|
|
12
|
+
const Modes: Record<Exclude<ModeNames, "Normal">, Mode> = {
|
|
13
|
+
// 超級阿禾
|
|
14
|
+
SuperHHH: {
|
|
15
|
+
InMode: false,
|
|
16
|
+
Rate: 15,
|
|
17
|
+
Times: 0,
|
|
18
|
+
Score: 0,
|
|
19
|
+
RandNum: 0,
|
|
20
|
+
Random(): void {
|
|
21
|
+
this.RandNum = RandInt();
|
|
22
|
+
},
|
|
23
|
+
Judge(Game: LaBaG): void {
|
|
24
|
+
if (
|
|
25
|
+
!Game.GameRunning() ||
|
|
26
|
+
this.RandNum === undefined ||
|
|
27
|
+
this.Times === undefined ||
|
|
28
|
+
this.Rate === undefined ||
|
|
29
|
+
this.Score === undefined
|
|
30
|
+
) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.Score = 0; // Reset score
|
|
35
|
+
if (this.InMode) {
|
|
36
|
+
this.Times -= 1;
|
|
37
|
+
|
|
38
|
+
if (Game.Ps.every((p) => p?.Code === "B")) {
|
|
39
|
+
this.Times += 2;
|
|
40
|
+
}
|
|
41
|
+
if (this.Times <= 0) {
|
|
42
|
+
this.InMode = false;
|
|
43
|
+
Game.JudgeMode();
|
|
44
|
+
Game.ModeToScreen = true;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
if (this.RandNum <= this.Rate && Game.Ps.some((p) => p?.Code === "B")) {
|
|
48
|
+
this.InMode = true;
|
|
49
|
+
this.Times += 6;
|
|
50
|
+
Game.ModeToScreen = true;
|
|
51
|
+
if (Modes.PiKaChu.InMode) {
|
|
52
|
+
Modes.PiKaChu.InMode = false;
|
|
53
|
+
}
|
|
54
|
+
// 超級阿禾加倍
|
|
55
|
+
if (Game.Ps.every((p) => p?.Code === "B")) {
|
|
56
|
+
this.Score = Math.round((Game.Score * Game.ScoreTime) / 2);
|
|
57
|
+
Game.MarginScore += this.Score;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
GreenWei: {
|
|
65
|
+
InMode: false,
|
|
66
|
+
Rate: 35,
|
|
67
|
+
Times: 0,
|
|
68
|
+
Score: 0, // 咖波累積數
|
|
69
|
+
RandNum: 0,
|
|
70
|
+
Random(): void {
|
|
71
|
+
this.RandNum = RandInt();
|
|
72
|
+
},
|
|
73
|
+
Judge(Game: LaBaG): void {
|
|
74
|
+
if (
|
|
75
|
+
!Game.GameRunning() ||
|
|
76
|
+
this.RandNum === undefined ||
|
|
77
|
+
this.Times === undefined ||
|
|
78
|
+
this.Rate === undefined ||
|
|
79
|
+
this.Score === undefined
|
|
80
|
+
) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this.InMode) {
|
|
85
|
+
this.Times -= 1;
|
|
86
|
+
|
|
87
|
+
if (Game.Ps.every((p) => p?.Code === "A")) {
|
|
88
|
+
this.Times += 1;
|
|
89
|
+
}
|
|
90
|
+
if (this.Times <= 0) {
|
|
91
|
+
this.InMode = false;
|
|
92
|
+
Game.JudgeMode();
|
|
93
|
+
Game.ModeToScreen = true;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
if (
|
|
97
|
+
this.RandNum <= this.Rate &&
|
|
98
|
+
Game.Ps.every((p) => p?.Code === "A")
|
|
99
|
+
) {
|
|
100
|
+
this.InMode = true;
|
|
101
|
+
this.Times += 2;
|
|
102
|
+
Game.ModeToScreen = true;
|
|
103
|
+
if (Modes.PiKaChu.InMode) {
|
|
104
|
+
Modes.PiKaChu.InMode = false;
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
} else if (this.Score >= 20) {
|
|
108
|
+
// 咖波累積數達到 20
|
|
109
|
+
this.InMode = true;
|
|
110
|
+
this.Times += 2;
|
|
111
|
+
this.Score = 0;
|
|
112
|
+
Game.ModeToScreen = true;
|
|
113
|
+
if (Modes.PiKaChu.InMode) {
|
|
114
|
+
Modes.PiKaChu.InMode = false;
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
PiKaChu: {
|
|
123
|
+
InMode: false,
|
|
124
|
+
Times: 0,
|
|
125
|
+
Judge(Game: LaBaG) {
|
|
126
|
+
if (!Game.GameRunning() && this.Times !== undefined) {
|
|
127
|
+
// 關掉其他模式
|
|
128
|
+
Modes.SuperHHH.InMode = false;
|
|
129
|
+
Modes.GreenWei.InMode = false;
|
|
130
|
+
if (Game.Ps.some((p) => p?.Code === "E")) {
|
|
131
|
+
this.InMode = true;
|
|
132
|
+
Game.Played -= 5;
|
|
133
|
+
this.Times += 1;
|
|
134
|
+
Game.ModeToScreen = true;
|
|
135
|
+
} else {
|
|
136
|
+
this.InMode = false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export { LaBaG, PlayLaBaG, JsonLaBaG, Modes, ModeNames, P, PData, PDatas };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Gss": {
|
|
3
|
+
"name": "咖波",
|
|
4
|
+
"code": "A",
|
|
5
|
+
"rates": { "Normal": 36, "SuperHHH": 19, "GreenWei": 36, "PiKaChu": 36 },
|
|
6
|
+
"scores": [800, 400, 180]
|
|
7
|
+
},
|
|
8
|
+
"Hhh": {
|
|
9
|
+
"name": "阿禾",
|
|
10
|
+
"code": "B",
|
|
11
|
+
"rates": { "Normal": 24, "SuperHHH": 5, "GreenWei": 24, "PiKaChu": 24 },
|
|
12
|
+
"scores": [1500, 800, 300]
|
|
13
|
+
},
|
|
14
|
+
"Hentai": {
|
|
15
|
+
"name": "猥褻男",
|
|
16
|
+
"code": "C",
|
|
17
|
+
"rates": { "Normal": 17, "SuperHHH": 19, "GreenWei": 17, "PiKaChu": 17 },
|
|
18
|
+
"scores": [2500, 1200, 500]
|
|
19
|
+
},
|
|
20
|
+
"Handsun": {
|
|
21
|
+
"name": "文傑",
|
|
22
|
+
"code": "D",
|
|
23
|
+
"rates": { "Normal": 12, "SuperHHH": 19, "GreenWei": 12, "PiKaChu": 12 },
|
|
24
|
+
"scores": [2900, 1450, 690]
|
|
25
|
+
},
|
|
26
|
+
"Kachu": {
|
|
27
|
+
"name": "皮卡丘",
|
|
28
|
+
"code": "E",
|
|
29
|
+
"rates": { "Normal": 8, "SuperHHH": 19, "GreenWei": 8, "PiKaChu": 8 },
|
|
30
|
+
"scores": [12000, 8000, 1250]
|
|
31
|
+
},
|
|
32
|
+
"Rrr": {
|
|
33
|
+
"name": "館長",
|
|
34
|
+
"code": "F",
|
|
35
|
+
"rates": { "Normal": 3, "SuperHHH": 19, "GreenWei": 3, "PiKaChu": 3 },
|
|
36
|
+
"scores": [20000, 12000, 2500]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { P } from "./P";
|
|
2
|
+
import { BaseLaBaG } from "./LaBaG";
|
|
3
|
+
import { Modes } from "..";
|
|
4
|
+
|
|
5
|
+
export class JsonLaBaG extends BaseLaBaG {
|
|
6
|
+
jsonData: BaseLaBaG["AllData"];
|
|
7
|
+
dataIndex: number;
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.jsonData = {};
|
|
11
|
+
this.dataIndex = 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SetupData(data: BaseLaBaG["AllData"]): void {
|
|
15
|
+
this.jsonData = data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Reset(): void {
|
|
19
|
+
super.Reset();
|
|
20
|
+
this.dataIndex = 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Random(): void {
|
|
24
|
+
const currData = this.jsonData[this.dataIndex];
|
|
25
|
+
if (!currData) {
|
|
26
|
+
super.Random();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const RandNums: [number, number, number] = [
|
|
32
|
+
currData["RandNum[0]"] ?? 0,
|
|
33
|
+
currData["RandNum[1]"] ?? 0,
|
|
34
|
+
currData["RandNum[2]"] ?? 0,
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
Modes.SuperHHH.RandNum = currData["SuperHHH"] ?? 0;
|
|
38
|
+
Modes.GreenWei.RandNum = currData["GreenWei"] ?? 0;
|
|
39
|
+
|
|
40
|
+
const RateRange = this.RateRanges[this.NowMode()];
|
|
41
|
+
const PCodes = Object.keys(P.Obj);
|
|
42
|
+
|
|
43
|
+
RandNums.forEach((RandNum, i) => {
|
|
44
|
+
const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
|
|
45
|
+
if (code) {
|
|
46
|
+
this.Ps[i] = P.Obj[code];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 累積 GreenWei 分數
|
|
51
|
+
this.Ps.forEach((p) => {
|
|
52
|
+
if (
|
|
53
|
+
p?.Code === "A" &&
|
|
54
|
+
Modes.GreenWei.Score !== undefined &&
|
|
55
|
+
Modes.GreenWei.Score < 20
|
|
56
|
+
) {
|
|
57
|
+
Modes.GreenWei.Score += 1;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Error in Random():", error);
|
|
62
|
+
super.Random();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Result(): void {
|
|
67
|
+
super.Result();
|
|
68
|
+
this.dataIndex++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { P } from "@/types/P";
|
|
2
|
+
import { Mode, ModeNames } from "@/types/Mode";
|
|
3
|
+
import { RandInt } from "../utils/RandInt";
|
|
4
|
+
import { Modes } from "..";
|
|
5
|
+
|
|
6
|
+
export interface LaBaG {
|
|
7
|
+
AllData: Record<string, Record<string, number>>;
|
|
8
|
+
OneData: Record<string, number>;
|
|
9
|
+
DataIndex: number;
|
|
10
|
+
|
|
11
|
+
Times: number;
|
|
12
|
+
Played: number;
|
|
13
|
+
|
|
14
|
+
Score: number;
|
|
15
|
+
MarginScore: number;
|
|
16
|
+
|
|
17
|
+
Ps: [P | null, P | null, P | null];
|
|
18
|
+
|
|
19
|
+
RateRanges: Record<ModeNames, number[]>;
|
|
20
|
+
ScoreTimes: Record<ModeNames, number>;
|
|
21
|
+
ScoreTime: number;
|
|
22
|
+
|
|
23
|
+
ModeToScreen: boolean;
|
|
24
|
+
|
|
25
|
+
GameRunning(): boolean;
|
|
26
|
+
NowMode(): ModeNames;
|
|
27
|
+
Reset(): void;
|
|
28
|
+
Random(): void;
|
|
29
|
+
CalculateScore(): void;
|
|
30
|
+
Result(): void;
|
|
31
|
+
JudgeMode(): void;
|
|
32
|
+
Logic(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class BaseLaBaG implements LaBaG {
|
|
36
|
+
AllData: Record<string, Record<string, number>> = {};
|
|
37
|
+
OneData: Record<string, number> = {};
|
|
38
|
+
DataIndex: number = 0;
|
|
39
|
+
|
|
40
|
+
Times: number = 30;
|
|
41
|
+
Played: number = 0;
|
|
42
|
+
|
|
43
|
+
Score: number = 0;
|
|
44
|
+
MarginScore: number = 0;
|
|
45
|
+
|
|
46
|
+
Ps: [P | null, P | null, P | null] = [null, null, null];
|
|
47
|
+
|
|
48
|
+
RateRanges: Record<ModeNames, number[]> = [
|
|
49
|
+
"Normal",
|
|
50
|
+
"SuperHHH",
|
|
51
|
+
"GreenWei",
|
|
52
|
+
"PiKaChu",
|
|
53
|
+
].reduce((Ranges: Record<ModeNames, number[]>, mode: string) => {
|
|
54
|
+
const res: number[] = [];
|
|
55
|
+
let accRate: number = 0;
|
|
56
|
+
for (const p of Object.values(P.Obj)) {
|
|
57
|
+
accRate += p.Rates[mode as ModeNames];
|
|
58
|
+
res.push(accRate);
|
|
59
|
+
}
|
|
60
|
+
Ranges[mode as ModeNames] = res;
|
|
61
|
+
return Ranges;
|
|
62
|
+
}, {} as Record<ModeNames, number[]>);
|
|
63
|
+
|
|
64
|
+
ScoreTimes: Record<ModeNames, number> = {
|
|
65
|
+
Normal: 1,
|
|
66
|
+
SuperHHH: 1,
|
|
67
|
+
GreenWei: 3,
|
|
68
|
+
PiKaChu: 1,
|
|
69
|
+
};
|
|
70
|
+
ScoreTime: number = 1;
|
|
71
|
+
|
|
72
|
+
ModeToScreen: boolean = false;
|
|
73
|
+
|
|
74
|
+
constructor() {}
|
|
75
|
+
|
|
76
|
+
GameRunning(): boolean {
|
|
77
|
+
//遊戲進行
|
|
78
|
+
return this.Times > this.Played;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
NowMode(): ModeNames {
|
|
82
|
+
// 查找當前模式
|
|
83
|
+
const mode = Object.entries(Modes).find(
|
|
84
|
+
([_, mode]: [string, Mode]) => mode.InMode ?? false
|
|
85
|
+
);
|
|
86
|
+
return mode ? (mode[0] as ModeNames) : "Normal";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Reset() {
|
|
90
|
+
// 重置
|
|
91
|
+
this.AllData = {};
|
|
92
|
+
this.DataIndex = 0;
|
|
93
|
+
|
|
94
|
+
this.Played = 0;
|
|
95
|
+
this.Score = 0;
|
|
96
|
+
this.MarginScore = 0;
|
|
97
|
+
this.ScoreTime = 1;
|
|
98
|
+
|
|
99
|
+
this.Ps = [null, null, null];
|
|
100
|
+
|
|
101
|
+
Object.values(Modes).forEach((mode: Mode) => {
|
|
102
|
+
if (mode.InMode !== undefined) mode.InMode = false;
|
|
103
|
+
if (mode.Score !== undefined) mode.Score = 0;
|
|
104
|
+
if (mode.RandNum !== undefined) mode.RandNum = 0;
|
|
105
|
+
if (mode.Times !== undefined) mode.Times = 0;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Random(): void {
|
|
110
|
+
const RandNums: [number, number, number] = Array.from({ length: 3 }, () =>
|
|
111
|
+
RandInt()
|
|
112
|
+
) as [number, number, number];
|
|
113
|
+
|
|
114
|
+
RandNums.forEach((RandNum: number, index: number) => {
|
|
115
|
+
this.OneData[`RandNums[${index}]`] = RandNum;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
Object.values(Modes).forEach((mode: Mode) => {
|
|
119
|
+
mode.Random?.();
|
|
120
|
+
});
|
|
121
|
+
this.OneData["SuperHHH"] = Modes.SuperHHH.RandNum as number;
|
|
122
|
+
this.OneData["GreenWei"] = Modes.GreenWei.RandNum as number;
|
|
123
|
+
|
|
124
|
+
const RateRange: number[] = this.RateRanges[this.NowMode()];
|
|
125
|
+
const PCodes: string[] = Object.keys(P.Obj);
|
|
126
|
+
RandNums.forEach((RandNum: number, i: number) => {
|
|
127
|
+
const code = PCodes.find((_, j: number) => RandNum <= RateRange[j]);
|
|
128
|
+
if (code) {
|
|
129
|
+
this.Ps[i] = P.Obj[code];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 累積咖波累積數
|
|
134
|
+
this.Ps.forEach((p) => {
|
|
135
|
+
if (Modes.GreenWei.Score !== undefined) {
|
|
136
|
+
if (p?.Code === "A" && Modes.GreenWei.Score < 20) {
|
|
137
|
+
Modes.GreenWei.Score += 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
CalculateScore(): void {
|
|
143
|
+
//計算分數
|
|
144
|
+
const UniqueCount: number = new Set(this.Ps.map((p) => p?.Code)).size;
|
|
145
|
+
switch (UniqueCount) {
|
|
146
|
+
case 1: // 三個一樣
|
|
147
|
+
this.MarginScore += this.Ps[0]?.Scores?.[0] as number;
|
|
148
|
+
break;
|
|
149
|
+
case 2: // 兩個一樣
|
|
150
|
+
if (this.Ps[0]?.Code === this.Ps[1]?.Code) {
|
|
151
|
+
this.MarginScore += this.Ps[0]?.Scores?.[1] as number;
|
|
152
|
+
this.MarginScore += this.Ps[2]?.Scores?.[2] as number;
|
|
153
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
154
|
+
} else if (this.Ps[1]?.Code === this.Ps[2]?.Code) {
|
|
155
|
+
this.MarginScore += this.Ps[1]?.Scores?.[1] as number;
|
|
156
|
+
this.MarginScore += this.Ps[0]?.Scores?.[2] as number;
|
|
157
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
158
|
+
} else if (this.Ps[2]?.Code === this.Ps[0]?.Code) {
|
|
159
|
+
this.MarginScore += this.Ps[2]?.Scores?.[1] as number;
|
|
160
|
+
this.MarginScore += this.Ps[1]?.Scores?.[2] as number;
|
|
161
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case 3: // 三個不一樣
|
|
165
|
+
this.MarginScore += this.Ps[0]?.Scores?.[2] as number;
|
|
166
|
+
this.MarginScore += this.Ps[1]?.Scores?.[2] as number;
|
|
167
|
+
this.MarginScore += this.Ps[2]?.Scores?.[2] as number;
|
|
168
|
+
this.MarginScore = Math.round(this.MarginScore / 3);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 根據當前模式更新加分倍數
|
|
173
|
+
this.ScoreTime = this.ScoreTimes[this.NowMode()];
|
|
174
|
+
this.MarginScore *= this.ScoreTime;
|
|
175
|
+
}
|
|
176
|
+
Result(): void {
|
|
177
|
+
// 結果
|
|
178
|
+
this.Played += 1;
|
|
179
|
+
this.DataIndex += 1;
|
|
180
|
+
this.Score += this.MarginScore;
|
|
181
|
+
this.AllData[`${this.DataIndex}`] = this.OneData;
|
|
182
|
+
}
|
|
183
|
+
JudgeMode(): void {
|
|
184
|
+
if (!this.GameRunning()) {
|
|
185
|
+
Modes.PiKaChu.Judge?.(this);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const mode: ModeNames = this.NowMode();
|
|
190
|
+
switch (mode) {
|
|
191
|
+
case "Normal":
|
|
192
|
+
case "PiKaChu":
|
|
193
|
+
Modes.SuperHHH.Judge?.(this);
|
|
194
|
+
if (!Modes.SuperHHH.InMode) {
|
|
195
|
+
Modes.GreenWei.Judge?.(this);
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
case "SuperHHH":
|
|
199
|
+
Modes.SuperHHH.Judge?.(this);
|
|
200
|
+
break;
|
|
201
|
+
case "GreenWei":
|
|
202
|
+
Modes.GreenWei.Judge?.(this);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
Logic(): void {
|
|
207
|
+
// 邏輯流程
|
|
208
|
+
this.Reset();
|
|
209
|
+
while (this.GameRunning()) {
|
|
210
|
+
this.ModeToScreen = false;
|
|
211
|
+
this.OneData = {};
|
|
212
|
+
|
|
213
|
+
this.MarginScore = 0;
|
|
214
|
+
|
|
215
|
+
this.Random();
|
|
216
|
+
this.CalculateScore();
|
|
217
|
+
this.Result();
|
|
218
|
+
this.JudgeMode();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LaBaG } from "./LaBaG";
|
|
2
|
+
|
|
3
|
+
export type Mode = {
|
|
4
|
+
InMode?: boolean;
|
|
5
|
+
Rate?: number;
|
|
6
|
+
Times?: number;
|
|
7
|
+
Score?: number;
|
|
8
|
+
RandNum?: number;
|
|
9
|
+
Random?: () => void;
|
|
10
|
+
Judge?: (Game: LaBaG) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ModeNames = "Normal" | "GreenWei" | "SuperHHH" | "PiKaChu";
|
package/src/types/P.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ModeNames } from "./Mode";
|
|
2
|
+
|
|
3
|
+
export type PData = {
|
|
4
|
+
name: string;
|
|
5
|
+
code: string;
|
|
6
|
+
rates: Record<ModeNames, number>;
|
|
7
|
+
scores: [number, number, number];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class P {
|
|
11
|
+
static Obj: Record<string, P> = {};
|
|
12
|
+
|
|
13
|
+
Code: string | null;
|
|
14
|
+
Scores: [number, number, number];
|
|
15
|
+
Rates: Record<ModeNames, number>;
|
|
16
|
+
constructor(
|
|
17
|
+
Code: string | null = null,
|
|
18
|
+
Scores: [number, number, number] = [0, 0, 0],
|
|
19
|
+
Rates: Record<ModeNames, number> = {
|
|
20
|
+
Normal: 0,
|
|
21
|
+
SuperHHH: 0,
|
|
22
|
+
GreenWei: 0,
|
|
23
|
+
PiKaChu: 0,
|
|
24
|
+
}
|
|
25
|
+
) {
|
|
26
|
+
this.Code = Code;
|
|
27
|
+
this.Scores = Scores;
|
|
28
|
+
this.Rates = Rates;
|
|
29
|
+
|
|
30
|
+
if (this.Code && !P.Obj[this.Code]) {
|
|
31
|
+
P.Obj[this.Code] = this;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Modes } from "..";
|
|
2
|
+
import { BaseLaBaG } from "./LaBaG";
|
|
3
|
+
import { ModeNames } from "./Mode";
|
|
4
|
+
|
|
5
|
+
export class PlayLaBaG extends BaseLaBaG {
|
|
6
|
+
Reset(): void {
|
|
7
|
+
super.Reset();
|
|
8
|
+
console.log("遊戲已重置");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Random(): void {
|
|
12
|
+
super.Random();
|
|
13
|
+
console.log(`機率區間: ${this.RateRanges[this.NowMode()]}`);
|
|
14
|
+
console.log(`超級阿禾隨機數為: ${Modes.SuperHHH.RandNum}`);
|
|
15
|
+
console.log(`綠光阿瑋隨機數為: ${Modes.GreenWei.RandNum}`);
|
|
16
|
+
console.log(`咖波累積數:${Modes.GreenWei.Score}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
CalculateScore(): void {
|
|
20
|
+
super.CalculateScore();
|
|
21
|
+
console.log(`加分倍數: ${this.ScoreTime}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Result(): void {
|
|
25
|
+
super.Result();
|
|
26
|
+
console.log("");
|
|
27
|
+
console.log(
|
|
28
|
+
`| ${this.Ps[0]?.Code} | ${this.Ps[1]?.Code} | ${this.Ps[2]?.Code} |`
|
|
29
|
+
);
|
|
30
|
+
console.log(`+ ${this.MarginScore}`);
|
|
31
|
+
console.log(`目前分數: ${this.Score}`);
|
|
32
|
+
console.log(`剩餘次數: ${this.Times - this.Played}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
JudgeMode(): void {
|
|
36
|
+
super.JudgeMode();
|
|
37
|
+
const mode: ModeNames = this.NowMode();
|
|
38
|
+
switch (mode) {
|
|
39
|
+
case "SuperHHH":
|
|
40
|
+
if (this.ModeToScreen) {
|
|
41
|
+
console.log("超級阿禾出現");
|
|
42
|
+
if (Modes.SuperHHH.Score !== 0) {
|
|
43
|
+
console.log(`(超級阿禾加倍分: ${Modes.SuperHHH.Score})`);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (this.Ps.every((p) => p?.Code === "B")) {
|
|
47
|
+
console.log("全阿禾,次數不消耗且+1!");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log(`超級阿禾剩餘次數:${Modes.SuperHHH.Times}次`);
|
|
51
|
+
break;
|
|
52
|
+
case "GreenWei":
|
|
53
|
+
if (this.ModeToScreen) {
|
|
54
|
+
console.log("綠光阿瑋出現");
|
|
55
|
+
} else {
|
|
56
|
+
if (this.Ps.every((p) => p?.Code === "A")) {
|
|
57
|
+
console.log("全咖波,次數不消耗!");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log(`綠光阿瑋剩餘次數:${Modes.GreenWei.Times}次`);
|
|
61
|
+
break;
|
|
62
|
+
case "PiKaChu":
|
|
63
|
+
if (this.ModeToScreen) {
|
|
64
|
+
console.log("皮卡丘為你充電");
|
|
65
|
+
console.log(`已觸發 ${Modes.PiKaChu.Times} 次皮卡丘充電`);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Logic(): void {
|
|
72
|
+
this.ModeToScreen = false;
|
|
73
|
+
this.OneData = {};
|
|
74
|
+
this.MarginScore = 0;
|
|
75
|
+
this.Random();
|
|
76
|
+
this.CalculateScore();
|
|
77
|
+
this.Result();
|
|
78
|
+
this.JudgeMode();
|
|
79
|
+
}
|
|
80
|
+
}
|