Convert field to jagged arrays; add local SignalR UI
Change game field representation to jagged arrays (int[][]) for JSON/SignalR compatibility and add conversion helpers in GameManager. Make Coordinates JSON-serializable (constructor and JsonPropertyName attributes). Update GameHubSocket: validate field size, fix JoinGame parameter order/Group join, rename Place->Drop and send proper game id. Add client-side local play support: GameConnection SignalR client, LocalGame orchestration for two local players, and UI components (GameCreationMenu, Slider) plus GameSettings interface. Update LocalMode route to use the new creation UI and start local games. These changes enable reliable serialization over SignalR and a local two-player flow with a creation UI.
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
namespace API.Models.Game;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public readonly struct Coordinates(int x, int y)
|
||||
namespace API.Models.Game;
|
||||
|
||||
public readonly struct Coordinates
|
||||
{
|
||||
public readonly int X = x;
|
||||
public readonly int Y = y;
|
||||
[JsonConstructor]
|
||||
public Coordinates(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
[JsonPropertyName("x")]
|
||||
public int X { get; init; }
|
||||
|
||||
[JsonPropertyName("y")]
|
||||
public int Y { get; init; }
|
||||
}
|
||||
|
||||
public enum DropResult
|
||||
@@ -146,4 +158,4 @@ public class GameField(Coordinates gFs)
|
||||
{
|
||||
Array.Copy(CurrentField, BackupField, CurrentField.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user