示例#1
0
 public int Level()
 {
     using (db.Database dbx = new db.Database())
     {
         int id = dbx.GetGuildId(this.Guild);
         return dbx.GetGuildLevel(id);
     }
 }
示例#2
0
 public void HandleRequest(HttpListenerContext context) //struct: ignore             guid    password
                                                        //values: int                string  string
                                                        //        prollycurrentacc   email   passwordnocrypt
 {
     NameValueCollection query;
     using (StreamReader rdr = new StreamReader(context.Request.InputStream))
         query = HttpUtility.ParseQueryString(rdr.ReadToEnd());
     //down here goes the code to identify the guild by the account
     string guid = query["guid"];
     int guildid;
     using (db.Database dbx = new db.Database())
     {
         var cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT guild FROM accounts WHERE [email protected]";
         cmd.Parameters.AddWithValue("@guid", guid);
         guildid = int.Parse(cmd.ExecuteScalar().ToString());
     }
     //down here goes the code to retrieve the board text by guild
     string[] lines;
     try
     {
         using (db.Database dbz = new db.Database())
         {
             var cmd = dbz.CreateQuery();
             cmd.CommandText = "SELECT board FROM guilds WHERE [email protected]";
             cmd.Parameters.AddWithValue("@id", guildid);
             object scalar = cmd.ExecuteScalar();
             lines = scalar.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
         }
     }
     catch
     {
         lines = new string[]
         {
           "Couldn't retrieve guild board"  
         };
     }
     string boardtext = null;
     foreach (var i in lines)
     {
         if (boardtext != null)
         {
             boardtext = boardtext + i.ToString() + "\n\r";
         }
         else
         {
             boardtext = i.ToString() + "\n\r";
         }
     }
     //down here goes the code to eventually check the formatting
     byte[] guildboardtext = Encoding.ASCII.GetBytes(boardtext);
     context.Response.OutputStream.Write(guildboardtext, 0, guildboardtext.Length);
 }
示例#3
0
 public void HandleRequest(HttpListenerContext context)
 {
     NameValueCollection query;
     string board;
     using (StreamReader rdr = new StreamReader(context.Request.InputStream))
         query = HttpUtility.ParseQueryString(rdr.ReadToEnd());
     using (db.Database dbx = new db.Database())
     {
         var cmd = dbx.CreateQuery();
         cmd.CommandText = "UPDATE guilds SET [email protected] WHERE [email protected]";
         var acc = dbx.Verify(query["guid"], query["password"]);
         cmd.Parameters.AddWithValue("@id", acc.Guild.Id);
         board = HttpUtility.HtmlDecode(query["board"]);
         cmd.Parameters.AddWithValue("@board", board);
         cmd.ExecuteNonQuery();
     }
     board = null;
     using (db.Database dbz = new db.Database())
     {
         var cmd = dbz.CreateQuery();
         cmd.CommandText = "SELECT board FROM guilds WHERE [email protected]";
         cmd.Parameters.AddWithValue("@id", dbz.Verify(query["guid"], query["password"]).Guild.Id);
         object scalar = cmd.ExecuteScalar();
         string[] lines = scalar.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);
         foreach (var i in lines)
         {
             if (board != null)
             {
                 board = board + i.ToString() + "\n\r";
             }
             else
             {
                 board = i.ToString() + "\n\r";
             }
         }
     }
     //down here goes the code to eventually check the formatting
     byte[] guildboardtext = Encoding.ASCII.GetBytes(board);
     context.Response.OutputStream.Write(guildboardtext, 0, guildboardtext.Length);
 }
示例#4
0
 public override void Buy(Player player)
 {
     using (db.Database dbx = new db.Database())
     {
         if (dbx.GetGuild(dbx.GetGuildId(player.Guild)).GuildFame >= this.Price)
         {
             dbx.DetractGuildFame(dbx.GetGuildId(player.Guild), this.Price);
             dbx.ChangeGuildLevel(dbx.GetGuildId(player.Guild), nextLevel);
             player.Client.SendPacket(new svrPackets.BuyResultPacket()
             {
                 Message = "Upgrade successful! Please leave the Guild Hall to have it upgraded",
                 Result = 0
             });
         }
         else
             player.Client.SendPacket(new wServer.svrPackets.BuyResultPacket()
             {
                 Message = "Not enough Guild Fame!",
                 Result = 9
             });
     }
 }
