public static PoliticalActionAttachment get(
     final PlayerID player,
     final String nameOfAttachment,
     final Collection<PlayerID> playersToSearch) {
   PoliticalActionAttachment rVal =
       (PoliticalActionAttachment) player.getAttachment(nameOfAttachment);
   if (rVal == null) {
     if (playersToSearch == null) {
       throw new IllegalStateException(
           "PoliticalActionAttachment: No attachment for:"
               + player.getName()
               + " with name: "
               + nameOfAttachment);
     } else {
       for (final PlayerID otherPlayer : playersToSearch) {
         if (otherPlayer == player) continue;
         rVal = (PoliticalActionAttachment) otherPlayer.getAttachment(nameOfAttachment);
         if (rVal != null) return rVal;
       }
       throw new IllegalStateException(
           "PoliticalActionAttachment: No attachment for:"
               + player.getName()
               + " with name: "
               + nameOfAttachment);
     }
   }
   return rVal;
 }
Пример #2
0
 // attaches to a PlayerID
 public static TechAttachment get(final PlayerID id) {
   final TechAttachment attachment =
       (TechAttachment) id.getAttachment(Constants.TECH_ATTACHMENT_NAME);
   // dont crash, as a map xml may not set the tech attachment for all players, so just create a
   // new tech attachment for them
   if (attachment == null) {
     return new TechAttachment();
   }
   return attachment;
 }
Пример #3
0
 public static TechAttachment get(final PlayerID id, final String nameOfAttachment) {
   if (!nameOfAttachment.equals(Constants.TECH_ATTACHMENT_NAME)) {
     throw new IllegalStateException(
         "TechAttachment may not yet get attachments not named:" + Constants.TECH_ATTACHMENT_NAME);
   }
   final TechAttachment attachment = (TechAttachment) id.getAttachment(nameOfAttachment);
   // dont crash, as a map xml may not set the tech attachment for all players, so just create a
   // new tech attachment for them
   if (attachment == null) {
     return new TechAttachment();
   }
   return attachment;
 }
Пример #4
0
 @Override
 public void initialize(final IPlayerBridge bridge, final PlayerID id) {
   super.initialize(bridge, id);
   m_xDimension = getGameData().getMap().getXDimension();
   m_yDimension = getGameData().getMap().getYDimension();
   {
     final PlayerAttachment pa = (PlayerAttachment) id.getAttachment("playerAttachment");
     if (pa != null) {
       if (pa.getNeedsKing()) {
         m_kingPlayer = true;
       }
       cutoffDepth = pa.getAlphaBetaSearchDepth();
     } else {
       m_kingPlayer = false;
     }
   }
   m_opponent = null;
   for (final PlayerID p : getGameData().getPlayerList().getPlayers()) {
     if (!p.equals(id) && !p.equals(PlayerID.NULL_PLAYERID)) {
       m_opponent = p;
       break;
     }
   }
 }