Add challenge APIs.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Aiursoft.ChessServer.Controllers;
|
||||
|
||||
[Route("challenges")]
|
||||
public class ChallengeController : ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
[Route("create")]
|
||||
public IActionResult Create(Guid userId)
|
||||
{
|
||||
// Create a new challenge. Add to database.
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("list")]
|
||||
public IActionResult List()
|
||||
{
|
||||
// Show all public challenges.
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("accept/{id:int}")]
|
||||
public IActionResult Accept(int id, Guid userId)
|
||||
{
|
||||
// Accept a challenge. Remove the challenge from database.
|
||||
// Create a new game. Redirect both players to the game.
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("reject/{id:int}")]
|
||||
public IActionResult Edit(int id, Guid userId)
|
||||
{
|
||||
// If challenge owner is the same as user id,
|
||||
// Edit a challenge in database.
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,30 @@ 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 Guid CreatorId { get; set; }
|
||||
|
||||
public Guid? AccepterId { 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;
|
||||
}
|
||||
Reference in New Issue
Block a user