SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public JassGame(long rngSeed, Map<PlayerId, Player> players, Map<PlayerId, String> playerNames) {
  2.         this.players = Collections.unmodifiableMap(new EnumMap<>(players));
  3.         this.playerNames = Collections.unmodifiableMap(new EnumMap<>(playerNames));
  4.         Random rng = new Random(rngSeed);
  5.         this.shuffleRng = new Random(rng.nextLong());
  6.         this.trumpRng = new Random(rng.nextLong());
  7.         List<Card> deck = new ArrayList<Card>();
  8.         for (Color c : Card.Color.ALL) {
  9.             for (Rank r : Card.Rank.ALL) {
  10.                 deck.add(Card.of(c, r));
  11.             }
  12.         }
  13.         Collections.shuffle(deck, shuffleRng);
  14.         long firstPlayerHand = PackedCardSet.EMPTY;
  15.         long secondPlayerHand = PackedCardSet.EMPTY;
  16.         long thirdPlayerHand = PackedCardSet.EMPTY;
  17.         long fourthPlayerHand = PackedCardSet.EMPTY;
  18.         for (int i =0; i<9; i++) {
  19.             PackedCardSet.add(firstPlayerHand, deck.get(i).packed());
  20.             PackedCardSet.add(secondPlayerHand, deck.get(i+9).packed());
  21.             PackedCardSet.add(thirdPlayerHand, deck.get(i+18).packed());
  22.             PackedCardSet.add(fourthPlayerHand, deck.get(i+27).packed());
  23.         }
  24.         this.firstPlayerHand = firstPlayerHand ;
  25.         this.secondPlayerHand = secondPlayerHand;
  26.         this.thirdPlayerHand = thirdPlayerHand;
  27.         this.fourthPlayerHand = fourthPlayerHand;
  28.         PlayerId starterPlayer;
  29.         if(PackedCardSet.contains(firstPlayerHand, PackedCard.pack(Card.Color.DIAMOND, Card.Rank.SEVEN))) {
  30.             starterPlayer = PlayerId.PLAYER_1;
  31.         }
  32.         if(PackedCardSet.contains(secondPlayerHand, PackedCard.pack(Card.Color.DIAMOND, Card.Rank.SEVEN))) {
  33.             starterPlayer = PlayerId.PLAYER_2;
  34.         }
  35.         if(PackedCardSet.contains(thirdPlayerHand, PackedCard.pack(Card.Color.DIAMOND, Card.Rank.SEVEN))) {
  36.             starterPlayer = PlayerId.PLAYER_3;
  37.         }
  38.         if(PackedCardSet.contains(fourthPlayerHand, PackedCard.pack(Card.Color.DIAMOND, Card.Rank.SEVEN))) {
  39.             starterPlayer = PlayerId.PLAYER_4;
  40.         }
  41.         Color trump = Card.Color.ALL.get(trumpRng.nextInt(4));
  42.         this.turnState = TurnState.initial(trump, Score.INITIAL, starterPlayer);
  43.     }
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