Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LinkedList<Card> pot1 = new LinkedList<>();
- LinkedList<Card> pot2 = new LinkedList<>();
- pot1.addLast(p1);
- pot2.addLast(p2);
- for (int j = 0; j < 3; j++) {
- pot1.addLast(player1.removeFirst());
- pot2.addLast(player2.removeFirst());
- }
- while (player1.peekFirst().value == player2.peekFirst().value) {
- for (int j = 0; j < 4; j++) {
- pot1.addLast(player1.removeFirst());
- pot2.addLast(player2.removeFirst());
- }
- }
- if (player1.peekFirst().value > player2.peekFirst().value) {
- //System.err.println("Player 1 wins Battle with " + player1.peekFirst().value+">"+player2.peekFirst().value);
- for (int j = 0; j < pot1.size(); j++) {
- player1.addLast(pot1.removeFirst());
- }
- player1.addLast(player1.removeFirst());
- for (int j = 0; j < pot2.size(); j++) {
- player1.addLast(pot2.removeFirst());
- }
- player1.addLast(player2.removeFirst());
- } else {
- //System.err.println("Player 2 wins Battle with " + player1.peekFirst().value+"<"+player2.peekFirst().value);
- for (int j = 0; j < pot1.size(); j++) {
- player2.addLast(pot1.removeFirst());
- }
- player2.addLast(player1.removeFirst());
- for (int j = 0; j < pot2.size(); j++) {
- player2.addLast(pot2.removeFirst());
- }
- player2.addLast(player2.removeFirst());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement