public ItemWrapper(string tmpType) { type = tmpType; if (tmpType == "Weapon") { bLogger = new BasicLogger(_WLog); } else if (tmpType == "Potion") { bLogger = new BasicLogger(_PLog); } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } reload(); }
/// <summary> /// Creates the wrapper for the specified type. Current valid types are: /// /// "Entity" /// "Player Entity" /// "Generated Entity" /// "Entity Template" /// /// </summary> /// <param name="tmpType"></param> public EntityTemplateWrapper(string tmpType) { this._EntityEncrypter = new EncrypterDecrypter(); this._EntityEncrypter.setKey(this._key); if (tmpType == "Entity Template") { this.bLogger = new BasicLogger(this._ETLog); this._ActivePath = this._ETPath; string encryptedEntities = this._EntityEncrypter.decryptFile(this._ETPath); if (encryptedEntities.Length > 0) { int TotalEntries = ParseItems.parseIntFrom(encryptedEntities, 4); encryptedEntities = encryptedEntities.Substring(4); int i = 0; while (i < TotalEntries) { int lengthOfEntity = ParseItems.parseIntFrom(encryptedEntities, 3); encryptedEntities = encryptedEntities.Substring(3); this.bLogger.Log("Attempting to decrypt: " + encryptedEntities.Substring(0, lengthOfEntity), debug); EntityTemplate newEntity = new EntityTemplate(encryptedEntities.Substring(0, lengthOfEntity)); encryptedEntities = encryptedEntities.Substring(lengthOfEntity); this._listOfEntities.Add(newEntity); this._usedIDs.Add(newEntity.id); i++; } } } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }
public override void reload() { if (type == "Weapon") { OdbcCommand WeaponQuery = new OdbcCommand("select * from Weapon", dbConnection); dbConnection.ConnectionString = connectionString; dbConnection.Open(); OdbcDataReader reader = WeaponQuery.ExecuteReader(); while (reader.Read()) { int WeaponID = (int)reader[0]; string WeaponName = reader[1].ToString(); string tmpCanBuy = reader[2].ToString(); bool WeaponCanBuy; if (tmpCanBuy == "False") { WeaponCanBuy = false; } else { WeaponCanBuy = true; } int WeaponValue = (int)reader[3]; int WeaponPower = (int)reader[4]; int WeaponMagiPower = (int)reader[5]; List<int> WeaponEffects = new List<int>(); List<int> WeaponClasses = new List<int>(); OdbcCommand WeaponEffectsQuery = new OdbcCommand("select EffectID from WeaponEffects where WeaponID = " + WeaponID, dbConnection); OdbcDataReader WeaponEffectReader = WeaponEffectsQuery.ExecuteReader(); while (WeaponEffectReader.Read()) { WeaponEffects.Add((int)WeaponEffectReader[0]); } OdbcCommand WeaponClassesQuery = new OdbcCommand("select ClassID from WeaponClasses where WeaponID = " + WeaponID, dbConnection); OdbcDataReader WeaponClassesReader = WeaponClassesQuery.ExecuteReader(); while (WeaponClassesReader.Read()) { WeaponClasses.Add((int)WeaponClassesReader[0]); } _listOfItems.Add(new Weapon(WeaponID, WeaponName, WeaponValue, WeaponPower, WeaponMagiPower, WeaponCanBuy, WeaponEffects, WeaponClasses)); _usedIDs.Add(WeaponID); } dbConnection.Close(); } else if (type == "Potion") { } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }
public ItemWrapper(string tmpType) { this._WeaponPotionEncrypter = new EncrypterDecrypter(); this._WeaponPotionEncrypter.setKey(this._key); if (tmpType == "Weapon") { this.bLogger = new BasicLogger(this._WLog); this._ActivePath = this._WPath; string encryptedWeapons = this._WeaponPotionEncrypter.decryptFile(this._WPath); if (encryptedWeapons.Length > 0) { int TotalItems = ParseItems.parseIntFrom(encryptedWeapons, 4); encryptedWeapons = encryptedWeapons.Substring(4); int i = 0; while (i < TotalItems) { int lengthOfWeapon = ParseItems.parseIntFrom(encryptedWeapons, 3); encryptedWeapons = encryptedWeapons.Substring(3); this.bLogger.Log("Attempting to decrypt: " + encryptedWeapons.Substring(0, lengthOfWeapon), debug); Weapon newWeapon = new Weapon(encryptedWeapons.Substring(0, lengthOfWeapon)); encryptedWeapons = encryptedWeapons.Substring(lengthOfWeapon); this._listOfItems.Add(newWeapon); this._usedIDs.Add(newWeapon.itemID); i++; } } } else if (tmpType == "Potion") { this.bLogger = new BasicLogger(this._PLog); this._ActivePath = this._PPath; string encryptedPotions = this._WeaponPotionEncrypter.decryptFile(this._PPath); if (encryptedPotions.Length > 0) { int TotalItems = ParseItems.parseIntFrom(encryptedPotions, 4); encryptedPotions = encryptedPotions.Substring(4); int i = 0; while (i < TotalItems) { int lengthOfPotion = ParseItems.parseIntFrom(encryptedPotions, 3); encryptedPotions = encryptedPotions.Substring(3); Potion newPotion = new Potion(encryptedPotions.Substring(0, lengthOfPotion)); encryptedPotions = encryptedPotions.Substring(lengthOfPotion); this._listOfItems.Add(newPotion); this._usedIDs.Add(newPotion.itemID); i++; } } } else { this.bLogger = new BasicLogger(this._ActivePath); bLogger.Log("ItemWrapper:ItemWrapper(Type): - Critical Error - Invalid ItemType"); MessageBox.Show("Critical Error, please see crit.err"); Environment.FailFast("Invalid Type"); } }