Extending the Card Game Plugin

This forum is currently in read-only mode.
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • I really think there's a heavy interest in using Construct for developing card games.

    http://www.scirra.com/phpBB3/viewtopic.php?f=3&t=2244

    http://www.scirra.com/phpBB3/viewtopic.php?f=3&t=2264

    Perhaps a good question to ask is how the card game plugin could be extended to offer a higher level of support for making card games.

  • I think it is planned that the object be improved; the problem is how. I mean, we could hard-code in features for specific card games like poker, but then where do we stop? Should it be a library of all card games possible? How can it be made general enough to usefully apply to any card game?

  • Yeah, you don't want to have 20 different types of poker premade.

    Dunno perhaps a few tutorials would probably be better. Perhaps some more expressions for betting, players, and maybe "looseness"..? But that's all stuff you can do with loops, and variables.

  • If this is turning into a feature request thread, I'd like to throw out a few suggestions for discussion.

    • Action: return card to deck (card number). Append the parameter to the end of the list of not-yet-drawn cards. (Perhaps perform a sanity check and complain via the debugger if the parameter is on that list already? But what if multiple decks are implemented?) Useful for games where cards can be drawn but not actually put into play, e.g. Solitaire. Also for games where you occasionally need to shuffle the cards that have been played, but not the players' hands (Crazy 8s and its five hundred million variants spring to mind). Alternative: maintain two lists. The "draw pile" is what is called the "deck" in the current implementation; the "discard pile" is initially empty and can have specific cards added to it via an action. Another action appends the discard pile (maintaining the order) to the draw pile and clears the discard. Problem: sanity checks become even more complicated ("User wants to add card #15 to the discard pile, so if the number of cards #15 in the draw pile plus the number of cards #15 in the discard pile equals the number of decks in use, throw an error message on the debugger.")
    • Conditions: same rank (card number, card number), same suit (card number, card number). Return true if the two parameters refer to cards of the same rank or suit respectively. For bonus points, accept an arbitrary number of parameters and return true only if they all match.
    • For convenience and readability, add "suit" and "rank" expressions that basically do card%13 and floor(card/13) respectively. (Or (card%13)+1 and ceil(card/13), if you prefer to number the ranks and suits from 1 rather than 0).
    • Allow multiple decks. This probably shouldn't be runtime-editable because removing a deck in mid-air is messy and underdefined. A property "number of decks" that defaults to 1 seems more plausible. Also, I don't expect users to want to know which specific deck a card came from; so a "draw pile" with two decks could simply(?) have two copies each of the numbers 1..52.
    • As an alternative, ignore everything I said above and go for flexibility: have a property "number of cards" that can be set to an arbitrary number. Remove all the conditions and let the users calculate (or look up in an array) what each number means in card terms. This would open the object as a shuffling mechanism for games with non-standard deck sizes (CCGs, Tarock and many more), but make it slightly less convenient for actual traditional card games.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Allow multiple decks. This probably shouldn't be runtime-editable because removing a deck in mid-air is messy and underdefined. A property "number of decks" that defaults to 1 seems more plausible. Also, I don't expect users to want to know which specific deck a card came from; so a "draw pile" with two decks could simply(?) have two copies each of the numbers 1..52.

    Couldn't you just use separate Card Game objects?

  • Couldn't you just use separate Card Game objects?

    "Could", yes; but unless I'm missing something, "just" is a bit optimistic. Keeping separate decks would indeed be easy that way, but I'm assuming here usually a game that uses multiple decks would want them shuffled together into one big pile. You'd have to do something like:

    Check some flags to see which decks have cards left in them (and jump to the "No Cards Left" route if none have).

    Generate a random number between 1 and (number of remaining decks).

    Draw a random card from the chosen deck -- AFAICT there's no case switch statement and no way to pick an object based on the content of a variable, so this in itself is a whole christmas tree of ... I don't even know ... Compare events? Anyway, get that value and write it to a global variable; otherwise we'll have to write the deck-picking structure twice.

    If the card is "-1", that means the deck had no cards left after all: update the flags and start over. Otherwise, we're done.

    So, yeah, it's possible, but possible in a way that makes reimplementing the plugin in event code (or Python, once that's fixed) seem the easy option.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)