Move new files.

This commit is contained in:
AnduinXue
2024-01-13 11:13:35 +00:00
parent 5e9bde7e51
commit 04f5c3ed3c
8 changed files with 61 additions and 48 deletions
@@ -28,6 +28,15 @@ public class HomeController : Controller
return View(model);
}
/// <summary>
/// This action will auto redirect to a challenge.
///
/// If the player has a challenge, then go to that challenge.
///
/// If not, then go to a public challenge. If not, then create a new challenge.
/// </summary>
/// <param name="playerId"></param>
/// <returns></returns>
[HttpGet]
public IActionResult Auto(Guid playerId)
{
@@ -0,0 +1,33 @@
using Aiursoft.AiurObserver;
namespace Aiursoft.ChessServer.Models;
public class Challenge
{
public Challenge(Player creator)
{
Creator = creator;
}
public Player Creator { get; set; }
public string Message { get; set; } = "A chess room.";
public Player? Accepter { get; set; } = null;
public Game? Game { get; set; } = null;
public RoleRule RoleRule { get; set; } = RoleRule.Random;
public TimeSpan TimeLimit { get; set; } = TimeSpan.FromMinutes(10);
public ChallengePermission Permission { get; set; } = ChallengePermission.Public;
// Possible messages:
// Player joined: p-joined-{player-nick-name}
// Player left: p-left-{player-nick-name}
// Room dropped: room-dropped
// Game started: game-started
// Creator transferred: creator-transferred-{new-owner-player-nick-name}
// Settings changed: settings-changed
public AsyncObservable<string> ChallengeChangedChannel { get; } = new();
}
@@ -0,0 +1,7 @@
namespace Aiursoft.ChessServer.Models;
public enum ChallengePermission
{
Public,
Unlisted,
}
-43
View File
@@ -10,47 +10,4 @@ public class Game
public AsyncObservable<string> FenChangedChannel { get; } = new();
public object MovePieceLock { get; } = new();
}
public enum RoleRule
{
CreatorWhite,
AccepterWhite,
Random
}
public enum ChallengePermission
{
Public,
Unlisted,
}
public class Challenge
{
public Challenge(Player creator)
{
Creator = creator;
}
public Player Creator { get; set; }
public string Message { get; set; } = "A chess room.";
public Player? Accepter { get; set; } = null;
public Game? Game { get; set; } = null;
public RoleRule RoleRule { get; set; } = RoleRule.Random;
public TimeSpan TimeLimit { get; set; } = TimeSpan.FromMinutes(10);
public ChallengePermission Permission { get; set; } = ChallengePermission.Public;
// Possible messages:
// Player joined: p-joined-{player-nick-name}
// Player left: p-left-{player-nick-name}
// Room dropped: room-dropped
// Game started: game-started
// Creator transferred: creator-transferred-{new-owner-player-nick-name}
// Settings changed: settings-changed
public AsyncObservable<string> ChallengeChangedChannel { get; } = new();
}
@@ -10,5 +10,4 @@ public class Player
}
public string NickName { get; set; } = "Anonymous";
}
@@ -0,0 +1,8 @@
namespace Aiursoft.ChessServer.Models;
public enum RoleRule
{
CreatorWhite,
AccepterWhite,
Random
}
@@ -1,6 +1,4 @@
using System.Collections.Concurrent;
namespace Aiursoft.ChessServer.Models;
namespace Aiursoft.ChessServer.Models;
public class IndexViewModel
{
@@ -6,7 +6,9 @@
<h1 class="display-4">Welcome challenger!</h1>
<p class="lead">Join a room, or create a room!</p>
<p>
<a class="btn btn-success btn-lg mt-4" role="button" id="autoButton" asp-controller="Home" asp-action="Auto" >Auto join</a>
@* JS Will Append the player id to the link. *@
<a class="btn btn-success btn-lg mt-4" role="button" id="autoButton" asp-controller="Home" asp-action="Auto">Auto join</a>
@* JS Will Append the player id to the link. *@
<a class="btn btn-secondary btn-lg mt-4" role="button" id="createButton" asp-controller="Home" asp-action="Create">Create a new room</a>
</p>
</div>