texas-poker-core 1.2.2 → 1.2.5

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/README.md CHANGED
@@ -10,9 +10,59 @@
10
10
  npm i texas-poker-core@latest
11
11
  ```
12
12
 
13
- # API 文档
14
-
15
- [点击跳转](https://www.wishufree.com/moment/share/213)
13
+ # 使用手册 Usage
14
+
15
+ ```ts
16
+ import { Texas } from 'texas-poker-core'
17
+
18
+ // 实例化Texas
19
+ const texas = new Texas({
20
+ // 大盲注
21
+ lowestBetAmount: 500,
22
+ // 允许的最大玩家数量
23
+ maximumCountOfPlayers: 7,
24
+ // 是否允许观战, 如果房间玩家达到上限时, 此字段决定玩家是否还可以加入房间
25
+ allowPlayersToWatch: true,
26
+ // room owner info
27
+ user: { id: 1, balance: 5000, name: 'ycr' },
28
+ thinkingTime: 5
29
+ })
30
+ const p2 = texas.createPlayer({ id: 2, name: 'yt', balance: 10000 })
31
+ const p3 = texas.createPlayer({ id: 3, name: 'wyz', balance: 10000 })
32
+ const p4 = texas.createPlayer({ id: 4, name: 'sen', balance: 10000 })
33
+ texas.room.joinMany(p2, p3, p4)
34
+
35
+ // 玩家行动前触发的回调函数, 包括允许的行动列表, 行动玩家的id, 以及允许的下注范围
36
+ texas.onPreAction((preAction) => {})
37
+ // 玩家行动后触发的回调函数
38
+ // 可在此函数中完成数据上报行为
39
+ texas.onAction((action) => {})
40
+ // 游戏阶段变化触发的回调函数
41
+ texas.onNextStage((stageInfo) => {})
42
+ // 游戏结束时触发的回调函数
43
+ texas.onGameEnd((gameEndInfo) => {
44
+ // 游戏结束后轮换庄家
45
+ texas.dealer.changeButtonToNextPlayer()
46
+ // 庄家变化后, 重新设置其他玩家的角色
47
+ texas.dealer.setOthers()
48
+ // 这里可以进行数据上报, 分配奖池, 更新用户的余额到数据库...
49
+
50
+ // 操作完成后重置对局信息
51
+ // 包括奖池, 底牌, 玩家手牌, 收回玩家的控制权...
52
+ texas.reset()
53
+ // 如果开启下一轮游戏, 只需再次调用`texas.start`即可
54
+ })
55
+ // 游戏进程中遇到错误触发的函数
56
+ texas.onError((texasError) => {})
57
+ // 房间初次创建时需调用, 确定各个玩家的角色
58
+ texas.ready()
59
+
60
+ // 开始游戏
61
+ // 大小盲默认下注, 可以通过texas.getDefaultBet获取默认下注信息
62
+ // 随后将控制权移交给小盲的下一位, 由具有行动权的玩家选择行动
63
+ // 会触发onPreAction回调, 可以在此方法中推送消息给客户端
64
+ texas.start()
65
+ ```
16
66
 
17
67
  # 发布记录
18
68
 
@@ -313,6 +363,16 @@ bufix
313
363
  修复 player.actionble 判断错误
314
364
 
315
365
  ## 1.2.1
316
- 完善texas.start逻辑
366
+
367
+ 完善 texas.start 逻辑
368
+
317
369
  ## 1.2.2
318
- 完善player.checkIfCanAct的逻辑
370
+
371
+ 完善 player.checkIfCanAct 的逻辑
372
+
373
+ ## 1.2.3
374
+
375
+ 测试 ncu
376
+
377
+ ## 1.2.5
378
+ 补充使用文档
@@ -2,9 +2,13 @@
2
2
 
3
3
  require("core-js/modules/es.symbol.js");
4
4
  require("core-js/modules/es.symbol.description.js");
5
+ require("core-js/modules/es.symbol.async-iterator.js");
5
6
  require("core-js/modules/es.symbol.iterator.js");
6
7
  require("core-js/modules/es.symbol.to-primitive.js");
8
+ require("core-js/modules/es.symbol.to-string-tag.js");
7
9
  require("core-js/modules/es.date.to-primitive.js");
10
+ require("core-js/modules/es.json.to-string-tag.js");
11
+ require("core-js/modules/es.math.to-string-tag.js");
8
12
  require("core-js/modules/es.number.constructor.js");
9
13
  require("core-js/modules/es.object.get-prototype-of.js");
10
14
  require("core-js/modules/es.promise.js");
@@ -370,7 +374,7 @@ var Controller = /*#__PURE__*/function () {
370
374
  value: function end() {
371
375
  if (this.status !== 'on') this.reportError(new _error.default(2100, '游戏不在进行中, 无法结束'));
372
376
  this.clearTimer();
373
- _classPrivateFieldSet(_status, this, 'waiting');
377
+ _classPrivateFieldSet(_status, this, 'end');
374
378
  this.resetActivePlayer();
375
379
  }
376
380
  }, {
@@ -2,11 +2,15 @@
2
2
 
3
3
  require("core-js/modules/es.symbol.js");
4
4
  require("core-js/modules/es.symbol.description.js");
5
+ require("core-js/modules/es.symbol.async-iterator.js");
5
6
  require("core-js/modules/es.symbol.iterator.js");
6
7
  require("core-js/modules/es.symbol.to-primitive.js");
8
+ require("core-js/modules/es.symbol.to-string-tag.js");
7
9
  require("core-js/modules/es.array.from.js");
8
10
  require("core-js/modules/es.array.slice.js");
9
11
  require("core-js/modules/es.date.to-primitive.js");
12
+ require("core-js/modules/es.json.to-string-tag.js");
13
+ require("core-js/modules/es.math.to-string-tag.js");
10
14
  require("core-js/modules/es.number.constructor.js");
11
15
  require("core-js/modules/es.object.get-prototype-of.js");
12
16
  require("core-js/modules/es.promise.js");
@@ -207,6 +211,15 @@ var Player = exports.Player = /*#__PURE__*/function () {
207
211
  get: function get() {
208
212
  return _classPrivateFieldGet(_thinkingTime, this);
209
213
  }
214
+ }, {
215
+ key: "getRemainThinkTime",
216
+ value:
217
+ /**
218
+ * @description 获取剩余的行动思考时间
219
+ */
220
+ function getRemainThinkTime() {
221
+ return _classPrivateFieldGet(_thinkingTime, this) - _classPrivateFieldGet(_countDownTime, this);
222
+ }
210
223
  }, {
211
224
  key: "setNextPlayer",
212
225
  value: function setNextPlayer(player) {
@@ -248,9 +261,12 @@ var Player = exports.Player = /*#__PURE__*/function () {
248
261
  return _classPrivateFieldGet(_status, this);
249
262
  }
250
263
  }, {
251
- key: "getOnlineStatus",
252
- value: function getOnlineStatus() {
264
+ key: "onlineStatus",
265
+ get: function get() {
253
266
  return _classPrivateFieldGet(_onlineStatus, this);
267
+ },
268
+ set: function set(value) {
269
+ _classPrivateFieldSet(_onlineStatus, this, value);
254
270
  }
255
271
  }, {
256
272
  key: "onPreAction",
@@ -759,6 +775,13 @@ var Player = exports.Player = /*#__PURE__*/function () {
759
775
  this.takeDefaultAction();
760
776
  return;
761
777
  }
778
+ // 如果当前玩家是离线状态, 延时一秒后直接采取默认行为
779
+ if (_classPrivateFieldGet(_onlineStatus, this) === 'offline') {
780
+ setTimeout(function () {
781
+ _this3.takeDefaultAction();
782
+ }, 1000);
783
+ return;
784
+ }
762
785
  if (!_classPrivateFieldGet(_timer, this)) _classPrivateFieldSet(_timer, this, setInterval(function () {
763
786
  var _this$countDownTime, _this$countDownTime2;
764
787
  if (_classPrivateFieldGet(_countDownTime, _this3) === 0 && _classPrivateFieldGet(_timer, _this3)) {
@@ -2,10 +2,14 @@
2
2
 
3
3
  require("core-js/modules/es.symbol.js");
4
4
  require("core-js/modules/es.symbol.description.js");
5
+ require("core-js/modules/es.symbol.async-iterator.js");
5
6
  require("core-js/modules/es.symbol.iterator.js");
6
7
  require("core-js/modules/es.symbol.to-primitive.js");
8
+ require("core-js/modules/es.symbol.to-string-tag.js");
7
9
  require("core-js/modules/es.array.slice.js");
8
10
  require("core-js/modules/es.date.to-primitive.js");
11
+ require("core-js/modules/es.json.to-string-tag.js");
12
+ require("core-js/modules/es.math.to-string-tag.js");
9
13
  require("core-js/modules/es.number.constructor.js");
10
14
  require("core-js/modules/es.object.get-prototype-of.js");
11
15
  require("core-js/modules/es.promise.js");
@@ -255,7 +255,11 @@ var Room = /*#__PURE__*/function () {
255
255
  if (_classPrivateFieldGet(_private, this) && _classPrivateFieldGet(_privateKey, this) !== key) this.reportError(new _error.default(2003, '私密房间不可加入'));
256
256
  if (!_classPrivateFieldGet(_allowPlayersToWatch, this) && this.playersCountOnSeat === _classPrivateFieldGet(_maximumCountOfPlayers, this)) this.reportError(new _error.default(2003, '房间设置了不可观战,并且玩家已满,不可加入'));
257
257
  if (!_classPrivateFieldGet(_allowPlayersToWatch, this) && player.lowestBetAmount < _classPrivateFieldGet(_lowestBetAmount, this)) this.reportError(new _error.default(2003, '房间设置了不可观战, 并且您的余额小于房间的最底下注,无法加入'));
258
- var seatStatus = this.playersCountOnSeat === _classPrivateFieldGet(_maximumCountOfPlayers, this) ? 'hang' : 'on-set';
258
+
259
+ // 人数已满 或者 游戏不在准备阶段, 都直接到观战席
260
+ // 要注意一点, 游戏也会在end阶段持续几秒, 这个时候也需要到观战席
261
+ // 防止在结算过程中,玩家加入坐席导致交互问题
262
+ var seatStatus = this.playersCountOnSeat === _classPrivateFieldGet(_maximumCountOfPlayers, this) || _classPrivateFieldGet(_controller, this).status !== 'waiting' ? 'hang' : 'on-set';
259
263
  if (seatStatus === 'hang') {
260
264
  _classPrivateFieldGet(_playersHang, this).add(player);
261
265
  } else {
@@ -283,6 +287,7 @@ var Room = /*#__PURE__*/function () {
283
287
  }, {
284
288
  key: "seat",
285
289
  value: function seat(player) {
290
+ if (_classPrivateFieldGet(_controller, this).status !== 'waiting') this.reportError(new _error.default(2003, '游戏还未结束, 无法入座'));
286
291
  if (!player || !_classPrivateFieldGet(_idToPlayerMap, this).has(player.getUserInfo().id)) this.reportError(new _error.default(2003, '您不在房间中,无法入座'));
287
292
  if (this.getPlayerSeatStatus(player) === 'on-set') this.reportError(new _error.default(2003, '您已在坐席中,请勿重复操作'));
288
293
  if (this.playersCountOnSeat === _classPrivateFieldGet(_maximumCountOfPlayers, this)) this.reportError(new _error.default(2003, '位置已满,无法加入坐席'));
@@ -298,6 +303,7 @@ var Room = /*#__PURE__*/function () {
298
303
  }, {
299
304
  key: "watch",
300
305
  value: function watch(player) {
306
+ if (_classPrivateFieldGet(_controller, this).status !== 'waiting') this.reportError(new _error.default(2003, '游戏正在进行中, 无法加入观战席'));
301
307
  if (!player || !_classPrivateFieldGet(_idToPlayerMap, this).has(player.getUserInfo().id)) this.reportError(new _error.default(2003, '您不在房间中,无法观战'));
302
308
  if (this.getPlayerSeatStatus(player) === 'hang') this.reportError(new _error.default(2003, '您已在观战席中,请勿重复操作'));
303
309
  _classPrivateFieldGet(_playersHang, this).add(player);
@@ -2,11 +2,15 @@
2
2
 
3
3
  require("core-js/modules/es.symbol.js");
4
4
  require("core-js/modules/es.symbol.description.js");
5
+ require("core-js/modules/es.symbol.async-iterator.js");
5
6
  require("core-js/modules/es.symbol.iterator.js");
7
+ require("core-js/modules/es.symbol.to-string-tag.js");
6
8
  require("core-js/modules/es.array.filter.js");
7
9
  require("core-js/modules/es.array.iterator.js");
8
10
  require("core-js/modules/es.array.slice.js");
9
11
  require("core-js/modules/es.function.name.js");
12
+ require("core-js/modules/es.json.to-string-tag.js");
13
+ require("core-js/modules/es.math.to-string-tag.js");
10
14
  require("core-js/modules/es.object.get-own-property-descriptor.js");
11
15
  require("core-js/modules/es.object.get-own-property-descriptors.js");
12
16
  require("core-js/modules/es.object.get-prototype-of.js");
package/dist/index.js CHANGED
@@ -36,9 +36,8 @@ var _exportNames = {
36
36
  Role: true,
37
37
  Action: true,
38
38
  ActionType: true,
39
- Player: true,
40
- ActionWithPayload: true,
41
- ActionWithOutPayload: true
39
+ OnlineStatus: true,
40
+ Player: true
42
41
  };
43
42
  Object.defineProperty(exports, "Action", {
44
43
  enumerable: true,
@@ -52,18 +51,6 @@ Object.defineProperty(exports, "ActionType", {
52
51
  return _Player.ActionType;
53
52
  }
54
53
  });
55
- Object.defineProperty(exports, "ActionWithOutPayload", {
56
- enumerable: true,
57
- get: function get() {
58
- return _Player.ActionWithOutPayload;
59
- }
60
- });
61
- Object.defineProperty(exports, "ActionWithPayload", {
62
- enumerable: true,
63
- get: function get() {
64
- return _Player.ActionWithPayload;
65
- }
66
- });
67
54
  Object.defineProperty(exports, "ControllerStatus", {
68
55
  enumerable: true,
69
56
  get: function get() {
@@ -82,6 +69,12 @@ Object.defineProperty(exports, "Deck", {
82
69
  return _Deck.default;
83
70
  }
84
71
  });
72
+ Object.defineProperty(exports, "OnlineStatus", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _Player.OnlineStatus;
76
+ }
77
+ });
85
78
  Object.defineProperty(exports, "Player", {
86
79
  enumerable: true,
87
80
  get: function get() {
@@ -3,10 +3,14 @@
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  require("core-js/modules/es.symbol.js");
5
5
  require("core-js/modules/es.symbol.description.js");
6
+ require("core-js/modules/es.symbol.async-iterator.js");
6
7
  require("core-js/modules/es.symbol.iterator.js");
8
+ require("core-js/modules/es.symbol.to-string-tag.js");
7
9
  require("core-js/modules/es.array.iterator.js");
8
10
  require("core-js/modules/es.array.slice.js");
9
11
  require("core-js/modules/es.function.name.js");
12
+ require("core-js/modules/es.json.to-string-tag.js");
13
+ require("core-js/modules/es.math.to-string-tag.js");
10
14
  require("core-js/modules/es.object.get-prototype-of.js");
11
15
  require("core-js/modules/es.string.iterator.js");
12
16
  require("core-js/modules/web.dom-collections.for-each.js");
@@ -3,10 +3,14 @@
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  require("core-js/modules/es.symbol.js");
5
5
  require("core-js/modules/es.symbol.description.js");
6
+ require("core-js/modules/es.symbol.async-iterator.js");
6
7
  require("core-js/modules/es.symbol.iterator.js");
8
+ require("core-js/modules/es.symbol.to-string-tag.js");
7
9
  require("core-js/modules/es.array.iterator.js");
8
10
  require("core-js/modules/es.array.slice.js");
9
11
  require("core-js/modules/es.function.name.js");
12
+ require("core-js/modules/es.json.to-string-tag.js");
13
+ require("core-js/modules/es.math.to-string-tag.js");
10
14
  require("core-js/modules/es.object.get-prototype-of.js");
11
15
  require("core-js/modules/es.string.iterator.js");
12
16
  require("core-js/modules/web.dom-collections.for-each.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "texas-poker-core",
3
- "version": "1.2.2",
3
+ "version": "1.2.5",
4
4
  "description": "德州扑克核心功能",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -12,13 +12,13 @@
12
12
  "lint": "eslint --cache --ext .ts ./src",
13
13
  "lint:fix": "eslint --fix --cache --ext .ts ./src",
14
14
  "prepublishOnly": "tsc --noEmit && pnpm run test",
15
- "build:types": "tsc && tsc-alias",
15
+ "build:types": "npx tsc && npx tsc-alias",
16
16
  "build:core": "babel src --out-dir dist --extensions \".ts\"",
17
17
  "build": "cross-env PROJECT_ENV=prd pnpm run build:types && pnpm run build:core",
18
18
  "push": "ts-node ./publish",
19
- "push-local": "npm run test && pnpm run build && pnpm run cp",
20
- "cp:types": "cp -r ./dist /Users/yangchengrong/Desktop/projects/wish_server/node_modules/texas-poker-core",
21
- "cp:js": "cp -r ./types /Users/yangchengrong/Desktop/projects/wish_server/node_modules/texas-poker-core",
19
+ "push-local": "pnpm run test && pnpm run build && pnpm run cp",
20
+ "cp:types": "cp -r ./dist /Users/yangxuanjing/Desktop/coding/wish_mono_server/node_modules/texas-poker-core",
21
+ "cp:js": "cp -r ./types /Users/yangxuanjing/Desktop/coding/wish_mono_server/node_modules/texas-poker-core",
22
22
  "cp": "pnpm run cp:types && pnpm run cp:js",
23
23
  "integration-test": "cross-env PROJECT_ENV=dev ts-node -r tsconfig-paths/register ./src/integration_test.ts",
24
24
  "simulator": "cross-env PROJECT_ENV=prd ts-node -r tsconfig-paths/register ./src/simulator_game_run.ts"
@@ -38,7 +38,6 @@
38
38
  "ramda": "^0.30.1"
39
39
  },
40
40
  "devDependencies": {
41
- "tsconfig-paths": "^4.2.0",
42
41
  "@babel/cli": "^7.26.4",
43
42
  "@babel/core": "^7.26.10",
44
43
  "@babel/preset-env": "^7.26.9",
@@ -60,6 +59,8 @@
60
59
  "ts-jest": "^29.2.6",
61
60
  "ts-node": "^10.9.2",
62
61
  "tsc-alias": "^1.8.11",
62
+ "tsconfig-paths": "^4.2.0",
63
+ "typescript": "^5.8.3",
63
64
  "typescript-eslint": "^8.26.0"
64
65
  },
65
66
  "lint-staged": {
@@ -4,18 +4,14 @@ import Controller from '../Controller';
4
4
  import { Poke } from '../Deck/constant';
5
5
  import { PreAction, GameComponent, TexasErrorCallback } from '../Texas';
6
6
  type PlayerStatus = 'allIn' | 'active' | 'waiting' | 'out';
7
- type OnlineStatus = 'online' | 'offline' | 'quit';
8
- export interface ActionWithOutPayload {
9
- type: Extract<ActionType, 'check' | 'fold'>;
10
- }
11
- export interface ActionWithPayload {
12
- type: Exclude<ActionType, 'check' | 'fold'>;
13
- payload: {
7
+ export type OnlineStatus = 'online' | 'offline' | 'quit';
8
+ export type Action = {
9
+ type: ActionType;
10
+ payload?: {
14
11
  value: number;
15
12
  [key: string]: any;
16
13
  };
17
- }
18
- export type Action = ActionWithOutPayload | ActionWithPayload;
14
+ };
19
15
  export type ActionType = 'check' | 'fold' | 'raise' | 'bet' | 'call' | 'allIn';
20
16
  export interface User {
21
17
  id: number;
@@ -61,6 +57,10 @@ export declare class Player implements GameComponent {
61
57
  get id(): number;
62
58
  get lowestBetAmount(): number;
63
59
  get thinkingTime(): number;
60
+ /**
61
+ * @description 获取剩余的行动思考时间
62
+ */
63
+ getRemainThinkTime(): number;
64
64
  setNextPlayer(player: Player | null): void;
65
65
  setPresentation(presentation: string): void;
66
66
  getPresentation(): string | undefined;
@@ -69,7 +69,8 @@ export declare class Player implements GameComponent {
69
69
  setLastPlayer(player: Player | null): void;
70
70
  setStatus(status: PlayerStatus): void;
71
71
  getStatus(): PlayerStatus;
72
- getOnlineStatus(): OnlineStatus;
72
+ get onlineStatus(): OnlineStatus;
73
+ set onlineStatus(value: OnlineStatus);
73
74
  onPreAction(callback: (params: PreAction) => void): void;
74
75
  reset(): void;
75
76
  setRole(role: Role): void;
package/types/index.d.ts CHANGED
@@ -8,6 +8,6 @@ import { roleMap, actionMap } from './Player/constant';
8
8
  import { Stage, ControllerStatus } from './Controller';
9
9
  import { texasErrorMap, TexasErrorCode } from './error/constant';
10
10
  import { RoomStatus, default as Room, PlayerSeatStatus } from './Room';
11
- import { User, Role, Action, ActionType, default as Player, ActionWithPayload, ActionWithOutPayload } from './Player';
11
+ import { User, Role, Action, ActionType, OnlineStatus, default as Player } from './Player';
12
12
  export * from './Deck/constant';
13
- export { Player, User, ActionType, Role, Action, ActionWithPayload, ActionWithOutPayload, roleMap, actionMap, Stage, ControllerStatus, stageMap, Dealer, Deck, Room, RoomStatus, PlayerSeatStatus, formatterPoke, TexasError, TexasErrorCode, texasErrorMap, Texas };
13
+ export { Player, User, ActionType, Role, Action, roleMap, actionMap, Stage, ControllerStatus, stageMap, Dealer, Deck, Room, RoomStatus, PlayerSeatStatus, formatterPoke, TexasError, TexasErrorCode, texasErrorMap, Texas, OnlineStatus };
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stageMap = void 0;
7
- require("core-js/modules/es.array.iterator.js");
8
- require("core-js/modules/es.map.js");
9
- require("core-js/modules/es.object.to-string.js");
10
- require("core-js/modules/es.string.iterator.js");
11
- require("core-js/modules/esnext.map.delete-all.js");
12
- require("core-js/modules/esnext.map.every.js");
13
- require("core-js/modules/esnext.map.filter.js");
14
- require("core-js/modules/esnext.map.find.js");
15
- require("core-js/modules/esnext.map.find-key.js");
16
- require("core-js/modules/esnext.map.includes.js");
17
- require("core-js/modules/esnext.map.key-of.js");
18
- require("core-js/modules/esnext.map.map-keys.js");
19
- require("core-js/modules/esnext.map.map-values.js");
20
- require("core-js/modules/esnext.map.merge.js");
21
- require("core-js/modules/esnext.map.reduce.js");
22
- require("core-js/modules/esnext.map.some.js");
23
- require("core-js/modules/esnext.map.update.js");
24
- require("core-js/modules/web.dom-collections.iterator.js");
25
- var stageMap = exports.stageMap = new Map([['pre_flop', '翻牌前'], ['flop', '翻牌圈'], ['turn', '转牌圈'], ['river', '河牌']]);
package/dist/__game.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- require("core-js/modules/es.symbol.js");
5
- require("core-js/modules/es.symbol.description.js");
6
- require("core-js/modules/es.symbol.iterator.js");
7
- require("core-js/modules/es.array.iterator.js");
8
- require("core-js/modules/es.array.slice.js");
9
- require("core-js/modules/es.function.name.js");
10
- require("core-js/modules/es.object.get-prototype-of.js");
11
- require("core-js/modules/es.string.iterator.js");
12
- require("core-js/modules/web.dom-collections.for-each.js");
13
- require("core-js/modules/web.dom-collections.iterator.js");
14
- require("core-js/modules/es.array.join.js");
15
- require("core-js/modules/es.object.to-string.js");
16
- require("core-js/modules/es.promise.js");
17
- var _main = require("./main");
18
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
19
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
20
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
21
- var texas = (0, _main.initialGame)({
22
- lowestBetAmount: 500,
23
- maximumCountOfPlayers: 7,
24
- allowPlayersToWatch: true,
25
- user: {
26
- id: 1,
27
- balance: 5000,
28
- name: 'ycr'
29
- }
30
- });
31
- // const p1 = texas.room.owner
32
- var p2 = texas.createPlayer({
33
- id: 2,
34
- balance: 10000,
35
- name: 'yt'
36
- });
37
- var p3 = texas.createPlayer({
38
- id: 3,
39
- balance: 10000,
40
- name: 'wyz'
41
- });
42
- var p4 = texas.createPlayer({
43
- id: 4,
44
- balance: 10000,
45
- name: 'the Sen'
46
- });
47
- texas.room.join(p2);
48
- texas.room.join(p3);
49
- texas.room.join(p4);
50
- var delay = function delay() {
51
- var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
52
- return new Promise(function (resolve) {
53
- setTimeout(function () {
54
- resolve(0);
55
- }, ms);
56
- });
57
- };
58
- function test() {
59
- return _test.apply(this, arguments);
60
- }
61
- function _test() {
62
- _test = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
63
- return _regeneratorRuntime().wrap(function _callee$(_context) {
64
- while (1) switch (_context.prev = _context.next) {
65
- case 0:
66
- if (!true) {
67
- _context.next = 6;
68
- break;
69
- }
70
- texas.start();
71
- _context.next = 4;
72
- return delay(50000);
73
- case 4:
74
- _context.next = 0;
75
- break;
76
- case 6:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }));
82
- return _test.apply(this, arguments);
83
- }
84
- test();
@@ -1,115 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- require("core-js/modules/es.symbol.js");
5
- require("core-js/modules/es.symbol.description.js");
6
- require("core-js/modules/es.symbol.iterator.js");
7
- require("core-js/modules/es.array.iterator.js");
8
- require("core-js/modules/es.array.slice.js");
9
- require("core-js/modules/es.function.name.js");
10
- require("core-js/modules/es.object.get-prototype-of.js");
11
- require("core-js/modules/es.string.iterator.js");
12
- require("core-js/modules/web.dom-collections.for-each.js");
13
- require("core-js/modules/web.dom-collections.iterator.js");
14
- require("core-js/modules/es.array.concat.js");
15
- require("core-js/modules/es.array.join.js");
16
- require("core-js/modules/es.object.to-string.js");
17
- require("core-js/modules/es.promise.js");
18
- var _main = require("./main");
19
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
20
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
21
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // 此文件为游戏进程的模拟
22
- // 循环运行, 尝试找出在实际运行中
23
- // 出现的边缘请款
24
- var texas = (0, _main.initialGame)({
25
- lowestBetAmount: 500,
26
- maximumCountOfPlayers: 7,
27
- allowPlayersToWatch: true,
28
- user: {
29
- id: 1,
30
- balance: 5000,
31
- name: 'ycr'
32
- }
33
- });
34
- // const p1 = texas.room.owner
35
- var p2 = texas.createPlayer({
36
- id: 2,
37
- balance: 10000,
38
- name: 'yt'
39
- });
40
- var p3 = texas.createPlayer({
41
- id: 3,
42
- balance: 10000,
43
- name: 'wyz'
44
- });
45
- var p4 = texas.createPlayer({
46
- id: 4,
47
- balance: 10000,
48
- name: 'the Sen'
49
- });
50
- var p5 = texas.createPlayer({
51
- id: 5,
52
- balance: 30000,
53
- name: 'wxl'
54
- });
55
- texas.room.join(p2);
56
- texas.room.join(p3);
57
- texas.room.join(p4);
58
- texas.room.join(p5);
59
- var delay = function delay() {
60
- var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
61
- return new Promise(function (resolve) {
62
- setTimeout(function () {
63
- resolve(0);
64
- }, ms);
65
- });
66
- };
67
- var count = 0;
68
- var errorCount = 0;
69
- function test() {
70
- return _test.apply(this, arguments);
71
- }
72
- function _test() {
73
- _test = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74
- return _regeneratorRuntime().wrap(function _callee$(_context) {
75
- while (1) switch (_context.prev = _context.next) {
76
- case 0:
77
- texas.ready();
78
- case 1:
79
- if (!(count < 10000)) {
80
- _context.next = 18;
81
- break;
82
- }
83
- try {
84
- texas.end();
85
- } catch (_unused) {}
86
- _context.prev = 3;
87
- texas.start();
88
- console.log(count);
89
- _context.next = 8;
90
- return delay(20);
91
- case 8:
92
- _context.next = 13;
93
- break;
94
- case 10:
95
- _context.prev = 10;
96
- _context.t0 = _context["catch"](3);
97
- errorCount++;
98
- case 13:
99
- _context.prev = 13;
100
- count++;
101
- return _context.finish(13);
102
- case 16:
103
- _context.next = 1;
104
- break;
105
- case 18:
106
- console.log("\u6A21\u62DF\u8FD0\u884C".concat(count, "\u6B21, \u5931\u8D25: ").concat(errorCount, "\u6B21"));
107
- case 19:
108
- case "end":
109
- return _context.stop();
110
- }
111
- }, _callee, null, [[3, 10, 13, 16]]);
112
- }));
113
- return _test.apply(this, arguments);
114
- }
115
- test();
package/dist/_game.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.join.js");
4
- var _main = require("./main");
5
- var texas = (0, _main.initialGame)({
6
- lowestBetAmount: 500,
7
- maximumCountOfPlayers: 7,
8
- allowPlayersToWatch: true,
9
- user: {
10
- id: 1,
11
- balance: 5000,
12
- name: 'ycr'
13
- }
14
- });
15
- // const p1 = texas.room.owner
16
- var p2 = texas.createPlayer({
17
- id: 2,
18
- balance: 10000,
19
- name: 'yt'
20
- });
21
- var p3 = texas.createPlayer({
22
- id: 3,
23
- balance: 10000,
24
- name: 'wyz'
25
- });
26
- var p4 = texas.createPlayer({
27
- id: 4,
28
- balance: 10000,
29
- name: 'the Sen'
30
- });
31
- texas.room.join(p2);
32
- texas.room.join(p3);
33
- texas.room.join(p4);
34
- texas.start();
package/dist/main.js DELETED
@@ -1,168 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- require("core-js/modules/es.symbol.js");
5
- require("core-js/modules/es.symbol.description.js");
6
- require("core-js/modules/es.symbol.iterator.js");
7
- require("core-js/modules/es.array.iterator.js");
8
- require("core-js/modules/es.array.slice.js");
9
- require("core-js/modules/es.function.name.js");
10
- require("core-js/modules/es.object.get-prototype-of.js");
11
- require("core-js/modules/es.string.iterator.js");
12
- require("core-js/modules/web.dom-collections.iterator.js");
13
- Object.defineProperty(exports, "__esModule", {
14
- value: true
15
- });
16
- exports.initialGame = void 0;
17
- require("core-js/modules/es.object.to-string.js");
18
- require("core-js/modules/es.promise.js");
19
- require("core-js/modules/web.dom-collections.for-each.js");
20
- var _Room = _interopRequireDefault(require("./Room"));
21
- var _Pool = _interopRequireDefault(require("./Pool"));
22
- var _Dealer = _interopRequireDefault(require("./Dealer"));
23
- var _error = _interopRequireDefault(require("./error"));
24
- var _Player = require("./Player");
25
- var _Controller = _interopRequireDefault(require("./Controller"));
26
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
28
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
29
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } // 控制游戏的进程
30
- // class Game
31
- // 在表单中填入一些基本的信息
32
- // 比如大盲注
33
- // 最大玩家数量
34
- // 是否允许观战
35
-
36
- var initialGame = exports.initialGame = function initialGame(_ref) {
37
- var user = _ref.user,
38
- thinkingTime = _ref.thinkingTime,
39
- lowestBetAmount = _ref.lowestBetAmount,
40
- allowPlayersToWatch = _ref.allowPlayersToWatch,
41
- maximumCountOfPlayers = _ref.maximumCountOfPlayers,
42
- shouldTakeDefaultAction = _ref.shouldTakeDefaultAction;
43
- var dealer = new _Dealer.default(lowestBetAmount);
44
- var controller = new _Controller.default(dealer);
45
- var pool = new _Pool.default();
46
- var owner = new _Player.Player({
47
- user: user,
48
- lowestBetAmount: lowestBetAmount,
49
- controller: controller,
50
- dealer: dealer,
51
- pool: pool,
52
- shouldTakeDefaultAction: shouldTakeDefaultAction,
53
- thinkingTime: thinkingTime
54
- });
55
- var room = new _Room.default(dealer, owner, controller, allowPlayersToWatch, maximumCountOfPlayers);
56
- return {
57
- room: room,
58
- pool: pool,
59
- dealer: dealer,
60
- controller: controller,
61
- createPlayer: function createPlayer(userInfo) {
62
- return new _Player.Player({
63
- pool: pool,
64
- dealer: dealer,
65
- controller: controller,
66
- thinkingTime: thinkingTime,
67
- user: userInfo,
68
- shouldTakeDefaultAction: shouldTakeDefaultAction,
69
- lowestBetAmount: dealer.lowestBetAmount
70
- });
71
- },
72
- // 设置各个玩家的初始角色
73
- ready: function ready() {
74
- room.ready();
75
- },
76
- start: function start() {
77
- var _this = this;
78
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
79
- return _regeneratorRuntime().wrap(function _callee$(_context) {
80
- while (1) switch (_context.prev = _context.next) {
81
- case 0:
82
- if (!(room.status === 'unReady')) {
83
- _context.next = 2;
84
- break;
85
- }
86
- throw new _error.default(2100, '玩家位置未确认, 无法进行游戏');
87
- case 2:
88
- if (!(controller.status !== 'waiting')) {
89
- _context.next = 4;
90
- break;
91
- }
92
- throw new _error.default(2100, '游戏已经开始, 请勿重复操作');
93
- case 4:
94
- _this.resetBeforeGameStart();
95
- dealer.dealCards();
96
- _context.next = 8;
97
- return controller.start();
98
- case 8:
99
- case "end":
100
- return _context.stop();
101
- }
102
- }, _callee);
103
- }))();
104
- },
105
- // 获取默认下注行为
106
- getDefaultBet: function getDefaultBet() {
107
- return controller.defaultBets;
108
- },
109
- onPreAction: function onPreAction(callback) {
110
- this.dealer.forEach(function (player) {
111
- player.onPreAction(callback);
112
- });
113
- },
114
- onGameEnd: function onGameEnd(callback) {
115
- this.controller.onGameEnd(callback);
116
- },
117
- onNextStage: function onNextStage(callback) {
118
- controller.onNextStage(callback);
119
- },
120
- onGameStart: function onGameStart(callback) {
121
- this.controller.onGameStart(callback);
122
- },
123
- /**
124
- * 监听玩家采取行动
125
- */
126
- onAction: function onAction(callback) {
127
- dealer.forEach(function (player) {
128
- return player.onAction(callback);
129
- });
130
- },
131
- // 测试阶段方法, 手动结束游戏
132
- end: function end() {
133
- if (controller.status === 'waiting') throw new _error.default(2100, '游戏还未开始, 无法结束游戏');
134
- controller.end();
135
- },
136
- settle: function settle() {
137
- return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
138
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
139
- while (1) switch (_context2.prev = _context2.next) {
140
- case 0:
141
- dealer.settle();
142
- // 计算并分配奖池
143
- _context2.next = 3;
144
- return pool.pay();
145
- case 3:
146
- case "end":
147
- return _context2.stop();
148
- }
149
- }, _callee2);
150
- }))();
151
- },
152
- reset: function reset() {
153
- pool.reset();
154
- dealer.reset();
155
- controller.reset();
156
- },
157
- /**
158
- *@description 在游戏开始时重置所有状态
159
- *目前没有考虑游戏异常结束的情况
160
- *所以需要在游戏开始时调用此方法去重置状态
161
- */
162
- resetBeforeGameStart: function resetBeforeGameStart() {
163
- pool.reset();
164
- dealer.reset();
165
- controller.reset();
166
- }
167
- };
168
- };
@@ -1,2 +0,0 @@
1
- import { Stage } from '.';
2
- export declare const stageMap: Map<Stage, string>;
@@ -1 +0,0 @@
1
- export {};
package/types/main.d.ts DELETED
@@ -1,57 +0,0 @@
1
- import Room from './Room';
2
- import Pool from './Pool';
3
- import Dealer from './Dealer';
4
- import { ActionType } from './Player/index';
5
- import { User, Player, CallbackOfAction } from './Player';
6
- import Controller, { CallbackOfGameEnd, CallbackOnNextStage } from './Controller';
7
- interface CreateRoomInputArgs {
8
- lowestBetAmount: number;
9
- maximumCountOfPlayers: number;
10
- allowPlayersToWatch: boolean;
11
- user: User;
12
- /**
13
- * 是否需要在超时 采取默认行动
14
- */
15
- shouldTakeDefaultAction?: boolean;
16
- thinkingTime?: number;
17
- }
18
- export interface PreAction {
19
- userId: number;
20
- allowedActions: ActionType[];
21
- restrict?: {
22
- min: number;
23
- max: number;
24
- };
25
- }
26
- declare const initialGame: ({ user, thinkingTime, lowestBetAmount, allowPlayersToWatch, maximumCountOfPlayers, shouldTakeDefaultAction }: CreateRoomInputArgs) => {
27
- room: Room;
28
- pool: Pool;
29
- dealer: Dealer;
30
- controller: Controller;
31
- createPlayer(userInfo: User): Player;
32
- ready(): void;
33
- start(): Promise<void>;
34
- getDefaultBet(): {
35
- userId: number;
36
- balance: number;
37
- amount: number;
38
- }[];
39
- onPreAction(callback: (params: PreAction) => void): void;
40
- onGameEnd(callback: CallbackOfGameEnd): void;
41
- onNextStage(callback: CallbackOnNextStage): void;
42
- onGameStart(callback: () => Promise<void>): void;
43
- /**
44
- * 监听玩家采取行动
45
- */
46
- onAction(callback: CallbackOfAction): void;
47
- end(): void;
48
- settle(): Promise<void>;
49
- reset(): void;
50
- /**
51
- *@description 在游戏开始时重置所有状态
52
- *目前没有考虑游戏异常结束的情况
53
- *所以需要在游戏开始时调用此方法去重置状态
54
- */
55
- resetBeforeGameStart(): void;
56
- };
57
- export { initialGame };
@@ -1 +0,0 @@
1
- export {};