//public ActionResult Hint([Bind(Include = "moves,winner")]string moves, string winner)
        //{
        //    HintModel hints = new HintModel();

        //    hints.currMoves = moves;

        //    hints.winner = winner;

        //    using (var context = new ChessAtomicCrawlingContext())
        //    {
        //        GameStatus res = string.Equals(winner, "white") ? GameStatus.WhiteVictorious : GameStatus.BlackVictorious;

        //        var games = from b in context.AtomicGameInfo
        //                    where b.status == res && b.moves.StartsWith(moves)
        //                    select b;

        //        string nextMove = string.Empty;

        //        int startIndex = moves.Length;

        //        foreach (var g in games)
        //        {
        //            if (g.moves.Length >= startIndex + 4)
        //            {
        //                nextMove = g.moves.Substring(startIndex, 4);

        //                if (hints.hints.ContainsKey(nextMove)) ++hints.hints[nextMove];
        //                else hints.hints.Add(nextMove, 1);
        //            }
        //        }
        //    }


        //    return View("~/Views/GameMoves/Hints.cshtml", hints);
        //}

        public ActionResult HintOld([Bind(Include = "moves,winner")] string moves, string winner)
        {
            HintModel hints = HintsEngine.Instance.FindHints(moves, winner);


            return(View("~/Views/GameMoves/Hintsold.cshtml", hints));
        }
        private void CreateHintController(HintModel hintModel)
        {
            var hintController = Instantiate(Hint3DControllerPrefab, transform);

            hintController.HintModel = hintModel;

            _hintControllers.Add(hintModel.ID, hintController);
        }
 private static void FillHintProperties(HintModel hint, uint id, uint taskID, uint stepID, string name, Vector3 position, Quaternion rotation, Vector3 scale)
 {
     hint.ID            = id;
     hint.TaskID        = taskID;
     hint.StepID        = stepID;
     hint.Name          = name;
     hint.LocalPosition = position;
     hint.LocalRotation = rotation;
     hint.LocalScale    = scale;
 }
        private void CreateHintController(HintModel hintModel)
        {
            // Instantiate hint controller:
            var hintController = Instantiate(HintControllerPrefab, HintControllersContainer);

            hintController.HintPanelItemViewsContainer = HintPanelItemViewsContainer;
            hintController.HintModel = hintModel;
            hintController.Showing   = Showing;
            hintController.OnEdit   += HintController_OnEdit;

            // Add to collection:
            _hints.Add(hintModel.ID, hintController);

            UpdatePanelSize();
        }
        public static void AssertHintsAreEqual(HintModel expected, HintModel actual, uint expectedTaskID, uint expectedStepID)
        {
            Assert.AreEqual(expected.Type, actual.Type);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expectedTaskID, actual.TaskID);
            Assert.AreEqual(expectedStepID, actual.StepID);
            UnityEngine.Assertions.Assert.AreEqual(expected.LocalPosition, actual.LocalPosition);
            UnityEngine.Assertions.Assert.AreEqual(expected.LocalRotation, actual.LocalRotation);
            UnityEngine.Assertions.Assert.AreEqual(expected.LocalScale, actual.LocalScale);

            if (expected.Type == HintType.Image)
            {
                Assert.AreEqual(((ImageHintModel)expected).ImageHintType, ((ImageHintModel)actual).ImageHintType);
            }
        }
        public void WhenRadioHintInvoked_TheViewModelIsUpdated(string key, string value)
        {
            var values = new Dictionary <string, string>()
            {
            };

            var component = new RadioHint();

            component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext();

            ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult;
            HintModel resultModel          = (HintModel)result.ViewData.Model;

            //Assert
            value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key));
        }
Пример #7
0
        public async Task <ApiResponse> GiveHint(
            [FromRoute] string code,
            [FromBody] HintModel hintModel)
        {
            (var game, var localPlayer) = await GetGameAndLocalPlayer(code);

            if (game.CanGiveHint(localPlayer).IsFailure(out string message))
            {
                return(BadRequest(message));
            }

            game.GiveHint(localPlayer, hintModel.HintWord, hintModel.WordCount);

            await _gameUpdater.UpdateGame(game);

            return(Accepted("Hint submitted."));
        }
Пример #8
0
        /// <summary>
        /// 初始化提示
        /// </summary>
        private void InitHint()
        {
            XDocument xDoc  = XDocument.Load("Config/hint.xml");
            XElement  xRoot = xDoc.Element("Root");

            foreach (var xHint in xRoot.Elements("Hint"))
            {
                HintModel hintModel = new HintModel();
                hintModel.Id      = int.Parse(xHint.Attribute("id").Value);
                hintModel.Content = xHint.Attribute("content").Value;
                String isHint = xHint.Attribute("isHint").Value;
                if (isHint.Equals("true"))
                {
                    hintModel.IsHint = true;
                }
                else
                {
                    hintModel.IsHint = false;
                }
                view.hintModelDictionary.Add(hintModel.Id, hintModel);
            }
        }
Пример #9
0
 public void Active(HintModel hint)
 {
     gameObject.SetActive(true);
     hintInfo.text = hint.HintInfo;
     hint.Result();
 }
Пример #10
0
 public void AddHints(HintModel hint)
 {
     hintWindow.Active(hint);
 }
Пример #11
0
 public Task <ApiResponse> GiveCurrentGameHint(
     [FromBody] HintModel hintModel)
 => GiveHint(User.GetGameCode(), hintModel);