Пример #1
0
        // GET: Game/Details/5
        public ActionResult Details(long id)
        {
            var user       = _manager.GetUserAsync(HttpContext.User).Result;
            var friendlyID = user?.FriendlyUserId;

            ViewData["UserId"]       = friendlyID ?? -1;
            ViewData["access_token"] = "";

            var api = new API.Controllers.GameController(_conn);

            var respGame = api.GetSingleGame(id);
            var gameOr   = (ObjectResult)(respGame.GetType() == typeof(NoContentResult) ? new ObjectResult(new Game()) : respGame);

            var respHand = api.GetGameHand(id);
            var hand     = (ObjectResult)(respHand.GetType() == typeof(NoContentResult) ? new ObjectResult(new DiceHand()) : respHand);

            var game = (Game)gameOr.Value;

            //get today's value
            var shakeValueResp = api.GetSpecificShakeValue(game.Year, game.Day);
            var shakeValue     = (ObjectResult)(shakeValueResp.GetType() == typeof(NoContentResult) ? new ObjectResult(-1) : shakeValueResp);

            var gameHand = new GameHand(game, (DiceHand)hand.Value, (int)shakeValue.Value);

            return(View(gameHand));
        }
Пример #2
0
        private string GenerateConclusion(GameHand player1, GameHand player2)
        {
            string Conclusion = "";
            if (player1 == player2) Conclusion += "Conclusion: Tie! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
            else
            {
                if (player1 == (GameHand)0 && player2 == (GameHand)2) Conclusion += "Conclusion: Player1 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else if (player1 == (GameHand)0 && player2 == (GameHand)1) Conclusion += "Conclusion: Player2 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else if (player1 == (GameHand)1 && player2 == (GameHand)2) Conclusion += "Conclusion: Player2 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else if (player1 == (GameHand)1 && player2 == (GameHand)0) Conclusion += "Conclusion: Player1 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else if (player1 == (GameHand)2 && player2 == (GameHand)1) Conclusion += "Conclusion: Player1 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else if (player1 == (GameHand)2 && player2 == (GameHand)0) Conclusion += "Conclusion: Player2 Wins! - player1:" + player1.ToString() + " vs. player2:" + player2.ToString();
                else { Conclusion += "Something went wrong"; Console.WriteLine("somewthing went wrong in Conclusion"); }


            }
            Game_in_session = false;
            return Conclusion;
        }