/// <summary>The central method that is used by the Game Engine to run the bot.</summary> public void Action(Common.Team myTeam, Common.Team enemyTeam, Common.Ball ball, Common.MatchInfo matchInfo) { try { var mapping = PlayerMapping.CreateForOwn(myTeam.Players, enemyTeam.Players); State.Add(myTeam, enemyTeam, ball, matchInfo); var fallen = State.Current.Players.Where(p => p.FallenTimer != 0).ToList(); var tackle = State.Current.Players.Where(p => p.TackleTimer != 0).ToList(); var queue = new PlayerQueue(State.Current.OwnPlayers); foreach (var scenario in Scenarios) { if (scenario.Apply(State, queue)) { break; } } mapping.Apply(queue.Actions); } catch (Exception x) { Log.Error(State.GetErrorMessage(), x); } finally { State.Current.Finish(); } }
/// <summary>Creates a mapping for the players.</summary> public static PlayerMapping CreateForOwn(IEnumerable <Common.Player> own, IEnumerable <Common.Player> other) { Guard.NotNull(own, "own"); Guard.NotNull(other, "other"); var mapping = new PlayerMapping(); foreach (var player in own) { mapping.Add(GetId(player.PlayerType, TeamType.Own), player); } foreach (var player in other) { mapping.Add(GetId(player.PlayerType, TeamType.Other), player); } return(mapping); }