Your task is to create a simplified version of card game “BANG” in Javascript…
- User
Your task is to create a simplified version of card game “BANG” in Javascript
Introduction to the game: The players are in the wild west, and since this is a simplified version of the game, they all fight against each other. In our simplified version of the game, we have neither characters nor weapons and also we don’t have many other cards from the original game.
Goal of the game: Be the last one alive.
Game preparation: The game can be played by 2-4 players. Each player starts with 4 cards from the deck and starts with 4 lives. The upper number of lives is not limited. Players play sequentially in a row. Each player's turn is divided into 3 parts:
- Drawing cards - at the beginning of his turn, the given player draws 2 cards from the deck. If he has blue cards (Prison, Dynamite) in front of him, their effect is excecuted as first.
- Playing cards - the player can play any number of cards during his turn, but he does not have to play any.
- Discarding excess cards - a player can only have as many cards in his hand as he has lives at the end of his turn.
Bang and Missed Bang cards are the main way to reduce the health of your opponents. In our simplified version of the game, you can play an unlimited number of these cards during your turn.
If you are a target of a Bang card, you can immediately play a card Missed to discard the effect of the Bang card, if you don't have one, you lose a life. If you lose all lives, you are out of the game.
An example of a move in our simplified version of the game: Player A plays a Bang card to Player B, Player B automatically checks if he has a card Missed on hand, if he has such a card, the card is automatically played, if he does not have, he loses a life.
- Assistant
Task:
- Create a deck of cards consisting of Bang cards, Missed cards, Prison cards and Dynamite cards.
- Create an array to keep track of each player’s lives.
- Create a function to shuffle the deck of cards.
- Create a function to distribute 4 cards to each player at the beginning of the game.
- Create a function to draw 2 cards from the deck at the beginning of each player’s turn.
- Create a function to execute the effects of the blue cards (Prison and Dynamite) if they are present in a player’s hand.
- Create a function to play a Bang card on an opponent and check if the opponent has a Missed card to nullify its effect.
- Create a function to switch to the next player after a player’s turn is finished.
- Create a function to discard excess cards from a player’s hand at the end of their turn.
Note: This is a simplified version of the game, so certain cards and mechanics from the original game are not present. Also, the game can be expanded upon by adding more card types and abilities.
- User
write a code using task
- Assistant