check functions

This commit is contained in:
Alexander Yakovlev 2024-04-26 20:29:09 +06:00
parent 80d86fdd84
commit 0313ba4f34
Signed by: oreolek
GPG key ID: 8269E24B4008E32A
3 changed files with 43 additions and 3 deletions

View file

@ -5,10 +5,13 @@ echo 'LIST cards = ';
$list = [];
foreach($suits as $suit) {
foreach($cards as $card) {
$list[] = '('.$card.'_of_'.$suit.')';
//$list[] = '('.$card.'_of_'.$suit.')';
//$list[] = '('.$card.'_of_'.$suit.')';
$list[] = 'x == "'.$card.'_of_'.$suit.'"';
}
}
echo implode(',', $list);
echo implode(' || ', $list);
/*
foreach($suits as $suit) {
foreach($cards as $card) {
$replace = [
@ -28,4 +31,4 @@ foreach($suits as $suit) {
EOF;
}
}
*/

View file

@ -19,3 +19,22 @@ VAR Inventory = ()
~ temp x = LIST_RANDOM(list)
~ list -= x
~ return x
=== function lastcard(ref list)
~ return LIST_MIN(list)
=== function is_clubs(x)
~ return (x == two_of_clubs || x == three_of_clubs || x == four_of_clubs || x == five_of_clubs || x == six_of_clubs || x == seven_of_clubs || x == eight_of_clubs || x == nine_of_clubs || x == ten_of_clubs || x == jack_of_clubs || x == queen_of_clubs || x == king_of_clubs || x == ace_of_clubs)
=== function is_hearts(x)
~ return (x == two_of_hearts || x == three_of_hearts || x == four_of_hearts || x == five_of_hearts || x == six_of_hearts || x == seven_of_hearts || x == eight_of_hearts || x == nine_of_hearts || x == ten_of_hearts || x == jack_of_hearts || x == queen_of_hearts || x == king_of_hearts || x == ace_of_hearts)
=== function is_diamonds(x)
~ return (x == two_of_diamonds || x == three_of_diamonds || x == four_of_diamonds || x == five_of_diamonds || x == six_of_diamonds || x == seven_of_diamonds || x == eight_of_diamonds || x == nine_of_diamonds || x == ten_of_diamonds || x == jack_of_diamonds || x == queen_of_diamonds || x == king_of_diamonds || x == ace_of_diamonds)
=== function is_spades(x)
~ return (x == two_of_spades || x == three_of_spades || x == four_of_spades || x == five_of_spades || x == six_of_spades || x == seven_of_spades || x == eight_of_spades || x == nine_of_spades || x == ten_of_spades || x == jack_of_spades || x == queen_of_spades || x == king_of_spades || x == ace_of_spades)
=== function is_black(ref list)
~ temp x = lastcard(list)
~ return is_clubs(x) || is_spades(x)

View file

@ -80,6 +80,10 @@ VAR full4 = ""
~ col8 += randomcard(cards)
~ col8 += randomcard(cards)
-> main
=== main
col1 is: {col1}
col2 is: {col2}
col3 is: {col3}
@ -89,6 +93,20 @@ col6 is: {col6}
col7 is: {col7}
col8 is: {col8}
empty1 is: {empty1}
empty2 is: {empty2}
full1 is: {full1}
full2 is: {full2}
full3 is: {full3}
full4 is: {full4}
Cards left: {LIST_COUNT(cards)}
col1 is black? {is_black(col1)}
-> END