Esempio n. 1
0
 public HttpResponseMessage FightPVP([FromUri]string login)
 {
     AzureQueue queue = new AzureQueue();
     string resultmsg = "33";
     resultmsg = queue.ViewMsg(login, false);
     if (resultmsg.Substring(0, 3) == "173" || resultmsg.Substring(0, 3) == "172" || resultmsg.Substring(0, 2) == "34")
         resultmsg = "03";
     else
     {
         string[] words = resultmsg.Split(new Char[] { '&' });
         resultmsg = String.Format("{0}{1} vs {2}NL{3}", words[2].Substring(0, 2), words[0], words[1], words[2].Substring(2));
     }
     string xml = string.Format("{0}", resultmsg);
     HttpResponseMessage response = Request.CreateResponse();
     response.Content = new StringContent(xml, System.Text.Encoding.UTF8, "text/plain");
     return response;
 }
Esempio n. 2
0
 public HttpResponseMessage FightPVP([FromUri]string login, [FromUri]double a, [FromUri]double b, [FromUri]double c)
 {
     AzureQueue queue = new AzureQueue();
     if (queue.PeekMsg(true))
     {
         bool result;
         string resultmsg = "33", resultopmsg = "33";
         CloudQueueMessage opponent = queue.deQueueMsg(true);
         string[] words = opponent.AsString.Split(new Char[] { ' ' });
         int enemyA = Int32.Parse(words[1]);
         int enemyB = Int32.Parse(words[2]);
         int enemyC = Int32.Parse(words[3]);
         Gladiator player = new Gladiator(a, b, c);
         Gladiator enemy = new Gladiator(enemyA, enemyB, enemyC);
         result = player.battle(enemy);
         azureTable user = new azureTable();
         if (result)
         {
             resultmsg = "01" + login + " vs " + words[0] + "NL" + player.GetLog(true);// victory
             resultopmsg = "00" + player.GetLog(false);
         }
         else
         {
             resultmsg = "00" + login + " vs " + words[0] + "NL" + player.GetLog(true);// defeat
             resultopmsg = "01" + player.GetLog(false);
         }
         user.UpdateLvl(login, result);
         user.UpdateLvl(words[0], !result);
         queue.AddMsgQ(String.Format("{0}&{1}&{2}", words[0], login, resultopmsg), false);
         string xml = string.Format("{0}", resultmsg);
         HttpResponseMessage response = Request.CreateResponse();
         response.Content = new StringContent(xml, System.Text.Encoding.UTF8, "text/plain");
         return response;
     }
     else
     {
         queue.AddMsgQ(String.Format("{0} {1} {2} {3}", login, a, b, c), true);
         string xml = string.Format("03");//Looking for opponents
         HttpResponseMessage response = Request.CreateResponse();
         response.Content = new StringContent(xml, System.Text.Encoding.UTF8, "text/plain");
         return response;
     }
 }