Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.12 KB | None | 0 0
  1. void
  2. tick_B(gamestate_t* gs)
  3. {
  4.     bool added_cards_1to2 = false;
  5.     bool added_cards_2to1 = false;
  6.     cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  7.     cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  8.     gs->move_count += 1;
  9.     while (get_war_status(gs->stack1, gs->stack2) == war_pending) {
  10.         if (gs->h1->size == 0) {
  11.             if (added_cards_2to1 || gs->h2->size < 4) {
  12.                 gs->status = game_player2_win;
  13.                 return;
  14.             }
  15.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack1);
  16.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack1);
  17.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  18.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  19.             added_cards_2to1 = true;
  20.         } else if (gs->h2->size == 0) {
  21.             if (added_cards_1to2 || gs->h1->size < 4) {
  22.                 gs->status = game_player1_win;
  23.                 return;
  24.             }
  25.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack2);
  26.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack2);
  27.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  28.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  29.             added_cards_1to2 = true;
  30.         } else if (gs->h1->size == 1) {
  31.             if (added_cards_2to1 || gs->h2->size < 3) {
  32.                 gs->status = game_player2_win;
  33.                 return;
  34.             }
  35.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  36.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  37.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack1);
  38.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  39.             added_cards_2to1 = true;
  40.  
  41.         } else if (gs->h2->size == 1) {
  42.             if (added_cards_1to2 || gs->h1->size < 3) {
  43.                 gs->status = game_player1_win;
  44.                 return;
  45.             }
  46.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  47.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  48.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack2);
  49.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  50.             added_cards_1to2 = true;
  51.         } else {
  52.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  53.             cardstack_push_bottom(hand_pop_top(gs->h1), gs->stack1);
  54.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  55.             cardstack_push_bottom(hand_pop_top(gs->h2), gs->stack2);
  56.         }
  57.         gs->move_count += 2;
  58.     }
  59.     if (get_war_status(gs->stack1, gs->stack2) == war_player1_won) {
  60.         if (gs->h2->size == 0) {
  61.             gs->status = game_player1_win;
  62.             return;
  63.         }
  64.         gs->return_procedure(gs->stack1, gs->stack2, gs->h1);
  65.     }
  66.     if (get_war_status(gs->stack1, gs->stack2) == war_player2_won) {
  67.         if (gs->h1->size == 0) {
  68.             gs->status = game_player2_win;
  69.             return;
  70.         }
  71.         gs->return_procedure(gs->stack2, gs->stack1, gs->h2);
  72.     }
  73.     return;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement