internal Character CreateNewCharacter(CharacterCreatePacket characterCreatePacket, string accountUsername) { AccountDAO accMgr = new AccountDAO(Server.ServerInstance.Database); int accountID = accMgr.GetAccountID(accountUsername); if (GetCharactersByAccount(accountID).Length >= 4) // Se necessario, possiamo creare due classi che ereditano da Exception per queste due eccezioni invece di usare SqlAlreadyFilledException. throw new SqlAlreadyFilledException( "This account already have four characters. Is not allowed another character."); if (GetCharacter(characterCreatePacket.CharacterName) != null) throw new SqlAlreadyFilledException("A character with this name already exists!"); MySqlDataReader writer = // OK LOL!!! _conn.Query( string.Format("INSERT INTO `character` (`name`, `race`, `account_id`) VALUES ('{0}', {1}, {2})", characterCreatePacket.CharacterName, characterCreatePacket.SexRace, accountID)); // TODO: Add CharacterPosition (account-relative) & Look to character table. // TODO: Set all values for the record and so call GetCharacter(uint) to get a Character's instance and return... writer.Close(); return null; }
internal static Character Create(string accountName, CharacterCreatePacket characterCreatePacket) { CharacterDAO chrMgr = new CharacterDAO(Server.ServerInstance.Database); return chrMgr.CreateNewCharacter(characterCreatePacket, accountName); // Cosa fare con OnCreate()? }