Ejemplo n.º 1
0
 public override void DoWork(IEnumerable<string> args)
 {
     if (Utils.CheckArgs(ArgsNeed, args.Count()))
     {
         if (Utils.IsInGame())
         {
             var request = new SurrenderRequest {From = CurrentUser.Name, GameID = CurrentUser.CurrentGame.Value};
             var response = ServerProvider.MakeRequest<ChatResponse>(request);
             if (response.Status != Statuses.Ok)
             {
                 Console.WriteLine("Bad status.");
             }
             else
             {
                 Console.WriteLine("You surrendered.");
                 CurrentUser.CurrentGame = null;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public ActionResult SurrenderRequest(string gameId)
 {
     var request = new SurrenderRequest {From = User.Identity.Name};
     try
     {
         request.GameID = Int32.Parse(gameId);
     }
     catch (Exception)
     {
         request.GameID = 0;
     }
     var response = ServerProvider.MakeRequest<SurrenderResponse>(request);
     string ret;
     switch (response.Status)
     {
         case Statuses.Ok:
             ret = "";
             break;
         default:
             ret = "Wrong status.";
             break;
     }
     return Json(ret, JsonRequestBehavior.AllowGet);
 }