The Duel Of Creatures (A trading card game in C++)


 A few days back I've been to my grandma's house for the Christmas vacation! Just when I was feeling quite bored with nothing to do, I stumbled upon the idea of creating a card game which is based on many famous card games like 'Yu-gi-oh', 'Duel masters' and 'Duels of order and chaos'. I had an idea of creating such a game for a long time, but I haven't taken the time to develop one. It might be due to the reason that my cousin brother who lives at my grandma's house because he plays these kinds of games. This might have triggered an interest in me to create the game and make him play.

   Coming to the game it's a CUI(Character user interface) game and I've developed it using C++. This is a turn-based card strategy game. For people who don't know these kinds of games, here's a simple (and non-comprehensive) explanation.
  • Each player has a deck which has a certain number(20 in my game) of cards.
  • Each card represents a creature which has a certain amount of attack(atk), defence(def) and health(hlt).
  • Apart from these cards, each player has a hero card which acts like the king piece in a game of chess.
  • And presumably, the first person to make the opponent hero card's health zero is the winner.
   Now, let me explain how the stats(statistics i.e, attack, defence and health) of a certain card are determined. The cards are divided into four types, namely bronze silver, gold and hero. As their names suggest, bronze cards have low stats while gold have high and silver have medium stats. Hero card has the maximum base stats as they are the most vital card for a player. Here's the table which shows the ranges of various stats of different types of cards.


CARD TYPE ATK RANGE DEF RANGE HLT RANGE
BRONZE 1-4 1-2 6-10
SILVER 5-8 3-4 16-20
GOLD 9-12 5-6 26-30
HERO 15-18 11-12 51-55

   It must be noted that the stats of any card are randomised between the given above ranges.For example, a silver card can have 7 atk, 3 def and 19 hlt while another silver card might have 5 atk, 4 def and 16 hlt. It must also be noted that every player gets exactly 21 cards which are 5 bronze cards, 10 silver cards, 5 gold cards and 1 hero card. There are more of silver cards as they increase the fun of the game by making it last longer. I have no statistical evidence to prove my previous statement. Those were the words straight out of the mouth of my cousin.

   I thought it was quite boring for all players having the same stats for the hero card, so I have introduced 4 different classes,  which mainly affect the stats of the hero card and also all other cards of a player. Every player gets to choose the class of his hero before starting a game. the four classes and their effects are mentioned in the below table.

CLASS TYPE HERO STATS OTHER EFFECTS
WARRIOR +10 ATK, -4 DEF +2 ATK FOR ALL THE CARDS
GOLLUM -6 ATK, +8 DEF +4 DEF FOR ALL THE CARDS
ELF +20 HLT +5 HLT FOR ALL THE CARDS
WIZARD NONE +3 HERO MANA* EVERY ROUND &
+1 ADDITIONAL MANA EVERY 5 ROUNDS
*Mana is the cost required to use a card. It is explained further in the post.

   So the class type and card type are the factors which decide the stats of a card. For example, if you have a hero card of the following stats 16 atk, 11 def and 51 hlt. If you choose your class as an elf then your resultant hero card would have 16 atk, 11 def and 71 hlt. I hope you get the idea.

   You might have seen the word mana used in the previous table. It's simply the cost required to use a card. Well, let me explain a little more in detail. Duel of creatures is a turn based game. At the beginning of the game, the 20 cards are shuffled and placed into the deck of the player. Then 6 cards are drawn out of the deck and placed in player's hand. Now the player has to choose which cards he would like to place into your battlefield slots. Here's a picture to help you understand better.


   So as you could see, you have 14 cards left in the deck(see the yellow circle) and the remaining 6 cards that are present in your hand are displayed at the bottom. For each card, a cost is mentioned. This is the amount of mana you'd require to place the card in one of your empty battlefield slots. The amount of mana you have is also mentioned(see the green circle). Now if you don't have enough mana to place any card, you must wait till your next turn so that mana gets refilled. A bronze card would cost 3 mana, silver would cost you 5 and gold would cost 7 mana. Moving on, when a card is placed on the battlefield, it must wait for 1 turn(i.e, completion of a single opponent's turn) before it can start attacking. If there is no opponent's card in the opposite slot to your card, then the damage is done to the hero. If not, then the damage is taken by the card in the opposite slot to your card. So you must strategically place cards in order to defend your hero and keep it alive.

   It must be noted that at the end of each round, your hand gets refilled so that it always has 6 cards. If you don't have any cards left in the deck, it results in damaging the health of your hero(this is also known as the out of cards damage). Therefore you must use your cards wisely and not run out of them which might affect your hero and ultimately cost you the game.

   One last exciting thing in the game is the Hero attack! Hero attack is the attack done by the hero and it can be done on anyone of your opponent's card on the battlefield including your opponent's hero card. In order to do a hero attack, you must have 10 hero mana. Every round you get +2 hero mana and +3 if your hero is of wizard class(If hope now you get the advantage of being a wizard). This means you could use hero attack, once every 5 rounds. Hero attack is very decisive as heroes generally have high attack stats.

   This is about the game. I hope you at least got a vague idea about the game. Apart from the game, I've implemented for the first time music in my program and it's quite amazing I'd say. Here's a small video of the game



I hope you enjoyed it! If you want to have a look at the code, here's the link to the file of the total project that I've developed using visual studio. If you have visual studio, paste the project directly into your project directory and build it. link: project file (click to open)

If you're not using visual studio, try to make changes to the code appropriately if you wanna play the game :). Here's the code in the text file(nearly 1100 lines!): text file (click to open). Make sure to change the address of music file in play_sound() function at the beginning of the program.

Comments

Popular posts from this blog

Beginner's guide to Solving the N-Queens problem using backtracking method

PvP Chain reaction game using Python

Guide to Solving Maximal Subarray Problem using Kadane's Algorithm