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(); }
public ActionResult CreateGame(List<String> ListBox, String player0, String player1, String player2, String player3, String player4, String player5, String player6) { if (!WebSecurity.IsAuthenticated) return RedirectToAction("ErrorPage", new { ErrorMessage = "You must be logged in to create a game" }); string CurrentUserMail = GetUserEmail(WebSecurity.CurrentUserName); RequestHandler rh = new RequestHandler(); rh.RegisterUserAsync(CurrentUserMail, false); List<string> listOfUsers = new List<string>(); listOfUsers.Add(CurrentUserMail); if (ListBox != null) { foreach (var item in ListBox) { string uMail = GetUserEmail(item); rh.RegisterUserAsync(uMail, false); if (!listOfUsers.Contains(uMail)) listOfUsers.Add(uMail); } } String[] paramHolder = new String[7] { player0, player1, player2, player3, player4, player5, player6 }; foreach (var item in paramHolder) { if (item != "") { if (IsEmailRegistered(item)) { rh.RegisterUserAsync(item, false); } else { rh.RegisterUserAsync(item, true); } if (!listOfUsers.Contains(item)) listOfUsers.Add(item); } } UsersContext ctxu = new UsersContext(); var qu = from users in ctxu.UserProfiles select users; List<string> UserList = qu.Select(u => u.UserName).ToList(); ViewBag.testList = UserList; if (listOfUsers.Count > 8 || listOfUsers.Count == 0) { ViewBag.Error = true; ViewBag.ErrorMessage = "You can not add more than 7 players"; return View(); } //If we get here we can create the game rh.CreateGameAsync(listOfUsers); return RedirectToAction("Index"); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.UserName, model.Password); WebSecurity.Login(model.UserName, model.Password); using (UsersContext ctx = new UsersContext()) { ctx.UserProfiles.First(x => x.UserName == model.UserName).UserEMail = model.EMail; ctx.SaveChanges(); } RequestHandler rh = new RequestHandler(); rh.RegisterUserAsync(model.EMail, false); return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }