The Making of Fantasy Rampage


Idea by Trodoss

Code by Trodoss


The idea for this game came from a card game that I played with my kids for years -- a simplified card game like "War."  It is not as complex as most Team a.r.g. games (no complicated map compression, scrolling, etc. ) so it should be fairly simple to follow in the code.


The cards are implemented as a structure (see card_info.h).  The physical data is stored in a char array (card_info_data)


     #define CARD_INFO_SIZE

     struct CardInfo {

          char suit;

          char power;

          char img;

          char ability;

     };


The main attributes are "suit," "power," "img," and "ability."  In the basic version of the game, "power" (number on the card) and "img" (picture) are the most significant attributes.


The core mechanic of a card-based game is shuffling the deck.  This game implements a simple Fisher-Yates Algorithm for Array Shuffling (see: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle )


     void shuffle_deck() {

          for ( char a=DECK_SIZE-1; a> 0; a--) {

               char r = random(a+1);

               if (r != a) {

                    char temp = deck[a];

                    deck[a] = deck[r];

                    deck[r] = temp;

               }

          }

     }


Once the deck is shuffled, the computer player's AI will sort the cards in it's hand by power and will see if there is a card in play.

If there is a card in play and the computer player has a card with a power that is greater it will play it.

If the computer does not have a card with a power greater than what is in play it will play it's lowest power card.


The advanced version of the game uses the "suit" (elements) and abilities on certain cards to add some strategic elements to the game.  


Where could you go with the game if you were going to extend it?  With the remaining space it could add either more abilities to the cards.  I had toyed with the mechanic of having cards that could force the re-shuffle of the deck, look at the other player's hand, etc.  Maybe allow more than one monster to be played.  Keeping game balance (a fair, playable game) when adding features is always a challenge.  In that way it has actually been a little challenging to make this game.  Hopefully you enjoy playing it.