From 4ccc50170080fedf9cfd9e824893fd9de080ec2f Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Tue, 3 Feb 2026 13:39:16 -0500 Subject: [PATCH] feat: all new networking changes (except reservations), huge refactor and fmt --- .editorconfig | 6 + scripts/AddressUI.cs | 12 +- scripts/AdminControls.cs | 14 +- scripts/BackButton.cs | 27 +- scripts/BoardScreen.cs | 443 ++++++++-------- scripts/BracketScene.cs | 188 +++---- scripts/ConnectButtonUI.cs | 90 ++-- scripts/Connection.cs | 1026 ++++++++++++++++++------------------ scripts/MatchData.cs | 22 +- scripts/PlayerData.cs | 20 +- scripts/TournamentType.cs | 5 + 11 files changed, 895 insertions(+), 958 deletions(-) create mode 100644 scripts/TournamentType.cs diff --git a/.editorconfig b/.editorconfig index f28239b..7c9423d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,3 +2,9 @@ root = true [*] charset = utf-8 +indent_style = space +indent_size = 2 +tab_width = 2 + +[*.{cs,vb}] +dotnet_diagnostic.CA1050.severity = none diff --git a/scripts/AddressUI.cs b/scripts/AddressUI.cs index 8a88187..b4775b6 100644 --- a/scripts/AddressUI.cs +++ b/scripts/AddressUI.cs @@ -1,10 +1,8 @@ using Godot; using System; -public partial class AddressUI : TextEdit -{ - public override void _Ready() - { - Text = Connection.WS_DEFAULT_ADDRESS; - } -} +public partial class AddressUI : TextEdit { + public override void _Ready() { + Text = Connection.WS_DEFAULT_ADDRESS; + } +} \ No newline at end of file diff --git a/scripts/AdminControls.cs b/scripts/AdminControls.cs index a113e31..a1358f2 100644 --- a/scripts/AdminControls.cs +++ b/scripts/AdminControls.cs @@ -12,9 +12,10 @@ public partial class AdminControls : HBoxContainer { Connection.Instance.OnBecomeAdmin += UpdateUI; Connection.Instance.OnTournamentEnd += UpdateUI; - Connection.Instance.OnStartTournamentAck += UpdateUI; + Connection.Instance.OnStartTournament += UpdateUI; Connection.Instance.OnCancelTournamentAck += UpdateUI; Connection.Instance.OnGetDataAcks += UpdateUI; + Connection.Instance.OnSetDataAcks += UpdateUI; StartTournament.Pressed += () => Connection.Instance.StartTournament(); CancelTournament.Pressed += () => Connection.Instance.CancelTournament(); @@ -23,7 +24,7 @@ public partial class AdminControls : HBoxContainer Timeout.ValueChanged += value => { - Connection.Instance.SetTournamentWait((float)value); + Connection.Instance.SetMoveWait((float)value); var time = Connection.Instance.CurrentWaitTimeout.ToString(); if (time.Length > 3) { @@ -32,16 +33,17 @@ public partial class AdminControls : HBoxContainer Label.Text = "Wait To Move: " + time + "s "; }; - BecomeAdmin.Pressed += ShowAuthPopup; + BecomeAdmin.Pressed += showAuthPopup; } public override void _ExitTree() { Connection.Instance.OnBecomeAdmin -= UpdateUI; Connection.Instance.OnTournamentEnd -= UpdateUI; - Connection.Instance.OnStartTournamentAck -= UpdateUI; + Connection.Instance.OnStartTournament -= UpdateUI; Connection.Instance.OnCancelTournamentAck -= UpdateUI; Connection.Instance.OnGetDataAcks -= UpdateUI; + Connection.Instance.OnSetDataAcks -= UpdateUI; } private void UpdateUI() @@ -66,7 +68,7 @@ public partial class AdminControls : HBoxContainer StartTournament.Hide(); CancelTournament.Hide(); } - else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament) + else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament != TournamentType.None) { StartTournament.Hide(); CancelTournament.Show(); @@ -87,7 +89,7 @@ public partial class AdminControls : HBoxContainer Label.Text = "Wait To Move: " + time + "s "; } - private void ShowAuthPopup() + private void showAuthPopup() { var authWindow = new Window(); authWindow.Theme = GD.Load("res://assets/theme.tres"); diff --git a/scripts/BackButton.cs b/scripts/BackButton.cs index 9b2a958..0e88d01 100644 --- a/scripts/BackButton.cs +++ b/scripts/BackButton.cs @@ -1,18 +1,15 @@ using Godot; using System; -public partial class BackButton : TextureButton -{ - private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn"; - - public override void _Pressed() - { - TransitionToBracket(); - base._Pressed(); - } - - private void TransitionToBracket() - { - GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); - } -} +public partial class BackButton : TextureButton { + private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn"; + + public override void _Pressed() { + TransitionToBracket(); + base._Pressed(); + } + + private void TransitionToBracket() { + GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); + } +} \ No newline at end of file diff --git a/scripts/BoardScreen.cs b/scripts/BoardScreen.cs index 271fa60..cae6ac5 100644 --- a/scripts/BoardScreen.cs +++ b/scripts/BoardScreen.cs @@ -1,264 +1,249 @@ using Godot; using System.Linq; -public partial class BoardScreen : Node2D -{ - [Export] private AudioStream endingSfx; - [Export] private Theme theme; - - private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn"; - private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn"; - private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn"; - private const int CHIP_SCALE = 3; - private const int CHIP_SIZE = 24; - private const int CHIP_PADDING = 2; - private const int CHIP_X_OFF = -(CHIP_SIZE + CHIP_PADDING) * 7 / 2 + (CHIP_SIZE + CHIP_PADDING) / 2; - private const int Y_OFF = 300; - private const int CARD_CENTER_X_DEFAULT = -536; - private const double MOVE_TIMEOUT_BEFORE_PLACE = 1.0f; +public partial class BoardScreen : Node2D { + [Export] private AudioStream endingSfx; + [Export] private Theme theme; - private double currentTimeout = 0.0f; + private const string RED_CHIP_PATH = "res://scenes/red_chip.tscn"; + private const string YELLOW_CHIP_PATH = "res://scenes/yellow_chip.tscn"; + private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn"; + private const int CHIP_SCALE = 3; + private const int CHIP_SIZE = 24; + private const int CHIP_PADDING = 2; + private const int CHIP_X_OFF = -(CHIP_SIZE + CHIP_PADDING) * 7 / 2 + (CHIP_SIZE + CHIP_PADDING) / 2; + private const int Y_OFF = 300; + private const int CARD_CENTER_X_DEFAULT = -536; + private const double MOVE_TIMEOUT_BEFORE_PLACE = 1.0f; - private PackedScene redChip; - private PackedScene ylwChip; + private double currentTimeout = 0.0f; - private Node2D player1Card; - private Node2D player2Card; - private MatchData matchData; - - private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left + private PackedScene redChip; + private PackedScene ylwChip; - private bool _lastMove = false; - private float _lastMoveTimer = 2.5f; - private string _winner = ""; + private Node2D player1Card; + private Node2D player2Card; + private MatchData matchData; - // Called when the node enters the scene tree for the first time. - public override void _Ready() { - // Node initialization - player1Card = GetNode("Player1Card"); - player2Card = GetNode("Player2Card"); + private RigidBody2D[,] chips = new RigidBody2D[6, 7]; // 6 rows 7 cols | 0, 0 is top left - player1Card.GetNode