Beispiel #1
0
 private Set<CardInfo> getCardsOnHand(Player p) {
   final Set<CardInfo> playercards = new HashSet<>();
   for (PlayCard pc : playcards) {
     if (pc.getOwner() != null && pc.getOwner().getId() == p.getId()) {
       CardInfo hc = new CardInfo(pc.getKarte());
       hc.setOffen(!p.isComputer());
       playercards.add(hc);
     }
   }
   return playercards;
 }
Beispiel #2
0
  private List<CardInfo> buildCardInfo() {

    final List<CardInfo> info = new ArrayList<>();
    final Map<Integer, CardInfo> roundCards = new HashMap<>();

    for (final PlayCard card : playcards) {
      final CardInfo ci = new CardInfo(card.getKarte());
      ci.setOffen(card.getOwner() != null && !card.getOwner().isComputer());
      ci.setPlayerPosition(card.getOwner() != null ? card.getOwner().getPosition() : 0);

      CardPlace location = CardPlace.Invisible; // Karte bereits gespielt

      // 0=bereits gespielt/nicht sichtbar, 1=auf Hand, 2=Original, 3=Stich, 4=Stapel

      if (card.equals(original)) {
        if (!originalSelected) {
          location = CardPlace.Original; // Aufgedeckt vor dem Spieler anzeigen
        }
      }
      if (location == CardPlace.Invisible && isCardInCurrentRound(card)) {
        location = CardPlace.Bid; // im aktuellen Stich
        roundCards.put(card.getBidNr(), ci);
      }
      if (location == CardPlace.Invisible && card.getOwner() == null) {
        location = CardPlace.Stock; // im Stapel
      }
      if (location == CardPlace.Invisible && card.getOwner() != null && card.getStichNr() == 0) {
        location = CardPlace.Hand; // Hand, nicht gespielt
      }
      ci.setCardPlace(location);
      info.add(ci);
    }
    // Integrate cards from bid in correct order
    info.removeAll(roundCards.values());
    info.addAll(roundCards.values());
    return info;
  }