Advertisement
marvk

Untitled

Oct 12th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. LinkedList<Card> pot1 = new LinkedList<>();
  2. LinkedList<Card> pot2 = new LinkedList<>();
  3. pot1.addLast(p1);
  4. pot2.addLast(p2);
  5. for (int j = 0; j < 3; j++) {
  6.     pot1.addLast(player1.removeFirst());
  7.     pot2.addLast(player2.removeFirst());
  8. }
  9. while (player1.peekFirst().value == player2.peekFirst().value) {
  10.     for (int j = 0; j < 4; j++) {
  11.         pot1.addLast(player1.removeFirst());
  12.         pot2.addLast(player2.removeFirst());
  13.     }
  14. }
  15.  
  16. if (player1.peekFirst().value > player2.peekFirst().value) {
  17.     //System.err.println("Player 1 wins Battle with " + player1.peekFirst().value+">"+player2.peekFirst().value);
  18.     for (int j = 0; j < pot1.size(); j++) {
  19.         player1.addLast(pot1.removeFirst());
  20.     }
  21.     player1.addLast(player1.removeFirst());
  22.     for (int j = 0; j < pot2.size(); j++) {
  23.         player1.addLast(pot2.removeFirst());
  24.     }
  25.     player1.addLast(player2.removeFirst());
  26. } else {
  27.     //System.err.println("Player 2 wins Battle with " + player1.peekFirst().value+"<"+player2.peekFirst().value);
  28.     for (int j = 0; j < pot1.size(); j++) {
  29.         player2.addLast(pot1.removeFirst());
  30.     }
  31.     player2.addLast(player1.removeFirst());
  32.     for (int j = 0; j < pot2.size(); j++) {
  33.         player2.addLast(pot2.removeFirst());
  34.     }
  35.     player2.addLast(player2.removeFirst());
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement