2023-08-11 14:44:54 +03:00
|
|
|
|
using BattleBitAPI.Common;
|
|
|
|
|
|
|
|
|
|
namespace BattleBitAPI.Server
|
|
|
|
|
{
|
|
|
|
|
public class RoundSettings<TPlayer> where TPlayer : Player<TPlayer>
|
|
|
|
|
{
|
2023-08-17 18:39:20 +03:00
|
|
|
|
// ---- Construction ----
|
2023-08-11 14:44:54 +03:00
|
|
|
|
private GameServer<TPlayer>.Internal mResources;
|
|
|
|
|
public RoundSettings(GameServer<TPlayer>.Internal resources)
|
|
|
|
|
{
|
|
|
|
|
mResources = resources;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:39:20 +03:00
|
|
|
|
// ---- Variables ----
|
2023-08-11 14:44:54 +03:00
|
|
|
|
public GameState State
|
|
|
|
|
{
|
|
|
|
|
get => this.mResources._RoundSettings.State;
|
|
|
|
|
}
|
2023-08-11 19:14:47 +03:00
|
|
|
|
public double TeamATickets
|
2023-08-11 14:44:54 +03:00
|
|
|
|
{
|
|
|
|
|
get => this.mResources._RoundSettings.TeamATickets;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this.mResources._RoundSettings.TeamATickets = value;
|
|
|
|
|
this.mResources.IsDirtyRoundSettings = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 19:14:47 +03:00
|
|
|
|
public double TeamBTickets
|
2023-08-11 14:44:54 +03:00
|
|
|
|
{
|
|
|
|
|
get => this.mResources._RoundSettings.TeamBTickets;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this.mResources._RoundSettings.TeamBTickets = value;
|
|
|
|
|
this.mResources.IsDirtyRoundSettings = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 19:14:47 +03:00
|
|
|
|
public double MaxTickets
|
2023-08-11 14:44:54 +03:00
|
|
|
|
{
|
2023-08-11 19:14:47 +03:00
|
|
|
|
get => this.mResources._RoundSettings.MaxTickets;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-08-11 19:14:47 +03:00
|
|
|
|
this.mResources._RoundSettings.MaxTickets = value;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
this.mResources.IsDirtyRoundSettings = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public int PlayersToStart
|
|
|
|
|
{
|
|
|
|
|
get => this.mResources._RoundSettings.PlayersToStart;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this.mResources._RoundSettings.PlayersToStart = value;
|
|
|
|
|
this.mResources.IsDirtyRoundSettings = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 19:14:47 +03:00
|
|
|
|
public int SecondsLeft
|
2023-08-11 14:44:54 +03:00
|
|
|
|
{
|
2023-08-11 19:14:47 +03:00
|
|
|
|
get => this.mResources._RoundSettings.SecondsLeft;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-08-11 19:14:47 +03:00
|
|
|
|
this.mResources._RoundSettings.SecondsLeft = value;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
this.mResources.IsDirtyRoundSettings = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 18:39:20 +03:00
|
|
|
|
// ---- Reset ----
|
2023-08-11 14:44:54 +03:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-17 18:39:20 +03:00
|
|
|
|
|
|
|
|
|
// ---- Classes ----
|
|
|
|
|
public class mRoundSettings
|
|
|
|
|
{
|
|
|
|
|
public const int Size = 1 + 8 + 8 + 8 + 4 + 4;
|
|
|
|
|
|
|
|
|
|
public GameState State = GameState.WaitingForPlayers;
|
|
|
|
|
public double TeamATickets = 0;
|
|
|
|
|
public double TeamBTickets = 0;
|
|
|
|
|
public double MaxTickets = 1;
|
|
|
|
|
public int PlayersToStart = 16;
|
|
|
|
|
public int SecondsLeft = 60;
|
|
|
|
|
|
|
|
|
|
public void Write(Common.Serialization.Stream ser)
|
|
|
|
|
{
|
|
|
|
|
ser.Write((byte)this.State);
|
|
|
|
|
ser.Write(this.TeamATickets);
|
|
|
|
|
ser.Write(this.TeamBTickets);
|
|
|
|
|
ser.Write(this.MaxTickets);
|
|
|
|
|
ser.Write(this.PlayersToStart);
|
|
|
|
|
ser.Write(this.SecondsLeft);
|
|
|
|
|
}
|
|
|
|
|
public void Read(Common.Serialization.Stream ser)
|
|
|
|
|
{
|
|
|
|
|
this.State = (GameState)ser.ReadInt8();
|
|
|
|
|
this.TeamATickets = ser.ReadDouble();
|
|
|
|
|
this.TeamBTickets = ser.ReadDouble();
|
|
|
|
|
this.MaxTickets = ser.ReadDouble();
|
|
|
|
|
this.PlayersToStart = ser.ReadInt32();
|
|
|
|
|
this.SecondsLeft = ser.ReadInt32();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
this.State = GameState.WaitingForPlayers;
|
|
|
|
|
this.TeamATickets = 0;
|
|
|
|
|
this.TeamBTickets = 0;
|
|
|
|
|
this.MaxTickets = 1;
|
|
|
|
|
this.PlayersToStart = 16;
|
|
|
|
|
this.SecondsLeft = 60;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 14:44:54 +03:00
|
|
|
|
}
|
|
|
|
|
}
|