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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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 { PlayLaBaG } from "./types/PlayLaBaG";
|
|
6
|
+
import { JsonLaBaG } from "./types/JsonLaBaG";
|
|
7
|
+
declare const Modes: Record<Exclude<ModeNames, "Normal">, Mode>;
|
|
8
|
+
export { LaBaG, PlayLaBaG, JsonLaBaG, Modes, ModeNames, P, PData, PDatas };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PDatas = exports.P = exports.Modes = exports.JsonLaBaG = exports.PlayLaBaG = void 0;
|
|
7
|
+
const PDatas_json_1 = __importDefault(require("@/json/PDatas.json"));
|
|
8
|
+
exports.PDatas = PDatas_json_1.default;
|
|
9
|
+
const P_1 = require("@/types/P");
|
|
10
|
+
Object.defineProperty(exports, "P", { enumerable: true, get: function () { return P_1.P; } });
|
|
11
|
+
const RandInt_1 = require("./utils/RandInt");
|
|
12
|
+
const PlayLaBaG_1 = require("./types/PlayLaBaG");
|
|
13
|
+
Object.defineProperty(exports, "PlayLaBaG", { enumerable: true, get: function () { return PlayLaBaG_1.PlayLaBaG; } });
|
|
14
|
+
const JsonLaBaG_1 = require("./types/JsonLaBaG");
|
|
15
|
+
Object.defineProperty(exports, "JsonLaBaG", { enumerable: true, get: function () { return JsonLaBaG_1.JsonLaBaG; } });
|
|
16
|
+
Object.values(PDatas_json_1.default).forEach((Pdata) => {
|
|
17
|
+
new P_1.P(Pdata.code, Pdata.scores, Pdata.rates);
|
|
18
|
+
});
|
|
19
|
+
const Modes = {
|
|
20
|
+
// 超級阿禾
|
|
21
|
+
SuperHHH: {
|
|
22
|
+
InMode: false,
|
|
23
|
+
Rate: 15,
|
|
24
|
+
Times: 0,
|
|
25
|
+
Score: 0,
|
|
26
|
+
RandNum: 0,
|
|
27
|
+
Random() {
|
|
28
|
+
this.RandNum = (0, RandInt_1.RandInt)();
|
|
29
|
+
},
|
|
30
|
+
Judge(Game) {
|
|
31
|
+
if (!Game.GameRunning() ||
|
|
32
|
+
this.RandNum === undefined ||
|
|
33
|
+
this.Times === undefined ||
|
|
34
|
+
this.Rate === undefined ||
|
|
35
|
+
this.Score === undefined) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.Score = 0; // Reset score
|
|
39
|
+
if (this.InMode) {
|
|
40
|
+
this.Times -= 1;
|
|
41
|
+
if (Game.Ps.every((p) => p?.Code === "B")) {
|
|
42
|
+
this.Times += 2;
|
|
43
|
+
}
|
|
44
|
+
if (this.Times <= 0) {
|
|
45
|
+
this.InMode = false;
|
|
46
|
+
Game.JudgeMode();
|
|
47
|
+
Game.ModeToScreen = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (this.RandNum <= this.Rate && Game.Ps.some((p) => p?.Code === "B")) {
|
|
52
|
+
this.InMode = true;
|
|
53
|
+
this.Times += 6;
|
|
54
|
+
Game.ModeToScreen = true;
|
|
55
|
+
if (Modes.PiKaChu.InMode) {
|
|
56
|
+
Modes.PiKaChu.InMode = false;
|
|
57
|
+
}
|
|
58
|
+
// 超級阿禾加倍
|
|
59
|
+
if (Game.Ps.every((p) => p?.Code === "B")) {
|
|
60
|
+
this.Score = Math.round((Game.Score * Game.ScoreTime) / 2);
|
|
61
|
+
Game.MarginScore += this.Score;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
GreenWei: {
|
|
68
|
+
InMode: false,
|
|
69
|
+
Rate: 35,
|
|
70
|
+
Times: 0,
|
|
71
|
+
Score: 0, // 咖波累積數
|
|
72
|
+
RandNum: 0,
|
|
73
|
+
Random() {
|
|
74
|
+
this.RandNum = (0, RandInt_1.RandInt)();
|
|
75
|
+
},
|
|
76
|
+
Judge(Game) {
|
|
77
|
+
if (!Game.GameRunning() ||
|
|
78
|
+
this.RandNum === undefined ||
|
|
79
|
+
this.Times === undefined ||
|
|
80
|
+
this.Rate === undefined ||
|
|
81
|
+
this.Score === undefined) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.InMode) {
|
|
85
|
+
this.Times -= 1;
|
|
86
|
+
if (Game.Ps.every((p) => p?.Code === "A")) {
|
|
87
|
+
this.Times += 1;
|
|
88
|
+
}
|
|
89
|
+
if (this.Times <= 0) {
|
|
90
|
+
this.InMode = false;
|
|
91
|
+
Game.JudgeMode();
|
|
92
|
+
Game.ModeToScreen = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (this.RandNum <= this.Rate &&
|
|
97
|
+
Game.Ps.every((p) => p?.Code === "A")) {
|
|
98
|
+
this.InMode = true;
|
|
99
|
+
this.Times += 2;
|
|
100
|
+
Game.ModeToScreen = true;
|
|
101
|
+
if (Modes.PiKaChu.InMode) {
|
|
102
|
+
Modes.PiKaChu.InMode = false;
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
else if (this.Score >= 20) {
|
|
107
|
+
// 咖波累積數達到 20
|
|
108
|
+
this.InMode = true;
|
|
109
|
+
this.Times += 2;
|
|
110
|
+
this.Score = 0;
|
|
111
|
+
Game.ModeToScreen = true;
|
|
112
|
+
if (Modes.PiKaChu.InMode) {
|
|
113
|
+
Modes.PiKaChu.InMode = false;
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
PiKaChu: {
|
|
121
|
+
InMode: false,
|
|
122
|
+
Times: 0,
|
|
123
|
+
Judge(Game) {
|
|
124
|
+
if (!Game.GameRunning() && this.Times !== undefined) {
|
|
125
|
+
// 關掉其他模式
|
|
126
|
+
Modes.SuperHHH.InMode = false;
|
|
127
|
+
Modes.GreenWei.InMode = false;
|
|
128
|
+
if (Game.Ps.some((p) => p?.Code === "E")) {
|
|
129
|
+
this.InMode = true;
|
|
130
|
+
Game.Played -= 5;
|
|
131
|
+
this.Times += 1;
|
|
132
|
+
Game.ModeToScreen = true;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.InMode = false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
exports.Modes = Modes;
|
|
@@ -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,10 @@
|
|
|
1
|
+
import { BaseLaBaG } from "./LaBaG";
|
|
2
|
+
export declare class JsonLaBaG extends BaseLaBaG {
|
|
3
|
+
jsonData: BaseLaBaG["AllData"];
|
|
4
|
+
dataIndex: number;
|
|
5
|
+
constructor();
|
|
6
|
+
SetupData(data: BaseLaBaG["AllData"]): void;
|
|
7
|
+
Reset(): void;
|
|
8
|
+
Random(): void;
|
|
9
|
+
Result(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonLaBaG = void 0;
|
|
4
|
+
const P_1 = require("./P");
|
|
5
|
+
const LaBaG_1 = require("./LaBaG");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
class JsonLaBaG extends LaBaG_1.BaseLaBaG {
|
|
8
|
+
jsonData;
|
|
9
|
+
dataIndex;
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.jsonData = {};
|
|
13
|
+
this.dataIndex = 0;
|
|
14
|
+
}
|
|
15
|
+
SetupData(data) {
|
|
16
|
+
this.jsonData = data;
|
|
17
|
+
}
|
|
18
|
+
Reset() {
|
|
19
|
+
super.Reset();
|
|
20
|
+
this.dataIndex = 0;
|
|
21
|
+
}
|
|
22
|
+
Random() {
|
|
23
|
+
const currData = this.jsonData[this.dataIndex];
|
|
24
|
+
if (!currData) {
|
|
25
|
+
super.Random();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const RandNums = [
|
|
30
|
+
currData["RandNum[0]"] ?? 0,
|
|
31
|
+
currData["RandNum[1]"] ?? 0,
|
|
32
|
+
currData["RandNum[2]"] ?? 0,
|
|
33
|
+
];
|
|
34
|
+
__1.Modes.SuperHHH.RandNum = currData["SuperHHH"] ?? 0;
|
|
35
|
+
__1.Modes.GreenWei.RandNum = currData["GreenWei"] ?? 0;
|
|
36
|
+
const RateRange = this.RateRanges[this.NowMode()];
|
|
37
|
+
const PCodes = Object.keys(P_1.P.Obj);
|
|
38
|
+
RandNums.forEach((RandNum, i) => {
|
|
39
|
+
const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
|
|
40
|
+
if (code) {
|
|
41
|
+
this.Ps[i] = P_1.P.Obj[code];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// 累積 GreenWei 分數
|
|
45
|
+
this.Ps.forEach((p) => {
|
|
46
|
+
if (p?.Code === "A" &&
|
|
47
|
+
__1.Modes.GreenWei.Score !== undefined &&
|
|
48
|
+
__1.Modes.GreenWei.Score < 20) {
|
|
49
|
+
__1.Modes.GreenWei.Score += 1;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error("Error in Random():", error);
|
|
55
|
+
super.Random();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Result() {
|
|
59
|
+
super.Result();
|
|
60
|
+
this.dataIndex++;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.JsonLaBaG = JsonLaBaG;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { P } from "@/types/P";
|
|
2
|
+
import { ModeNames } from "@/types/Mode";
|
|
3
|
+
export interface LaBaG {
|
|
4
|
+
AllData: Record<string, Record<string, number>>;
|
|
5
|
+
OneData: Record<string, number>;
|
|
6
|
+
DataIndex: number;
|
|
7
|
+
Times: number;
|
|
8
|
+
Played: number;
|
|
9
|
+
Score: number;
|
|
10
|
+
MarginScore: number;
|
|
11
|
+
Ps: [P | null, P | null, P | null];
|
|
12
|
+
RateRanges: Record<ModeNames, number[]>;
|
|
13
|
+
ScoreTimes: Record<ModeNames, number>;
|
|
14
|
+
ScoreTime: number;
|
|
15
|
+
ModeToScreen: boolean;
|
|
16
|
+
GameRunning(): boolean;
|
|
17
|
+
NowMode(): ModeNames;
|
|
18
|
+
Reset(): void;
|
|
19
|
+
Random(): void;
|
|
20
|
+
CalculateScore(): void;
|
|
21
|
+
Result(): void;
|
|
22
|
+
JudgeMode(): void;
|
|
23
|
+
Logic(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class BaseLaBaG implements LaBaG {
|
|
26
|
+
AllData: Record<string, Record<string, number>>;
|
|
27
|
+
OneData: Record<string, number>;
|
|
28
|
+
DataIndex: number;
|
|
29
|
+
Times: number;
|
|
30
|
+
Played: number;
|
|
31
|
+
Score: number;
|
|
32
|
+
MarginScore: number;
|
|
33
|
+
Ps: [P | null, P | null, P | null];
|
|
34
|
+
RateRanges: Record<ModeNames, number[]>;
|
|
35
|
+
ScoreTimes: Record<ModeNames, number>;
|
|
36
|
+
ScoreTime: number;
|
|
37
|
+
ModeToScreen: boolean;
|
|
38
|
+
constructor();
|
|
39
|
+
GameRunning(): boolean;
|
|
40
|
+
NowMode(): ModeNames;
|
|
41
|
+
Reset(): void;
|
|
42
|
+
Random(): void;
|
|
43
|
+
CalculateScore(): void;
|
|
44
|
+
Result(): void;
|
|
45
|
+
JudgeMode(): void;
|
|
46
|
+
Logic(): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseLaBaG = void 0;
|
|
4
|
+
const P_1 = require("@/types/P");
|
|
5
|
+
const RandInt_1 = require("../utils/RandInt");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
class BaseLaBaG {
|
|
8
|
+
AllData = {};
|
|
9
|
+
OneData = {};
|
|
10
|
+
DataIndex = 0;
|
|
11
|
+
Times = 30;
|
|
12
|
+
Played = 0;
|
|
13
|
+
Score = 0;
|
|
14
|
+
MarginScore = 0;
|
|
15
|
+
Ps = [null, null, null];
|
|
16
|
+
RateRanges = [
|
|
17
|
+
"Normal",
|
|
18
|
+
"SuperHHH",
|
|
19
|
+
"GreenWei",
|
|
20
|
+
"PiKaChu",
|
|
21
|
+
].reduce((Ranges, mode) => {
|
|
22
|
+
const res = [];
|
|
23
|
+
let accRate = 0;
|
|
24
|
+
for (const p of Object.values(P_1.P.Obj)) {
|
|
25
|
+
accRate += p.Rates[mode];
|
|
26
|
+
res.push(accRate);
|
|
27
|
+
}
|
|
28
|
+
Ranges[mode] = res;
|
|
29
|
+
return Ranges;
|
|
30
|
+
}, {});
|
|
31
|
+
ScoreTimes = {
|
|
32
|
+
Normal: 1,
|
|
33
|
+
SuperHHH: 1,
|
|
34
|
+
GreenWei: 3,
|
|
35
|
+
PiKaChu: 1,
|
|
36
|
+
};
|
|
37
|
+
ScoreTime = 1;
|
|
38
|
+
ModeToScreen = false;
|
|
39
|
+
constructor() { }
|
|
40
|
+
GameRunning() {
|
|
41
|
+
//遊戲進行
|
|
42
|
+
return this.Times > this.Played;
|
|
43
|
+
}
|
|
44
|
+
NowMode() {
|
|
45
|
+
// 查找當前模式
|
|
46
|
+
const mode = Object.entries(__1.Modes).find(([_, mode]) => mode.InMode ?? false);
|
|
47
|
+
return mode ? mode[0] : "Normal";
|
|
48
|
+
}
|
|
49
|
+
Reset() {
|
|
50
|
+
// 重置
|
|
51
|
+
this.AllData = {};
|
|
52
|
+
this.DataIndex = 0;
|
|
53
|
+
this.Played = 0;
|
|
54
|
+
this.Score = 0;
|
|
55
|
+
this.MarginScore = 0;
|
|
56
|
+
this.ScoreTime = 1;
|
|
57
|
+
this.Ps = [null, null, null];
|
|
58
|
+
Object.values(__1.Modes).forEach((mode) => {
|
|
59
|
+
if (mode.InMode !== undefined)
|
|
60
|
+
mode.InMode = false;
|
|
61
|
+
if (mode.Score !== undefined)
|
|
62
|
+
mode.Score = 0;
|
|
63
|
+
if (mode.RandNum !== undefined)
|
|
64
|
+
mode.RandNum = 0;
|
|
65
|
+
if (mode.Times !== undefined)
|
|
66
|
+
mode.Times = 0;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
Random() {
|
|
70
|
+
const RandNums = Array.from({ length: 3 }, () => (0, RandInt_1.RandInt)());
|
|
71
|
+
RandNums.forEach((RandNum, index) => {
|
|
72
|
+
this.OneData[`RandNums[${index}]`] = RandNum;
|
|
73
|
+
});
|
|
74
|
+
Object.values(__1.Modes).forEach((mode) => {
|
|
75
|
+
mode.Random?.();
|
|
76
|
+
});
|
|
77
|
+
this.OneData["SuperHHH"] = __1.Modes.SuperHHH.RandNum;
|
|
78
|
+
this.OneData["GreenWei"] = __1.Modes.GreenWei.RandNum;
|
|
79
|
+
const RateRange = this.RateRanges[this.NowMode()];
|
|
80
|
+
const PCodes = Object.keys(P_1.P.Obj);
|
|
81
|
+
RandNums.forEach((RandNum, i) => {
|
|
82
|
+
const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
|
|
83
|
+
if (code) {
|
|
84
|
+
this.Ps[i] = P_1.P.Obj[code];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
// 累積咖波累積數
|
|
88
|
+
this.Ps.forEach((p) => {
|
|
89
|
+
if (__1.Modes.GreenWei.Score !== undefined) {
|
|
90
|
+
if (p?.Code === "A" && __1.Modes.GreenWei.Score < 20) {
|
|
91
|
+
__1.Modes.GreenWei.Score += 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
CalculateScore() {
|
|
97
|
+
//計算分數
|
|
98
|
+
const UniqueCount = new Set(this.Ps.map((p) => p?.Code)).size;
|
|
99
|
+
switch (UniqueCount) {
|
|
100
|
+
case 1: // 三個一樣
|
|
101
|
+
this.MarginScore += this.Ps[0]?.Scores?.[0];
|
|
102
|
+
break;
|
|
103
|
+
case 2: // 兩個一樣
|
|
104
|
+
if (this.Ps[0]?.Code === this.Ps[1]?.Code) {
|
|
105
|
+
this.MarginScore += this.Ps[0]?.Scores?.[1];
|
|
106
|
+
this.MarginScore += this.Ps[2]?.Scores?.[2];
|
|
107
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
108
|
+
}
|
|
109
|
+
else if (this.Ps[1]?.Code === this.Ps[2]?.Code) {
|
|
110
|
+
this.MarginScore += this.Ps[1]?.Scores?.[1];
|
|
111
|
+
this.MarginScore += this.Ps[0]?.Scores?.[2];
|
|
112
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
113
|
+
}
|
|
114
|
+
else if (this.Ps[2]?.Code === this.Ps[0]?.Code) {
|
|
115
|
+
this.MarginScore += this.Ps[2]?.Scores?.[1];
|
|
116
|
+
this.MarginScore += this.Ps[1]?.Scores?.[2];
|
|
117
|
+
this.MarginScore = Math.round(this.MarginScore / 1.4);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case 3: // 三個不一樣
|
|
121
|
+
this.MarginScore += this.Ps[0]?.Scores?.[2];
|
|
122
|
+
this.MarginScore += this.Ps[1]?.Scores?.[2];
|
|
123
|
+
this.MarginScore += this.Ps[2]?.Scores?.[2];
|
|
124
|
+
this.MarginScore = Math.round(this.MarginScore / 3);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
// 根據當前模式更新加分倍數
|
|
128
|
+
this.ScoreTime = this.ScoreTimes[this.NowMode()];
|
|
129
|
+
this.MarginScore *= this.ScoreTime;
|
|
130
|
+
}
|
|
131
|
+
Result() {
|
|
132
|
+
// 結果
|
|
133
|
+
this.Played += 1;
|
|
134
|
+
this.DataIndex += 1;
|
|
135
|
+
this.Score += this.MarginScore;
|
|
136
|
+
this.AllData[`${this.DataIndex}`] = this.OneData;
|
|
137
|
+
}
|
|
138
|
+
JudgeMode() {
|
|
139
|
+
if (!this.GameRunning()) {
|
|
140
|
+
__1.Modes.PiKaChu.Judge?.(this);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const mode = this.NowMode();
|
|
144
|
+
switch (mode) {
|
|
145
|
+
case "Normal":
|
|
146
|
+
case "PiKaChu":
|
|
147
|
+
__1.Modes.SuperHHH.Judge?.(this);
|
|
148
|
+
if (!__1.Modes.SuperHHH.InMode) {
|
|
149
|
+
__1.Modes.GreenWei.Judge?.(this);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case "SuperHHH":
|
|
153
|
+
__1.Modes.SuperHHH.Judge?.(this);
|
|
154
|
+
break;
|
|
155
|
+
case "GreenWei":
|
|
156
|
+
__1.Modes.GreenWei.Judge?.(this);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
Logic() {
|
|
161
|
+
// 邏輯流程
|
|
162
|
+
this.Reset();
|
|
163
|
+
while (this.GameRunning()) {
|
|
164
|
+
this.ModeToScreen = false;
|
|
165
|
+
this.OneData = {};
|
|
166
|
+
this.MarginScore = 0;
|
|
167
|
+
this.Random();
|
|
168
|
+
this.CalculateScore();
|
|
169
|
+
this.Result();
|
|
170
|
+
this.JudgeMode();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.BaseLaBaG = BaseLaBaG;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LaBaG } from "./LaBaG";
|
|
2
|
+
export type Mode = {
|
|
3
|
+
InMode?: boolean;
|
|
4
|
+
Rate?: number;
|
|
5
|
+
Times?: number;
|
|
6
|
+
Score?: number;
|
|
7
|
+
RandNum?: number;
|
|
8
|
+
Random?: () => void;
|
|
9
|
+
Judge?: (Game: LaBaG) => void;
|
|
10
|
+
};
|
|
11
|
+
export type ModeNames = "Normal" | "GreenWei" | "SuperHHH" | "PiKaChu";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModeNames } from "./Mode";
|
|
2
|
+
export type PData = {
|
|
3
|
+
name: string;
|
|
4
|
+
code: string;
|
|
5
|
+
rates: Record<ModeNames, number>;
|
|
6
|
+
scores: [number, number, number];
|
|
7
|
+
};
|
|
8
|
+
export declare class P {
|
|
9
|
+
static Obj: Record<string, P>;
|
|
10
|
+
Code: string | null;
|
|
11
|
+
Scores: [number, number, number];
|
|
12
|
+
Rates: Record<ModeNames, number>;
|
|
13
|
+
constructor(Code?: string | null, Scores?: [number, number, number], Rates?: Record<ModeNames, number>);
|
|
14
|
+
}
|
package/dist/types/P.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.P = void 0;
|
|
4
|
+
class P {
|
|
5
|
+
static Obj = {};
|
|
6
|
+
Code;
|
|
7
|
+
Scores;
|
|
8
|
+
Rates;
|
|
9
|
+
constructor(Code = null, Scores = [0, 0, 0], Rates = {
|
|
10
|
+
Normal: 0,
|
|
11
|
+
SuperHHH: 0,
|
|
12
|
+
GreenWei: 0,
|
|
13
|
+
PiKaChu: 0,
|
|
14
|
+
}) {
|
|
15
|
+
this.Code = Code;
|
|
16
|
+
this.Scores = Scores;
|
|
17
|
+
this.Rates = Rates;
|
|
18
|
+
if (this.Code && !P.Obj[this.Code]) {
|
|
19
|
+
P.Obj[this.Code] = this;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.P = P;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlayLaBaG = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const LaBaG_1 = require("./LaBaG");
|
|
6
|
+
class PlayLaBaG extends LaBaG_1.BaseLaBaG {
|
|
7
|
+
Reset() {
|
|
8
|
+
super.Reset();
|
|
9
|
+
console.log("遊戲已重置");
|
|
10
|
+
}
|
|
11
|
+
Random() {
|
|
12
|
+
super.Random();
|
|
13
|
+
console.log(`機率區間: ${this.RateRanges[this.NowMode()]}`);
|
|
14
|
+
console.log(`超級阿禾隨機數為: ${__1.Modes.SuperHHH.RandNum}`);
|
|
15
|
+
console.log(`綠光阿瑋隨機數為: ${__1.Modes.GreenWei.RandNum}`);
|
|
16
|
+
console.log(`咖波累積數:${__1.Modes.GreenWei.Score}`);
|
|
17
|
+
}
|
|
18
|
+
CalculateScore() {
|
|
19
|
+
super.CalculateScore();
|
|
20
|
+
console.log(`加分倍數: ${this.ScoreTime}`);
|
|
21
|
+
}
|
|
22
|
+
Result() {
|
|
23
|
+
super.Result();
|
|
24
|
+
console.log("");
|
|
25
|
+
console.log(`| ${this.Ps[0]?.Code} | ${this.Ps[1]?.Code} | ${this.Ps[2]?.Code} |`);
|
|
26
|
+
console.log(`+ ${this.MarginScore}`);
|
|
27
|
+
console.log(`目前分數: ${this.Score}`);
|
|
28
|
+
console.log(`剩餘次數: ${this.Times - this.Played}`);
|
|
29
|
+
}
|
|
30
|
+
JudgeMode() {
|
|
31
|
+
super.JudgeMode();
|
|
32
|
+
const mode = this.NowMode();
|
|
33
|
+
switch (mode) {
|
|
34
|
+
case "SuperHHH":
|
|
35
|
+
if (this.ModeToScreen) {
|
|
36
|
+
console.log("超級阿禾出現");
|
|
37
|
+
if (__1.Modes.SuperHHH.Score !== 0) {
|
|
38
|
+
console.log(`(超級阿禾加倍分: ${__1.Modes.SuperHHH.Score})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (this.Ps.every((p) => p?.Code === "B")) {
|
|
43
|
+
console.log("全阿禾,次數不消耗且+1!");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
console.log(`超級阿禾剩餘次數:${__1.Modes.SuperHHH.Times}次`);
|
|
47
|
+
break;
|
|
48
|
+
case "GreenWei":
|
|
49
|
+
if (this.ModeToScreen) {
|
|
50
|
+
console.log("綠光阿瑋出現");
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
if (this.Ps.every((p) => p?.Code === "A")) {
|
|
54
|
+
console.log("全咖波,次數不消耗!");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.log(`綠光阿瑋剩餘次數:${__1.Modes.GreenWei.Times}次`);
|
|
58
|
+
break;
|
|
59
|
+
case "PiKaChu":
|
|
60
|
+
if (this.ModeToScreen) {
|
|
61
|
+
console.log("皮卡丘為你充電");
|
|
62
|
+
console.log(`已觸發 ${__1.Modes.PiKaChu.Times} 次皮卡丘充電`);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
Logic() {
|
|
68
|
+
this.ModeToScreen = false;
|
|
69
|
+
this.OneData = {};
|
|
70
|
+
this.MarginScore = 0;
|
|
71
|
+
this.Random();
|
|
72
|
+
this.CalculateScore();
|
|
73
|
+
this.Result();
|
|
74
|
+
this.JudgeMode();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.PlayLaBaG = PlayLaBaG;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RandInt(): number;
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "labag",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"type": "commonjs",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.8.3"
|
|
17
|
+
}
|
|
18
|
+
}
|