示例#1
0
文件: Rules.java 项目: bitsai/courses
  /** Processes a Piloting Skill check. Returns true if check succeeds, false otherwise. */
  public static boolean rollPiloting(int modifier, MechRemote mech) {
    try {
      if (mech.isShutdown()
          || mech.getMW()
              .isUnconscious()) // If mech is shutdown or mechwarrior is unconscious, we fail and
                                // fall automatically
      {
        mech.fall();
        return false;
      }

      boolean pilotingCheck = checkPiloting(modifier, mech);

      if (pilotingCheck == false) // See if pilot can avoid fall
      {
        mech.fall();
        return false;
      }

      mech.getOwner().addOutput("Mech avoided fall!");
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return true;
  }
示例#2
0
文件: Rules.java 项目: bitsai/courses
  /** 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);
  }
示例#3
0
文件: Rules.java 项目: bitsai/courses
  /** 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);
  }