Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            RequestHandler rh = new RequestHandler();
            Console.WriteLine("Adding user");

            string guid = Guid.NewGuid().ToString("N");
            string s = String.Format("Hi, \n You can play the game at:\n http://89.147.71.220/Monopoly/Home/ViewAnonymGame?UId={0}\n" +
                                    "Cheers,\nOnline Monopoly Team", guid);
            Console.WriteLine(s);

            //rh.ShutdownService(); return;
            List<string> emails = new List<string>() { @"*****@*****.**", @"*****@*****.**"};
            Task t0 = rh.RegisterUserAsync(emails[0], true);
            Task t1 = rh.RegisterUserAsync(emails[1], true);
            t0.Wait();
            t1.Wait();
            Console.WriteLine("Users added");
            rh.CreateGameAsync(emails);
            Console.WriteLine("Started creating game, waiting ...");
            int id = 1;
            Console.WriteLine("Game created with id " + id);
            rh.AcceptAsync(emails[0], id);
            Console.WriteLine("can start? " + rh.CanStart(id));
            rh.AcceptAsync(emails[1], id);
            Console.WriteLine("can start? " + rh.CanStart(id));
            rh.StartGameAsync(id);
            Console.WriteLine("starting  ... " );
            List<Move> moves = rh.GetPossibilites(emails[0], id);
            Console.WriteLine("--- Moves");
            foreach (Move m in moves)
            {
                Console.WriteLine(m.Description);
            }

            Console.WriteLine("---");
            Console.WriteLine("Making move .. {0}", moves[0].Type);
            rh.MakeMoveAsync(moves[0].Id, "");
            moves = rh.GetPossibilites(emails[0], id);
            Console.WriteLine("--- Moves");
            foreach (Move m in moves)
            {
                Console.WriteLine("{0} : {1}",m.Description, m.Param);
            }
            Console.WriteLine("---");
            Console.WriteLine("Making move .. {0}", moves[0].Type);
            rh.MakeMoveAsync(moves[0].Id, "");
            moves = rh.GetPossibilites(emails[0], id);
            Console.WriteLine("--- Moves");
            foreach (Move m in moves)
            {
                Console.WriteLine("{0} : {1}", m.Description, m.Param);
            }
            Console.WriteLine("---");
            UIGame game = rh.GetUIGameState(emails[0], id);
            Console.WriteLine("Actmoney {0}", game.ActUserMoney);
            Console.WriteLine(game.GameState.ToString());
            Console.WriteLine(Enum.GetName(typeof(UIGame.UIGameStatus), game.GameState));
            rh.ShutdownService();
        }
Ejemplo n.º 2
0
 public ActionResult MakeMove(int move, string movementParam, int gameId, string optionalInput = "", string UId = "")
 {
     RequestHandler rh = new RequestHandler();
     if (UId != "")
     {
         string userEmail = rh.VerifyUniqueID(UId);
         if (userEmail == null) return RedirectToAction("ErrorPage", new { ErrorMessage = "You have provided an invalid UId" });
         //if (gi.GameId != gameId) return RedirectToAction("ErrorPage", new { ErrorMessage = "You are not eligible to make a move in the given game." });
     }
     else
     {
         if (!WebSecurity.IsAuthenticated) return RedirectToAction("ErrorPage", new { ErrorMessage = "You are not logged in and neither have provided a UID" });
     }
     string param = movementParam;
     int index = optionalInput.IndexOf('\r') == -1 ? optionalInput.Length : optionalInput.IndexOf('\r');
     if (optionalInput != "") param = optionalInput.Substring(0, index) + ";" + param;
     rh.MakeMoveAsync(move, movementParam);
     return RedirectToAction("ViewBoard", new { gameId = gameId, UId = UId });
 }