示例#1
0
 public void test() throws BoardException {
   // TODO
   for (Element element : getBoardPackage().getElements()) {
     for (MetaCard card : element.getCards()) {
       if (Math.random() > .6) {
         if (players.size() == 1) executeAction(new DealCardAction(card, getCurrentPlayer()));
         else executeAction(new DealCardAction(card, getNextPlayer()));
       }
     }
   }
 }
示例#2
0
 protected MetaCardDO dealCard() {
   List<MetaCardDO> cards = new ArrayList<MetaCardDO>();
   int n = 0;
   for (Element element : getBoardPackage().getElements()) {
     n += element.getCards().length;
   }
   if (n == dealtCardKeys.size()) dealtCardKeys.clear();
   for (Element element : getBoardPackage().getElements()) {
     for (MetaCard card : element.getCards()) {
       MetaCardDO record = (MetaCardDO) card;
       if (dealtCardKeys.contains(record.getKey())) continue;
       dealtCardKeys.add(record.getKey());
       cards.add(record);
     }
   }
   int index = (int) (cards.size() * Math.random());
   return cards.get(index);
 }