Advertisement
matthewdeanmartin

fictional language magic

Dec 26th, 2022
2,276
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.95 KB | None | 0 0
  1. * Main Program
  2.   CTL  START
  3. * Declare variables
  4.   DATA  PLAYER_1, PLAYER_2
  5.   DATA  PLAYER_1_LIFE, PLAYER_2_LIFE
  6.   DATA  PLAYER_1_HAND, PLAYER_2_HAND
  7.   DATA  PLAYER_1_BOARD, PLAYER_2_BOARD
  8.   DATA  TURN_NUMBER
  9.   BEGIN
  10. * Initialize variables
  11.   PLAYER_1_LIFE  SET  20
  12.   PLAYER_2_LIFE  SET  20
  13.   TURN_NUMBER    SET  1
  14. * Deal starting hands
  15.   DEAL  5, PLAYER_1_HAND
  16.   DEAL  5, PLAYER_2_HAND
  17. * Main game loop
  18.   LOOP
  19.     * Alternate turns between players
  20.     TURN_NUMBER  SET  TURN_NUMBER + 1
  21.     IF  TURN_NUMBER % 2 == 1  THEN
  22.       PLAYER_1  SET  ACTIVE_PLAYER
  23.       PLAYER_2  SET  INACTIVE_PLAYER
  24.     ELSE
  25.       PLAYER_1  SET  INACTIVE_PLAYER
  26.       PLAYER_2  SET  ACTIVE_PLAYER
  27.     END
  28.     * Display active player's hand
  29.    PRINT  ACTIVE_PLAYER + "'s hand: " + ACTIVE_PLAYER_HAND
  30.    * Prompt active player to play a card
  31.    PROMPT  "Enter the number of the card you want to play: "
  32.    INPUT  CARD_NUMBER
  33.    * Play the selected card
  34.    PLAY  CARD_NUMBER, ACTIVE_PLAYER_BOARD
  35.    * Check for end of game
  36.    IF  INACTIVE_PLAYER_LIFE <= 0  THEN
  37.      PRINT  ACTIVE_PLAYER + " wins!"
  38.      BREAK
  39.    END
  40.  END
  41.  END
  42. * Subroutines
  43.  * Deal cards from deck to player's hand
  44.  DEAL  NUMBER_OF_CARDS, PLAYER_HAND
  45.    FOR  I  FROM  1  TO  NUMBER_OF_CARDS
  46.      * Draw a random card from the deck
  47.      CARD  SET  DRAW_CARD()
  48.      * Add the card to the player's hand
  49.      PLAYER_HAND  ADD  CARD
  50.    END
  51.  END
  52.  * Play a card from a player's hand
  53.  PLAY  CARD_NUMBER, PLAYER_BOARD
  54.    * Remove the selected card from the player's hand
  55.    CARD  SET  PLAYER_HAND[CARD_NUMBER]
  56.    PLAYER_HAND  REMOVE  CARD_NUMBER
  57.    * Add the selected card to the player's board
  58.    PLAYER_BOARD  ADD  CARD
  59.  END
  60.  * Draw a random card from the deck
  61.  DRAW_CARD()
  62.    * Generate a random number between 1 and the number of cards in the deck
  63.    CARD_NUMBER  SET  RANDOM(1, DECK_SIZE)
  64.    * Return the selected card
  65.    RETURN  DECK[CARD_NUMBER]
  66.  END
  67.  
Advertisement
Comments
  • 0650390084
    1 year
    # C# 0.02 KB | 0 0
    1. rwtyjtsgxsnhjytxwz
  • 0650390084
    1 year
    # text 0.02 KB | 0 0
    1. frstsghystrna bt
  • 0650390084
    1 year
    1. * Main Program
    2.   CTL  START
    3. * Declare variables
    4.   DATA  PLAYER_1, PLAYER_2
    5.   DATA  PLAYER_1_LIFE, PLAYER_2_LIFE
    6.   DATA  PLAYER_1_HAND, PLAYER_2_HAND
    7.   DATA  PLAYER_1_BOARD, PLAYER_2_BOARD
    8.   DATA  TURN_NUMBER
    9.   BEGIN
    10. * Initialize variables
    11.   PLAYER_1_LIFE  SET  20
    12.   PLAYER_2_LIFE  SET  20
    13.   TURN_NUMBER    SET  1
    14. * Deal starting hands
    15.   DEAL  5, PLAYER_1_HAND
    16.   DEAL  5, PLAYER_2_HAND
    17. * Main game loop
    18.   LOOP
    19.     * Alternate turns between players
    20.     TURN_NUMBER  SET  TURN_NUMBER + 1
    21.     IF  TURN_NUMBER % 2 == 1  THEN
    22.       PLAYER_1  SET  ACTIVE_PLAYER
    23.       PLAYER_2  SET  INACTIVE_PLAYER
    24.     ELSE
    25.       PLAYER_1  SET  INACTIVE_PLAYER
    26.       PLAYER_2  SET  ACTIVE_PLAYER
    27.     END
    28.     * Display active player's hand
    29.    PRINT  ACTIVE_PLAYER + "'s hand: " + ACTIVE_PLAYER_HAND
    30.    * Prompt active player to play a card
    31.    PROMPT  "Enter the number of the card you want to play: "
    32.    INPUT  CARD_NUMBER
    33.    * Play the selected card
    34.    PLAY  CARD_NUMBER, ACTIVE_PLAYER_BOARD
    35.    * Check for end of game
    36.    IF  INACTIVE_PLAYER_LIFE <= 0  THEN
    37.      PRINT  ACTIVE_PLAYER + " wins!"
    38.      BREAK
    39.    END
    40.  END
    41.  END
    42. * Subroutines
    43.  * Deal cards from deck to player's hand
    44.  DEAL  NUMBER_OF_CARDS, PLAYER_HAND
    45.    FOR  I  FROM  1  TO  NUMBER_OF_CARDS
    46.      * Draw a random card from the deck
    47.      CARD  SET  DRAW_CARD()
    48.      * Add the card to the player's hand
    49.      PLAYER_HAND  ADD  CARD
    50.    END
    51.  END
    52.  * Play a card from a player's hand
    53.  PLAY  CARD_NUMBER, PLAYER_BOARD
    54.    * Remove the selected card from the player's hand
    55.    CARD  SET  PLAYER_HAND[CARD_NUMBER]
    56.    PLAYER_HAND  REMOVE  CARD_NUMBER
    57.    * Add the selected card to the player's board
    58.    PLAYER_BOARD  ADD  CARD
    59.  END
    60.  * Draw a random card from the deck
    61.  DRAW_CARD()
    62.    * Generate a random number between 1 and the number of cards in the deck
    63.    CARD_NUMBER  SET  RANDOM(1, DECK_SIZE)
    64.    * Return the selected card
    65.    RETURN  DECK[CARD_NUMBER]
    66.  
Add Comment
Please, Sign In to add comment
Advertisement