Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * Main Program
- CTL START
- * Declare variables
- DATA PLAYER_1, PLAYER_2
- DATA PLAYER_1_LIFE, PLAYER_2_LIFE
- DATA PLAYER_1_HAND, PLAYER_2_HAND
- DATA PLAYER_1_BOARD, PLAYER_2_BOARD
- DATA TURN_NUMBER
- BEGIN
- * Initialize variables
- PLAYER_1_LIFE SET 20
- PLAYER_2_LIFE SET 20
- TURN_NUMBER SET 1
- * Deal starting hands
- DEAL 5, PLAYER_1_HAND
- DEAL 5, PLAYER_2_HAND
- * Main game loop
- LOOP
- * Alternate turns between players
- TURN_NUMBER SET TURN_NUMBER + 1
- IF TURN_NUMBER % 2 == 1 THEN
- PLAYER_1 SET ACTIVE_PLAYER
- PLAYER_2 SET INACTIVE_PLAYER
- ELSE
- PLAYER_1 SET INACTIVE_PLAYER
- PLAYER_2 SET ACTIVE_PLAYER
- END
- * Display active player's hand
- PRINT ACTIVE_PLAYER + "'s hand: " + ACTIVE_PLAYER_HAND
- * Prompt active player to play a card
- PROMPT "Enter the number of the card you want to play: "
- INPUT CARD_NUMBER
- * Play the selected card
- PLAY CARD_NUMBER, ACTIVE_PLAYER_BOARD
- * Check for end of game
- IF INACTIVE_PLAYER_LIFE <= 0 THEN
- PRINT ACTIVE_PLAYER + " wins!"
- BREAK
- END
- END
- END
- * Subroutines
- * Deal cards from deck to player's hand
- DEAL NUMBER_OF_CARDS, PLAYER_HAND
- FOR I FROM 1 TO NUMBER_OF_CARDS
- * Draw a random card from the deck
- CARD SET DRAW_CARD()
- * Add the card to the player's hand
- PLAYER_HAND ADD CARD
- END
- END
- * Play a card from a player's hand
- PLAY CARD_NUMBER, PLAYER_BOARD
- * Remove the selected card from the player's hand
- CARD SET PLAYER_HAND[CARD_NUMBER]
- PLAYER_HAND REMOVE CARD_NUMBER
- * Add the selected card to the player's board
- PLAYER_BOARD ADD CARD
- END
- * Draw a random card from the deck
- DRAW_CARD()
- * Generate a random number between 1 and the number of cards in the deck
- CARD_NUMBER SET RANDOM(1, DECK_SIZE)
- * Return the selected card
- RETURN DECK[CARD_NUMBER]
- END
Advertisement
Comments
-
- rwtyjtsgxsnhjytxwz
-
- frstsghystrna bt
-
- * Main Program
- CTL START
- * Declare variables
- DATA PLAYER_1, PLAYER_2
- DATA PLAYER_1_LIFE, PLAYER_2_LIFE
- DATA PLAYER_1_HAND, PLAYER_2_HAND
- DATA PLAYER_1_BOARD, PLAYER_2_BOARD
- DATA TURN_NUMBER
- BEGIN
- * Initialize variables
- PLAYER_1_LIFE SET 20
- PLAYER_2_LIFE SET 20
- TURN_NUMBER SET 1
- * Deal starting hands
- DEAL 5, PLAYER_1_HAND
- DEAL 5, PLAYER_2_HAND
- * Main game loop
- LOOP
- * Alternate turns between players
- TURN_NUMBER SET TURN_NUMBER + 1
- IF TURN_NUMBER % 2 == 1 THEN
- PLAYER_1 SET ACTIVE_PLAYER
- PLAYER_2 SET INACTIVE_PLAYER
- ELSE
- PLAYER_1 SET INACTIVE_PLAYER
- PLAYER_2 SET ACTIVE_PLAYER
- END
- * Display active player's hand
- PRINT ACTIVE_PLAYER + "'s hand: " + ACTIVE_PLAYER_HAND
- * Prompt active player to play a card
- PROMPT "Enter the number of the card you want to play: "
- INPUT CARD_NUMBER
- * Play the selected card
- PLAY CARD_NUMBER, ACTIVE_PLAYER_BOARD
- * Check for end of game
- IF INACTIVE_PLAYER_LIFE <= 0 THEN
- PRINT ACTIVE_PLAYER + " wins!"
- BREAK
- END
- END
- END
- * Subroutines
- * Deal cards from deck to player's hand
- DEAL NUMBER_OF_CARDS, PLAYER_HAND
- FOR I FROM 1 TO NUMBER_OF_CARDS
- * Draw a random card from the deck
- CARD SET DRAW_CARD()
- * Add the card to the player's hand
- PLAYER_HAND ADD CARD
- END
- END
- * Play a card from a player's hand
- PLAY CARD_NUMBER, PLAYER_BOARD
- * Remove the selected card from the player's hand
- CARD SET PLAYER_HAND[CARD_NUMBER]
- PLAYER_HAND REMOVE CARD_NUMBER
- * Add the selected card to the player's board
- PLAYER_BOARD ADD CARD
- END
- * Draw a random card from the deck
- DRAW_CARD()
- * Generate a random number between 1 and the number of cards in the deck
- CARD_NUMBER SET RANDOM(1, DECK_SIZE)
- * Return the selected card
- RETURN DECK[CARD_NUMBER]
Add Comment
Please, Sign In to add comment
Advertisement