Пример #1
0
 /**
  * @param paa the action to check if it succeeds
  * @return true if the action succeeds, usually because the die-roll succeeded.
  */
 private boolean actionRollSucceeds(final PoliticalActionAttachment paa) {
   final int hitTarget = paa.getChanceToHit();
   final int diceSides = paa.getChanceDiceSides();
   if (diceSides <= 0 || hitTarget >= diceSides) {
     paa.changeChanceDecrementOrIncrementOnSuccessOrFailure(m_bridge, true, true);
     return true;
   } else if (hitTarget <= 0) {
     paa.changeChanceDecrementOrIncrementOnSuccessOrFailure(m_bridge, false, true);
     return false;
   }
   final int rollResult =
       m_bridge.getRandom(
               diceSides,
               m_player,
               DiceType.NONCOMBAT,
               "Attempting the Political Action: "
                   + MyFormatter.attachmentNameToText(paa.getName()))
           + 1;
   final boolean success = rollResult <= hitTarget;
   final String notificationMessage =
       "rolling ("
           + hitTarget
           + " out of "
           + diceSides
           + ") result: "
           + rollResult
           + " = "
           + (success ? "Success!" : "Failure!");
   m_bridge
       .getHistoryWriter()
       .addChildToEvent(
           MyFormatter.attachmentNameToText(paa.getName()) + " : " + notificationMessage);
   paa.changeChanceDecrementOrIncrementOnSuccessOrFailure(m_bridge, success, true);
   sendNotification(notificationMessage);
   return success;
 }