trucoshi 0.0.21 → 0.0.22

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.
@@ -1,3 +1,3 @@
1
1
  import { IPlayer } from "../types";
2
- export type IPublicPlayer = Pick<IPlayer, "id" | "disabled" | "ready" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "session">;
2
+ export type IPublicPlayer = Pick<IPlayer, "id" | "disabled" | "ready" | "hand" | "usedHand" | "prevHand" | "teamIdx" | "session" | "isTurn">;
3
3
  export declare function Player(id: string, teamIdx: number): IPlayer;
@@ -30,8 +30,12 @@ function Player(id, teamIdx) {
30
30
  commands: [],
31
31
  usedHand: [],
32
32
  prevHand: [],
33
+ isTurn: false,
33
34
  disabled: false,
34
35
  ready: false,
36
+ setTurn: function (turn) {
37
+ player.isTurn = turn;
38
+ },
35
39
  getPublicPlayer: function () {
36
40
  return __assign(__assign({}, player), { hand: player.hand.map(function () { return "xx"; }), session: undefined });
37
41
  },
package/dist/lib/index.js CHANGED
@@ -85,9 +85,11 @@ var GameLoop = function (match) {
85
85
  return [3 /*break*/, 1];
86
86
  case 3:
87
87
  if (!(play.state === types_1.EHandState.WAITING_PLAY)) return [3 /*break*/, 5];
88
+ play.player.setTurn(true);
88
89
  return [4 /*yield*/, gameloop._onTurn(play)];
89
90
  case 4:
90
91
  _a.sent();
92
+ play.player.setTurn(false);
91
93
  return [3 /*break*/, 1];
92
94
  case 5: return [3 /*break*/, 1];
93
95
  case 6:
@@ -21,8 +21,10 @@ export interface IPlayer {
21
21
  commands: Array<ECommand>;
22
22
  usedHand: Array<ICard>;
23
23
  prevHand: Array<ICard>;
24
+ isTurn: boolean;
24
25
  disabled: boolean;
25
26
  ready: boolean;
27
+ setTurn(turn: boolean): void;
26
28
  getPublicPlayer(): IPlayer;
27
29
  setSession(session: string): void;
28
30
  enable(): void;
@@ -344,10 +344,10 @@ io.on("connection", function (_socket) {
344
344
  users.set(session, updatedUser);
345
345
  socket.session = session;
346
346
  var currentTable = currentMatchId ? tables.get(currentMatchId) : null;
347
- if (currentTable && currentTable.isSessionPlaying(session)) {
347
+ if (currentTable) {
348
348
  addSocketToUser(session, socket.id, currentTable);
349
349
  socket.join(currentTable.matchSessionId);
350
- if (session === ((_a = currentTable.currentPlayer) === null || _a === void 0 ? void 0 : _a.session)) {
350
+ if (currentTable.isSessionPlaying(session) && session === ((_a = currentTable.currentPlayer) === null || _a === void 0 ? void 0 : _a.session)) {
351
351
  try {
352
352
  var _b = turns.get(currentTable.matchSessionId) || {}, play = _b.play, resolve = _b.resolve;
353
353
  if (!play) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucoshi",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "main": "build/lib/trucoshi.js",
5
5
  "license": "GPL-3.0",
6
6
  "scripts": {