texas-poker-core 1.3.1 → 1.3.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/README.md +3 -1
- package/dist/Dealer/index.js +3 -2
- package/dist/Player/constant.js +36 -12
- package/dist/Player/index.js +13 -7
- package/dist/index.js +7 -0
- package/package.json +1 -1
- package/types/Player/constant.d.ts +26 -3
- package/types/Player/index.d.ts +4 -3
- package/types/index.d.ts +2 -2
package/README.md
CHANGED
package/dist/Dealer/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _Deck = _interopRequireDefault(require("../Deck"));
|
|
9
9
|
var _TexasError = _interopRequireDefault(require("../TexasError"));
|
|
10
10
|
var _utils = require("../utils");
|
|
11
|
+
var _Player = require("../Player");
|
|
11
12
|
var _constant = require("../Player/constant");
|
|
12
13
|
var _core = require("../Deck/core");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -322,7 +323,7 @@ var Dealer = /*#__PURE__*/function () {
|
|
|
322
323
|
value: function setButton(player) {
|
|
323
324
|
var _this2 = this;
|
|
324
325
|
if (player) {
|
|
325
|
-
player.setRole(
|
|
326
|
+
player.setRole(_Player.RoleEnum.BTN);
|
|
326
327
|
_classPrivateFieldSet(_button, this, player);
|
|
327
328
|
return;
|
|
328
329
|
}
|
|
@@ -334,7 +335,7 @@ var Dealer = /*#__PURE__*/function () {
|
|
|
334
335
|
var random = (0, _utils.getRandomInt)(0, count - 1);
|
|
335
336
|
this.forEach(function (p, i) {
|
|
336
337
|
if (i === random) {
|
|
337
|
-
p.setRole(
|
|
338
|
+
p.setRole(_Player.RoleEnum.BTN);
|
|
338
339
|
_classPrivateFieldSet(_button, _this2, p);
|
|
339
340
|
}
|
|
340
341
|
});
|
package/dist/Player/constant.js
CHANGED
|
@@ -3,22 +3,46 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.roleMap = exports.playerRoleSetMap = exports.ActionTypeMap = exports.ActionTypeEnum = void 0;
|
|
6
|
+
exports.roleMap = exports.playerRoleSetMap = exports.RoleEnum = exports.ActionTypeMap = exports.ActionTypeEnum = void 0;
|
|
7
7
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
9
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
10
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
11
11
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
/** 座位角色枚举 */
|
|
14
|
+
var RoleEnum = exports.RoleEnum = /*#__PURE__*/function (RoleEnum) {
|
|
15
|
+
/** 庄家/按钮 */
|
|
16
|
+
RoleEnum["BTN"] = "btn";
|
|
17
|
+
/** 小盲 */
|
|
18
|
+
RoleEnum["SB"] = "sb";
|
|
19
|
+
/** 大盲 */
|
|
20
|
+
RoleEnum["BB"] = "bb";
|
|
21
|
+
/** 枪口 */
|
|
22
|
+
RoleEnum["UTG"] = "utg";
|
|
23
|
+
/** 枪口+1 */
|
|
24
|
+
RoleEnum["UTG1"] = "utg1";
|
|
25
|
+
/** 枪口+2(10 人桌) */
|
|
26
|
+
RoleEnum["UTG2"] = "utg2";
|
|
27
|
+
/** 中位 */
|
|
28
|
+
RoleEnum["MP"] = "mp";
|
|
29
|
+
/** Lojack(10 人桌) */
|
|
30
|
+
RoleEnum["LJ"] = "lj";
|
|
31
|
+
/** 劫持位 */
|
|
32
|
+
RoleEnum["HJ"] = "hj";
|
|
33
|
+
/** 关煞位 */
|
|
34
|
+
RoleEnum["CO"] = "co";
|
|
35
|
+
return RoleEnum;
|
|
36
|
+
}({});
|
|
37
|
+
var twoPlayer = [RoleEnum.BTN, RoleEnum.BB];
|
|
38
|
+
var threePlayer = [RoleEnum.BTN, RoleEnum.SB, RoleEnum.BB];
|
|
39
|
+
var fourPlayer = threePlayer.concat(RoleEnum.UTG);
|
|
40
|
+
var fivePlayer = fourPlayer.concat(RoleEnum.MP);
|
|
41
|
+
var sixPlayer = fivePlayer.concat(RoleEnum.CO);
|
|
42
|
+
var sevenPlayer = [].concat(_toConsumableArray(sixPlayer.slice(0, -1)), [RoleEnum.HJ], _toConsumableArray(sixPlayer.slice(-1)));
|
|
43
|
+
var eightPlayer = [].concat(_toConsumableArray(sevenPlayer.slice(0, 5)), [RoleEnum.LJ], _toConsumableArray(sevenPlayer.slice(5)));
|
|
44
|
+
var ninePlayer = [].concat(_toConsumableArray(eightPlayer.slice(0, 4)), [RoleEnum.UTG1], _toConsumableArray(eightPlayer.slice(4)));
|
|
45
|
+
var tenPlayer = [].concat(_toConsumableArray(ninePlayer.slice(0, 5)), [RoleEnum.UTG2], _toConsumableArray(ninePlayer.slice(5)));
|
|
22
46
|
var ActionTypeEnum = exports.ActionTypeEnum = /*#__PURE__*/function (ActionTypeEnum) {
|
|
23
47
|
ActionTypeEnum["CALL"] = "call";
|
|
24
48
|
ActionTypeEnum["CHECK"] = "check";
|
|
@@ -29,5 +53,5 @@ var ActionTypeEnum = exports.ActionTypeEnum = /*#__PURE__*/function (ActionTypeE
|
|
|
29
53
|
return ActionTypeEnum;
|
|
30
54
|
}({});
|
|
31
55
|
var ActionTypeMap = exports.ActionTypeMap = new Map([[ActionTypeEnum.CALL, '跟注'], [ActionTypeEnum.CHECK, '过牌'], [ActionTypeEnum.FOLD, '弃牌'], [ActionTypeEnum.RAISE, '加注'], [ActionTypeEnum.ALL_IN, 'All In'], [ActionTypeEnum.BET, '下注']]);
|
|
32
|
-
var roleMap = exports.roleMap = new Map([[
|
|
33
|
-
var playerRoleSetMap = exports.playerRoleSetMap = new Map([[1, [
|
|
56
|
+
var roleMap = exports.roleMap = new Map([[RoleEnum.BTN, '庄家'], [RoleEnum.SB, '小盲'], [RoleEnum.BB, '大盲'], [RoleEnum.UTG, '枪口'], [RoleEnum.UTG1, '枪口+1'], [RoleEnum.UTG2, '枪口+2'], [RoleEnum.MP, '中位'], [RoleEnum.LJ, 'Lojack'], [RoleEnum.HJ, '劫持位'], [RoleEnum.CO, '关煞']]);
|
|
57
|
+
var playerRoleSetMap = exports.playerRoleSetMap = new Map([[1, [RoleEnum.BTN]], [2, twoPlayer], [3, threePlayer], [4, fourPlayer], [5, fivePlayer], [6, sixPlayer], [7, sevenPlayer], [8, eightPlayer], [9, ninePlayer], [10, tenPlayer]]);
|
package/dist/Player/index.js
CHANGED
|
@@ -10,7 +10,14 @@ Object.defineProperty(exports, "ActionTypeEnum", {
|
|
|
10
10
|
return _constant.ActionTypeEnum;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.
|
|
13
|
+
exports.Player = void 0;
|
|
14
|
+
Object.defineProperty(exports, "RoleEnum", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _constant.RoleEnum;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.default = void 0;
|
|
14
21
|
var _TexasError = _interopRequireDefault(require("../TexasError"));
|
|
15
22
|
var _utils = require("../utils");
|
|
16
23
|
var _config = require("../config");
|
|
@@ -38,9 +45,11 @@ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t),
|
|
|
38
45
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
39
46
|
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
40
47
|
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
41
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
42
|
-
// 玩家的状态
|
|
48
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } // 玩家的状态
|
|
43
49
|
// 玩家回合时采取的行动(使用枚举值作为类型)
|
|
50
|
+
/**
|
|
51
|
+
* 玩家
|
|
52
|
+
*/
|
|
44
53
|
var _role = /*#__PURE__*/new WeakMap();
|
|
45
54
|
var _userInfo = /*#__PURE__*/new WeakMap();
|
|
46
55
|
var _pool = /*#__PURE__*/new WeakMap();
|
|
@@ -65,9 +74,6 @@ var _rankStrength = /*#__PURE__*/new WeakMap();
|
|
|
65
74
|
var _callback = /*#__PURE__*/new WeakMap();
|
|
66
75
|
var _callbackOfAction = /*#__PURE__*/new WeakMap();
|
|
67
76
|
var _Player_brand = /*#__PURE__*/new WeakSet();
|
|
68
|
-
/**
|
|
69
|
-
* 玩家
|
|
70
|
-
*/
|
|
71
77
|
var Player = exports.Player = /*#__PURE__*/function () {
|
|
72
78
|
function Player(_ref) {
|
|
73
79
|
var lowestBetAmount = _ref.lowestBetAmount,
|
|
@@ -865,7 +871,7 @@ var Player = exports.Player = /*#__PURE__*/function () {
|
|
|
865
871
|
}();
|
|
866
872
|
_Player = Player;
|
|
867
873
|
function _isBigBlindOptionInPreFlop() {
|
|
868
|
-
return _classPrivateFieldGet(_controller, this).stage === _Controller.StageEnum.PRE_FLOP && _classPrivateFieldGet(_role, this) ===
|
|
874
|
+
return _classPrivateFieldGet(_controller, this).stage === _Controller.StageEnum.PRE_FLOP && _classPrivateFieldGet(_role, this) === _constant.RoleEnum.BB && _classPrivateFieldGet(_currentStageTotalAmount, this) >= this.getMaxBetAmountAtCurrentStage();
|
|
869
875
|
}
|
|
870
876
|
/**
|
|
871
877
|
* @description 获取玩家允许的行动列表
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var _exportNames = {
|
|
|
27
27
|
PlayerSeatStatus: true,
|
|
28
28
|
User: true,
|
|
29
29
|
Role: true,
|
|
30
|
+
RoleEnum: true,
|
|
30
31
|
Action: true,
|
|
31
32
|
ActionType: true,
|
|
32
33
|
OnlineStatus: true,
|
|
@@ -99,6 +100,12 @@ Object.defineProperty(exports, "Role", {
|
|
|
99
100
|
return _Player.Role;
|
|
100
101
|
}
|
|
101
102
|
});
|
|
103
|
+
Object.defineProperty(exports, "RoleEnum", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function get() {
|
|
106
|
+
return _Player.RoleEnum;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
102
109
|
Object.defineProperty(exports, "Room", {
|
|
103
110
|
enumerable: true,
|
|
104
111
|
get: function get() {
|
package/package.json
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/** 座位角色枚举 */
|
|
2
|
+
export declare enum RoleEnum {
|
|
3
|
+
/** 庄家/按钮 */
|
|
4
|
+
BTN = "btn",
|
|
5
|
+
/** 小盲 */
|
|
6
|
+
SB = "sb",
|
|
7
|
+
/** 大盲 */
|
|
8
|
+
BB = "bb",
|
|
9
|
+
/** 枪口 */
|
|
10
|
+
UTG = "utg",
|
|
11
|
+
/** 枪口+1 */
|
|
12
|
+
UTG1 = "utg1",
|
|
13
|
+
/** 枪口+2(10 人桌) */
|
|
14
|
+
UTG2 = "utg2",
|
|
15
|
+
/** 中位 */
|
|
16
|
+
MP = "mp",
|
|
17
|
+
/** Lojack(10 人桌) */
|
|
18
|
+
LJ = "lj",
|
|
19
|
+
/** 劫持位 */
|
|
20
|
+
HJ = "hj",
|
|
21
|
+
/** 关煞位 */
|
|
22
|
+
CO = "co"
|
|
23
|
+
}
|
|
24
|
+
export type Role = RoleEnum;
|
|
2
25
|
export declare enum ActionTypeEnum {
|
|
3
26
|
CALL = "call",
|
|
4
27
|
CHECK = "check",
|
|
@@ -8,6 +31,6 @@ export declare enum ActionTypeEnum {
|
|
|
8
31
|
BET = "bet"
|
|
9
32
|
}
|
|
10
33
|
export declare const ActionTypeMap: Map<ActionTypeEnum, string>;
|
|
11
|
-
export declare const roleMap: Map<
|
|
12
|
-
declare const playerRoleSetMap: Map<number,
|
|
34
|
+
export declare const roleMap: Map<RoleEnum, string>;
|
|
35
|
+
declare const playerRoleSetMap: Map<number, RoleEnum[]>;
|
|
13
36
|
export { playerRoleSetMap };
|
package/types/Player/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Pool from '../Pool';
|
|
2
2
|
import Dealer from '../Dealer';
|
|
3
|
-
import { ActionTypeEnum } from './constant';
|
|
3
|
+
import { ActionTypeEnum, RoleEnum, type Role } from './constant';
|
|
4
4
|
import Controller from '../Controller';
|
|
5
5
|
import { Poke, RankSignature } from '../Deck/constant';
|
|
6
6
|
import { PreAction, GameComponent, TexasErrorCallback } from '../Texas';
|
|
@@ -31,7 +31,8 @@ export interface User {
|
|
|
31
31
|
avatar?: string;
|
|
32
32
|
}
|
|
33
33
|
export type CallbackOfAction = (player: Player, isPreFlop?: boolean) => Promise<void>;
|
|
34
|
-
export type
|
|
34
|
+
export type { Role } from './constant';
|
|
35
|
+
export { RoleEnum } from './constant';
|
|
35
36
|
/**
|
|
36
37
|
* 玩家
|
|
37
38
|
*/
|
|
@@ -121,7 +122,7 @@ export declare class Player implements GameComponent {
|
|
|
121
122
|
returnLatestPlayerIf(filter: (player: Player) => boolean): Player | null;
|
|
122
123
|
returnNextPlayerIf(filter: (player: Player) => boolean): Player | null;
|
|
123
124
|
getAction(): Action | undefined;
|
|
124
|
-
getRole():
|
|
125
|
+
getRole(): RoleEnum | undefined;
|
|
125
126
|
getUserInfo(): User;
|
|
126
127
|
checkIfCanAct(): void;
|
|
127
128
|
toString(): string;
|
package/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { roleMap, ActionTypeMap } from './Player/constant';
|
|
|
8
8
|
import { Stage, StageEnum, ControllerStatus } from './Controller';
|
|
9
9
|
import { texasErrorMap, TexasErrorCode } from './TexasError/constant';
|
|
10
10
|
import { RoomStatus, default as Room, PlayerSeatStatus } from './Room';
|
|
11
|
-
import { User, Role, Action, ActionType, OnlineStatus, ActionTypeEnum, default as Player } from './Player';
|
|
11
|
+
import { User, Role, RoleEnum, Action, ActionType, OnlineStatus, ActionTypeEnum, default as Player } from './Player';
|
|
12
12
|
export * from './Deck/constant';
|
|
13
13
|
export { getBestPokesRankSignature, compareRankSignature, getFiveCardsStrength, getStrengthFromRankSignature } from './Deck/core';
|
|
14
|
-
export { Player, User, ActionType, ActionTypeEnum, Role, Action, roleMap, ActionTypeMap, Stage, StageEnum, ControllerStatus, stageMap, Dealer, Deck, Room, RoomStatus, PlayerSeatStatus, formatterPoke, TexasError, TexasErrorCode, texasErrorMap, Texas, OnlineStatus };
|
|
14
|
+
export { Player, User, ActionType, ActionTypeEnum, Role, RoleEnum, Action, roleMap, ActionTypeMap, Stage, StageEnum, ControllerStatus, stageMap, Dealer, Deck, Room, RoomStatus, PlayerSeatStatus, formatterPoke, TexasError, TexasErrorCode, texasErrorMap, Texas, OnlineStatus };
|