[Trigger] Deckbuilder Shuffle Trigger - HELP!

Status
Not open for further replies.
Level 1
Joined
Nov 3, 2012
Messages
1
Hey everyone, I've been trying to work this out for days but to no avail!! Please help!

I am trying to build a deckbuilder (think games like Dominion etc) where each player has a deck of cards that they can draw. Once their deck has "run out" they shuffle their "discard pile" and that becomes their new deck.

The problem is detecting what cards they are currently holding so they don't redraw them as the new pool of cards to draw from should only be cards they've played / discarded previously.

Any help or ideas would be appreciated.


[INIT] - "Setting up my variables"
EVENTS : Map initialization
  • Set P1_DeckSize = 6
  • Set P1_DeckRemaining = 6
  • Set P1_Decklist[1] = Claws of Attack +15
  • Set P1_Decklist[2] = Crown of Kings +5
  • Set P1_Decklist[3] = Kelen's Dagger of Escape
  • Set P1_Decklist[4] = Mask of Death
  • Set P1_Decklist[5] = Orb of Frost
  • Set P1_Decklist[6] = Ring of Protection +5
[Draw] - "The draw ability"
EVENTS : Player types a chat message containing DRAW
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • P1_DeckRemaining Greater than 0
    • Then - Actions
      • Set P1_DeckCardIndex = (Random integer number between 1 and P1_DeckRemaining)
      • Set P1_CardChosen = P1_Decklist[P1_DeckCardIndex]
      • -------- --------
      • Set P1_Decklist[P1_DeckCardIndex] = P1_Decklist[P1_DeckRemaining]
      • Set P1_Decklist[P1_DeckRemaining] = P1_CardChosen
      • -------- --------
      • Set P1_DeckRemaining = (P1_DeckRemaining - 1)
      • Hero - Create P1_CardChosen and give it to Paladin 0000 <gen>
    • Else - Actions
      • Trigger - Run Shuffle Discard <gen> (checking conditions)
[Shuffle Discard] - "Shuffling the discard deck to become the new deck, and detecting held cards so as to remove them from the pool of cards
  • Set P1_DeckRemaining = P1_DeckSize
  • For each (Integer A) from 1 to 6, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to P1_DeckSize, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Paladin 0000 <gen> in slot (Integer A))) Equal to P1_Decklist[(Integer B)]
            • Then - Actions
              • Set P1_CardChosen = P1_Decklist[(Integer B)]
              • -------- --------
              • Set P1_Decklist[(Integer B)] = P1_Decklist[P1_DeckRemaining]
              • Set P1_Decklist[P1_DeckRemaining] = P1_CardChosen
              • -------- --------
              • Set P1_DeckRemaining = (P1_DeckRemaining - 1)
            • Else - Actions
 
How would it work out to add a boolean-array which detects if a card was played? Just sort it the same way as the card position in the array and mark it everytime as true if a card is drawn and false if it left the hand. Currently, thew trigger throws all card out which shares a card type with the held card. This can work out, if you only allow unique cards, but sometimes it don't.

Above this, i would highly recomment using a hashtable instead of an array or turn it into a 2d one (the last option only if you have a max cap of cards a player can have, else it can get quite messy). With this, you don't have to redo all the triggers with players beyond player 1, since you can use a child value for each player.
 
Last edited:
Status
Not open for further replies.
Top