Splinterverse wrote:Anyone know a good example of repeating/parity being used to iterate through a library? Or, does anyone have a good breakdown of how repeating/parity works . . . like a template? I get confused when I look at those blocks on what goes where and what things are pretty much constants.
Edit: I'd like to have a deeper understanding of the technique for all cards, but the example I cited is from
Dichotomancy.
Repeating actions are sort of like loops in that the block is executed again and again until you return false. It also has a loop counter that you can get by calling MTG():GetActionRepCount(). Parity is just an artificial construct that is used to separate the action into a pre-/post-phase (since certain commands will end an action and have to be checked afterwards, like asking the user a question, searching for a card, etc...). Parity is essentially doubling (or tripling) the number of iterations in the repeating action loop.
For example you need to ask all players to select a card. Since we can't ask all players at once we need to ask them one at a time and since each selection ends the action and we don't necessarily know before hand how many players are in the match we use a repeating action to ask the first player to select a card (iteration 0, parity 0), we store the first player's selection (iteration 1, parity 1), we ask the second player (iteration 2 parity 0), store the second player's choice (iteration 3 parity 1), up to the number of players in the match (n). Then on iteration 2*n (parity 0) we don't have a valid player pointer and we end the repeating action.
For
Dichotomancy you would probably first evaluate a filter to capture what needs to be searched for store off that number then do 2 * that number of iterations through a repeating action to have the player search for each card and store those results in a separate chest, then as a final action loop through that chest and put all the valid card pointers into play.