public Agent(AgentConfiguration agentConfiguration) { logger.Info("[Agent] Agent created"); var teamId = agentConfiguration.TeamID.ToLower() == "red" ? TeamId.Red : TeamId.Blue; StartGameComponent = new StartGameComponent(this, teamId); AgentInformationsComponent = new AgentInformationsComponent(this); AgentConfiguration = agentConfiguration; NetworkComponent = new ClientNetworkComponent(agentConfiguration.CsIP, agentConfiguration.CsPort); Piece = null; WaitingPlayers = new List <int>(); switch (agentConfiguration.Strategy) { case winningStrategy: strategy = new WinningStrategy(); break; case doNothingStrategy: strategy = new DoNothingStrategy(); break; default: strategy = new SimpleStrategy(); break; } injectedMessages = new List <BaseMessage>(); AgentState = AgentState.Created; ProcessMessages = new ProcessMessages(this); }
public ActionResult AcceptMessage(BaseMessage message) { AgentInformationsComponent.Discovered = false; var ingameTypes = ProcessMessages.GetIngameMessageTypes(); if (ingameTypes.Contains(message.MessageId) && AgentState != AgentState.InGame) { logger.Warn("[Agent {id}] Received message of type {type}, but not in game", Id, message.MessageId); return(EndIfUnexpectedMessage ? ActionResult.Finish : ActionResult.Continue); } dynamic dynamicMessage = message; return(ProcessMessages.Process(dynamicMessage)); }