Hello.
I’m creating a card game. I have a problem with sorting cards in the deck view passage.
At the beginning I have some generic objects stored in the array.
<<set $s7 to {type: "s", num: 7, id: 107}>>
<<set $s8 to {type: "s", num: 8, id: 108}>>
<<set $s9 to {type: "s", num: 9, id: 109}>>
<<set $s10 to {type: "s", num: 10, id: 110}>>
<<set $deck to [$s7, $s8, $s9, $s10]>>
And some cards to find during the game
\<<set $a7 to {type: "a", num: 7, id:207}>>
\<<set $a8 to {type: "a", num: 8, id:208}>>
\<<set $a9 to {type: "a", num: 9, id:209}>>
\<<set $a10 to {type: "a", num: 10, id:210}>>
Then the player finds some new cards and puts them into the deck in random order
<<set $deck.push($a8)>>
<<set $deck.push($a10)>>
<<set $deck.push($a7)>>
<<set $deck.push($a9)>>
So our array looks like that now
[$s7, $s8, $s9, $s10, $a8, $a10, $a7, $a9]
I want to show him all the cards that he’s already found. Not in random order, but sorted properly. And I dont know how to do that.
I tried this
<<if $deck.count($s7) gt 0>>
<img @src='"img/cards/"+ $s7.type + $s7.num + ".svg"' style="position:relative; left:0; top:0;" height="`10%" width="10%">
<</if>>
<<if $deck.count($a7) gt 0>>
<img @src='"img/cards/"+ $a7.type + $a7.num + ".svg"' style="position:relative; left:0; top:0;" height="`10%" width="10%">
<</if>>
/* etc. */
But .count method always returns 0, because it cant read generic object inside the array. Maybe I’m doing something wrong in this solution?
Or maybe there is a way to sort generic objects inside the array. If I can make array to look like that, it would be awesome
[$s7, $a7, $s8, $a8, $s9, $a9, $s10, $a10]