vary the suits for fun and games
This commit is contained in:
parent
d4759cf422
commit
bfe89124be
|
@ -6,9 +6,27 @@
|
|||
~ temp x = LIST_MIN(list)
|
||||
~ list -= x
|
||||
~ return x
|
||||
|
||||
|
||||
VAR start = 0
|
||||
=== function randomcard(ref list)
|
||||
~ temp x = LIST_RANDOM(list)
|
||||
{list == ():
|
||||
~ return 0
|
||||
}
|
||||
// Cards are arranged by suits, so start of the list is black ones.
|
||||
// LIST_RANDOM is not random enough, so I just alternate between
|
||||
// start and the end of the list for fun games.
|
||||
~ temp x = 0
|
||||
~ x = LIST_RANDOM(cards)
|
||||
{
|
||||
- start == 0 && !is_black(x):
|
||||
~ return randomcard(list)
|
||||
- start == 0 && is_black(x):
|
||||
~ start = 1
|
||||
- start == 1 && !is_black(x):
|
||||
~ start = 0
|
||||
- start == 1 && is_black(x):
|
||||
~ return randomcard(list)
|
||||
}
|
||||
~ list -= x
|
||||
~ return x
|
||||
|
||||
|
@ -128,12 +146,18 @@
|
|||
~ return true
|
||||
|
||||
=== function can_move_to_col(ref column_one, ref column_two)
|
||||
{ column_one == ():
|
||||
~ return false
|
||||
}
|
||||
{ column_two == ():
|
||||
~ return true
|
||||
}
|
||||
~ temp x = lastcard(column_one)
|
||||
~ temp y = lastcard(column_two)
|
||||
{ x == ():
|
||||
~ return false
|
||||
}
|
||||
{ y == ():
|
||||
~ return true
|
||||
}
|
||||
~ temp x = lastcard(column_one)
|
||||
~ temp y = lastcard(column_two)
|
||||
~ return (( (!is_black(x) && is_black(y)) || (is_black(x) && !is_black(y)) ) && follows(x,y) )
|
||||
|
|
|
@ -28,6 +28,8 @@ VAR foundation4 = ()
|
|||
~ col1 += randomcard(cards)
|
||||
~ col1 += randomcard(cards)
|
||||
|
||||
Column1 is: {col1}
|
||||
|
||||
~ col2 += randomcard(cards)
|
||||
~ col2 += randomcard(cards)
|
||||
~ col2 += randomcard(cards)
|
||||
|
@ -101,7 +103,9 @@ VAR foundation4 = ()
|
|||
<div id="col8" class="cardcolumn">{col8}</div> <>
|
||||
</div>
|
||||
|
||||
{LIST_COUNT(foundation1) == 13 && LIST_COUNT(foundation2) == 13 && LIST_COUNT(foundation3) == 13 && LIST_COUNT(foundation4) == 13: <div id="winner">YOU WIN!</div>}
|
||||
|
||||
+ [Test winning] -> debug_win
|
||||
+ {can_move_to_col(col1, col1)} [Move {lastcard(col1)} to column 1] -> move_from_col1_to_col1
|
||||
+ {can_move_to_col(col1, col2)} [Move {lastcard(col1)} to column 1] -> move_from_col1_to_col2
|
||||
+ {can_move_to_col(col1, col3)} [Move {lastcard(col1)} to column 1] -> move_from_col1_to_col3
|
||||
|
@ -199,6 +203,9 @@ VAR foundation4 = ()
|
|||
+ {can_move_to_empty(col8, empty1)} [Move {lastcard(col8)} to empty space] -> move_from_col8_to_empty1
|
||||
+ {empty1 != () && can_move_to_empty(col8, empty2)} [Move {lastcard(col8)} to empty space] -> move_from_col8_to_empty2
|
||||
|
||||
// ------ END OF ACTIONS -------
|
||||
+ -> END
|
||||
|
||||
=== move_from_col1_to_col1
|
||||
|
||||
~ col1 += pop(col1)
|
||||
|
@ -240,9 +247,6 @@ VAR foundation4 = ()
|
|||
|
||||
-> main
|
||||
|
||||
// ------ END OF ACTIONS -------
|
||||
+ -> END
|
||||
|
||||
=== move_from_col1_to_empty1
|
||||
|
||||
~ empty1 += pop(col1)
|
||||
|
@ -819,3 +823,23 @@ VAR foundation4 = ()
|
|||
~ foundation4 = pop(col8)
|
||||
}
|
||||
-> main
|
||||
|
||||
=== debug_win ===
|
||||
~ foundation1 = LIST_RANGE(cards, 1, 13)
|
||||
~ foundation1 = LIST_RANGE(cards, 14, 26)
|
||||
~ foundation1 = LIST_RANGE(cards, 27, 39)
|
||||
~ foundation1 = LIST_RANGE(cards, 40, 52)
|
||||
// ~ foundation2 = (ace_of_clubs),(two_of_clubs),(three_of_clubs),(four_of_clubs),(five_of_clubs),(six_of_clubs),(seven_of_clubs),(eight_of_clubs),(nine_of_clubs),(ten_of_clubs),(jack_of_clubs),(queen_of_clubs),(king_of_clubs)
|
||||
// ~ foundation3 = (ace_of_hearts),(two_of_hearts),(three_of_hearts),(four_of_hearts),(five_of_hearts),(six_of_hearts),(seven_of_hearts),(eight_of_hearts),(nine_of_hearts),(ten_of_hearts),(jack_of_hearts),(queen_of_hearts),(king_of_hearts)
|
||||
// ~ foundation4 = (ace_of_diamonds),(two_of_diamonds),(three_of_diamonds),(four_of_diamonds),(five_of_diamonds),(six_of_diamonds),(seven_of_diamonds),(eight_of_diamonds),(nine_of_diamonds),(ten_of_diamonds),(jack_of_diamonds),(queen_of_diamonds),(king_of_diamonds)
|
||||
~ empty1 = ()
|
||||
~ empty2 = ()
|
||||
~ col1 = ()
|
||||
~ col2 = ()
|
||||
~ col3 = ()
|
||||
~ col4 = ()
|
||||
~ col5 = ()
|
||||
~ col6 = ()
|
||||
~ col7 = ()
|
||||
~ col8 = ()
|
||||
->main
|
||||
|
|
|
@ -92,6 +92,12 @@ function arrange_cards() {
|
|||
* @var {string|number} index
|
||||
*/
|
||||
function saveChoice(index: any) {
|
||||
/**
|
||||
* Normally, in this game I gotta save the board too.
|
||||
* It is easier just to disable saving.
|
||||
*/
|
||||
return true;
|
||||
/*
|
||||
window['progress_steps']++;
|
||||
window['progress'].push(index);
|
||||
if (window['progress_steps'] % 5 === 0) {
|
||||
|
@ -103,6 +109,7 @@ function saveChoice(index: any) {
|
|||
localStorage.setItem("progress_30", JSON.stringify(window['progress']));
|
||||
}
|
||||
return localStorage.setItem("progress", JSON.stringify(window['progress']));
|
||||
*/
|
||||
};
|
||||
|
||||
function displayText(interactive = true) {
|
||||
|
|
Loading…
Reference in a new issue