labag 1.0.1 → 1.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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import PDatas from "@/json/PDatas.json";
2
- import { P, PData } from "@/types/P";
3
1
  import { LaBaG } from "./types/LaBaG";
4
2
  import { Mode, ModeNames } from "./types/Mode";
5
3
  import { PlayLaBaG } from "./types/PlayLaBaG";
6
4
  import { JsonLaBaG } from "./types/JsonLaBaG";
5
+ import { P, PData } from "./types/P";
6
+ declare const PDatas: Record<string, PData>;
7
7
  declare const Modes: Record<Exclude<ModeNames, "Normal">, Mode>;
8
8
  export { LaBaG, PlayLaBaG, JsonLaBaG, Modes, ModeNames, P, PData, PDatas };
package/dist/index.js CHANGED
@@ -1,20 +1,54 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  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
4
  const RandInt_1 = require("./utils/RandInt");
12
5
  const PlayLaBaG_1 = require("./types/PlayLaBaG");
13
6
  Object.defineProperty(exports, "PlayLaBaG", { enumerable: true, get: function () { return PlayLaBaG_1.PlayLaBaG; } });
14
7
  const JsonLaBaG_1 = require("./types/JsonLaBaG");
15
8
  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);
9
+ const P_1 = require("./types/P");
10
+ Object.defineProperty(exports, "P", { enumerable: true, get: function () { return P_1.P; } });
11
+ const PDatas = {
12
+ Gss: {
13
+ name: "咖波",
14
+ code: "A",
15
+ rates: { Normal: 36, SuperHHH: 19, GreenWei: 36, PiKaChu: 36 },
16
+ scores: [800, 400, 180],
17
+ },
18
+ Hhh: {
19
+ name: "阿禾",
20
+ code: "B",
21
+ rates: { Normal: 24, SuperHHH: 5, GreenWei: 24, PiKaChu: 24 },
22
+ scores: [1500, 800, 300],
23
+ },
24
+ Hentai: {
25
+ name: "猥褻男",
26
+ code: "C",
27
+ rates: { Normal: 17, SuperHHH: 19, GreenWei: 17, PiKaChu: 17 },
28
+ scores: [2500, 1200, 500],
29
+ },
30
+ Handsun: {
31
+ name: "文傑",
32
+ code: "D",
33
+ rates: { Normal: 12, SuperHHH: 19, GreenWei: 12, PiKaChu: 12 },
34
+ scores: [2900, 1450, 690],
35
+ },
36
+ Kachu: {
37
+ name: "皮卡丘",
38
+ code: "E",
39
+ rates: { Normal: 8, SuperHHH: 19, GreenWei: 8, PiKaChu: 8 },
40
+ scores: [12000, 8000, 1250],
41
+ },
42
+ Rrr: {
43
+ name: "館長",
44
+ code: "F",
45
+ rates: { Normal: 3, SuperHHH: 19, GreenWei: 3, PiKaChu: 3 },
46
+ scores: [20000, 12000, 2500],
47
+ },
48
+ };
49
+ exports.PDatas = PDatas;
50
+ Object.values(PDatas).forEach((pd) => {
51
+ new P_1.P(pd.name, pd.code, pd.scores, pd.rates);
18
52
  });
