2024-05-02 15:24:13 -07:00

158 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace WebAPI.Models.IceBreak
{
public enum GameType
{
WereWolf,
WhoIsSpy
}
public interface IGameRoom
{
string Id { get; set; }
string Name { get; set; }
List<IGamePlayer> Players { get; set; }
int TotalPlayer { get; }
string SignalRClientId { get; set; }
}
public class GameRoom : IGameRoom
{
GameType Type { get; set; }
public string Id { get; set; }
public string SignalRClientId { get; set; }
public string Name { get; set; }
private List<IGamePlayer> _players;
public int TotalPlayer => Players.Count;
public List<IGamePlayer> Players
{
get
{
if (_players == null)
{
_players = new List<IGamePlayer>();
}
return _players;
}
set => _players = value;
}
}
public interface IGamePlayer
{
public string Id { get; set; }
public string SignalRClientId { get; set; }
public string TabId { get; set; }
[Required]
public string Name { get; set; }
public string GameRoomId { get; set; }
public bool IsPlayer { get; set; }
}
public class GamePlayer : IGamePlayer
{
public string Id { get; set; }
public string SignalRClientId { get; set; }
public string TabId { get; set; }
[Required]
public string Name { get; set; }
public string GameRoomId { get; set; }
public bool IsPlayer { get; set; }
}
public enum WhoIsSpyProcess
{
WaitForPlayer,
Started,
Votting,
DisplayResult,
End,
Closed
}
public class WhoIsSpyGameRoom : GameRoom, IGameRoom
{
public WhoIsSpyGameRoom()
{
PlayedAnswerId = new List<int>();
}
public int Question { get; set; }
[Required]
public int SpyAmount { get; set; }
[Required]
public int EmptyAmount { get; set; }
public int StartIndex { get; set; }
public WhoIsSpyAnswer Answer { get; set; }
public WhoIsSpyAnswer SpysAnswer { get; set; }
public WhoIsSpyProcess Status { get; set; }
public List<int> PlayedAnswerId { get; set; }
public int VoteAmount { get; set; }
}
public class WhoIsSpyPlayer : GamePlayer, IGamePlayer
{
public string RoomId { get; set; }
public int Seed { get; set; }
public WhoIsSpyAnswer Answer { get; set; }
public bool IsSpy { get; set; }
public bool IsDead { get; set; }
public WhoIsSpyProcess GameStatus { get; set; }
public List<string> VoteTo { get; set; }
public int ReceviedVotes { get; set; }
public int VoteAmount { get; set; }
public List<WhoIsSpyVoteOption> VoteOption { get; set; }
}
public class WhoIsSpyVoteOption
{
public WhoIsSpyVoteOption(string id, string name)
{
Id = id;
Name = name;
}
public string Id { get; set; }
public string Name { get; set; }
}
public class WhoIsSpyAnswer
{
public WhoIsSpyAnswer()
{
}
public WhoIsSpyAnswer(string answerCht, string answerChs, string answerEn, string answerImage)
{
AnswerCht = answerCht;
AnswerChs = answerChs;
AnswerEn = answerEn;
AnswerImage = answerImage;
}
public string AnswerCht { get; set; }
public string AnswerChs { get; set; }
public string AnswerEn { get; set; }
public string AnswerImage { get; set; }
}
}