/// <summary> /// Registers and returns a new ID for an object of the given type. /// </summary> /// <returns>A new unique ID that can be used to identify the object.</returns> public int RegisterBotID() { if (Bots.Any() && _botID <= Bots.Max(e => e.ID)) { _botID = Bots.Max(e => e.ID) + 1; } return(_botID++); }
public int GetFreeTeamID(string exceptUser) { return (Enumerable.Range(0, TasClient.MaxTeams - 1).FirstOrDefault( teamID => !Users.Where(u => !u.IsSpectator).Any(user => user.Name != exceptUser && user.TeamNumber == teamID) && !Bots.Any(x => x.TeamNumber == teamID))); }
public bool IsPositionBlocked(Position position) { var positionHasBot = Bots.Any(b => b.Position.Equals(position)); var positionHasBlockingGameObject = this.GameObjects.Any(gi => gi.IsBlocking && gi.Position.Equals(position)); return(positionHasBot || positionHasBlockingGameObject); }
private bool IsPositionEmpty(Position position) { var positionHasBot = Bots.Any(b => b.Position.Equals(position)); var positionHasBase = Bots.Any(b => b.Base.Equals(position)); var positionHasDiamond = Diamonds.Contains(position); var positionHasGameObject = GameObjects.Any(gi => gi.Position.Equals(position)); return(positionHasBot == false && positionHasBase == false && positionHasDiamond == false && positionHasGameObject == false); }
private Task WaitForNextTurnAsync() { var speedUp = Bots.Any() ? new TimeSpan(Settings.NextTurnDelay.Ticks / Bots.Count(b => b.HP > 0)) : new TimeSpan(); return(Task.Delay(Settings.NextTurnDelay - speedUp)); }