Updated Tarot Question

Thank you to those who helped me with the coding of my final puzzle, especially the coding of Ryan Veeder. I am now trying to add images to the code. The code says:

To present a tarot challenge:
	repeat with leftovercard running through tarot cards enclosed by the location:
		remove leftovercard from play;
	let layout be a list of tarot cards;
	add the correct card to layout;
	let badcard1 be a random incorrect tarot card;
	add badcard1 to layout;
	let badcard2 be a random incorrect tarot card;
	add badcard2 to layout;
	sort layout in random order;
	repeat with newcard running through layout:
		now newcard is in the location;
	say "The gypsy places [the list of visible tarot cards] before you and tells you to pick the right one.";

Each of the image entries is coded this way:

figure of image Eight of Cups is in the file Cups08.jpg.
figure of image Nine of Cups is in the file Cups09.jpg.
figure of image Ten of Cups is in the file Cups10.jpg.

what needs to be added to the first code above would look like:

display the figure of image printed name of correct card;
display the figure of image printed name of bardcard1;
display the figure of image printed name of bardcard2;

Which does not work. Other things that I tried that did not work:

display the figure of image correct card;

which obviously won’t work because this isn’t the name of the image

display the figure of image "[printed name of correct card]"

Did not work, either.

Any help would be appreciated, as always. Thank you!

I think you might need to do something like this- although it’s a bit repetitive with 78 cards to assign picture files to:

Figure of Ace of Cups is the file "Ace of Cups.jpg".
Figure of Two of Cups is the file "Two of Cups.jpg".

A card is a kind of thing. A card has a figure name called picture.
The Ace of Cups and the Two of Cups are cards carried by the player.
The picture of the Ace of Cups is Figure of Ace of Cups.
The picture of the Two of Cups is Figure of Two of Cups.
After examining a card:
	display the picture of the noun.
1 Like

Thank you for the suggestion. I was unable to get it to work, but it at least ruled out another way of solving the problem. Thank you!

The key is that ā€œfigure of ___ā€ isn’t a phrase, it’s the name of a value. Peter’s suggestion of making the figure a property of the thing is the best way to do this.

3 Likes

It works for me exactly as presented here…

Note that it’s Figure of Ace of Cups is the file "Ace of Cups.jpg" not Figure of Ace of Cups is in the file ā€œAce of Cups.jpgā€.

Also, as Daniel mentioned Figure... (in this case Figure of Ace of Cups) is, in its entirety, a name and could in fact be any arbitrary name unrelated to the name of the card or the name of the file, except that it has to start with Figure.

So you could, if you wanted, write:

Figure 1 is the file "Ace of Cups.jpg".
Figure 2 is the file "Two of Cups.jpg".

The picture of Ace of Cups is Figure 1.
The picture of Two of Cups is Figure 2.

etc.
etc.
3 Likes

Wouldn’t be the first time I was wrong. Here’s what I typed:

The Ace of Cups is a tarot card.  The picture of Ace of Cups is figure of Ace of Cups.

The Two of Cups is a tarot card. The picture of Two of Cups is figure of the Two of Cups.

and also

A tarot card is a kind of thing.  A tarot card has a figure name called picture

If I try to compile just these three changes I get the error message:

In the sentence ā€˜The picture of Ace of Cups is figure of Ace of Cups’, it looks as if you intend ā€˜The picture of Ace of Cups is figure of Ace of Cups’ to be asserting something, but that tries to set the value of the ā€˜picture’ property to a tarot card - which must be wrong because this property has to be a figure name.

I also shortened the figure entry to what you described:

figure Ace of Cups is the file "Cups01.jpg".
figure Two of Cups is the file "Cups02.jpg".

I’m sure it’s just my learning to code is the issue but I can’t see why code (as least the first two changes) isn’t working when yours is.

figure of Ace of Cups is the file ā€œCups01.jpgā€.

to match

The picture of Ace of Cups is figure of Ace of Cups.

(or miss out ā€˜of’ in both of them)

1 Like

And as usual I was incorrect. Your code worked just fine once I got out of the way.

Now, based on your code, I made a couple of changes to the original code:

To present a tarot challenge:
	repeat with leftovercard running through tarot cards enclosed by the location:
		remove leftovercard from play;
	let layout be a list of tarot cards;
	add the correct card to layout;
	let badcard1 be a random incorrect tarot card;
	add badcard1 to layout;
	let badcard2 be a random incorrect tarot card;
	add badcard2 to layout;
	sort layout in random order;
	repeat with newcard running through layout:
		now newcard is in the location;
		silently try examining newcard;
	say "The gypsy places [the list of visible tarot cards] before you and tells you to pick the right one.";
	
instead of examining tarot card:
	 display the picture of the noun;

This works except the pictures of the tarot cards don’t appear in the same order as they are printed out The first picture is always the correct picture. I’m not seeing why this isn’t arranging them in the same order.

[the list of visible tarot cards] lists the cards in the location in the reverse order they were moved there, which ends up as being the reverse of their order in layout. Try

say "The gypsy places [layout] before you and tells you to pick the right one.";
1 Like

As an aside, the code as you have it could add the same random incorrect card twice to layout…

Yes, I have been trying to figure out how to code that but didn’t want to bother the community until I had absolutely tried everything.

The quick & dirty way to do it is to keep choosing a card until it’s different from the first badcard:

	let badcard2 be badcard1;
	while badcard2 is badcard1:
		now badcard2 is a random incorrect tarot card;
2 Likes