public static PCOusterInfo GetPCOusterInfo(string pcname) { PCOusterInfo result = new PCOusterInfo(); //build query string string cmdstr = String.Format(@"SELECT * FROM Ouster WHERE Name = '{0}'", pcname); //execute query MySqlCommand cmd = new MySqlCommand(cmdstr, mysqlconn); MySqlDataReader datareader = cmd.ExecuteReader(); //read data if (datareader.HasRows) { datareader.Read(); // name result.Name = datareader.GetString((int)TOuster.Name); // alignment result.Alignment = datareader.GetInt32((int)TOuster.Alignment); // colors result.CoatColor = datareader.GetUInt16((int)TOuster.CoatColor); result.HairColor = datareader.GetUInt16((int)TOuster.HairColor); result.ArmColor = datareader.GetUInt16((int)TOuster.ArmColor); result.BootsColor = datareader.GetUInt16((int)TOuster.BootsColor); // coat type & arm type result.CoatType = (OusterCoatType)Enum.Parse(typeof(OusterCoatType), datareader.GetString((int)TOuster.CoatType)); result.ArmType = (OusterArmType)Enum.Parse(typeof(OusterArmType), datareader.GetString((int)TOuster.ArmType)); // rank result.Rank = datareader.GetByte((int)TOuster.Rank); // level result.Level = datareader.GetByte((int)TOuster.Level); // str dex & int result.STR = datareader.GetUInt16((int)TOuster.STR); result.DEX = datareader.GetUInt16((int)TOuster.DEX); result.INT = datareader.GetUInt16((int)TOuster.INT); // hp maxhp mp & maxmp result.HP = datareader.GetUInt16((int)TOuster.HP); result.MaxHP = datareader.GetUInt16((int)TOuster.MaxHP); result.MP = datareader.GetUInt16((int)TOuster.MP); result.MaxMP = datareader.GetUInt16((int)TOuster.MaxMP); // exp result.Exp = datareader.GetUInt32((int)TOuster.EXP); // fame result.Fame = datareader.GetUInt32((int)TOuster.Fame); // bonus & skillbonus result.Bonus = datareader.GetUInt16((int)TOuster.Bonus); result.SkillBonus = datareader.GetUInt16((int)TOuster.SkillBonus); // advancementlevel result.AdvancementLevel = datareader.GetByte((int)TOuster.AdvancementLevel); } else { result = null; }; datareader.Close(); //return result return(result); }
public static PCInfo[] GetPCInfoList(string userid) { PCInfo[] result = new PCInfo[3]; // build query string string cmdstr = String.Format(@"SELECT SLOT1, SLOT2, SLOT3 FROM Player WHERE UserID = '{0}'", userid); // execute query MySqlCommand cmd = new MySqlCommand(cmdstr, mysqlconn); MySqlDataReader datareader = cmd.ExecuteReader(); // read data if (datareader.HasRows) { datareader.Read(); string name1 = null; string name2 = null; string name3 = null; if (!datareader.IsDBNull(0)) { name1 = datareader.GetString(0); } if (!datareader.IsDBNull(1)) { name2 = datareader.GetString(1); } if (!datareader.IsDBNull(2)) { name3 = datareader.GetString(2); } datareader.Close(); if (name1 != null) { PCType pctype = GetPCType(name1); if (pctype == PCType.SLAYER) { PCSlayerInfo pc = GetPCSlayerInfo(name1); pc.Slot = Slot.SLOT1; result[0] = pc; } else if (pctype == PCType.VAMPIRE) { PCVampireInfo pc = GetPCVampireInfo(name1); pc.Slot = Slot.SLOT1; result[0] = pc; } else if (pctype == PCType.OUSTER) { PCOusterInfo pc = GetPCOusterInfo(name1); pc.Slot = Slot.SLOT1; result[0] = pc; } } if (name2 != null) { PCType pctype = GetPCType(name2); if (pctype == PCType.SLAYER) { PCSlayerInfo pc = GetPCSlayerInfo(name2); pc.Slot = Slot.SLOT2; result[1] = pc; } else if (pctype == PCType.VAMPIRE) { PCVampireInfo pc = GetPCVampireInfo(name2); pc.Slot = Slot.SLOT2; result[1] = pc; } else if (pctype == PCType.OUSTER) { PCOusterInfo pc = GetPCOusterInfo(name2); pc.Slot = Slot.SLOT2; result[1] = pc; } } if (name3 != null) { PCType pctype = GetPCType(name3); if (pctype == PCType.SLAYER) { PCSlayerInfo pc = GetPCSlayerInfo(name3); pc.Slot = Slot.SLOT3; result[2] = pc; } else if (pctype == PCType.VAMPIRE) { PCVampireInfo pc = GetPCVampireInfo(name3); pc.Slot = Slot.SLOT3; result[2] = pc; } else if (pctype == PCType.OUSTER) { PCOusterInfo pc = GetPCOusterInfo(name3); pc.Slot = Slot.SLOT3; result[2] = pc; } } } // return result return(result); }