wip
This commit is contained in:
parent
dc7c0c1c6e
commit
bc9aec0044
1 changed files with 5 additions and 13 deletions
|
|
@ -101,7 +101,7 @@ export class Game {
|
||||||
this.players.forEach((player) => {
|
this.players.forEach((player) => {
|
||||||
player.cards = this.cardStack.cards.splice(0, 12);
|
player.cards = this.cardStack.cards.splice(0, 12);
|
||||||
player.knownCardPositions = new Array(12).fill(false);
|
player.knownCardPositions = new Array(12).fill(false);
|
||||||
player.playersTurn = false;
|
player.playersTurn = true;
|
||||||
player.cardCache = null;
|
player.cardCache = null;
|
||||||
player.tookDispiledCard = false;
|
player.tookDispiledCard = false;
|
||||||
player.roundPoints = 0;
|
player.roundPoints = 0;
|
||||||
|
|
@ -330,12 +330,13 @@ export class Game {
|
||||||
if (playerSocket) {
|
if (playerSocket) {
|
||||||
expectedActions.forEach((expectedAction) => {
|
expectedActions.forEach((expectedAction) => {
|
||||||
const [actionName, processAction] = expectedAction;
|
const [actionName, processAction] = expectedAction;
|
||||||
const eventListener = (data: ActionDataType) => {
|
const eventListener = (data: ActionDataType, ackFunction: any) => {
|
||||||
console.log(`Received ${actionName} from ${playerSocketId}`);
|
console.log(`Received ${actionName} from ${playerSocketId}`);
|
||||||
processAction(playerSocketId, data);
|
processAction(playerSocketId, data);
|
||||||
// remove current and event listeners of alternative expected actions
|
// remove current and event listeners of alternative expected actions
|
||||||
removePlayerActionListeners();
|
removePlayerActionListeners();
|
||||||
const playerResponse = { playerSocketId, data };
|
const playerResponse = { playerSocketId, data };
|
||||||
|
// ackFunction("success");
|
||||||
resolve(playerResponse);
|
resolve(playerResponse);
|
||||||
};
|
};
|
||||||
playerSocket.on(actionName, eventListener);
|
playerSocket.on(actionName, eventListener);
|
||||||
|
|
@ -383,16 +384,7 @@ export class Game {
|
||||||
discardPile: this.discardPile,
|
discardPile: this.discardPile,
|
||||||
players: this.players.map(({ cards, ...player }) => {
|
players: this.players.map(({ cards, ...player }) => {
|
||||||
return {
|
return {
|
||||||
id: player.id,
|
...player,
|
||||||
socketId: player.socketId,
|
|
||||||
name: player.name,
|
|
||||||
playersTurn: player.playersTurn,
|
|
||||||
cardCache: player.cardCache,
|
|
||||||
tookDispiledCard: player.tookDispiledCard,
|
|
||||||
knownCardPositions: player.knownCardPositions,
|
|
||||||
roundPoints: player.roundPoints,
|
|
||||||
totalPoints: player.totalPoints,
|
|
||||||
closedRound: player.closedRound,
|
|
||||||
cards: cards.map((card: Card, index: number) => {
|
cards: cards.map((card: Card, index: number) => {
|
||||||
// unknown cards are obfuscated to 0
|
// unknown cards are obfuscated to 0
|
||||||
return {
|
return {
|
||||||
|
|
@ -483,7 +475,7 @@ export class Game {
|
||||||
const alreadyClosedPlayers = this.players.filter(
|
const alreadyClosedPlayers = this.players.filter(
|
||||||
(player) => player.closedRound
|
(player) => player.closedRound
|
||||||
);
|
);
|
||||||
if (alreadyClosedPlayers) return;
|
if (alreadyClosedPlayers.length > 1) return;
|
||||||
|
|
||||||
const playerWithAllCardsRevealed = this.players.find((player) =>
|
const playerWithAllCardsRevealed = this.players.find((player) =>
|
||||||
player.knownCardPositions.every(
|
player.knownCardPositions.every(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue