Skip to content

Commit

Permalink
Auctions: Remove formatted bid messages + only send errors on bids to…
Browse files Browse the repository at this point in the history
… the bidder (#10813)
  • Loading branch information
Karthik99999 authored Jan 10, 2025
1 parent a4c3528 commit c8bc6be
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions server/chat-plugins/auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
);
}

Expand Down Expand Up @@ -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 <username class="username">${user.name}</username>[${team.name}]: <b>${bid}</b>`);
// this.sendMessage(Utils.html`/html <username class="username">${user.name}</username>[${team.name}]: <b>${bid}</b>`);
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 <span class="message-error">${e.message}</span>`);
} else {
user.sendTo(this.room, `/html <span class="message-error">An unexpected error occurred while placing your bid.</span>`);
}
} catch (e) {
if (e instanceof Chat.ErrorMessage) {
user.sendTo(this.room, Utils.html`|raw|<span class="message-error">${e.message}</span>`);
} else {
user.sendTo(this.room, `|raw|<span class="message-error">An unexpected error occurred while placing your bid.</span>`);
}
}
return '';
}
}

Expand Down

0 comments on commit c8bc6be

Please sign in to comment.