/// <summary> /// </summary> /// <param name="charid"> /// </param> public void DeleteChar(int charid) { var ms = new SqlWrapper(); try { /* delete char */ /* i assume there should be somewhere a flag, caus FC can reenable a deleted char.. */ string sqlQuery = "DELETE FROM `characters` WHERE ID = " + charid; ms.SqlDelete(sqlQuery); StatDao.DeleteStats(50000, charid); sqlQuery = "DELETE FROM `organizations` WHERE ID = " + charid; ms.SqlDelete(sqlQuery); sqlQuery = "DELETE FROM `inventory` WHERE ID = " + charid; ms.SqlDelete(sqlQuery); } catch (Exception e) { Console.WriteLine(this.Name + e.Message); } }
/// <summary> /// </summary> /// <returns> /// </returns> private int CreateNewChar() { int charID = 0; switch (this.Breed) { case 0x1: /* solitus */ this.Abis = new[] { 6, 6, 6, 6, 6, 6 }; break; case 0x2: /* opifex */ this.Abis = new[] { 3, 3, 10, 6, 6, 15 }; break; case 0x3: /* nanomage */ this.Abis = new[] { 3, 10, 6, 15, 3, 3 }; break; case 0x4: /* atrox */ this.Abis = new[] { 15, 3, 3, 3, 10, 6 }; break; default: Console.WriteLine("unknown breed: ", this.Breed); break; } /* * Note, all default values are not specified here as defaults are handled * in the CharacterStats Class for us automatically. Also minimises SQL * usage for default stats that are never changed from their default value * ~NV */ // Delete orphaned stats for charID StatDao.DeleteStats(50000, charID); try { CharacterDao.AddCharacter( new DBCharacter { FirstName = string.Empty, LastName = string.Empty, Name = this.Name, Username = this.AccountName, }); } catch (Exception e) { LogUtil.ErrorException(e); return(0); } try { /* select new char id */ charID = CharacterDao.GetByCharName(this.Name).Id; } catch (Exception e) { LogUtil.ErrorException(e); return(0); } List <DBStats> stats = new List <DBStats>(); // Transmit GM level into stats table stats.Add( new DBStats { type = 50000, instance = charID, statid = 215, statvalue = LoginDataDao.GetByUsername(this.AccountName).GM }); // Flags stats.Add(new DBStats { type = 50000, instance = charID, statid = 0, statvalue = 20 }); // Level stats.Add(new DBStats { type = 50000, instance = charID, statid = 54, statvalue = 1 }); // SEXXX stats.Add(new DBStats { type = 50000, instance = charID, statid = 59, statvalue = this.Gender }); // Headmesh stats.Add(new DBStats { type = 50000, instance = charID, statid = 64, statvalue = this.HeadMesh }); // MonsterScale stats.Add(new DBStats { type = 50000, instance = charID, statid = 360, statvalue = this.MonsterScale }); // Visual Sex (even better ^^) stats.Add(new DBStats { type = 50000, instance = charID, statid = 369, statvalue = this.Gender }); // Breed stats.Add(new DBStats { type = 50000, instance = charID, statid = 4, statvalue = this.Breed }); // Visual Breed stats.Add(new DBStats { type = 50000, instance = charID, statid = 367, statvalue = this.Breed }); // Profession / 60 stats.Add(new DBStats { type = 50000, instance = charID, statid = 60, statvalue = this.Profession }); // VisualProfession / 368 stats.Add(new DBStats { type = 50000, instance = charID, statid = 368, statvalue = this.Profession }); // Fatness / 47 stats.Add(new DBStats { type = 50000, instance = charID, statid = 47, statvalue = this.Fatness }); // Strength / 16 stats.Add(new DBStats { type = 50000, instance = charID, statid = 16, statvalue = this.Abis[0] }); // Psychic / 21 stats.Add(new DBStats { type = 50000, instance = charID, statid = 21, statvalue = this.Abis[1] }); // Sense / 20 stats.Add(new DBStats { type = 50000, instance = charID, statid = 20, statvalue = this.Abis[2] }); // Intelligence / 19 stats.Add(new DBStats { type = 50000, instance = charID, statid = 19, statvalue = this.Abis[3] }); // Stamina / 18 stats.Add(new DBStats { type = 50000, instance = charID, statid = 18, statvalue = this.Abis[4] }); // Agility / 17 stats.Add(new DBStats { type = 50000, instance = charID, statid = 17, statvalue = this.Abis[5] }); // Set HP and NP auf 1 stats.Add(new DBStats { type = 50000, instance = charID, statid = 1, statvalue = 1 }); stats.Add(new DBStats { type = 50000, instance = charID, statid = 214, statvalue = 1 }); stats.Add( new DBStats { type = 50000, instance = charID, statid = 389, statvalue = LoginDataDao.GetByUsername(this.AccountName).Expansions }); StatDao.BulkReplace(stats); return(charID); }