daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch.epfl.javass.jass;
  2. import ch.epfl.javass.jass.Card.Color;;
  3.  
  4. public final class TurnState {
  5.    
  6.     public long pkScore;
  7.     public int pkTrick;
  8.     public long pkUnplayedCards;
  9.    
  10.     private TurnState(long pkScore,long pkUnplayedCards,int pkTrick) {
  11.         this.pkScore = pkScore;
  12.         this.pkTrick = pkTrick;
  13.         this.pkUnplayedCards = pkUnplayedCards;
  14.     }
  15.    
  16.     public static TurnState initial(Color trump, Score score, PlayerId firstPlayer) {
  17.         return ofPackedComponents(score.packed(), PackedCardSet.ALL_CARDS, PackedTrick.firstEmpty(trump, firstPlayer));
  18.     }
  19.    
  20.     public static TurnState ofPackedComponents(long pkScore, long pkUnplayedCards, int pkTrick) {
  21.         if (PackedScore.isValid(pkScore) && PackedCardSet.isValid(pkUnplayedCards) && PackedTrick.isValid(pkTrick)) {
  22.             return new TurnState(pkScore,pkUnplayedCards,pkTrick);
  23.         }
  24.         else {
  25.             throw new IllegalArgumentException();
  26.         }
  27.     }
  28.    
  29.     public long packedScore() {
  30.         return pkScore;
  31.     }
  32.    
  33.     public long packedUnplayedCards() {
  34.         return pkUnplayedCards;
  35.     }
  36.    
  37.     public long packedTrick() {
  38.         return pkTrick;
  39.     }
  40.    
  41.     public Score score() {
  42.         return Score.ofPacked(pkScore);
  43.     }
  44.    
  45.     public CardSet unplayedCards() {
  46.         return CardSet.ofPacked(pkUnplayedCards);
  47.     }
  48.    
  49.     public Trick trick() {
  50.         return Trick.ofPacked(pkTrick);
  51.     }
  52.    
  53.    
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top