From b7a39748ba7d7359d45d4681f21eb015c87a585d Mon Sep 17 00:00:00 2001 From: Karthik Bandagonda <32044378+Karthik99999@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:32:15 -0700 Subject: [PATCH] Auctions: Send nomination notification to managers only (#10587) * Auctions: Send nomination notification to managers only * Update server/chat-plugins/auction.ts --------- Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com> --- server/chat-plugins/auction.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/server/chat-plugins/auction.ts b/server/chat-plugins/auction.ts index 3cc2c7286132..224d2c9785b8 100644 --- a/server/chat-plugins/auction.ts +++ b/server/chat-plugins/auction.ts @@ -543,7 +543,13 @@ export class Auction extends Rooms.SimpleRoomGame { this.state = 'bid'; this.highestBid = this.minBid; this.highestBidder = this.nominatingTeam; - this.room.add(Utils.html`|notify|${this.room.title} Auction|${player.name} has been nominated!`); + + const notifyMsg = Utils.html`|notify|${this.room.title} Auction|${player.name} has been nominated!`; + for (const currManager of this.managers.values()) { + if (currManager.team === this.nominatingTeam) continue; + Users.getExact(currManager.id)?.sendTo(this.room, notifyMsg); + } + this.sendMessage(Utils.html`/html ${user.name} from team ${this.nominatingTeam.name} has nominated ${player.name} for auction. Use /bid or type a number to place a bid!`); if (this.type === 'auction') this.sendBidInfo(); this.sendTimer(); @@ -562,11 +568,13 @@ export class Auction extends Rooms.SimpleRoomGame { if (this.type === 'blind') { if (this.bidsPlaced.has(team)) throw new Chat.ErrorMessage(`Your team has already placed a bid.`); if (bid <= this.minBid) throw new Chat.ErrorMessage(`Your bid must be higher than the minimum bid.`); + + const msg = `|c:|${Math.floor(Date.now() / 1000)}|&|/html Your team placed a bid of ${bid} on ${Utils.escapeHTML(this.nominatedPlayer.name)}.`; for (const manager of this.managers.values()) { if (manager.team !== team) continue; - const msg = `|c:|${Math.floor(Date.now() / 1000)}|&|/html Your team placed a bid of ${bid} on ${Utils.escapeHTML(this.nominatedPlayer.name)}.`; Users.getExact(manager.id)?.sendTo(this.room, msg); } + if (bid > this.highestBid) { this.highestBid = bid; this.highestBidder = team; @@ -588,9 +596,10 @@ export class Auction extends Rooms.SimpleRoomGame { } onChatMessage(message: string, user: User) { - if (this.state !== 'bid' || !Number(message.replace(',', '.'))) return; - this.bid(user, parseCredits(message)); - return ''; + if (this.state === 'bid' && Number(message.replace(',', '.'))) { + this.bid(user, parseCredits(message)); + return ''; + } } skipNom() {