/// <summary> /// Creates the wrapper for the specified type. Current valid types are: /// /// "Entity" /// "Player Entity" /// "Generated Entity" /// /// /// Migrated type /// "Entity Template" - To EntityTemplateWrapper /// /// </summary> /// <param name="tmpType"></param> public EntityWrapper(string tmpType, List<Weapon> currentWeapons) { this._EntityEncrypter = new EncrypterDecrypter(); this._EntityEncrypter.setKey(this._key); if (tmpType == "Player Entity") { this.bLogger = new BasicLogger(this._ELog); this._ActivePath = this._PEPath; string encryptedEntities = this._EntityEncrypter.decryptFile(this._PEPath); 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); Entity newEntity = new Entity(encryptedEntities.Substring(0, lengthOfEntity), currentWeapons); encryptedEntities = encryptedEntities.Substring(lengthOfEntity); this._listOfEntities.Add(newEntity); this._usedIDs.Add(newEntity.id); i++; } } } else if (tmpType == "Generated Entity") { this.bLogger = new BasicLogger(this._ELog); this._ActivePath = this._GEPath; string encryptedEntities = this._EntityEncrypter.decryptFile(this._GEPath); 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); Entity newEntity = new Entity(encryptedEntities.Substring(0, lengthOfEntity), currentWeapons); 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 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"); } }
/// <summary> /// Constructs the wrapper(Opens/decryptes the effect data file and starts the logger) /// </summary> public EffectWrapper() { bLogger = new BasicLogger(elog); _effectEncrypter = new EncrypterDecrypter(_key); string decryptedResults = _effectEncrypter.decryptFile(epath); int numOfEffects = 0; if (decryptedResults.Length > 0) { numOfEffects = ParseItems.parseIntFrom(decryptedResults, 4); decryptedResults = decryptedResults.Substring(4); } int i = 0; while (i < numOfEffects) { int length = ParseItems.parseIntFrom(decryptedResults, 3); decryptedResults = decryptedResults.Substring(3); string currentEffect = ParseItems.parseStringFrom(decryptedResults, length); _listOfEffects.Add(new Effect(currentEffect)); _usedIDs.Add(_listOfEffects.Last().id); decryptedResults = decryptedResults.Substring(length); i++; } }
public AbilityWrapper() { bLogger = new BasicLogger(alog); _abilityEncrypter = new EncrypterDecrypter(_key); string decryptedResults = _abilityEncrypter.decryptFile(apath); int numOfAbilities = 0; if (decryptedResults.Length > 0) { numOfAbilities = ParseItems.parseIntFrom(decryptedResults, 4); decryptedResults = decryptedResults.Substring(4); } int i = 0; while (i < numOfAbilities) { int length = ParseItems.parseIntFrom(decryptedResults, 3); decryptedResults = decryptedResults.Substring(3); string currentAbility = ParseItems.parseStringFrom(decryptedResults, length); _listOfAbilities.Add(new Ability(currentAbility)); _usedIDs.Add(_listOfAbilities.Last().id); decryptedResults = decryptedResults.Substring(length); i++; } }