示例#5
0
        public void EditAccountList(RealmTime time, EditAccountListPacket pkt)
        {
            List<int> list;
            if (pkt.AccountListId == LOCKED_LIST_ID)
                list = Locked;
            else if (pkt.AccountListId == IGNORED_LIST_ID)
                list = Ignored;
            else return;
            if (list == null)
                list = new List<int>();
            Player player = Owner.GetEntity(pkt.ObjectId) as Player;
            if (player == null) return;
            int accId = player.psr.Account.AccountId;
            db.Database dbx = new db.Database();
            //if (pkt.Add && list.Count < 6)
            //    list.Add(accId);
            //else
            //    list.Remove(accId);

            if (pkt.Add)
            {
                list.Add(accId);
                if (pkt.AccountListId == LOCKED_LIST_ID)
                    dbx.AddLock(psr.Account.AccountId, accId);
                if (pkt.AccountListId == IGNORED_LIST_ID)
                    dbx.AddIgnore(psr.Account.AccountId, accId);
            }
            else
            {
                list.Remove(accId);
                if (pkt.AccountListId == LOCKED_LIST_ID)
                    dbx.RemoveLock(psr.Account.AccountId, accId);
                if (pkt.AccountListId == IGNORED_LIST_ID)
                    dbx.RemoveIgnore(psr.Account.AccountId, accId);
            }

            SendAccountList(list, pkt.AccountListId);
        }
示例#6
0
 //values: int       int     int                 string  string
 //        members   0       prollycurrentacc    email   passwordnocrypt
 //response:
 //<Guild name="STRING" id="INT">
 //<TotalFame>INT</TotalFame>
 //<CurrentFame>INT</Currentfame>
 //<HallType>Guild Hall INT</HallType>
 //<Member>
 //<Name>STRING</Name>
 //<Rank>INT</Rank>
 //<Fame>INT</Fame>
 //</Member>
 //</Guild>
 public void HandleRequest(HttpListenerContext context)
 {
     NameValueCollection query;
     using (StreamReader rdr = new StreamReader(context.Request.InputStream))
         query = HttpUtility.ParseQueryString(rdr.ReadToEnd());
     XDocument doc;
     XElement guildd;
     using (db.Database dbx = new db.Database())
     {
         Account acc = dbx.Verify(query["guid"], query["password"]);
         guildd = new XElement("Guild", new XAttribute("name", acc.Guild.Name), new XAttribute("id", acc.Guild.Id));
         //get the hall level
         var cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT level FROM guilds WHERE [email protected]";
         cmd.Parameters.AddWithValue("@id", acc.Guild.Id);
         guildd.Add(new XElement("HallType", "Guild Hall "+cmd.ExecuteScalar().ToString()));
         //get the current fame
         cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT fame FROM guilds WHERE [email protected]";
         cmd.Parameters.AddWithValue("@id", acc.Guild.Id);
         guildd.Add(new XElement("CurrentFame", cmd.ExecuteScalar().ToString()));
         //get the total fame
         cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT totalFame FROM guilds WHERE [email protected]";
         cmd.Parameters.AddWithValue("@id", acc.Guild.Id);
         guildd.Add(new XElement("TotalFame", cmd.ExecuteScalar().ToString()));
         //get the members list and data
         cmd = dbx.CreateQuery();
         cmd.CommandText = "SELECT members FROM guilds WHERE [email protected]";
         cmd.Parameters.AddWithValue("@id", acc.Guild.Id);
         string[] membersids = cmd.ExecuteScalar().ToString().Split(',');
         foreach (var memberid in membersids)
         {
             var accc = dbx.GetAccount(int.Parse(memberid));
             guildd.Add(new XElement("Member",
                 new XElement("Name", accc.Name),
                 new XElement("Rank", accc.Guild.Rank),
                 new XElement("Fame", 0)));
         }
         doc = new XDocument(guildd);
     }
     byte[] bytes = Encoding.ASCII.GetBytes(doc.ToString());
     context.Response.OutputStream.Write(bytes, 0, bytes.Length);
 }