コード例 #1
0
 @Override
 public void unloadData(Compacter data) throws CompactedDataCorruptException {
   if (data.getSize() < 4) {
     throw new CompactedDataCorruptException("Too little data in compressor.")
         .setCorruptData(data);
   }
   rawScoreTeam1 = data.getInt(0);
   rawScoreTeam2 = data.getInt(1);
   String finisherData = data.getData(2);
   finishers = new int[finisherData.length()];
   for (int i = 0; i < finishers.length; i++) {
     finishers[i] = Integer.parseInt(String.valueOf(finisherData.charAt(i)), 10);
   }
   String tichuData = data.getData(3);
   TichuBidType[] bids = new TichuBidType[TichuGame.TOTAL_PLAYERS];
   for (int i = 0; i < bids.length; i++) {
     bids[i] = TichuBidType.getFromKey(String.valueOf(tichuData.charAt(i)));
   }
   finishers = completeFinishers(finishers, rawScoreTeam1, rawScoreTeam2);
   tichus = makeTichus(bids, finishers[0]);
   try {
     checkAndThrowTichuRoundState();
   } catch (InadequateRoundInfo e) {
     throw new CompactedDataCorruptException(e).setCorruptData(data);
   }
 }
コード例 #2
0
 @Override
 public void unloadData(Compacter compactedData) throws CompactedDataCorruptException {
   if (compactedData.getSize() < 4) {
     throw new CompactedDataCorruptException().setCorruptData(compactedData);
   }
   mType = compactedData.getInt(1);
   if (!isValidType(mType)) {
     throw new CompactedDataCorruptException().setCorruptData(compactedData);
   }
   setFirstReIndex(compactedData.getInt(2));
   setSecondReIndex(compactedData.getInt(3));
 }
コード例 #3
0
 @Override
 public String compact() {
   Compacter cmp = new Compacter();
   cmp.appendData(DoppelkopfRoundStyle.RE_STYLE_MARK);
   cmp.appendData(getType());
   cmp.appendData(getFirstIndex());
   cmp.appendData(getSecondIndex());
   return cmp.compact();
 }
コード例 #4
0
 @Override
 public String compact() {
   Compacter cmp = new Compacter();
   // score team1 in slot 0
   cmp.appendData(rawScoreTeam1);
   // score team2 in slot 1
   cmp.appendData(rawScoreTeam2);
   // finishers in slot 2
   StringBuilder finisherData = new StringBuilder(TichuGame.TOTAL_PLAYERS);
   for (int i : finishers) {
     finisherData.append(i);
   }
   cmp.appendData(finisherData.toString());
   // tichus in slot 3
   StringBuilder tichuData = new StringBuilder(TichuGame.TOTAL_PLAYERS);
   for (TichuBid bid : tichus) {
     tichuData.append(bid.getType().getKey());
   }
   cmp.appendData(tichuData.toString());
   return cmp.compact();
 }