public HttpResponseMessage Signup([FromUri]string login, [FromUri]string password) { string resultmsg = "33"; //TODO: Connecto DB and complete sign up procedure // Проверить наличие такого логина // Выслать мейл // Записать в базу новый пароль // Выслать ответ в приложение azureTable user = new azureTable(); resultmsg = user.InsertEntity(login, password); HttpResponseMessage response = Request.CreateResponse(); response.Content = new StringContent(resultmsg, System.Text.Encoding.UTF8, "text/plain"); return response; }
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; } }
public HttpResponseMessage Login([FromUri]string login, [FromUri]string password) { string resultmsg = "33"; azureTable user = new azureTable(); resultmsg = user.AuthenticateUser(login, password); HttpResponseMessage response = Request.CreateResponse(); response.Content = new StringContent(resultmsg, System.Text.Encoding.UTF8, "text/plain"); return response; }
public HttpResponseMessage Fight([FromUri]string login, [FromUri]double a, [FromUri]double b, [FromUri]double c, [FromUri]int d) { Gladiator enemy = new Gladiator(d); Gladiator player = new Gladiator(a, b, c); bool result; string resultmsg = "33"; result = player.battle(enemy); azureTable user = new azureTable(); if (result) { resultmsg = "01" + player.GetLog(true);// victory } else resultmsg = "00" + player.GetLog(true);// defeat user.UpdateLvl(login, result); string xml = string.Format("{0}", resultmsg); HttpResponseMessage response = Request.CreateResponse(); response.Content = new StringContent(xml, System.Text.Encoding.UTF8, "text/plain"); return response; }