labag 2.0.0 → 2.0.2

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.
@@ -0,0 +1,84 @@
1
+ import { Mode } from "../mode";
2
+ import { randInt } from "../utils/randInt";
3
+
4
+ export default new Mode(
5
+ false,
6
+ "greenwei",
7
+ {
8
+ gss: 36,
9
+ hhh: 24,
10
+ hentai: 17,
11
+ handson: 12,
12
+ kachu: 8,
13
+ rrr: 3,
14
+ },
15
+ {
16
+ gameStart: (_, mode) => {
17
+ mode.active = false;
18
+ mode.variable.times = 0;
19
+ },
20
+ roundStart: (_, mode) => {
21
+ if (!mode.active) return;
22
+ mode.variable.times -= 1;
23
+ },
24
+ rollSlots: (_, mode) => {
25
+ mode.variable.randNum = randInt(1, 100);
26
+ },
27
+ calculateScore: (game, mode) => {
28
+ if (mode.active) {
29
+ game.marginScore = Math.round(game.marginScore * 3);
30
+ }
31
+ },
32
+ roundEnd: (game, mode) => {
33
+ const { patterns } = game;
34
+ const { variable } = mode;
35
+
36
+ let gssCount = 0;
37
+ let allGSS = true;
38
+ for (const p of patterns) {
39
+ if (p?.name === "gss") gssCount++;
40
+ else allGSS = false;
41
+ }
42
+
43
+ variable.count += gssCount;
44
+
45
+ if (mode.active) {
46
+ if (allGSS) {
47
+ variable.times += 1;
48
+ }
49
+ if (variable.times <= 0) {
50
+ mode.active = false;
51
+ }
52
+ } else {
53
+ let activated = false;
54
+ if (variable.randNum <= variable.rate && allGSS) {
55
+ activated = true;
56
+ variable.times += 2;
57
+ } else if (variable.count >= 20) {
58
+ activated = true;
59
+ variable.times += 2;
60
+ variable.count -= 20;
61
+ }
62
+
63
+ if (activated) {
64
+ mode.active = true;
65
+ for (let i = 0; i < patterns.length; i++) {
66
+ if (patterns[i]?.name === "gss") {
67
+ patterns[i] = variable.pattern;
68
+ }
69
+ }
70
+ }
71
+ }
72
+ },
73
+ },
74
+ {
75
+ times: 0,
76
+ rate: 35,
77
+ randNum: 0,
78
+ count: 0,
79
+ pattern: {
80
+ name: "greenwei",
81
+ scores: [800, 400, 180],
82
+ },
83
+ }
84
+ );
@@ -0,0 +1,10 @@
1
+ import { Mode } from "../mode";
2
+
3
+ export default new Mode(true, "normal", {
4
+ gss: 36,
5
+ hhh: 24,
6
+ hentai: 17,
7
+ handson: 12,
8
+ kachu: 8,
9
+ rrr: 3,
10
+ });
@@ -0,0 +1,37 @@
1
+ import { Mode } from "../mode";
2
+
3
+ export default new Mode(
4
+ false,
5
+ "pikachu",
6
+ {
7
+ gss: 36,
8
+ hhh: 24,
9
+ hentai: 17,
10
+ handson: 12,
11
+ kachu: 8,
12
+ rrr: 3,
13
+ },
14
+ {
15
+ gameStart: (_, mode) => {
16
+ mode.active = false;
17
+ mode.variable.times = 0;
18
+ },
19
+ roundEnd: (game, mode) => {
20
+ if (
21
+ !game.isRunning() &&
22
+ game.patterns.some((p) => p && p.name === "kachu")
23
+ ) {
24
+ mode.active = true;
25
+ game.played -= 5;
26
+ mode.variable.times += 1;
27
+ }
28
+ },
29
+ },
30
+ {
31
+ times: 0,
32
+ pattern: {
33
+ name: "pikachu",
34
+ scores: [12000, 8000, 1250],
35
+ },
36
+ }
37
+ );
@@ -0,0 +1,70 @@
1
+ import { Mode } from "../mode";
2
+ import { randInt } from "../utils/randInt";
3
+
4
+ export default new Mode(
5
+ false,
6
+ "superhhh",
7
+ {
8
+ gss: 19,
9
+ hhh: 5,
10
+ hentai: 19,
11
+ handson: 19,
12
+ kachu: 19,
13
+ rrr: 19,
14
+ },
15
+ {
16
+ gameStart: (_, mode) => {
17
+ mode.active = false;
18
+ mode.variable.times = 0;
19
+ },
20
+ roundStart: (_, mode) => {
21
+ if (!mode.active) return;
22
+ mode.variable.score = 0;
23
+ mode.variable.times -= 1;
24
+ },
25
+ rollSlots: (_, mode) => {
26
+ mode.variable.randNum = randInt(1, 100);
27
+ },
28
+ roundEnd: (game, mode) => {
29
+ const { patterns } = game;
30
+ const { variable } = mode;
31
+
32
+ let hhhCount = 0;
33
+ let allHHH = true;
34
+ for (const p of patterns) {
35
+ if (p?.name === "hhh") hhhCount++;
36
+ else allHHH = false;
37
+ }
38
+
39
+ if (mode.active) {
40
+ if (allHHH) {
41
+ variable.times += 2;
42
+ }
43
+ if (variable.times <= 0) {
44
+ mode.active = false;
45
+ }
46
+ } else {
47
+ if (variable.randNum <= variable.rate && hhhCount > 0) {
48
+ mode.active = true;
49
+ variable.times += 6;
50
+
51
+ for (let i = 0; i < patterns.length; i++) {
52
+ if (patterns[i]?.name === "hhh") {
53
+ patterns[i] = variable.pattern;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ },
59
+ },
60
+ {
61
+ times: 0,
62
+ rate: 15,
63
+ score: 0,
64
+ randNum: 0,
65
+ pattern: {
66
+ name: "superhhh",
67
+ scores: [1500, 800, 300],
68
+ },
69
+ }
70
+ );
@@ -1,26 +0,0 @@
1
- import { AllDataType, LaBaG, OneDataType } from "./LaBaG";
2
- import { ModeNames } from "./Mode";
3
- import { P } from "./P";
4
- export declare class BaseLaBaG implements LaBaG {
5
- AllData: AllDataType;
6
- OneData: OneDataType;
7
- DataIndex: number;
8
- Times: number;
9
- Played: number;
10
- Score: number;
11
- MarginScore: number;
12
- Ps: [P | null, P | null, P | null];
13
- RateRanges: Record<ModeNames, number[]>;
14
- ScoreTimes: Record<ModeNames, number>;
15
- ScoreTime: number;
16
- ModeToScreen: boolean;
17
- constructor();
18
- GameRunning(): boolean;
19
- NowMode(): ModeNames;
20
- Reset(): void;
21
- Random(): void;
22
- CalculateScore(): void;
23
- Result(): void;
24
- JudgeMode(): void;
25
- Logic(): void;
26
- }
@@ -1,174 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseLaBaG = void 0;
4
- const __1 = require("..");
5
- const P_1 = require("./P");
6
- const RandInt_1 = require("../utils/RandInt");
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 P_1.P.Map.values()) {
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)(1, 100));
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 = Array.from(P_1.P.Map.keys());
81
- RandNums.forEach((RandNum, i) => {
82
- const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
83
- if (code) {
84
- this.Ps[i] = P_1.P.Map.get(code) ?? null;
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;
@@ -1,11 +0,0 @@
1
- import { BaseLaBaG } from "./BaseLaBaG";
2
- import { AllDataType } from "./LaBaG";
3
- export declare class JsonLaBaG extends BaseLaBaG {
4
- jsonData: AllDataType;
5
- dataIndex: number;
6
- constructor();
7
- SetupData(data: AllDataType): void;
8
- Reset(): void;
9
- Random(): void;
10
- Result(): void;
11
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonLaBaG = void 0;
4
- const P_1 = require("./P");
5
- const __1 = require("..");
6
- const BaseLaBaG_1 = require("./BaseLaBaG");
7
- class JsonLaBaG extends BaseLaBaG_1.BaseLaBaG {
8
- jsonData;
9
- dataIndex;
10
- constructor() {
11
- super();
12
- this.jsonData = {};
13
- this.dataIndex = 1;
14
- }
15
- SetupData(data) {
16
- this.jsonData = data;
17
- }
18
- Reset() {
19
- super.Reset();
20
- this.dataIndex = 1;
21
- }
22
- Random() {
23
- const currData = this.jsonData[`${this.dataIndex}`];
24
- if (!currData) {
25
- throw new Error("No data found for the current index");
26
- }
27
- try {
28
- const RandNums = [
29
- currData["RandNums[0]"] ?? 0,
30
- currData["RandNums[1]"] ?? 0,
31
- currData["RandNums[2]"] ?? 0,
32
- ];
33
- __1.Modes.SuperHHH.RandNum = currData["SuperHHH"] ?? 0;
34
- __1.Modes.GreenWei.RandNum = currData["GreenWei"] ?? 0;
35
- const RateRange = this.RateRanges[this.NowMode()];
36
- const PCodes = Array.from(P_1.P.Map.keys());
37
- RandNums.forEach((RandNum, i) => {
38
- const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
39
- if (code) {
40
- this.Ps[i] = P_1.P.Map.get(code) ?? null;
41
- }
42
- });
43
- // 累積 GreenWei 分數
44
- this.Ps.forEach((p) => {
45
- if (p?.code === "A" &&
46
- __1.Modes.GreenWei.Score !== undefined &&
47
- __1.Modes.GreenWei.Score < 20) {
48
- __1.Modes.GreenWei.Score += 1;
49
- }
50
- });
51
- }
52
- catch (error) {
53
- console.error("Error in Random():", error);
54
- super.Random();
55
- }
56
- }
57
- Result() {
58
- super.Result();
59
- this.dataIndex++;
60
- }
61
- }
62
- exports.JsonLaBaG = JsonLaBaG;
@@ -1,26 +0,0 @@
1
- import { P } from "../types/P";
2
- import { ModeNames } from "../types/Mode";
3
- export type OneDataType = Partial<Record<"SuperHHH" | "GreenWei" | `RandNums[${0 | 1 | 2}]`, number>>;
4
- export type AllDataType = Record<`${number}`, OneDataType>;
5
- export interface LaBaG {
6
- AllData: AllDataType;
7
- OneData: OneDataType;
8
- DataIndex: number;
9
- Times: number;
10
- Played: number;
11
- Score: number;
12
- MarginScore: number;
13
- Ps: [P | null, P | null, P | null];
14
- RateRanges: Record<ModeNames, number[]>;
15
- ScoreTimes: Record<ModeNames, number>;
16
- ScoreTime: number;
17
- ModeToScreen: boolean;
18
- GameRunning(): boolean;
19
- NowMode(): ModeNames;
20
- Reset(): void;
21
- Random(): void;
22
- CalculateScore(): void;
23
- Result(): void;
24
- JudgeMode(): void;
25
- Logic(): void;
26
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
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";
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/types/P.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import { ModeNames } from "./Mode";
2
- type ModeRates = Record<ModeNames, number>;
3
- export interface PData {
4
- name: string;
5
- code: string;
6
- rates: ModeRates;
7
- scores: [number, number, number];
8
- }
9
- export declare class P implements PData {
10
- static Map: Map<string, P>;
11
- name: string;
12
- code: string;
13
- scores: [number, number, number];
14
- rates: ModeRates;
15
- constructor(name: string | undefined, code: string, scores?: [number, number, number], rates?: ModeRates);
16
- }
17
- export {};
package/dist/types/P.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.P = void 0;
4
- class P {
5
- static Map = new Map();
6
- name;
7
- code;
8
- scores;
9
- rates;
10
- constructor(name = "", code, scores = [0, 0, 0], rates = {
11
- Normal: 0,
12
- SuperHHH: 0,
13
- GreenWei: 0,
14
- PiKaChu: 0,
15
- }) {
16
- this.name = name;
17
- this.code = code;
18
- this.scores = scores;
19
- this.rates = rates;
20
- if (this.code && !P.Map.has(this.code)) {
21
- P.Map.set(this.code, this);
22
- }
23
- }
24
- }
25
- exports.P = P;
@@ -1,9 +0,0 @@
1
- import { BaseLaBaG } from "./BaseLaBaG";
2
- export declare class PlayLaBaG extends BaseLaBaG {
3
- Reset(): void;
4
- Random(): void;
5
- CalculateScore(): void;
6
- Result(): void;
7
- JudgeMode(): void;
8
- Logic(): void;
9
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlayLaBaG = void 0;
4
- const __1 = require("..");
5
- const BaseLaBaG_1 = require("./BaseLaBaG");
6
- class PlayLaBaG extends BaseLaBaG_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;
@@ -1,3 +0,0 @@
1
- import { AllDataType } from "../types/LaBaG";
2
- export declare const parseScore: (allData: AllDataType) => number;
3
- export declare const verifyScore: (score: number, allData: AllDataType) => boolean;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyScore = exports.parseScore = void 0;
4
- const JsonLaBaG_1 = require("../types/JsonLaBaG");
5
- const parseScore = (allData) => {
6
- const game = new JsonLaBaG_1.JsonLaBaG();
7
- game.SetupData(allData);
8
- game.Logic();
9
- return game.Score;
10
- };
11
- exports.parseScore = parseScore;
12
- const verifyScore = (score, allData) => (0, exports.parseScore)(allData) === score;
13
- exports.verifyScore = verifyScore;
File without changes
File without changes