diff --git a/Account.cs b/Account.cs index e6f1432..b6e4af5 100644 --- a/Account.cs +++ b/Account.cs @@ -63,7 +63,7 @@ public class Account } } rdr.Close(); - sql = "select username,name,level,race,class from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.account=@id"; + sql = "select guid,username,name,level,race,class from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.account=@id"; cmd = new MySqlCommand(sql, conn); cmd.Parameters.AddWithValue("id", this.Id); rdr = cmd.ExecuteReader(); @@ -73,11 +73,12 @@ public class Account try { Character c = new Character(); - c.Username = rdr.GetString(0); - c.Name = rdr.GetString(1); - c.Level = rdr.GetByte(2); - c.Race = rdr.GetByte(3); - c.Class = rdr.GetByte(4); + c.guid = (int)rdr.GetUInt32(0); + c.Username = rdr.GetString(1); + c.Name = rdr.GetString(2); + c.Level = rdr.GetByte(3); + c.Race = rdr.GetByte(4); + c.Class = rdr.GetByte(5); this.Characters.Add(c); } catch (Exception e) diff --git a/Character.cs b/Character.cs index 3afc49b..9d1d5fb 100644 --- a/Character.cs +++ b/Character.cs @@ -1,13 +1,21 @@ -public class Character +using System; +using MySql.Data.MySqlClient; + +namespace NightmareCoreWeb2 { - //select username,name,level,race,class from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.online = 1; - public string Username { get; set; } - public string Name { get; set; } - public int Level { get; set; } - public int Race { get; set; } - public int Class { get; set; } - public string[] classes = { + public class Character + { + //select username,name,level,race,class from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.online = 1; + public int guid { get; set; } + public string Username { get; set; } + public string Name { get; set; } + public int Level { get; set; } + public int Race { get; set; } + public int Class { get; set; } + public AtLoginOptions AtLogin { get; set; } + + public string[] classes = { "Null", "Warrior", "Paladin", @@ -22,7 +30,7 @@ public class Character "Druid", "Demon Hunter" }; - public string[] races = { + public string[] races = { "Null", "Human", "Orc", @@ -36,12 +44,65 @@ public class Character "Blood Elf", "Draenei" }; - public string GetClass() - { - return classes[this.Class]; - } - public string GetRace() - { - return races[this.Race]; + [Flags] + public enum AtLoginOptions + { + AT_LOGIN_RENAME = 1, + AT_LOGIN_RESET_SPELLS = 2, + AT_LOGIN_RESET_TALENTS = 4, + AT_LOGIN_CUSTOMIZE = 8, + AT_LOGIN_RESET_PET_TALENTS = 16, + AT_LOGIN_FIRST = 32, + AT_LOGIN_CHANGE_FACTION = 64, + AT_LOGIN_CHANGE_RACE = 128 + } + public string GetClass() + { + return classes[this.Class]; + } + public string GetRace() + { + return races[this.Race]; + } + + public Character() { } + public Character(int guid, MySqlConnection conn) + { + conn.Open(); + + string sql = "select username,name,level,race,class,at_login from characters.characters join auth.account on characters.characters.account = auth.account.id where characters.characters.guid=@id"; + MySqlCommand cmd = new MySqlCommand(sql, conn); + cmd.Parameters.AddWithValue("id", guid); + MySqlDataReader rdr = cmd.ExecuteReader(); + while (rdr.Read()) + { + try + { + this.guid = guid; + this.Username = rdr.GetString(0); + this.Name = rdr.GetString(1); + this.Level = rdr.GetByte(2); + this.Race = rdr.GetByte(3); + this.Class = rdr.GetByte(4); + this.AtLogin = (AtLoginOptions)rdr.GetUInt16(5); + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + rdr.Close(); + conn.Close(); + } + + public void SetAtLogin(MySqlConnection conn) { + conn.Open(); + string sql = "update characters.characters set at_login=@loginOpts where guid=@guid"; + MySqlCommand cmd = new MySqlCommand(sql, conn); + cmd.Parameters.AddWithValue("guid", this.guid); + cmd.Parameters.AddWithValue("loginOpts", (int)this.AtLogin); + cmd.ExecuteNonQuery(); + conn.Close(); + } } } \ No newline at end of file diff --git a/Pages/Account.cshtml b/Pages/Account.cshtml index 5646e31..7dfbfb8 100644 --- a/Pages/Account.cshtml +++ b/Pages/Account.cshtml @@ -73,7 +73,10 @@
@character.Name
-

Card action buttons could go here!

+ Rename Character + Recustomize Character + Change Faction + Change Race