Add IGame.Running

This commit is contained in:
UnknownShadow200 2017-08-07 09:57:06 +10:00
parent e9c02198ce
commit 92ecccdc51
8 changed files with 28 additions and 8 deletions

View File

@ -41,6 +41,9 @@ namespace MCGalaxy.Games {
internal string map1 = "", map2 = "", map3 = "";
public bool started = false;
/// <summary> Gets whether CTF is currently running. </summary>
public override bool Running { get { return started; } }
public CtfTeam2 Red, Blue;
List<CtfData> cache = new List<CtfData>();

View File

@ -32,6 +32,8 @@ namespace MCGalaxy.Games {
/// <summary> Current status of the countdown game. </summary>
public CountdownGameStatus Status = CountdownGameStatus.Disabled;
// <summary> Gets whether countdown is currently running. </summary>
public override bool Running { get { return Status != CountdownGameStatus.Disabled; } }
/// <summary> Whether the game is running in freeze mode or not. </summary>
public bool FreezeMode = false;

View File

@ -27,6 +27,9 @@ namespace MCGalaxy.Games {
/// <summary> Level instance of the map this game is running on. </summary>
public Level Map;
/// <summary> Gets whether this game is currently running. </summary>
public abstract bool Running { get; }
/// <summary> Whether players are allowed to teleport to others when not in referee mode. </summary>
public virtual bool TeleportAllowed { get { return true; } }

View File

@ -39,6 +39,9 @@ namespace MCGalaxy.Games
public Level map;
public MapSettings mapSettings;
public MapData mapData;
/// <summary> Gets whether lava survival is currently running. </summary>
public override bool Running { get { return active; } }
// Settings
public bool startOnStartup, sendAfkMain = true;

View File

@ -32,7 +32,18 @@ namespace MCGalaxy.Games {
internal string Candidate1 = "", Candidate2 = "", Candidate3 = "";
internal int Votes1 = 0, Votes2 = 0, Votes3 = 0;
public string ChooseNextLevel(ZSGame game) {
public void AddRecentMap(string map) {
if (RecentMaps.Count >= 20)
RecentMaps.RemoveAt(0);
RecentMaps.Add(map);
}
public void Clear() {
QueuedMap = null;
RecentMaps.Clear();
}
public string ChooseNextLevel(IGame game) {
if (QueuedMap != null) return QueuedMap;
try {
@ -51,7 +62,7 @@ namespace MCGalaxy.Games {
DoLevelVote(game);
if (!game.Running) return null;
return NextLevel(r, maps, game);
return NextLevel(r, maps);
} catch (Exception ex) {
Logger.LogError(ex);
return null;
@ -102,7 +113,7 @@ namespace MCGalaxy.Games {
}
}
string NextLevel(Random r, List<string> levels, ZSGame game) {
string NextLevel(Random r, List<string> levels) {
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online) pl.voted = false;

View File

@ -101,9 +101,7 @@ namespace MCGalaxy.Games {
if (!Running) { Status = ZombieGameStatus.LastRound; return; }
EndRound();
if (Picker.RecentMaps.Count > 20)
Picker.RecentMaps.RemoveAt(0);
Picker.RecentMaps.Add(MapName);
Picker.AddRecentMap(MapName);
}
Player PickFirstZombie(Random random, List<Player> players) {

View File

@ -49,7 +49,7 @@ namespace MCGalaxy.Games {
public ZombieGameStatus Status = ZombieGameStatus.NotStarted;
/// <summary> Gets whether zombie survival is currently running. </summary>
public bool Running { get { return Status != ZombieGameStatus.NotStarted; } }
public override bool Running { get { return Status != ZombieGameStatus.NotStarted; } }
/// <summary> Whether a round is currently in progress. </summary>
public bool RoundInProgress = false;

View File

@ -198,7 +198,7 @@ namespace MCGalaxy.Games {
Infected.Clear();
Bounties.Clear();
Picker.RecentMaps.Clear();
Picker.Clear();
foreach (Player pl in online) {
pl.Game.Referee = false;