Beispiel #1
0
 /**
  * Randomly distributes available magic points. May reallocate points already spent.
  *
  * @throws InvalidStatsException
  */
 private void distributeMagic() throws InvalidStatsException, BoostNotFoundException {
   Elements element;
   try {
     if (!isLuna()) checkLuna();
     if (isLuna()) {
       if (spellPoints() > 0 && spellPoints() <= 34) {
         while (spellPoints() > 0) {
           element = Elements.identifyElement(JSlime.rng.nextInt(6));
           if (element == Elements.LUNA && getMagic(Elements.LUNA) < 14)
             setMagic(Elements.LUNA, (getMagic(Elements.LUNA) + 1));
           if (element != Elements.LUNA && getMagic(element) < 10)
             setMagic(element, (getMagic(element) + 1));
         }
       } else {
         setMagic(Elements.LUNA, 14);
         for (short i = 1; i < getMagic(null); i++) {
           setMagic(Elements.identifyElement(i), 10);
         }
         while (spellPoints() < 0) {
           element = Elements.identifyElement(JSlime.rng.nextInt(6));
           if (element == Elements.LUNA && getMagic(Elements.LUNA) > 6)
             setMagic(Elements.LUNA, (getMagic(Elements.LUNA) - 1));
           if (element != Elements.LUNA && getMagic(element) > 0)
             setMagic(element, (getMagic(element) - 1));
         }
       }
     } else {
       if (spellPoints() > 0 && spellPoints() < 34) {
         while (spellPoints() > 0) {
           element = Elements.identifyElement(1 + JSlime.rng.nextInt(5));
           if (getMagic(element) < 10) setMagic(element, (getMagic(element) + 1));
         }
       } else {
         while (spellPoints() < 0) {
           for (short i = 1; i < getMagic(null); i++) {
             setMagic(Elements.identifyElement(i), 10);
           }
           element = Elements.identifyElement(1 + JSlime.rng.nextInt(5));
           if (getMagic(element) > 0) setMagic(element, (getMagic(element) - 1));
         }
       }
     }
   } catch (UnknownTypeException e) {
     System.err.print(e.getMessage());
   }
 } // distributeMagic
Beispiel #2
0
 /**
  * Randomly distributes available weapon points. May reallocate points already spent.
  *
  * @throws InvalidStatsException
  */
 private void distributeWeapons() throws InvalidStatsException, BoostNotFoundException {
   Weapons weapon;
   try {
     if (weaponPoints() > 0 && weaponPoints() <= 30) {
       while (weaponPoints() < 0) {
         weapon = Weapons.identifyWeapon(JSlime.rng.nextInt(5));
         if (getWeapon(weapon) < 10) {
           setWeapon(weapon, (getWeapon(weapon) + 1));
         }
       }
     } else {
       for (int i = 0; i < getWeapon(null); i++) {
         setWeapon(Weapons.identifyWeapon(i), 10);
       }
       while (weaponPoints() > 0) {
         weapon = Weapons.identifyWeapon(JSlime.rng.nextInt(5));
         if (getWeapon(weapon) > 0) setWeapon(weapon, (getWeapon(weapon) - 1));
       }
     }
   } catch (UnknownTypeException e) {
     System.err.print(e.getMessage());
   }
 } // distributeWeapons
Beispiel #3
0
 /**
  * Randomly distributes available stat points. May reallocate points already spent.
  *
  * @throws InvalidStatsException
  */
 private void distributeStats() throws InvalidStatsException {
   short localStr;
   short localDex;
   short localVit;
   short localInt;
   short localAgi;
   short localMen;
   Attributes attribute;
   try {
     if (getNormalLevel() < 300) {
       localStr = 0;
       localDex = 0;
       localVit = 0;
       localInt = 0;
       localAgi = 0;
       localMen = 0;
       while (statPoints() > 0) {
         attribute = Attributes.identifyAttribute(JSlime.rng.nextInt(5));
         if (attribute == Attributes.STRENGTH && localStr < 100) localStr++;
         else if (attribute == Attributes.DEXTERITY && localDex < 100) localDex++;
         else if (attribute == Attributes.VITALITY && localVit < 100) localVit++;
         else if (attribute == Attributes.INTELLIGENCE && localInt < 100) localInt++;
         else if (attribute == Attributes.AGILITY && localAgi < 100) localAgi++;
         else if (attribute == Attributes.MENTALITY && localMen < 100) localMen++;
       }
       setNormalStat(Attributes.STRENGTH, localStr);
       setNormalStat(Attributes.DEXTERITY, localDex);
       setNormalStat(Attributes.VITALITY, localVit);
       setNormalStat(Attributes.INTELLIGENCE, localInt);
       setNormalStat(Attributes.AGILITY, localAgi);
       setNormalStat(Attributes.MENTALITY, localMen);
     } else if (getNormalLevel() < 600) {
       localStr = 100;
       localDex = 100;
       localVit = 100;
       localInt = 100;
       localAgi = 100;
       localMen = 100;
       while (statPoints() < 0) {
         attribute = Attributes.identifyAttribute(JSlime.rng.nextInt(5));
         if (attribute == Attributes.STRENGTH && localStr > 0) localStr++;
         else if (attribute == Attributes.DEXTERITY && localDex > 0) localDex++;
         else if (attribute == Attributes.VITALITY && localVit > 0) localVit++;
         else if (attribute == Attributes.INTELLIGENCE && localInt > 0) localInt++;
         else if (attribute == Attributes.AGILITY && localAgi > 0) localAgi++;
         else if (attribute == Attributes.MENTALITY && localMen > 0) localMen++;
       }
       setNormalStat(Attributes.STRENGTH, localStr);
       setNormalStat(Attributes.DEXTERITY, localDex);
       setNormalStat(Attributes.VITALITY, localVit);
       setNormalStat(Attributes.INTELLIGENCE, localInt);
       setNormalStat(Attributes.AGILITY, localAgi);
       setNormalStat(Attributes.MENTALITY, localMen);
     } else {
       setNormalStat(Attributes.STRENGTH, 100);
       setNormalStat(Attributes.DEXTERITY, 100);
       setNormalStat(Attributes.VITALITY, 100);
       setNormalStat(Attributes.INTELLIGENCE, 100);
       setNormalStat(Attributes.AGILITY, 100);
       setNormalStat(Attributes.MENTALITY, 100);
     }
     statCheck();
   } catch (UnknownTypeException e) {
     System.err.print(e.getMessage());
   }
 } // distributeStats