From c8bc6be7be986bcb308126b7e4d402738f154c89 Mon Sep 17 00:00:00 2001
From: Karthik Bandagonda <32044378+Karthik99999@users.noreply.github.com>
Date: Fri, 10 Jan 2025 01:04:33 -0500
Subject: [PATCH] Auctions: Remove formatted bid messages + only send errors on
bids to the bidder (#10813)
---
server/chat-plugins/auction.ts | 38 +++++++++++++++++++---------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/server/chat-plugins/auction.ts b/server/chat-plugins/auction.ts
index ea818acf6735..b768935066d1 100644
--- a/server/chat-plugins/auction.ts
+++ b/server/chat-plugins/auction.ts
@@ -63,7 +63,10 @@ class Team {
return this.suspended || (
this.auction.type === 'snake' ?
this.players.length >= this.auction.minPlayers :
- (this.credits < this.auction.minBid || this.players.length >= this.auction.maxPlayers)
+ (
+ this.credits < this.auction.minBid ||
+ (this.auction.maxPlayers && this.players.length >= this.auction.maxPlayers)
+ )
);
}
@@ -608,34 +611,35 @@ export class Auction extends Rooms.SimpleRoomGame {
if (bid <= this.highestBid) throw new Chat.ErrorMessage(`Your bid must be higher than the current bid.`);
this.highestBid = bid;
this.highestBidder = team;
- this.sendMessage(Utils.html`/html ${user.name}[${team.name}]: ${bid}`);
+ // this.sendMessage(Utils.html`/html ${user.name}[${team.name}]: ${bid}`);
this.sendBidInfo();
this.startBidTimer();
}
}
onChatMessage(message: string, user: User) {
- if (this.state !== 'bid') return;
+ if (this.state !== 'bid' || this.type !== 'blind') return;
+ if (message.startsWith('.')) message = message.slice(1);
+ if (Number(message.replace(',', '.'))) {
+ this.bid(user, parseCredits(message));
+ return '';
+ }
+ }
- const originalMsg = message;
+ onLogMessage(message: string, user: User) {
+ if (this.state !== 'bid' || this.type === 'blind') return;
if (message.startsWith('.')) message = message.slice(1);
if (Number(message.replace(',', '.'))) {
- if (this.type === 'blind') {
+ this.room.update();
+ try {
this.bid(user, parseCredits(message));
- } else {
- // If bid is unsuccessful, the original message is sent to the room
- try {
- this.bid(user, parseCredits(message));
- } catch (e) {
- this.room.add(`|c|${user.getIdentity(this.room)}|${originalMsg}`);
- if (e instanceof Chat.ErrorMessage) {
- user.sendTo(this.room, Utils.html`/html ${e.message}`);
- } else {
- user.sendTo(this.room, `/html An unexpected error occurred while placing your bid.`);
- }
+ } catch (e) {
+ if (e instanceof Chat.ErrorMessage) {
+ user.sendTo(this.room, Utils.html`|raw|${e.message}`);
+ } else {
+ user.sendTo(this.room, `|raw|An unexpected error occurred while placing your bid.`);
}
}
- return '';
}
}