Пример #1
0
  /** Returns the difficulty for physical attacks. */
  public static int getPhysicalAttackDifficulty(MechRemote shooter, MechRemote target, int base) {
    int difficulty = base;

    try {
      Map map = shooter.getMap();

      difficulty = difficulty + shooter.getMovementMode(); // Shooter movement modifiers

      difficulty = difficulty + getMovementModifier(target); // Target movement modifier

      difficulty = difficulty + map.getTerrainModifier(shooter, target); // Terrain modifiers

      if (target.isProne()) {
        difficulty = difficulty - 2;
      } // Prone target modifier

      if (target.isShutdown() || target.getMW().isUnconscious()) // Immobile target modifier
      {
        difficulty = difficulty - 4;
      }
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return (difficulty);
  }
Пример #2
0
  /** Returns the difficulty for weapon attacks. */
  public static int getGunneryDifficulty(MechRemote shooter, MechRemote target, Weapon weapon) {
    int difficulty = 0;

    try {
      Map map = shooter.getMap();

      double distance = getDistance(shooter.getLocation(), target.getLocation());

      difficulty = difficulty + shooter.getMW().getGunnery(); // MechWarrior's Gunnery skill

      difficulty = difficulty + shooter.getAttackModifier(); // Shooter attack modifiers

      difficulty =
          difficulty + getRangeModifier(distance, weapon, map.getMapGridSize()); // Range modifiers

      difficulty = difficulty + map.getTerrainModifier(shooter, target); // Terrain modifiers

      if (target.isProne()) // Prone target modifier
      {
        if (distance <= map.getMapGridSize()) {
          difficulty = difficulty - 2;
        } else {
          difficulty = difficulty + 1;
        }
      }

      if (target.isShutdown() || target.getMW().isUnconscious()) // Immobile target modifier
      {
        difficulty = difficulty - 4;
      }

      difficulty = difficulty + getMovementModifier(target); // Target movement modifier
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return (difficulty);
  }