labag 3.0.0 → 3.0.1

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/labag.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { Pattern, Payout } from "./types";
2
2
  export declare class LaBaG {
3
3
  patterns: Pattern[];
4
- reel: Pattern[];
4
+ reels: Pattern[];
5
5
  payouts: Payout[];
6
6
  constructor(patterns: Pattern[], payouts: Payout[]);
7
7
  spin(): {
8
- reel: Pattern[];
8
+ reels: Pattern[];
9
9
  reward: number;
10
10
  };
11
11
  randomPattern(): Pattern;
package/dist/labag.js CHANGED
@@ -4,22 +4,22 @@ exports.LaBaG = void 0;
4
4
  const randInt_1 = require("./utils/randInt");
5
5
  class LaBaG {
6
6
  patterns;
7
- reel;
7
+ reels;
8
8
  payouts;
9
9
  constructor(patterns, payouts) {
10
10
  this.patterns = patterns;
11
- this.reel = [patterns[0], patterns[1], patterns[2]];
11
+ this.reels = [patterns[0], patterns[1], patterns[2]];
12
12
  this.payouts = payouts;
13
13
  }
14
14
  spin() {
15
- this.reel = [
15
+ this.reels = [
16
16
  this.randomPattern(),
17
17
  this.randomPattern(),
18
18
  this.randomPattern(),
19
19
  ];
20
- const reward = this.caculateReward(this.reel);
20
+ const reward = this.caculateReward(this.reels);
21
21
  return {
22
- reel: this.reel,
22
+ reels: this.reels,
23
23
  reward,
24
24
  };
25
25
  }
package/dist/test.js CHANGED
@@ -1,2 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const labag_1 = require("./labag");
4
+ const patterns = [
5
+ { id: "A", weight: 50, image: "A.png" },
6
+ { id: "B", weight: 30, image: "B.png" },
7
+ { id: "C", weight: 20, image: "C.png" },
8
+ ];
9
+ const payouts = [
10
+ { id: "payout1", pattern_id: "A", match_count: 3, reward: 100 },
11
+ { id: "payout2", pattern_id: "B", match_count: 3, reward: 50 },
12
+ { id: "payout3", pattern_id: "C", match_count: 3, reward: 20 },
13
+ { id: "payout4", pattern_id: "A", match_count: 2, reward: 10 },
14
+ { id: "payout5", pattern_id: "B", match_count: 2, reward: 5 },
15
+ { id: "payout6", pattern_id: "C", match_count: 2, reward: 2 },
16
+ ];
17
+ const labag = new labag_1.LaBaG(patterns, payouts);
18
+ let totalReward = 0;
19
+ for (let i = 0; i < 10; i++) {
20
+ const result = labag.spin();
21
+ console.log(`Spin ${i + 1}:`, result);
22
+ totalReward += result.reward;
23
+ }
24
+ console.log("Total Reward:", totalReward);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "labag",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/labag.ts CHANGED
@@ -1,26 +1,25 @@
1
1
  import { Pattern, Payout } from "./types";
2
2
  import { randInt } from "./utils/randInt";
3
3
 
4
-
5
4
  export class LaBaG {
6
5
  patterns: Pattern[];
7
- reel: Pattern[];
6
+ reels: Pattern[];
8
7
  payouts: Payout[];
9
8
 
10
9
  constructor(patterns: Pattern[], payouts: Payout[]) {
11
10
  this.patterns = patterns;
12
- this.reel = [patterns[0], patterns[1], patterns[2]];
11
+ this.reels = [patterns[0], patterns[1], patterns[2]];
13
12
  this.payouts = payouts;
14
13
  }
15
14
  spin() {
16
- this.reel = [
15
+ this.reels = [
17
16
  this.randomPattern(),
18
17
  this.randomPattern(),
19
18
  this.randomPattern(),
20
19
  ];
21
- const reward = this.caculateReward(this.reel);
20
+ const reward = this.caculateReward(this.reels);
22
21
  return {
23
- reel: this.reel,
22
+ reels: this.reels,
24
23
  reward,
25
24
  };
26
25
  }
package/src/test.ts CHANGED
@@ -0,0 +1,26 @@
1
+ import { LaBaG } from "./labag";
2
+
3
+ const patterns = [
4
+ { id: "A", weight: 50 , image: "A.png"},
5
+ { id: "B", weight: 30 , image: "B.png"},
6
+ { id: "C", weight: 20 , image: "C.png"},
7
+ ];
8
+
9
+ const payouts = [
10
+ { id: "payout1", pattern_id: "A", match_count: 3, reward: 100 },
11
+ { id: "payout2", pattern_id: "B", match_count: 3, reward: 50 },
12
+ { id: "payout3", pattern_id: "C", match_count: 3, reward: 20 },
13
+ { id: "payout4", pattern_id: "A", match_count: 2, reward: 10 },
14
+ { id: "payout5", pattern_id: "B", match_count: 2, reward: 5 },
15
+ { id: "payout6", pattern_id: "C", match_count: 2, reward: 2 },
16
+ ];
17
+
18
+ const labag = new LaBaG(patterns, payouts);
19
+
20
+ let totalReward = 0;
21
+ for (let i = 0; i < 10; i++) {
22
+ const result = labag.spin();
23
+ console.log(`Spin ${i + 1}:`, result);
24
+ totalReward += result.reward;
25
+ }
26
+ console.log("Total Reward:", totalReward);