# Card-based skill checks

I think so–this takes a bit more trickery because we can’t just repeat through the cards, but we can assign places to the cards when we redraw and then use those places to list them (or dashes, if there’s nothing in the place).

Assigning places:

``````A card has a number called the hand order.

Carry out redrawing:
now every card is in the discard;
now every card is unwritten;
repeat with N running from 1 to the focus of the player:
if there is a card (called the draw) in the discard:
initialize the draw;
now the player has the draw;
now the hand order of the draw is N; [new!]
otherwise:
say "The discard has been exhausted.";
break. [this stops the loop so the message doesn't repeat--not that it should be possible to get here anyway!]
``````

Listing:

``````Ordering relates a card (called X) to a number (called Y) when the hand order of X is Y. The verb to be ordered in means the ordering relation.

To say abbreviated description of the player's hand:
repeat with index running from 1 to the focus of the player:
if the player has a card (called flop) that is ordered in the index:
say "[rank of flop as an abbreviated card name] [abbreviation of suit of flop] ";
otherwise:
say "-- ".
``````

I feel like there should be some less roundabout way to check whether the player has a card with hand order index other than by defining a new relation, but I couldn’t think of one.

Oh OK! I get the logic now–I think there was some trickery with the command prompt that was confusing me, but that might be due to my changes too.

Also I think my “every turn” logic isn’t quite working. Probably what would work better than “every turn” is to put the check for whether you beat the spider in the carry out playing rules, and maybe change the report playing rules to report whether the spider is defeated.

Yes, adding an adjective to things to prevent disambiguation loops is very useful!

I see, that’s where I introduced the bug!

I just finished patching out all the tables with your new code! I did have to squish one bug:

``````	repeat with index running from 1 to (will of the player minus focus of the player):
say "- ".
``````

Originally it was focus of the player minus the cards held by the player, which just added a dash mark every time a card was played and reset them all at the end. I think this was just a typo, because will of the player minus focus of the player got exactly what I was looking for. Cards and spider AI are both working, so now I can move onto the upper floor and figuring out how to make logic puzzles.

EDIT: I went ahead and made Matt W’s last post the solution just to get this thread marked as solved, but really, the solution was cobbled together from like eight different posts, so thank you very much to everyone who helped me figure out this complex, multi-faceted system!

1 Like