Пример #1
0
 public static void main(String[] args) throws IOException {
   Character debug = new Character("Debug", 0, 0);
   Character debug2 = new Character("Debug2", 0, 1);
   ShortSword testsword = new ShortSword("TairaSlayer");
   Armor testarmor = new Armor("TestArmor");
   System.out.print("Level: ");
   System.out.println(debug.getLevel());
   System.out.print("Health, pre levelup: ");
   System.out.println(debug.getHealth());
   debug.levelUp();
   System.out.print("Level: ");
   System.out.println(debug.getLevel());
   System.out.print("Health, post levelup: ");
   System.out.println(debug.getHealth());
   System.out.println("Name of Testsword: " + testsword.name);
   System.out.println("Testswords damage: " + testsword.damage);
   System.out.println("Equipped damage: " + debug.equippedDamage());
   System.out.println("Start Equip");
   debug.equipWeapon(testsword);
   // debug.equipWeapon(testsword);
   debug2.equipArmor(testarmor);
   System.out.println("Equipped Damage: " + debug.equippedDamage());
   System.out.println("Equip Finished");
   System.out.println("Debugs health prefight: " + debug.getHealth());
   System.out.println("Debug2s health prefight: " + debug2.getHealth());
   Action.Fight(debug, debug2);
   debug.checkDead();
   debug2.checkDead();
   System.out.println("Debugs health postfight: " + debug.getHealth());
   System.out.println("Debug2s health postfight: " + debug2.getHealth());
   System.out.println("Is debug dead? " + debug.getDead());
   System.out.println("Is debug2 dead? " + debug2.getDead());
   Tile testTile = new Tile(Tile.Type.DIRT);
   Map map = new Map(testTile);
   System.out.println("printing testtile..");
   // System.out.println(testTile.getType());
   System.out.println("printing map..");
   System.out.println(map);
   Map map1 =
       map.readMap(
           "maps/map1.txt",
           "maps/map1h.txt"); // Just change ArrayList stuff to Map when readmap has been updated.
   // System.out.println(map.getTile(0,0,1).getType());
 }
Пример #2
0
  private void displayInfo(Character character) {

    ((TextView) findViewById(R.id.toonNameLabel)).setText(character.getName());
    ((TextView) findViewById(R.id.toonLevelLabel)).setText(character.getLevel().toString());
    ((TextView) findViewById(R.id.realmNameLabel)).setText(character.getServer());
    ((TextView) findViewById(R.id.battlegroupLabel)).setText(character.getBattlegroup());
    ((TextView) findViewById(R.id.achievementLabel))
        .setText(character.getAchievements().toString());
    ((TextView) findViewById(R.id.honorableKillsLabel))
        .setText(character.getHonorableKills().toString());
  }
Пример #3
0
  public boolean Battle() throws IOException {
    player.update();
    boolean alive = true;
    int health;
    flee = false;
    P_HEALTH = player.getHealth();
    PC_HEALTH = player.getCHealth();
    plevel = player.getLevel();
    elevel = elgen.nextInt(2) + (plevel - 1);
    if (elevel != -1) {
      health = 70 + (elevel) * 30;
    } else {
      health = 70;
      elevel = 0;
    }

    E_HEALTH = health;
    EC_HEALTH = health;

    H.pln("You have encountered a level " + elevel + " enemy");
    while (EC_HEALTH > 0 && PC_HEALTH > 0 && !flee) {
      engine = new Random();
      H.pln("Your Health: " + PC_HEALTH + "/" + P_HEALTH);
      H.pln("Enemy's Health : " + EC_HEALTH + "/" + E_HEALTH);
      H.pln("What do you want to do?");
      H.pln("(1)Attack, (2)Defend, (3)Flee");
      choice = H.inputInt();

      switch (choice) {
        case 1:
          if (engine.nextInt(99) + 1 <= 95) {
            damage = (int) ((engine.nextInt(P_MAX_DAMAGE[plevel])) * wD[player.getWeapon()]);
            if (damage <= EC_HEALTH) {
              H.pln("Enemy lost " + damage + " health!");
              EC_HEALTH -= damage;
            } else {
              helper = EC_HEALTH;
              H.pln("Enemy lost " + helper + " health!");
              EC_HEALTH -= damage;
            }
          } else {
            if (plevel <= 8) {
              damage = (int) (engine.nextInt(P_MAX_DAMAGE[plevel + 2]) * wD[player.getWeapon()]);
              H.pln("Critical Hit!");
              if (damage <= EC_HEALTH) {
                H.pln("Enemy lost " + damage + " health!");
                EC_HEALTH -= damage;
              } else {
                helper = EC_HEALTH;
                H.pln("Enemy lost " + helper + " health!");
                EC_HEALTH = 0;
              }
            } else {
              if (plevel == 9) {
                damage = (int) (engine.nextInt(P_MAX_DAMAGE[plevel + 1]) * wD[player.getWeapon()]);
                H.pln("Critical Hit!");
                if (damage <= EC_HEALTH) {
                  H.pln("Enemy lost " + damage + " health!");
                  EC_HEALTH -= damage;
                } else {
                  helper = EC_HEALTH;
                  H.pln("Enemy lost " + helper + " health!");
                  EC_HEALTH -= damage;
                }
              }
              if (plevel == 10) {
                damage = EC_HEALTH;
                H.pln("You destroyed the Enemy with one blow!!!");
              }
            }
          }
          damage = engine.nextInt(E_MAX_DAMAGE[elevel]) + 1;
          H.pln("You lost " + damage + " health");
          PC_HEALTH -= damage;
          player.setCHealth(PC_HEALTH);
          if (player.getCHealth() <= 0) return false;
          break;
        case 2:
          H.pln("You have blocked the enemy attack!");
          break;
        case 3:
          H.pln("You have fled");
          flee = true;
          break;
      }
    }
    if (EC_HEALTH <= 0 && PC_HEALTH > 0) {
      player.addXP(EC_HEALTH * (-1));
      H.pln("You gained " + String.valueOf(EC_HEALTH * (-1)) + " XP!");
    }
    if (flee) {
      player.addXP((EC_HEALTH) * (-1));
      H.pln("You lost " + EC_HEALTH + " XP!");
    }
    player.saveAll();
    return true;
  }