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");
     }
 }
Ejemplo n.º 2
0
        private void btnAddEdit_Click(object sender, EventArgs e)
        {
            if (this.rWeapon.Checked)
            {
                int newID;
                if (this.selectedItemID > -1)
                {
                    newID = this.selectedItemID;
                }
                else if (this.cIDOverride.Checked)
                {
                    newID = (int)this.nIDForce.Value;

                }else{
                    newID = this._weaponWrapper.getNextID();
                }

                Weapon newWep = new Weapon(newID, this.txtName.Text, (int)this.nValue.Value, (int)this.nEffect.Value, (int)this.nAttackRollBonus.Value);
                this._weaponWrapper.AddItem(newWep);
            }
            else
            {
                int newID;
                if (this.selectedItemID > -1)
                {
                    newID = this.selectedItemID;
                }
                else if (this.cIDOverride.Checked)
                {
                    newID = (int)this.nIDForce.Value;
                }
                else
                {
                    newID = this._potionWrapper.getNextID();
                }

                Potion newPotion = new Potion(newID, this.txtName.Text, (int)this.nValue.Value, (int)this.nEffect.Value);
                this._potionWrapper.AddItem(newPotion);
            }

            this.populateDataGrid();
            this.changesSaved = false;
        }