misc: more formatting changes
This commit is contained in:
@@ -2,7 +2,5 @@ using Godot;
|
||||
using System;
|
||||
|
||||
public partial class AddressUI : TextEdit {
|
||||
public override void _Ready() {
|
||||
Text = Connection.WS_DEFAULT_ADDRESS;
|
||||
}
|
||||
public override void _Ready() { Text = Connection.WS_DEFAULT_ADDRESS; }
|
||||
}
|
||||
@@ -1,151 +1,133 @@
|
||||
using Godot;
|
||||
|
||||
public partial class AdminControls : HBoxContainer
|
||||
{
|
||||
[Export] public Button BecomeAdmin;
|
||||
[Export] public Button StartTournament;
|
||||
[Export] public Button CancelTournament;
|
||||
[Export] public Label Label;
|
||||
[Export] public Slider Timeout;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Connection.Instance.OnBecomeAdmin += UpdateUI;
|
||||
Connection.Instance.OnTournamentEnd += 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();
|
||||
|
||||
UpdateUI();
|
||||
|
||||
Timeout.ValueChanged += value =>
|
||||
{
|
||||
Connection.Instance.SetMoveWait((float)value);
|
||||
var time = Connection.Instance.CurrentWaitTimeout.ToString();
|
||||
if (time.Length > 3)
|
||||
{
|
||||
time = time.Substring(0, 3);
|
||||
}
|
||||
Label.Text = "Wait To Move: " + time + "s ";
|
||||
};
|
||||
|
||||
BecomeAdmin.Pressed += showAuthPopup;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
Connection.Instance.OnBecomeAdmin -= UpdateUI;
|
||||
Connection.Instance.OnTournamentEnd -= UpdateUI;
|
||||
Connection.Instance.OnStartTournament -= UpdateUI;
|
||||
Connection.Instance.OnCancelTournamentAck -= UpdateUI;
|
||||
Connection.Instance.OnGetDataAcks -= UpdateUI;
|
||||
Connection.Instance.OnSetDataAcks -= UpdateUI;
|
||||
}
|
||||
public partial class AdminControls : HBoxContainer {
|
||||
[Export] public Button BecomeAdmin;
|
||||
[Export] public Button StartTournament;
|
||||
[Export] public Button CancelTournament;
|
||||
[Export] public Label Label;
|
||||
[Export] public Slider Timeout;
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (!Connection.Instance.IsAdmin)
|
||||
{
|
||||
BecomeAdmin.Show();
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Hide();
|
||||
Label.Hide();
|
||||
Timeout.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
BecomeAdmin.Hide();
|
||||
Label.Show();
|
||||
Timeout.Show();
|
||||
}
|
||||
public override void _Ready() {
|
||||
Connection.Instance.OnBecomeAdmin += UpdateUI;
|
||||
Connection.Instance.OnTournamentEnd += UpdateUI;
|
||||
Connection.Instance.OnStartTournament += UpdateUI;
|
||||
Connection.Instance.OnCancelTournamentAck += UpdateUI;
|
||||
Connection.Instance.OnGetDataAcks += UpdateUI;
|
||||
Connection.Instance.OnSetDataAcks += UpdateUI;
|
||||
|
||||
if (Connection.Instance.IsAdmin && Connection.Instance.DemoMode)
|
||||
{
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Hide();
|
||||
}
|
||||
else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament != TournamentType.None)
|
||||
{
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Show();
|
||||
}
|
||||
else if (Connection.Instance.IsAdmin)
|
||||
{
|
||||
StartTournament.Show();
|
||||
CancelTournament.Hide();
|
||||
}
|
||||
StartTournament.Pressed += () => Connection.Instance.StartTournament();
|
||||
CancelTournament.Pressed += () => Connection.Instance.CancelTournament();
|
||||
|
||||
Timeout.Value = Connection.Instance.CurrentWaitTimeout;
|
||||
var time = Connection.Instance.CurrentWaitTimeout.ToString();
|
||||
if (time.Length > 3)
|
||||
{
|
||||
time = time.Substring(0, 3);
|
||||
}
|
||||
|
||||
Label.Text = "Wait To Move: " + time + "s ";
|
||||
}
|
||||
UpdateUI();
|
||||
|
||||
private void showAuthPopup()
|
||||
{
|
||||
var authWindow = new Window();
|
||||
authWindow.Theme = GD.Load<Theme>("res://assets/theme.tres");
|
||||
authWindow.AlwaysOnTop = true;
|
||||
authWindow.MaximizeDisabled = true;
|
||||
authWindow.Unresizable = true;
|
||||
authWindow.InitialPosition = Window.WindowInitialPosition.CenterMainWindowScreen;
|
||||
authWindow.Size = new Vector2I(256, 128);
|
||||
authWindow.CloseRequested += () =>
|
||||
{
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
};
|
||||
|
||||
var vbox = new VBoxContainer();
|
||||
vbox.LayoutMode = 1;
|
||||
vbox.AnchorBottom = 1.0f;
|
||||
vbox.AnchorRight = 1.0f;
|
||||
vbox.GrowHorizontal = GrowDirection.Both;
|
||||
vbox.GrowVertical = GrowDirection.Both;
|
||||
vbox.Alignment = AlignmentMode.Center;
|
||||
|
||||
var passwordBox = new TextEdit();
|
||||
passwordBox.PlaceholderText = "Password";
|
||||
passwordBox.SetCustomMinimumSize(new Vector2(32, 32));
|
||||
|
||||
passwordBox.GuiInput += e =>
|
||||
{
|
||||
if (passwordBox.HasFocus() && e is InputEventKey inputEventKey && inputEventKey.IsPressed())
|
||||
{
|
||||
if (inputEventKey.KeyLabel == Key.Enter)
|
||||
{
|
||||
Connection.Instance.AdminAuth(passwordBox.Text);
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
Timeout.ValueChanged += value =>
|
||||
{
|
||||
Connection.Instance.SetMoveWait((float)value);
|
||||
var time = Connection.Instance.CurrentWaitTimeout.ToString();
|
||||
if (time.Length > 3) {
|
||||
time = time.Substring(0, 3);
|
||||
}
|
||||
Label.Text = "Wait To Move: " + time + "s ";
|
||||
};
|
||||
|
||||
if (inputEventKey.KeyLabel == Key.Space)
|
||||
{
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var button = new Button();
|
||||
button.Text = "Login";
|
||||
button.Pressed += () =>
|
||||
{
|
||||
Connection.Instance.AdminAuth(passwordBox.Text);
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
};
|
||||
|
||||
vbox.AddChild(passwordBox);
|
||||
vbox.AddChild(button);
|
||||
|
||||
authWindow.AddChild(vbox);
|
||||
|
||||
GetTree().Root.AddChild(authWindow);
|
||||
}
|
||||
}
|
||||
BecomeAdmin.Pressed += showAuthPopup;
|
||||
}
|
||||
|
||||
public override void _ExitTree() {
|
||||
Connection.Instance.OnBecomeAdmin -= UpdateUI;
|
||||
Connection.Instance.OnTournamentEnd -= UpdateUI;
|
||||
Connection.Instance.OnStartTournament -= UpdateUI;
|
||||
Connection.Instance.OnCancelTournamentAck -= UpdateUI;
|
||||
Connection.Instance.OnGetDataAcks -= UpdateUI;
|
||||
Connection.Instance.OnSetDataAcks -= UpdateUI;
|
||||
}
|
||||
|
||||
private void UpdateUI() {
|
||||
if (!Connection.Instance.IsAdmin) {
|
||||
BecomeAdmin.Show();
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Hide();
|
||||
Label.Hide();
|
||||
Timeout.Hide();
|
||||
} else {
|
||||
BecomeAdmin.Hide();
|
||||
Label.Show();
|
||||
Timeout.Show();
|
||||
}
|
||||
|
||||
if (Connection.Instance.IsAdmin && Connection.Instance.DemoMode) {
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Hide();
|
||||
} else if (Connection.Instance.IsAdmin && Connection.Instance.ActiveTournament != TournamentType.None) {
|
||||
StartTournament.Hide();
|
||||
CancelTournament.Show();
|
||||
} else if (Connection.Instance.IsAdmin) {
|
||||
StartTournament.Show();
|
||||
CancelTournament.Hide();
|
||||
}
|
||||
|
||||
Timeout.Value = Connection.Instance.CurrentWaitTimeout;
|
||||
var time = Connection.Instance.CurrentWaitTimeout.ToString();
|
||||
if (time.Length > 3) {
|
||||
time = time.Substring(0, 3);
|
||||
}
|
||||
|
||||
Label.Text = "Wait To Move: " + time + "s ";
|
||||
}
|
||||
|
||||
private void showAuthPopup() {
|
||||
var authWindow = new Window();
|
||||
authWindow.Theme = GD.Load<Theme>("res://assets/theme.tres");
|
||||
authWindow.AlwaysOnTop = true;
|
||||
authWindow.MaximizeDisabled = true;
|
||||
authWindow.Unresizable = true;
|
||||
authWindow.InitialPosition = Window.WindowInitialPosition.CenterMainWindowScreen;
|
||||
authWindow.Size = new Vector2I(256, 128);
|
||||
authWindow.CloseRequested += () =>
|
||||
{
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
};
|
||||
|
||||
var vbox = new VBoxContainer();
|
||||
vbox.LayoutMode = 1;
|
||||
vbox.AnchorBottom = 1.0f;
|
||||
vbox.AnchorRight = 1.0f;
|
||||
vbox.GrowHorizontal = GrowDirection.Both;
|
||||
vbox.GrowVertical = GrowDirection.Both;
|
||||
vbox.Alignment = AlignmentMode.Center;
|
||||
|
||||
var passwordBox = new TextEdit();
|
||||
passwordBox.PlaceholderText = "Password";
|
||||
passwordBox.SetCustomMinimumSize(new Vector2(32, 32));
|
||||
|
||||
passwordBox.GuiInput += e =>
|
||||
{
|
||||
if (passwordBox.HasFocus() && e is InputEventKey inputEventKey && inputEventKey.IsPressed()) {
|
||||
if (inputEventKey.KeyLabel == Key.Enter) {
|
||||
Connection.Instance.AdminAuth(passwordBox.Text);
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
|
||||
if (inputEventKey.KeyLabel == Key.Space) {
|
||||
GetViewport().SetInputAsHandled();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var button = new Button();
|
||||
button.Text = "Login";
|
||||
button.Pressed += () =>
|
||||
{
|
||||
Connection.Instance.AdminAuth(passwordBox.Text);
|
||||
GetTree().Root.CallDeferred(Node.MethodName.RemoveChild, authWindow);
|
||||
};
|
||||
|
||||
vbox.AddChild(passwordBox);
|
||||
vbox.AddChild(button);
|
||||
|
||||
authWindow.AddChild(vbox);
|
||||
|
||||
GetTree().Root.AddChild(authWindow);
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,9 @@ public partial class BackButton : TextureButton {
|
||||
private const string BRACKET_SCENE_PATH = "res://scenes/bracket_view.tscn";
|
||||
|
||||
public override void _Pressed() {
|
||||
TransitionToBracket();
|
||||
transitionToBracket();
|
||||
base._Pressed();
|
||||
}
|
||||
|
||||
private void TransitionToBracket() {
|
||||
GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH);
|
||||
}
|
||||
private void transitionToBracket() { GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); }
|
||||
}
|
||||
@@ -52,12 +52,10 @@ public partial class BoardScreen : Node2D {
|
||||
if (Connection.Instance.PreviousMoves.Count == 0) {
|
||||
player1Card.GetNode<Label>("Status").Show();
|
||||
player2Card.GetNode<Label>("Status").Hide();
|
||||
}
|
||||
else if (Connection.Instance.PreviousMoves.Last().Item1 == matchData.player1) {
|
||||
} else if (Connection.Instance.PreviousMoves.Last().Item1 == matchData.player1) {
|
||||
player1Card.GetNode<Label>("Status").Hide();
|
||||
player2Card.GetNode<Label>("Status").Show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
player1Card.GetNode<Label>("Status").Show();
|
||||
player2Card.GetNode<Label>("Status").Hide();
|
||||
}
|
||||
@@ -74,14 +72,12 @@ public partial class BoardScreen : Node2D {
|
||||
Connection.Instance.PreviousMoves.RemoveAt(0);
|
||||
if (move.Item1 == matchData.player1) {
|
||||
spawnRed(move.Item2);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
spawnYellow(move.Item2);
|
||||
}
|
||||
|
||||
currentTimeout = MOVE_TIMEOUT_BEFORE_PLACE;
|
||||
}
|
||||
else if (currentTimeout >= 0.0f) {
|
||||
} else if (currentTimeout >= 0.0f) {
|
||||
currentTimeout -= delta;
|
||||
}
|
||||
|
||||
@@ -92,8 +88,7 @@ public partial class BoardScreen : Node2D {
|
||||
if (_lastMoveTimer <= 0.0f) {
|
||||
if (_winner == "") {
|
||||
showPopupMessage("Draw!");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
showPopupMessage(_winner + " wins!");
|
||||
}
|
||||
}
|
||||
@@ -130,8 +125,7 @@ public partial class BoardScreen : Node2D {
|
||||
if (!_lastMove)
|
||||
player2Card.GetNode<Label>("Status").Show();
|
||||
player1Card.GetNode<Label>("Status").Hide();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!_lastMove)
|
||||
player1Card.GetNode<Label>("Status").Show();
|
||||
player2Card.GetNode<Label>("Status").Hide();
|
||||
@@ -166,9 +160,7 @@ public partial class BoardScreen : Node2D {
|
||||
transitionToBracket();
|
||||
}
|
||||
|
||||
private void transitionToBracket() {
|
||||
GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH);
|
||||
}
|
||||
private void transitionToBracket() { GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); }
|
||||
|
||||
/*
|
||||
* Determines if the column can have a new chip placed
|
||||
|
||||
@@ -40,13 +40,13 @@ public partial class BracketScene : Control {
|
||||
private void updatePlayers(List<PlayerData> newPlayerList) {
|
||||
Players.Clear();
|
||||
playerList = newPlayerList;
|
||||
playerList.Sort((a, b) => a.username.CompareTo(b.username));
|
||||
playerList.Sort((a, b) => a.Username.CompareTo(b.Username));
|
||||
var root = Players.CreateItem();
|
||||
for (int i = 0; i < playerList.Count; i++) {
|
||||
var item = Players.CreateItem(root);
|
||||
item.SetText(0, newPlayerList[i].username);
|
||||
item.SetText(1, newPlayerList[i].isReady ? "Yes" : "No");
|
||||
item.SetText(2, newPlayerList[i].isPlaying ? "Yes" : "No");
|
||||
item.SetText(0, newPlayerList[i].Username);
|
||||
item.SetText(1, newPlayerList[i].IsReady ? "Yes" : "No");
|
||||
item.SetText(2, newPlayerList[i].IsPlaying ? "Yes" : "No");
|
||||
if (Connection.Instance.IsAdmin) {
|
||||
item.AddButton(0, TerminateKickButton, i, false, "Kick");
|
||||
}
|
||||
@@ -83,11 +83,9 @@ public partial class BracketScene : Control {
|
||||
|
||||
private void kickPlayer(TreeItem item, long column, long id, long mouseButtonIndex) {
|
||||
if (mouseButtonIndex == 1 && column == 0) {
|
||||
Connection.Instance.KickPlayer(playerList[(int)id].username);
|
||||
Connection.Instance.KickPlayer(playerList[(int)id].Username);
|
||||
}
|
||||
}
|
||||
|
||||
private void transitionToBoard() {
|
||||
GetTree().ChangeSceneToFile(BOARD_SCENE_PATH);
|
||||
}
|
||||
private void transitionToBoard() { GetTree().ChangeSceneToFile(BOARD_SCENE_PATH); }
|
||||
}
|
||||
@@ -17,7 +17,8 @@ public partial class ConnectButtonUI : Button {
|
||||
ErrorLabel.Text = Connection.Instance.LastError;
|
||||
}
|
||||
|
||||
AddressField.GuiInput += e => {
|
||||
AddressField.GuiInput += e =>
|
||||
{
|
||||
if (AddressField.HasFocus() && e is InputEventKey inputEventKey && inputEventKey.IsPressed()) {
|
||||
if (inputEventKey.KeyLabel == Key.Enter) {
|
||||
Connection.Instance.Connect(AddressField.Text);
|
||||
@@ -36,13 +37,9 @@ public partial class ConnectButtonUI : Button {
|
||||
Connection.Instance.OnWsConnectionFailed -= OnConnectionFailed;
|
||||
}
|
||||
|
||||
public override void _Pressed() {
|
||||
Connection.Instance.Connect(AddressField.Text);
|
||||
}
|
||||
public override void _Pressed() { Connection.Instance.Connect(AddressField.Text); }
|
||||
|
||||
private void OnConnectionSuccess() {
|
||||
GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH);
|
||||
}
|
||||
private void OnConnectionSuccess() { GetTree().ChangeSceneToFile(BRACKET_SCENE_PATH); }
|
||||
|
||||
private void OnConnectionFailed() {
|
||||
ErrorLabel.Text = "Couldn't connect to server! " + Connection.Instance.LastError;
|
||||
|
||||
@@ -100,13 +100,11 @@ public partial class Connection : Node {
|
||||
UpdateGameList();
|
||||
UpdatePlayerList();
|
||||
refreshGamePlayerListTimer = 5.0f;
|
||||
}
|
||||
else if (refreshGamePlayerListTimer <= 0.0f) {
|
||||
} else if (refreshGamePlayerListTimer <= 0.0f) {
|
||||
UpdateGameList();
|
||||
UpdatePlayerList();
|
||||
refreshGamePlayerListTimer = 5.0f;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
refreshGamePlayerListTimer -= (float)delta;
|
||||
}
|
||||
|
||||
@@ -124,19 +122,15 @@ public partial class Connection : Node {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == WebSocketPeer.State.Connecting) {
|
||||
} else if (state == WebSocketPeer.State.Connecting) {
|
||||
// Do nothing
|
||||
}
|
||||
else if (state == WebSocketPeer.State.Closing) {
|
||||
} else if (state == WebSocketPeer.State.Closing) {
|
||||
// Do nothing
|
||||
}
|
||||
else if (state == WebSocketPeer.State.Closed) {
|
||||
} else if (state == WebSocketPeer.State.Closed) {
|
||||
if (isConnecting) {
|
||||
isConnecting = false;
|
||||
OnWsConnectionFailed?.Invoke();
|
||||
}
|
||||
else if (isConnected) {
|
||||
} else if (isConnected) {
|
||||
isConnected = false;
|
||||
IsAdmin = false;
|
||||
CurrentWaitTimeout = 5.0;
|
||||
@@ -169,52 +163,22 @@ public partial class Connection : Node {
|
||||
sendCommand("CONNECT", clientId);
|
||||
}
|
||||
|
||||
public void SendDisconnect() {
|
||||
sendCommand("DISCONNECT");
|
||||
}
|
||||
|
||||
public void SendReady() {
|
||||
sendCommand("READY");
|
||||
}
|
||||
|
||||
public void SendPlay(int column) {
|
||||
sendCommand("PLAY", column.ToString());
|
||||
}
|
||||
public void SendDisconnect() { sendCommand("DISCONNECT"); }
|
||||
public void SendReady() { sendCommand("READY"); }
|
||||
public void SendPlay(int column) { sendCommand("PLAY", column.ToString()); }
|
||||
|
||||
// Observer commands
|
||||
public void UpdateGameList() {
|
||||
sendCommand("GAME", "LIST");
|
||||
}
|
||||
|
||||
public void UpdatePlayerList() {
|
||||
sendCommand("PLAYER", "LIST");
|
||||
}
|
||||
|
||||
public void SendWatchGame(int matchID) {
|
||||
sendCommand("GAME", "WATCH:" + matchID);
|
||||
}
|
||||
|
||||
public void UpdateGameList() { sendCommand("GAME", "LIST"); }
|
||||
public void UpdatePlayerList() { sendCommand("PLAYER", "LIST"); }
|
||||
public void SendWatchGame(int matchID) { sendCommand("GAME", "WATCH:" + matchID); }
|
||||
public void AdminAuth(string password) {
|
||||
if (IsAdmin) return;
|
||||
sendCommand("ADMIN", "AUTH:" + password);
|
||||
}
|
||||
|
||||
public void GetMoveWait() {
|
||||
sendCommand("GET", "MOVE_WAIT");
|
||||
}
|
||||
|
||||
public void GetTournamentStatus() {
|
||||
sendCommand("GET", "TOURNAMENT_STATUS");
|
||||
}
|
||||
|
||||
public void GetDemoMode() {
|
||||
sendCommand("GET", "DEMO_MODE");
|
||||
}
|
||||
|
||||
public void GetMaxTimeout() {
|
||||
sendCommand("GET", "MAX_TIMEOUT");
|
||||
}
|
||||
|
||||
public void GetMoveWait() { sendCommand("GET", "MOVE_WAIT"); }
|
||||
public void GetTournamentStatus() { sendCommand("GET", "TOURNAMENT_STATUS"); }
|
||||
public void GetDemoMode() { sendCommand("GET", "DEMO_MODE"); }
|
||||
public void GetMaxTimeout() { sendCommand("GET", "MAX_TIMEOUT"); }
|
||||
|
||||
// Admin commands
|
||||
public void KickPlayer(string playerId) {
|
||||
@@ -278,8 +242,7 @@ public partial class Connection : Node {
|
||||
if (separatorIndex >= 0) {
|
||||
header = message.Substring(0, separatorIndex).Trim();
|
||||
body = message.Substring(separatorIndex + 1).Trim();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
header = message.Trim();
|
||||
body = string.Empty;
|
||||
}
|
||||
@@ -309,8 +272,7 @@ public partial class Connection : Node {
|
||||
case "OPPONENT":
|
||||
if (int.TryParse(body, out int column)) {
|
||||
OnOpponentMove?.Invoke(column);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
GD.PrintErr($"Invalid opponent column: {body}");
|
||||
}
|
||||
|
||||
@@ -331,24 +293,19 @@ public partial class Connection : Node {
|
||||
string data = body.Split(":")[1];
|
||||
if (body.StartsWith("MOVE_WAIT")) {
|
||||
CurrentWaitTimeout = double.Parse(data);
|
||||
}
|
||||
else if (body.StartsWith("MAX_TIMEOUT")) {
|
||||
} else if (body.StartsWith("MAX_TIMEOUT")) {
|
||||
MaxTimeout = double.Parse(data);
|
||||
}
|
||||
else if (body.StartsWith("DEMO_MODE")) {
|
||||
} else if (body.StartsWith("DEMO_MODE")) {
|
||||
DemoMode = bool.Parse(data);
|
||||
}
|
||||
else if (body.StartsWith("TOURNAMENT_STATUS")) {
|
||||
} else if (body.StartsWith("TOURNAMENT_STATUS")) {
|
||||
TournamentType? type = parseTournamentType(data);
|
||||
|
||||
if (type == null) {
|
||||
GD.PrintErr($"Unhandled tournament type: {data}");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ActiveTournament = type.Value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
GD.PrintErr($"Unhandled data get: {body}");
|
||||
}
|
||||
|
||||
@@ -395,8 +352,7 @@ public partial class Connection : Node {
|
||||
TournamentType? type = parseTournamentType(argument);
|
||||
if (type == null) {
|
||||
GD.PrintErr($"Unhandled tournament type: {argument}");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ActiveTournament = type.Value;
|
||||
OnStartTournament?.Invoke();
|
||||
}
|
||||
@@ -471,8 +427,7 @@ public partial class Connection : Node {
|
||||
GD.Print($"Unhandled GAME message: {body}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // Regular observer/admin
|
||||
} else // Regular observer/admin
|
||||
{
|
||||
switch (command) {
|
||||
case "WIN":
|
||||
@@ -510,8 +465,7 @@ public partial class Connection : Node {
|
||||
if (activeMatchData.IsEmpty()) {
|
||||
string[] matchData = segments[2].Split(',');
|
||||
CurrentObservingMatch = new MatchData(int.Parse(matchData[0]), matchData[1], matchData[2]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
string[] matchData = activeMatchData[0].Split(',');
|
||||
CurrentObservingMatch = new MatchData(int.Parse(matchData[0]), matchData[1], matchData[2]);
|
||||
for (int i = 1; i < activeMatchData.Length; i++) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
public class PlayerData {
|
||||
public string username { get; private set; }
|
||||
public bool isReady { get; private set; }
|
||||
public bool isPlaying { get; private set; }
|
||||
public string Username { get; private set; }
|
||||
public bool IsReady { get; private set; }
|
||||
public bool IsPlaying { get; private set; }
|
||||
|
||||
public PlayerData(string username, bool isReady, bool isPlaying) {
|
||||
this.username = username;
|
||||
this.isReady = isReady;
|
||||
this.isPlaying = isPlaying;
|
||||
Username = username;
|
||||
IsReady = isReady;
|
||||
IsPlaying = isPlaying;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
public enum TournamentType {
|
||||
None,
|
||||
RoundRobin
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user