Skip to content

Commit

Permalink
Auctions: Send nomination notification to managers only (smogon#10587)
Browse files Browse the repository at this point in the history
* Auctions: Send nomination notification to managers only

* Update server/chat-plugins/auction.ts

---------

Co-authored-by: Kris Johnson <[email protected]>
  • Loading branch information
Karthik99999 and KrisXV authored Sep 30, 2024
1 parent 3edcdd1 commit b7a3974
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions server/chat-plugins/auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <username class="username">${user.name}</username> from team <b>${this.nominatingTeam.name}</b> has nominated <username>${player.name}</username> for auction. Use /bid or type a number to place a bid!`);
if (this.type === 'auction') this.sendBidInfo();
this.sendTimer();
Expand All @@ -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 <b>${bid}</b> on <username>${Utils.escapeHTML(this.nominatedPlayer.name)}</username>.`;
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 <b>${bid}</b> on <username>${Utils.escapeHTML(this.nominatedPlayer.name)}</username>.`;
Users.getExact(manager.id)?.sendTo(this.room, msg);
}

if (bid > this.highestBid) {
this.highestBid = bid;
this.highestBidder = team;
Expand All @@ -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() {
Expand Down

0 comments on commit b7a3974

Please sign in to comment.