Exemplo n.º 1
0
 /**
  * Let all players involved in this action know the action has failed.
  *
  * @param paa the political action attachment that just failed.
  */
 private void notifyFailure(final PoliticalActionAttachment paa) {
   getSoundChannel().playSoundForAll(SoundPath.CLIP_POLITICAL_ACTION_FAILURE, m_player);
   final String transcriptText =
       m_bridge.getPlayerID().getName()
           + " fails on action: "
           + MyFormatter.attachmentNameToText(paa.getName());
   m_bridge.getHistoryWriter().addChildToEvent(transcriptText);
   sendNotification(PoliticsText.getInstance().getNotificationFailure(paa.getText()));
   notifyOtherPlayers(paa, PoliticsText.getInstance().getNotificationFailureOthers(paa.getText()));
 }
Exemplo n.º 2
0
 /**
  * Let all players involved in this action know the action was successful
  *
  * @param paa the political action attachment that just succeeded.
  */
 private void notifySuccess(final PoliticalActionAttachment paa) {
   getSoundChannel().playSoundForAll(SoundPath.CLIP_POLITICAL_ACTION_SUCCESSFUL, m_player);
   sendNotification(PoliticsText.getInstance().getNotificationSucccess(paa.getText()));
   notifyOtherPlayers(paa, PoliticsText.getInstance().getNotificationSuccessOthers(paa.getText()));
 }
Exemplo n.º 3
0
 /**
  * Get a list of players that should accept this action and then ask each player if it accepts
  * this action.
  *
  * @param paa the politicalActionAttachment that should be accepted
  */
 private boolean actionIsAccepted(final PoliticalActionAttachment paa) {
   final GameData data = getData();
   final CompositeMatchOr<PoliticalActionAttachment> intoAlliedChainOrIntoOrOutOfWar =
       new CompositeMatchOr<>(
           Matches.politicalActionIsRelationshipChangeOf(
               null,
               Matches.RelationshipTypeIsAlliedAndAlliancesCanChainTogether.invert(),
               Matches.RelationshipTypeIsAlliedAndAlliancesCanChainTogether,
               data),
           Matches.politicalActionIsRelationshipChangeOf(
               null,
               Matches.RelationshipTypeIsAtWar.invert(),
               Matches.RelationshipTypeIsAtWar,
               data),
           Matches.politicalActionIsRelationshipChangeOf(
               null,
               Matches.RelationshipTypeIsAtWar,
               Matches.RelationshipTypeIsAtWar.invert(),
               data));
   if (!games.strategy.triplea.Properties.getAlliancesCanChainTogether(data)
       || !intoAlliedChainOrIntoOrOutOfWar.match(paa)) {
     for (final PlayerID player : paa.getActionAccept()) {
       if (!(getRemotePlayer(player))
           .acceptAction(
               m_player, PoliticsText.getInstance().getAcceptanceQuestion(paa.getText()), true)) {
         return false;
       }
     }
   } else {
     // if alliances chain together, then our allies must have a say in anyone becoming a new
     // ally/enemy
     final LinkedHashSet<PlayerID> playersWhoNeedToAccept = new LinkedHashSet<>();
     playersWhoNeedToAccept.addAll(paa.getActionAccept());
     playersWhoNeedToAccept.addAll(
         Match.getMatches(
             data.getPlayerList().getPlayers(),
             Matches.isAlliedAndAlliancesCanChainTogether(m_player, data)));
     for (final PlayerID player : paa.getActionAccept()) {
       playersWhoNeedToAccept.addAll(
           Match.getMatches(
               data.getPlayerList().getPlayers(),
               Matches.isAlliedAndAlliancesCanChainTogether(player, data)));
     }
     final HashSet<PlayerID> alliesWhoMustAccept = playersWhoNeedToAccept;
     alliesWhoMustAccept.removeAll(paa.getActionAccept());
     for (final PlayerID player : playersWhoNeedToAccept) {
       String actionText = PoliticsText.getInstance().getAcceptanceQuestion(paa.getText());
       if (actionText.equals("NONE")) {
         actionText =
             m_player.getName()
                 + " wants to take the following action: "
                 + MyFormatter.attachmentNameToText(paa.getName())
                 + " \r\n Do you approve?";
       } else {
         actionText =
             m_player.getName()
                 + " wants to take the following action: "
                 + MyFormatter.attachmentNameToText(paa.getName())
                 + ".  Do you approve? \r\n\r\n "
                 + m_player.getName()
                 + " will ask "
                 + MyFormatter.defaultNamedToTextList(paa.getActionAccept())
                 + ", the following question: \r\n "
                 + actionText;
       }
       if (!(getRemotePlayer(player)).acceptAction(m_player, actionText, true)) {
         return false;
       }
     }
     for (final PlayerID player : paa.getActionAccept()) {
       if (!(getRemotePlayer(player))
           .acceptAction(
               m_player, PoliticsText.getInstance().getAcceptanceQuestion(paa.getText()), true)) {
         return false;
       }
     }
   }
   return true;
 }