Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making a TCG

Discussion in 'General Discussion' started by Aazadan, May 18, 2015.

  1. Aazadan

    Aazadan

    Joined:
    Jun 21, 2014
    Posts:
    14
    I have about 1.5 years experience with Unity at this point, I've built a whole bunch of games from tutorials, made a few on my own from scratch, and completed a few Ludum Dare Compo's with it. I'm looking at doing something a bit more complex next and have settled on a tcg style game (Magic, Hearthstone, etc). I have most of my initial game rules and card sketched out at this point and it's time to start building it.

    I think I've answered most of my initial build questions and I know how I'm going to go about it but one part is still nagging at me and I thought I would ask some more experienced people for suggestions. Different cards are going to have different abilities, one card may be unblockable if the opponent controls a specific card, or another card may give all of my creatures a passive bonus. I need to come up with a scripting system that can handle 200+ unique cards that can also be easily expanded in the future.

    Right now I have two solutions, and perhaps others have more.
    Solution #1 - I break down effects into their simplest components and each card is tagged in the card database as having these simple components active or inactive and more complicated effects are brought about as a combination of these simple abilities. This solution is creates exponential expansion of my possible card effects for each ability I add, and is easy to scale up. However it makes cards feel a bit more generic.

    Solution #2 - I program a script for each cards more complicated behavior and then attach them to my card prefabs. This solution gives me more control over how each card acts but requires some extensive code support. Every single card before it can be tested or used must first be programmed and debugged. I am also worried that this eventually leads to too many scripts as a 1000 count card pool means I now have 1000 scripts to organize and manage.

    Are there any other options I may be overlooking?
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Look at how a real TCG does it. Magic is a great example. But the same type of thing can be seen from Pokemon to Net Runner.

    Cards have types. The card type defines how and when it plays. At a quick glance a player knows the difference between an instant, a sorcery, a land and a creature. Cards also have key words, like flying or plains walker or wall. Cards also have consistent stats.

    Between the type, key words, and stats, most of a cards behaviour is defined. These things would be represented as generic components that can be mixed and matched across cards as you would like.

    The final mechanical element on traditional TCG cards is text. This text is where the uniqueness of the card comes in. This would probably have to be a hand crafted component for each card. But note that in a TCG, many cards don't actually have text.
     
  3. delinx32

    delinx32

    Joined:
    Apr 20, 2012
    Posts:
    417
    I once took a crack at making a computerized magic interface (before the actual computerized magic interface existed, whose existence killed my enthusiasm for my own implementation). Good thing, because I'd probably still be programming all the new stupid rules.

    Don't think of cards as having abilities. Think of abilities as standing alone. Each card has a List<Ability>. Then you can "Abilities.OrderBy(x => x.ResolveOrder).Resolve(_target);" Each abilities "Resolve" method could evaluate the List on the target and examine for abilities that counter its own ability, or are modified in some way by its ability.

    This also gives you the ability to add temporary abilities to the list and remove them during the resolve phase if they're temporaryness has expired.

    Now you could simply have an xml/json file that stores all the basic abilities, but more difficult ones may require a specialized script to do the processing.

    So as BoredMorman said "Flying", "Haste", et al would all be individual abilities, and a card would contain those abilities in its collection. Again, you can define the card library with xml/json and store which abilities the cards have and load them when you load the library.

    You may need more than one resolve, ie (ResolvePreCombat, ResolveBlock, ResolveCombat, ResolvePostCombat, etc) depending on your game's flow.

    In this manner, even something as basic as "attack" just becomes another ability that is resolved during the combat phase.
     
    Kiwasi likes this.
  4. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @BoredMormon I know I'm in the minority here, but my favorite (mechanically / rules) TCG is duel masters. Worst name ever, worst tv series ever, but the mechanics for mana are genius.

    Magic mana - land cards... a specialized card, RNG for some will provide a very sad game
    DM mana - A card placed into your mana pool will become mana of its type

    I'm 50/50 on the shield setup. It's interesting that monsters no matter how strong they are deal the same amount of 'damage'. The game makes it work with blockers and those R monsters who can do nothing but attack tapped monsters.
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    My favourite is Dominion. But that's for the deck building mechanic, not the TCG mechanic. I'm not really a huge fan of TCGs anymore after spending hundreds (thousands?) of dollars on the games as a teenager.
     
    zombiegorilla likes this.
  6. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Tabletop simulator. They have magic the gathering, munchkin, cards against humanity, etc.
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Never been a huge fan of board / card games on a PC. If I'm going to play games designed for ultra low spec machines, I want the full raft of social gaming features that come with it. I want to be able to stare into your eyes as I crush you in chess. I want to hear you groan as I play a thirty card turn in Dominion. I want to hear the pleading note in your voice as I hold onto the only source of brick in Settlers. I want to laugh as I seduce you with the alluring kneepads in Munchkin. (That said feeling the spit from your breath attack in Rampage is probably taking it a little too far).

    If I'm playing on a computer I want a game that uses the power of the machine I'm sitting on. Lets face it, the graphics in Munchkin suck when put against any PC title.

    Its like casual games belong on mobiles, action games belong on consoles, complex simulations belong on PCs. And table top games belong on a table top.
     
    Tomnnn likes this.
  8. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I agree with that for the most part. I've seen table top-esque games done really well on pc. It was more like making contextual decisions with a bunch of other systems around it instead of dragging pieces around. I like when the rules are enforced by the environment.
     
  9. derf

    derf

    Joined:
    Aug 14, 2011
    Posts:
    354
    I would use an abstract class, maybe inheriting from an interface where the card methods would be established but not implemented yet.
     
    Last edited: May 18, 2015
  10. Aazadan

    Aazadan

    Joined:
    Jun 21, 2014
    Posts:
    14
    I'm not talking about card types. In Magic terms what I would be referring to is effects like Infect/Wither which deal an alternate form of damage or Landwalk which makes a card conditionally unable to be blocked. Effects which would be passive but change how the card behaves. Obviously I don't want many of these in the initial pass of the game, but what I'm curious about is the architecture behind how I make such things because it's possible that one day in the future there will be a lot of these cards. Basically like you said, the text part. The goal is to be able to make those quickly because in the future I don't want to have to program a card before I can test a card that just seems like asking for trouble.

    This makes some sense but how would such a system resolve passive abilities? Would I just want to call/resolve it through every pass? Using my test cases above, an alternative form of damage seems like something I would have to hardcode, and specifically check for while doing combat damage. I suppose that just seems inelegant.

    This on the other hand makes a lot of sense. Thanks.
     
  11. delinx32

    delinx32

    Joined:
    Apr 20, 2012
    Posts:
    417

    In the case of a passive that modifies an attribute (strength, etc) you could resolve it during the main phase and add a value to the card's base strength for the duration of the round, or maybe you can add an "onadded" method that resolves when the ability is added to the target, and an "onremoved" that resets the strength when it is dispelled/expired.

    In the case of something that adds resistance or some other type of passive, you could add a return type to resolve that specifies whether or not the loop can continue.

    So lets say you have one ability "attack" and the opposing card has "flying" on the stack. Flying would return false if the attack can't hit flying and the loop would break the minute flying is resolved on the opponent.

    Now say you have "ranged" and "attack". Ranged would resolve before attack and bypass flying (maybe it sets a state variable on "flying" to false for the duration of the resolution) and the attack would then resolve. Since flying has already been deactivated due to ranged, the attack gets through.
     
  12. derf

    derf

    Joined:
    Aug 14, 2011
    Posts:
    354
    Would be better to make passive abilities an enumerated list so cards could have more than one passive ability for those rare cards.