Example #1
0
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Player p1 = new Player("Bob");

    System.out.println(p1.name + ", You came across an item. +10 health!");
    p1.boostHealth(100);
    System.out.println("Your health is now " + p1.health);
    System.out.println(p1.strength);

    Item i1 = new Item("sword", 0, 10);
    i1.boost(p1);
    System.out.println(p1.strength);

    Poison i2 = new Poison();
    System.out.println("You came across Poison!");
    i2.boost(p1);
    System.out.println(p1.health);

    System.out.println(p1.isAlive());

    // Instant kill the player
    System.out.println("You stepped on a snake!");
    p1.health = p1.health - p1.health;

    System.out.println(p1.isAlive());
    System.out.println("You are dead!");
    clearscreen();
    System.out.println("You are a clear screen");

    p1.health += 100;
    Enemy e1 = new Enemy("qoB");

    Shirt s1 = new Shirt();
    s1.boost(p1);

    // e1.fight(p1);

    // make empty array
    Enemy[] enemyArray = new Enemy[5]; // Array holds 5 enemies

    // fills the enemy array
    for (int i = 0; i < enemyArray.length; i++) {
      enemyArray[i] = new Enemy("qoB" + i);
    }

    // fight every single enemy in this array
    for (int i = 0; i < enemyArray.length; i++) {
      enemyArray[i].fight(p1);
      p1.obliterateNum += 5;
    }
  }
 @Override
 public void affectPhyStats(Physical affected, PhyStats affectableStats) {
   super.affectPhyStats(affected, affectableStats);
   affectableStats.setSpeed(affectableStats.speed() + 0.25);
   int oldDisposition = affectableStats.disposition();
   oldDisposition =
       oldDisposition
           & (~(PhyStats.IS_SLEEPING
               | PhyStats.IS_SNEAKING
               | PhyStats.IS_SITTING
               | PhyStats.IS_CUSTOM));
   affectableStats.setDisposition(oldDisposition);
 }
 @Override
 public void restoreFromBundle(Bundle bundle) {
   super.restoreFromBundle(bundle);
   damage = bundle.getInt(DAMAGE);
 }
 @Override
 public void storeInBundle(Bundle bundle) {
   super.storeInBundle(bundle);
   bundle.put(DAMAGE, damage);
 }
 /** Applying any extra effects (poisoning, freezing, etc) after the attack. */
 public static void applyMagicEffects(Entity attacker, Entity victim, int hit) {
   if (attacker instanceof Player) {
     Player player = (Player) attacker;
     int spellId =
         player.getMagic().getSpellDefinitions()[player.getMagic().getMagicIndex()].getSpellId();
     switch (spellId) {
       case 12891: // Ice barrage
         FreezeEntity.freezeEntity(victim, true, 34);
         break;
       case 12871: // Ice blitz
         FreezeEntity.freezeEntity(victim, true, 25);
         break;
       case 12881: // Ice burst
         FreezeEntity.freezeEntity(victim, true, 17);
         break;
       case 12861: // Ice burst
         FreezeEntity.freezeEntity(victim, true, 9);
         break;
       case 12929: // Blood barrage
       case 12911: // Blood blitz
       case 12918: // Blood burst
       case 12901: // Blood rush
         int finalHitpoints = player.getSkill().getLevel()[3] + (hit / 4);
         if (finalHitpoints <= player.getSkill().getLevelForXP(player.getSkill().getExp()[3])) {
           player.getSkill().getLevel()[3] = finalHitpoints;
         } else {
           player.getSkill().getLevel()[3] =
               player.getSkill().getLevelForXP(player.getSkill().getExp()[3]);
         }
         player.getSkill().refresh(3);
         break;
       case 13023: // Shadow barrage
         if (victim instanceof Player) {
           Player otherPlayer = (Player) victim;
           int finalAttack =
               (otherPlayer.getSkill().getLevelForXP(otherPlayer.getSkill().getExp()[0])
                   - (int)
                       (otherPlayer.getSkill().getLevelForXP(otherPlayer.getSkill().getExp()[0])
                           * 0.15));
           if (otherPlayer.getSkill().getLevel()[0] > finalAttack) {
             otherPlayer.getSkill().getLevel()[0] = finalAttack;
           }
           otherPlayer.getSkill().refresh(0);
         }
         break;
       case 12999: // Shadow bitz
       case 13011: // Shadow burst
       case 12987: // Shadow rush
         if (victim instanceof Player) {
           Player otherPlayer = (Player) victim;
           int finalAttack =
               (otherPlayer.getSkill().getLevelForXP(otherPlayer.getSkill().getExp()[0])
                   - (int)
                       (otherPlayer.getSkill().getLevelForXP(otherPlayer.getSkill().getExp()[0])
                           * 0.1));
           if (otherPlayer.getSkill().getLevel()[0] > finalAttack) {
             otherPlayer.getSkill().getLevel()[0] = finalAttack;
           }
           otherPlayer.getSkill().refresh(0);
         }
         break;
       case 12975: // Smoke barrage
       case 12951: // Smoke blitz
         if (Misc.randomNumber(10) == 0) Poison.appendPoison(victim, true, 4);
         break;
       case 12963: // Smoke burst
       case 12939: // Smoke rush
         if (Misc.randomNumber(10) == 0) Poison.appendPoison(victim, true, 2);
         break;
     }
   }
 }