Creating a card based, turn based RPG

Hello community!

I’ve been delving into the Unreal Engine and C++ for a couple of months now and I’m thinking up an RPG game with a turnbased battle system, but using randomly spawned cards to use as the attacks. Sadly I am unable to find any resources on creating such a game.

I have been able to make a widget blueprint that, on start, rolls numbers 1-7 for 3 variables, attack power, defense power, and a general card type. According to the number that’s rolled, it turns an image corresponding to that number visible, so that you would always have a random card with 3 variables that show visibly on the card. I’m not very knowledgable on everything yet, but how would I now store that data for the card, so it can be used in further calculations when the actual fighting happens. There will always be a max of 5 cards, so if say 3 characters would all use a card, after the turn is done, it will spawn 3 new cards in the next round.

I hope someone can help me and point me into some direction I can delve further into.

I think what you’re looking for is a Struct, which would represent a rolled card. A Struct will allow you to create a data structure for a randomly generated card, with variables of any type.

From the details you provided, here are some of my thoughts on how you would implement this:

  • Attack and defense power would be represented by floats or integers in your struct. The card type would likely be a Enum.

  • The player’s hand could be represented by an array of those Card structs, and then you can pass the struct to whatever functions you want to calculate the results of playing that card.

  • You may want to change to a setup where the struct is generated by the player/character, and then passed to your widget blueprint, which simply displays the information according to the card struct.

Here’s a tutorial that’s related to melee combat, but in the “Creating Structure DamageInfo” section, Ali covers how to make a struct and DamageType enum, very similar to what I mentioned here. Though it’s not a card based RPG, this should help you get going in the right direction. He also covers Interfaces, which are a great tool for keeping your code clean.

Good Luck!

Thank you very much for the response and thinking along with me. I’m going to look into this, looks perfect for what I’m looking for!