Fix /tw end not working

This commit is contained in:
UnknownShadow200 2020-02-23 09:53:29 +11:00
parent 4a5a79afa4
commit b917fa3d95
2 changed files with 18 additions and 13 deletions

View File

@ -31,13 +31,15 @@ namespace MCGalaxy.Games {
if (!Running) return;
RoundInProgress = true;
while (Blue.Captures < cfg.RoundPoints && Red.Captures < cfg.RoundPoints) {
if (!Running) return;
if (!RoundInProgress) break;
while (Running && RoundInProgress && !HasSomeoneWon()) {
Tick();
Thread.Sleep(300);
}
}
bool HasSomeoneWon() {
return Blue.Captures >= cfg.RoundPoints || Red.Captures >= cfg.RoundPoints;
}
void Tick() {
Player[] online = PlayerInfo.Online.Items;

View File

@ -94,20 +94,23 @@ namespace MCGalaxy.Games {
RoundInProgress = true;
MessageMap(CpeMessageType.Announcement, "&4TNT Wars has started!");
bool won = false;
while (Running && !won) {
if (Config.Mode == TWGameMode.TDM) {
won = Red.Score >= cfg.ScoreRequired || Blue.Score >= cfg.ScoreRequired;
} else {
all = allPlayers.Items;
foreach (Player p in all) {
if (Get(p).Score >= cfg.ScoreRequired) won = true;
}
}
while (Running && RoundInProgress && !HasSomeoneWon()) {
Thread.Sleep(250);
}
}
bool HasSomeoneWon() {
if (Config.Mode == TWGameMode.TDM) {
return Red.Score >= cfg.ScoreRequired || Blue.Score >= cfg.ScoreRequired;
}
Player[] all = allPlayers.Items;
foreach (Player p in all) {
if (Get(p).Score >= cfg.ScoreRequired) return true;
}
return false;
}
void GracePeriod() {
if (!cfg.GracePeriod) return;
int duration = (int)cfg.GracePeriodTime.SecondsLong();