19
53
  const Modes = {
20
54
  // 超級阿禾
@@ -38,7 +72,7 @@ const Modes = {
38
72
  this.Score = 0; // Reset score
39
73
  if (this.InMode) {
40
74
  this.Times -= 1;
41
- if (Game.Ps.every((p) => p?.Code === "B")) {
75
+ if (Game.Ps.every((p) => p?.code === "B")) {
42
76
  this.Times += 2;
43
77
  }
44
78
  if (this.Times <= 0) {
@@ -48,7 +82,7 @@ const Modes = {
48
82
  }
49
83
  }
50
84
  else {
51
- if (this.RandNum <= this.Rate && Game.Ps.some((p) => p?.Code === "B")) {
85
+ if (this.RandNum <= this.Rate && Game.Ps.some((p) => p?.code === "B")) {
52
86
  this.InMode = true;
53
87
  this.Times += 6;
54
88
  Game.ModeToScreen = true;
@@ -56,7 +90,7 @@ const Modes = {
56
90
  Modes.PiKaChu.InMode = false;
57
91
  }
58
92
  // 超級阿禾加倍
59
- if (Game.Ps.every((p) => p?.Code === "B")) {
93
+ if (Game.Ps.every((p) => p?.code === "B")) {
60
94
  this.Score = Math.round((Game.Score * Game.ScoreTime) / 2);
61
95
  Game.MarginScore += this.Score;
62
96
  }
@@ -83,7 +117,7 @@ const Modes = {
83
117
  }
84
118
  if (this.InMode) {
85
119
  this.Times -= 1;
86
- if (Game.Ps.every((p) => p?.Code === "A")) {
120
+ if (Game.Ps.every((p) => p?.code === "A")) {
87
121
  this.Times += 1;
88
122
  }
89
123
  if (this.Times <= 0) {
@@ -94,7 +128,7 @@ const Modes = {
94
128
  }
95
129
  else {
96
130
  if (this.RandNum <= this.Rate &&
97
- Game.Ps.every((p) => p?.Code === "A")) {
131
+ Game.Ps.every((p) => p?.code === "A")) {
98
132
  this.InMode = true;
99
133
  this.Times += 2;
100
134
  Game.ModeToScreen = true;
@@ -125,7 +159,7 @@ const Modes = {
125
159
  // 關掉其他模式
126
160
  Modes.SuperHHH.InMode = false;
127
161
  Modes.GreenWei.InMode = false;
128
- if (Game.Ps.some((p) => p?.Code === "E")) {
162
+ if (Game.Ps.some((p) => p?.code === "E")) {
129
163
  this.InMode = true;
130
164
  Game.Played -= 5;
131
165
  this.Times += 1;
@@ -34,16 +34,16 @@ class JsonLaBaG extends LaBaG_1.BaseLaBaG {
34
34
  __1.Modes.SuperHHH.RandNum = currData["SuperHHH"] ?? 0;
35
35
  __1.Modes.GreenWei.RandNum = currData["GreenWei"] ?? 0;
36
36
  const RateRange = this.RateRanges[this.NowMode()];
37
- const PCodes = Object.keys(P_1.P.Obj);
37
+ const PCodes = Object.keys(P_1.P.Map);
38
38
  RandNums.forEach((RandNum, i) => {
39
39
  const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
40
40
  if (code) {
41
- this.Ps[i] = P_1.P.Obj[code];
41
+ this.Ps[i] = P_1.P.Map.get(code) ?? null;
42
42
  }
43
43
  });
44
44
  // 累積 GreenWei 分數
45
45
  this.Ps.forEach((p) => {
46
- if (p?.Code === "A" &&
46
+ if (p?.code === "A" &&
47
47
  __1.Modes.GreenWei.Score !== undefined &&
48
48
  __1.Modes.GreenWei.Score < 20) {
49
49
  __1.Modes.GreenWei.Score += 1;
@@ -21,7 +21,7 @@ class BaseLaBaG {
21
21
  ].reduce((Ranges, mode) => {
22
22
  const res = [];
23
23
  let accRate = 0;
24
- for (const p of Object.values(P_1.P.Obj)) {
24
+ for (const p of Object.values(P_1.P.Map)) {
25
25
  accRate += p.Rates[mode];
26
26
  res.push(accRate);
27
27
  }
@@ -77,17 +77,17 @@ class BaseLaBaG {
77
77
  this.OneData["SuperHHH"] = __1.Modes.SuperHHH.RandNum;
78
78
  this.OneData["GreenWei"] = __1.Modes.GreenWei.RandNum;
79
79
  const RateRange = this.RateRanges[this.NowMode()];
80
- const PCodes = Object.keys(P_1.P.Obj);
80
+ const PCodes = Object.keys(P_1.P.Map);
81
81
  RandNums.forEach((RandNum, i) => {
82
82
  const code = PCodes.find((_, j) => RandNum <= RateRange[j]);
83
83
  if (code) {
84
- this.Ps[i] = P_1.P.Obj[code];
84
+ this.Ps[i] = P_1.P.Map.get(code) ?? null;
85
85
  }
86
86
  });
87
87
  // 累積咖波累積數
88
88
  this.Ps.forEach((p) => {
89
89
  if (__1.Modes.GreenWei.Score !== undefined) {
90
- if (p?.Code === "A" && __1.Modes.GreenWei.Score < 20) {
90
+ if (p?.code === "A" && __1.Modes.GreenWei.Score < 20) {
91
91
  __1.Modes.GreenWei.Score += 1;
92
92
  }
93
93
  }
@@ -95,32 +95,32 @@ class BaseLaBaG {
95
95
  }
96
96
  CalculateScore() {
97
97
  //計算分數
98
- const UniqueCount = new Set(this.Ps.map((p) => p?.Code)).size;
98
+ const UniqueCount = new Set(this.Ps.map((p) => p?.code)).size;
99
99
  switch (UniqueCount) {
100
100
  case 1: // 三個一樣
101
- this.MarginScore += this.Ps[0]?.Scores?.[0];
101
+ this.MarginScore += this.Ps[0]?.scores?.[0];
102
102
  break;
103
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];
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
107
  this.MarginScore = Math.round(this.MarginScore / 1.4);
108
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];
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
112
  this.MarginScore = Math.round(this.MarginScore / 1.4);
113
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];
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
117
  this.MarginScore = Math.round(this.MarginScore / 1.4);
118
118
  }
119
119
  break;
120
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];
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
124
  this.MarginScore = Math.round(this.MarginScore / 3);
125
125
  break;
126
126
  }
package/dist/types/P.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  import { ModeNames } from "./Mode";
2
- export type PData = {
2
+ type ModeRates = Record<ModeNames, number>;
3
+ export interface PData {
3
4
  name: string;
4
5
  code: string;
5
- rates: Record<ModeNames, number>;
6
+ rates: ModeRates;
6
7
  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
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 CHANGED
@@ -2,21 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.P = void 0;
4
4
  class P {
5
- static Obj = {};
6
- Code;
7
- Scores;
8
- Rates;
9
- constructor(Code = null, Scores = [0, 0, 0], Rates = {
5
+ static Map = new Map();
6
+ name;
7
+ code;
8
+ scores;
9
+ rates;
10
+ constructor(name = "", code, scores = [0, 0, 0], rates = {
10
11
  Normal: 0,
11
12
  SuperHHH: 0,
12
13
  GreenWei: 0,
13
14
  PiKaChu: 0,
14
15
  }) {
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;
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);
20
22
  }
21
23
  }
22
24
  }
@@ -22,7 +22,7 @@ class PlayLaBaG extends LaBaG_1.BaseLaBaG {
22
22
  Result() {
23
23
  super.Result();
24
24
  console.log("");
25
- console.log(`| ${this.Ps[0]?.Code} | ${this.Ps[1]?.Code} | ${this.Ps[2]?.Code} |`);
25
+ console.log(`| ${this.Ps[0]?.code} | ${this.Ps[1]?.code} | ${this.Ps[2]?.code} |`);
26
26
  console.log(`+ ${this.MarginScore}`);
27
27
  console.log(`目前分數: ${this.Score}`);
28
28
  console.log(`剩餘次數: ${this.Times - this.Played}`);
@@ -39,7 +39,7 @@ class PlayLaBaG extends LaBaG_1.BaseLaBaG {
39
39
  }
40
40
  }
41
41
  else {
42
- if (this.Ps.every((p) => p?.Code === "B")) {
42
+ if (this.Ps.every((p) => p?.code === "B")) {
43
43
  console.log("全阿禾,次數不消耗且+1!");
44
44
  }
45
45
  }
@@ -50,7 +50,7 @@ class PlayLaBaG extends LaBaG_1.BaseLaBaG {
50
50
  console.log("綠光阿瑋出現");
51
51
  }
52
52
  else {
53
- if (this.Ps.every((p) => p?.Code === "A")) {
53
+ if (this.Ps.every((p) => p?.code === "A")) {
54
54
  console.log("全咖波,次數不消耗!");
55
55
  }
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labag",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,38 +0,0 @@
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
- }