texas-poker-core 1.2.1 → 1.2.3
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 +7 -1
- package/dist/Controller/index.js +1 -1
- package/dist/Player/index.js +3 -10
- package/dist/Room/index.js +7 -1
- package/dist/Texas/index.js +1 -1
- package/package.json +1 -1
- package/types/Player/index.d.ts +1 -12
- package/types/Room/index.d.ts +1 -6
package/README.md
CHANGED
package/dist/Controller/index.js
CHANGED
|
@@ -370,7 +370,7 @@ var Controller = /*#__PURE__*/function () {
|
|
|
370
370
|
value: function end() {
|
|
371
371
|
if (this.status !== 'on') this.reportError(new _error.default(2100, '游戏不在进行中, 无法结束'));
|
|
372
372
|
this.clearTimer();
|
|
373
|
-
_classPrivateFieldSet(_status, this, '
|
|
373
|
+
_classPrivateFieldSet(_status, this, 'end');
|
|
374
374
|
this.resetActivePlayer();
|
|
375
375
|
}
|
|
376
376
|
}, {
|
package/dist/Player/index.js
CHANGED
|
@@ -8,10 +8,7 @@ require("core-js/modules/es.array.from.js");
|
|
|
8
8
|
require("core-js/modules/es.array.slice.js");
|
|
9
9
|
require("core-js/modules/es.date.to-primitive.js");
|
|
10
10
|
require("core-js/modules/es.number.constructor.js");
|
|
11
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
12
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
13
11
|
require("core-js/modules/es.object.get-prototype-of.js");
|
|
14
|
-
require("core-js/modules/es.object.keys.js");
|
|
15
12
|
require("core-js/modules/es.promise.js");
|
|
16
13
|
require("core-js/modules/es.regexp.exec.js");
|
|
17
14
|
require("core-js/modules/web.dom-collections.for-each.js");
|
|
@@ -43,8 +40,6 @@ var _utils = require("../utils");
|
|
|
43
40
|
var _config = require("../config");
|
|
44
41
|
var _Player;
|
|
45
42
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
46
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
47
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
48
43
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
49
44
|
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."); }
|
|
50
45
|
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; } }
|
|
@@ -643,15 +638,13 @@ var Player = exports.Player = /*#__PURE__*/function () {
|
|
|
643
638
|
}, {
|
|
644
639
|
key: "getUserInfo",
|
|
645
640
|
value: function getUserInfo() {
|
|
646
|
-
return
|
|
647
|
-
// 余额需要用实时的, 而不是来自于数据库
|
|
648
|
-
balance: this.balance
|
|
649
|
-
});
|
|
641
|
+
return _classPrivateFieldGet(_userInfo, this);
|
|
650
642
|
}
|
|
651
643
|
}, {
|
|
652
644
|
key: "checkIfCanAct",
|
|
653
645
|
value: function checkIfCanAct() {
|
|
654
|
-
if (_classPrivateFieldGet(
|
|
646
|
+
if (_classPrivateFieldGet(_controller, this).status !== 'on') this.reportError(new _error.default(2003, '游戏不在进行中, 不可行动'));
|
|
647
|
+
if (_classPrivateFieldGet(_status, this) !== 'active') this.reportError(new _error.default(2003, '没有控制权, 无法行动'));
|
|
655
648
|
}
|
|
656
649
|
}, {
|
|
657
650
|
key: "toString",
|
package/dist/Room/index.js
CHANGED
|
@@ -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
|
-
|
|
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);
|
package/dist/Texas/index.js
CHANGED
|
@@ -158,7 +158,7 @@ var Texas = /*#__PURE__*/function (_GameEventEmitter2) {
|
|
|
158
158
|
case 0:
|
|
159
159
|
if (this.room.getPlayersBySeatStatus('on-set').length < 2) this.handleError(new _error.default(2100, '玩家数量不足, 无法开始游戏'));
|
|
160
160
|
if (this.room.status === 'unReady') this.handleError(new _error.default(2100, '玩家位置未确认, 无法进行游戏'));
|
|
161
|
-
if (this.controller.status !== 'waiting') this.handleError(new _error.default(2100, '游戏已经开始,
|
|
161
|
+
if (this.controller.status !== 'waiting') this.handleError(new _error.default(2100, '游戏已经开始, 请勿重复开始游戏'));
|
|
162
162
|
this.resetBeforeGameStart();
|
|
163
163
|
this.dealer.dealCards();
|
|
164
164
|
_context.next = 7;
|
package/package.json
CHANGED
package/types/Player/index.d.ts
CHANGED
|
@@ -111,18 +111,7 @@ export declare class Player implements GameComponent {
|
|
|
111
111
|
returnNextPlayerIf(filter: (player: Player) => boolean): Player | null;
|
|
112
112
|
getAction(): Action | undefined;
|
|
113
113
|
getRole(): Role | undefined;
|
|
114
|
-
getUserInfo():
|
|
115
|
-
balance: number;
|
|
116
|
-
id: number;
|
|
117
|
-
/**
|
|
118
|
-
* 昵称
|
|
119
|
-
*/
|
|
120
|
-
name?: string;
|
|
121
|
-
/**
|
|
122
|
-
* 用户头像
|
|
123
|
-
*/
|
|
124
|
-
avatar?: string;
|
|
125
|
-
};
|
|
114
|
+
getUserInfo(): User;
|
|
126
115
|
checkIfCanAct(): void;
|
|
127
116
|
toString(): string;
|
|
128
117
|
log(prefix?: string): void;
|
package/types/Room/index.d.ts
CHANGED
|
@@ -24,12 +24,7 @@ declare class Room implements GameComponent {
|
|
|
24
24
|
onSeatCount: number;
|
|
25
25
|
allowPlayersToWatch: boolean;
|
|
26
26
|
maximumCountOfPlayers: number;
|
|
27
|
-
owner: Omit<
|
|
28
|
-
balance: number;
|
|
29
|
-
id: number;
|
|
30
|
-
name?: string;
|
|
31
|
-
avatar?: string;
|
|
32
|
-
}, "balance">;
|
|
27
|
+
owner: Omit<import("../Player").User, "balance">;
|
|
33
28
|
};
|
|
34
29
|
getAllPlayers(): Player[];
|
|
35
30
|
get totalPlayersCount(): number;
|