Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Lobby.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type Client from "./Client.js";
import type { InsaneInt } from "./InsaneInt.js";
import { InsaneInt } from "./InsaneInt.js";
import GameModes from "./GameMode.js";
import type {
ActionLobbyInfo,
Expand Down Expand Up @@ -350,13 +350,15 @@ class Lobby {
this.host.setLocation("Blind Select");
this.host.furthestBlind = 0;
this.host.skips = 0;
this.host.score = new InsaneInt(0, 0, 0);
}
if (this.guest) {
this.guest.isReady = false;
this.guest.resetBlocker();
this.guest.setLocation("Blind Select");
this.guest.furthestBlind = 0;
this.guest.skips = 0;
this.guest.score = new InsaneInt(0, 0, 0);
}
this.tcgBets.clear();
this.firstReadyAt = null;
Expand Down
29 changes: 25 additions & 4 deletions src/actionHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ const playHandAction = (
// player has genuinely played this blind. Hand counts can vary in this game, so
// handsLeft is not a reliable signal.
const playedRealHand = client.score.greaterThan(new InsaneInt(0, 0, 0));
const wasFirstHand = playedRealHand && !client.playedThisBlind;
if (playedRealHand) client.playedThisBlind = true;

const isHostTurn = lobby.host.score.equalTo(lobby.guest.score) ? lobby.host.firstReady : lobby.host.score.greaterThan(lobby.guest.score)

// Reveal our score to the enemy immediately, unless we're withholding it
// until they have also committed a hand this blind. This stops a player from
// watching the opponent's score before playing their own hand.
Expand All @@ -261,22 +262,42 @@ const playHandAction = (
score: client.score.toString(),
skips: client.skips,
lives: client.lives,
pvpTimerOrder: isHostTurn ? "host" : "guest"
});
}
} else {
enemy.sendAction({
action: "enemyInfo",
handsLeft,
score: null,
skips: client.skips,
lives: client.lives,
noScore: true,
});
}

// On our first hand of the blind, send the enemy's current state to us. If
// they have already played, this is the score that was withheld until now;
// if they haven't, it's their reset state (score 0, full hands) — enough for
// us to stop masking their hand count now that we've committed our own hand.
if (hideScore && wasFirstHand) {
if (!hideScore || client.playedThisBlind) {
client.sendAction({
action: "enemyInfo",
handsLeft: enemy.handsLeft,
score: enemy.score.toString(),
skips: enemy.skips,
lives: enemy.lives,
pvpTimerOrder: isHostTurn ? "host" : "guest"
});
}
} else {
client.sendAction({
action: "enemyInfo",
handsLeft: enemy.handsLeft,
score: null,
skips: enemy.skips,
lives: enemy.lives,
noScore: true,
});
}

// This info is only sent on a boss blind, so it shouldn't
// affect other blinds
Expand Down
9 changes: 9 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export type ActionEnemyInfo = {
handsLeft: number
skips: number
lives: number
pvpTimerOrder?: "guest" | "host"
} | {
action: 'enemyInfo'
noScore: true
score: null
handsLeft: number
skips: number
lives: number
pvpTimerOrder?: "guest" | "host"
}
export type ActionEndPvP = { action: 'endPvP'; lost: boolean, pvpTimerLost?: boolean }
export type ActionLobbyOptions = { action: 'lobbyOptions', gamemode: string }
Expand Down