Exemplo n.º 1
0
        void BP()
        {
            if (game != null)
            {
                while (!new BPEndRule(game).Validate())
                {
                    actionDone.WaitOne();

                    InstructionTokenRule instructionTokenRule = new InstructionTokenRule(game);
                    instructionTokenRule.Validate();

                    rotateBPDecision(game);

                    TeammateRule teammateRule = new TeammateRule(game);
                    teammateRule.Validate();

                    UpdateChampionPoolWeightRule updateChampionPoolWeightRule = new UpdateChampionPoolWeightRule(game);
                    updateChampionPoolWeightRule.Validate();

                    RecommendRule recommendRule = new RecommendRule(game);
                    recommendRule.Validate();

                    JSONInstruction = new JavaScriptSerializer().Serialize(game.instruction);
                    ruleAndDesicionDone.Set();
                }
            }
        }
Exemplo n.º 2
0
        string startNewGame(string[] ourLane, string[] enemylane, bool firstMove)
        {
            string msg           = "";
            bool   dataPersisted = StaticValue.allChampions.Count > 0;

            if (dataPersisted)
            {
                cancelRunningGameTask();
                game              = new Game();
                game.FirstMove    = firstMove;
                game.ChampionPool = StaticValue.getCopyOfAllChampions();
                game.OurTeam.UpdateLane(ourLane);
                game.EnemyTeam.UpdateLane(enemylane);

                rotateBPDecision(game);

                TeammateRule teammateRule = new TeammateRule(game);
                teammateRule.Validate();

                UpdateChampionPoolWeightRule updateChampionPoolWeightRule = new UpdateChampionPoolWeightRule(game);
                updateChampionPoolWeightRule.Validate();

                RecommendRule recommendRule = new RecommendRule(game);
                recommendRule.Validate();

                game_t = Task.Run(BP);

                var jsonresponse = new JavaScriptSerializer().Serialize(game.instruction);
                return(jsonresponse);
            }
            else
            {
                msg = "Data has not been persisted yet.";
            }
            return(msg);
        }