feat: add admin award winner command #13

Merged
remhelper merged 2 commits from feature/admin-award-winner into master 2026-03-06 05:25:29 +00:00
remhelper commented 2026-03-06 01:18:37 +00:00 (Migrated from github.com)

Summary

  • add Connection.AwardGameWinner helper to send GAME:AWARD for admins

Testing

  • not run (not requested)
## Summary - add Connection.AwardGameWinner helper to send GAME:AWARD for admins ## Testing - not run (not requested)
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-03-06 04:25:03 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

Adds an admin-only helper on Connection to send a GAME:AWARD command to the server to award a match winner.

Changes:

  • Add Connection.AwardGame(int matchID, string winnerUsername) admin helper.
  • Validate admin status and non-empty winner username before sending the command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

## Pull request overview Adds an admin-only helper on `Connection` to send a `GAME:AWARD` command to the server to award a match winner. **Changes:** - Add `Connection.AwardGame(int matchID, string winnerUsername)` admin helper. - Validate admin status and non-empty winner username before sending the command. --- 💡 <a href="/joshuafhiggins/connect4-moderator-observer/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.<br><br>You can also share your feedback on Copilot code review. [Take the survey](https://www.surveymonkey.com/r/XP6L3XJ).
@@ -211,0 +211,4 @@
public void AwardGameWinner(int matchID, string winnerUsername) {
if (!IsAdmin) return;
if (string.IsNullOrWhiteSpace(winnerUsername)) return;
sendCommand("GAME", "AWARD:" + matchID + ":" + winnerUsername.Trim());
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-06 04:25:03 +00:00

winnerUsername is inserted into a colon-delimited wire format ("GAME:AWARD::"). If the username contains : it will change the segment structure and can lead to malformed commands / protocol injection. Consider trimming into a local variable and rejecting (or escaping) reserved delimiter characters like : (consistent with SendConnect, which blocks : in the client id).

    var trimmedWinnerUsername = winnerUsername.Trim();
    if (trimmedWinnerUsername.Contains(":")) {
      GD.PushError("AwardGame: winner username contains invalid ':' character and will not be sent.");
      return;
    }
    sendCommand("GAME", "AWARD:" + matchID + ":" + trimmedWinnerUsername);
`winnerUsername` is inserted into a colon-delimited wire format ("GAME:AWARD:<matchID>:<username>"). If the username contains `:` it will change the segment structure and can lead to malformed commands / protocol injection. Consider trimming into a local variable and rejecting (or escaping) reserved delimiter characters like `:` (consistent with `SendConnect`, which blocks `:` in the client id). ```suggestion var trimmedWinnerUsername = winnerUsername.Trim(); if (trimmedWinnerUsername.Contains(":")) { GD.PushError("AwardGame: winner username contains invalid ':' character and will not be sent."); return; } sendCommand("GAME", "AWARD:" + matchID + ":" + trimmedWinnerUsername); ```
Sign in to join this conversation.