Skip to content

Commit

Permalink
remove -> unseat, decrease duration to 1500
Browse files Browse the repository at this point in the history
  • Loading branch information
pwmarcz committed Jan 23, 2021
1 parent c288954 commit 0d96e47
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<button class="take-seat btn btn-primary">Take seat</button>
<button class="kick btn btn-dark" style="display: none"
data-toggle="tooltip" data-placement="top"
title="Press and hold to remove">
title="Click and hold to unseat">
<div class="btn-progress"></div>
<span class="btn-progress-text"></span>
</button>
Expand All @@ -46,7 +46,7 @@
<button class="take-seat btn btn-primary">Take seat</button>
<button class="kick btn btn-dark" style="display: none"
data-toggle="tooltip" data-placement="top"
title="Press and hold to remove">
title="Click and hold to unseat">
<div class="btn-progress"></div>
<span class="btn-progress-text"></span>
</button>
Expand All @@ -55,7 +55,7 @@
<button class="take-seat btn btn-primary">Take seat</button>
<button class="kick btn btn-dark" style="display: none"
data-toggle="tooltip" data-placement="top"
title="Press and hold to remove">
title="Click and hold to unseat">
<div class="btn-progress"></div>
<span class="btn-progress-text"></span>
</button>
Expand All @@ -64,7 +64,7 @@
<button class="take-seat btn btn-primary">Take seat</button>
<button class="kick btn btn-dark" style="display: none"
data-toggle="tooltip" data-placement="top"
title="Press and hold to remove">
title="Click and hold to unseat">
<div class="btn-progress"></div>
<span class="btn-progress-text"></span>
</button>
Expand Down
10 changes: 5 additions & 5 deletions server/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Game {
private collections: Map<string, Map<string | number, any>> = new Map();

constructor(gameId: string) {
console.log(`new game: ${gameId}`);
console.log(`[${gameId}] new game`);
this.gameId = gameId;
this.expiryTime = new Date().getTime() + EXPIRY_TIME;
}
Expand All @@ -44,7 +44,7 @@ export class Game {
client.playerId = playerId;
client.game = this;

console.log(`${this.gameId}: join: ${playerId}`);
console.log(`[${this.gameId}.${playerId}] join`);

this.send(client, {
type: 'JOINED',
Expand Down Expand Up @@ -138,7 +138,7 @@ export class Game {
const value = item[field];
if (value !== null && value !== undefined) {
if (occupied.has(value)) {
console.log(`conflict on ${kind}, ${field} = ${value}`);
console.log(`[${this.gameId}] conflict on ${kind}, ${field} = ${value}`);
return false;
}
occupied.add(value);
Expand All @@ -149,7 +149,7 @@ export class Game {
}

leave(client: Client): void {
console.log(`${this.gameId}: leave: ${client.playerId}`);
console.log(`[${this.gameId}.${client.playerId}] leave`);

this.clients.delete(client.playerId!);
const toUpdate: Array<Entry> = [];
Expand All @@ -173,7 +173,7 @@ export class Game {

private send(client: Client, message: Message): void {
const data = JSON.stringify(message);
console.debug(`send ${this.gameId}.${client.playerId} ${data}`);
console.debug(`[${this.gameId}.${client.playerId}] send ${data}`);
client.send(data);
}

Expand Down
9 changes: 4 additions & 5 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export class Server {

client.on('message', data => {
if (client.game !== null) {
console.debug(`recv ${client.game.gameId}.${client.playerId} ${data}`);
console.debug(`[${client.game.gameId}.${client.playerId}] recv ${data}`);
} else {
console.debug(`recv * ${data}`);
console.debug(`recv ${data}`);
}

const message = JSON.parse(data as string) as Message;
Expand All @@ -43,7 +43,6 @@ export class Server {
});

client.on('close', () => {
console.debug('> disconnect');
this.onClose(client);
});
});
Expand Down Expand Up @@ -75,7 +74,7 @@ export class Server {
case 'JOIN': {
let game = this.games.get(message.gameId);
if (!game) {
console.warn(`game not found, creating: ${message.gameId}`);
console.warn(`[${message.gameId}] game not found, creating`);
game = new Game(message.gameId);
this.games.set(message.gameId, game);
}
Expand All @@ -97,7 +96,7 @@ export class Server {
const now = new Date().getTime();
for (const [gameId, game] of this.games.entries()) {
if (game.expiryTime !== null && game.expiryTime < now) {
console.log(`deleting expired: ${gameId}`);
console.log(`[${gameId}] deleting expired`);
this.games.delete(gameId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class GameUi {
};
}
for (let i = 0; i < 4; i++) {
this.setupProgressButton(this.elements.kick[i], 2000, () => {
this.setupProgressButton(this.elements.kick[i], 1500, () => {
const kickedId = this.client.seatPlayers[i];
if (kickedId !== null) {
this.client.seats.set(kickedId, { seat: null });
Expand Down

0 comments on commit 0d96e47

Please sign in to comment.