public async void UpdateStory(QuestMatch match) { JObject data = new JObject(); data["card"] = match.CurrentStory.Converter.Json.ToJObject(match.CurrentStory); EventData evn = new EventData("update_story", data); await this.messageHandler.SendToMatchAsync(match, evn.ToString()); }
private void OnJoinGame(Player player, JToken data) { QuestMatch game = this.gameWithId((int)data["game_id"]); player.Behaviour = new HumanPlayer(); game.AddPlayer(player); this.matches.Add(player, game); this.UpdatePlayers(this.matches[player]); }
public async void Message(QuestMatch match, string message) { JObject data = new JObject(); data["message"] = message; EventData evn = new EventData("message", data); await this.messageHandler.SendToMatchAsync(match, evn.ToString()); }
public async void UpdateOtherArea(QuestMatch match, List <Card> cards) { foreach (Player player in match.Players) { if (this.matches.ContainsKey(player)) { this.UpdateOtherArea(player, cards); } } }
public async void UpdatePlayers(QuestMatch match) { JObject data = new JObject(); JArray playerArray = new JArray(); match.Players.ForEach((p) => playerArray.Add(p.Converter.Json.ToJObject(p))); data["players"] = playerArray; EventData evn = new EventData("update_players", data); await this.messageHandler.SendToMatchAsync(match, evn.ToString()); }
public GameController(QuestMessageHandler messageHandler, QuestMatch match = null) { if (match == null) { this.matches = new Dictionary <Player, QuestMatch>(); } else { this.matches = new Dictionary <Player, QuestMatch>(); } this.messageHandler = messageHandler; this.InitEventHandlers(); }
private void OnCreateGame(Player player, JToken data) { QuestMatch match = ScenarioCreator.EmptyGame(this); int scenario = (int)data["scenario"]; if (scenario == 1) { match = ScenarioCreator.Scenario1(this); } if (scenario == 2) { match = ScenarioCreator.Scenario2(this); } player.Behaviour = new HumanPlayer(); match.AddPlayer(player); this.matches.Add(player, match); this.UpdatePlayers(this.matches[player]); }
private void OnAddAI(Player player, JToken data) { int strat = (int)data["strategy"]; QuestMatch match = this.matches[player]; Player aiPlayer = new Player("AI Player " + match.Players.Count); if (strat == 1) { aiPlayer.Behaviour = new Strategy1(); } if (strat == 2) { aiPlayer.Behaviour = new Strategy2(); } if (strat == 3) { aiPlayer.Behaviour = new Strategy3(); } match.AddPlayer(aiPlayer); this.UpdatePlayers(this.matches[player]); }
public async void EndStory(QuestMatch match) { EventData evn = new EventData("end_story", new JObject()); await this.messageHandler.SendToMatchAsync(match, evn.ToString()); }