2023-08-17 18:39:20 +03:00
|
|
|
|
|
2023-08-14 17:13:31 +03:00
|
|
|
|
namespace BattleBitAPI.Server
|
2023-08-01 22:11:52 +03:00
|
|
|
|
{
|
2023-08-11 11:04:47 +03:00
|
|
|
|
public class MapRotation<TPlayer> where TPlayer : Player<TPlayer>
|
2023-08-01 22:11:52 +03:00
|
|
|
|
{
|
2023-08-11 11:04:47 +03:00
|
|
|
|
private GameServer<TPlayer>.Internal mResources;
|
|
|
|
|
public MapRotation(GameServer<TPlayer>.Internal resources)
|
2023-08-01 22:11:52 +03:00
|
|
|
|
{
|
|
|
|
|
mResources = resources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<string> GetMapRotation()
|
|
|
|
|
{
|
2023-08-11 11:04:47 +03:00
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
return new List<string>(mResources._MapRotation);
|
2023-08-01 22:11:52 +03:00
|
|
|
|
}
|
|
|
|
|
public bool InRotation(string map)
|
|
|
|
|
{
|
|
|
|
|
map = map.ToUpperInvariant();
|
|
|
|
|
|
2023-08-11 11:04:47 +03:00
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
return mResources._MapRotation.Contains(map);
|
2023-08-01 22:11:52 +03:00
|
|
|
|
}
|
|
|
|
|
public bool RemoveFromRotation(string map)
|
|
|
|
|
{
|
|
|
|
|
map = map.ToUpperInvariant();
|
|
|
|
|
|
2023-08-11 11:04:47 +03:00
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
if (!mResources._MapRotation.Remove(map))
|
2023-08-01 22:11:52 +03:00
|
|
|
|
return false;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
mResources.IsDirtyMapRotation = true;
|
2023-08-01 22:11:52 +03:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public bool AddToRotation(string map)
|
|
|
|
|
{
|
|
|
|
|
map = map.ToUpperInvariant();
|
|
|
|
|
|
2023-08-11 11:04:47 +03:00
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
if (!mResources._MapRotation.Add(map))
|
2023-08-01 22:11:52 +03:00
|
|
|
|
return false;
|
2023-08-11 14:44:54 +03:00
|
|
|
|
mResources.IsDirtyMapRotation = true;
|
2023-08-01 22:11:52 +03:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-08-14 12:43:58 +03:00
|
|
|
|
public void SetRotation(params string[] maps)
|
|
|
|
|
{
|
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
{
|
|
|
|
|
mResources._MapRotation.Clear();
|
|
|
|
|
foreach (var item in maps)
|
|
|
|
|
mResources._MapRotation.Add(item);
|
|
|
|
|
}
|
|
|
|
|
mResources.IsDirtyMapRotation = true;
|
|
|
|
|
}
|
|
|
|
|
public void ClearRotation()
|
|
|
|
|
{
|
|
|
|
|
lock (mResources._MapRotation)
|
|
|
|
|
{
|
|
|
|
|
if (mResources._MapRotation.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mResources._MapRotation.Clear();
|
|
|
|
|
}
|
|
|
|
|
mResources.IsDirtyMapRotation = true;
|
|
|
|
|
}
|
2023-08-11 11:04:47 +03:00
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
}
|
2023-08-01 22:11:52 +03:00
|
|
|
|
}
|
|
|
|
|
}
|