Skip to content

Commit

Permalink
continue defining an FC_Solve method.
Browse files Browse the repository at this point in the history
Disable/hide the animated/graphic solution display if the game-variant rules do not match 8cols+4reserves freecell
  • Loading branch information
shlomif committed Apr 7, 2024
1 parent 8956430 commit eeb41e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fc-solve/site/wml/src/ts/tests/fcs-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function my_func(qunit: QUnit, _my_mod, my_callback: () => void) {
qunit.test(
"FC_Solve user_get_sequences_are_built_by_type after CLI flag",
(assert) => {
assert.expect(1);
assert.expect(2);

const instance: w.FC_Solve = new FC_Solve({
module_wrapper,
Expand All @@ -594,6 +594,13 @@ function my_func(qunit: QUnit, _my_mod, my_callback: () => void) {
FCS_SEQ_BUILT_BY_SUIT,
"get_sequences_are_built_by_type() returns the modified value after command line.",
);

// TEST
const check_ret = instance.check_if_params_match_freecell();
assert.notOk(
check_ret.verdict,
"different get_sequences_are_built_by_type() setting.",
);
},
);

Expand Down
12 changes: 12 additions & 0 deletions fc-solve/site/wml/src/ts/web-fc-solve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,13 @@ export class FC_Solve {
private _check_if_params_match_preset({
empty_stacks_filled_by,
sequence_move,
sequences_are_built_by_type,
wanted_num_freecells,
wanted_num_stacks,
}: {
empty_stacks_filled_by: number;
sequence_move: number;
sequences_are_built_by_type: number;
wanted_num_freecells: number;
wanted_num_stacks: number;
}): GameVariantPresetCheckRet {
Expand All @@ -493,6 +495,13 @@ export class FC_Solve {
reasons += "Wrong sequence_move!\n";
}

if (
that.get_sequences_are_built_by_type() !==
sequences_are_built_by_type
) {
reasons += "Wrong sequences_are_built_by_type!\n";
}

const verdict: boolean = reasons.length == 0;

return { reasons: reasons, verdict: verdict };
Expand All @@ -506,10 +515,13 @@ export class FC_Solve {
const wanted_num_stacks: number = 8;
const empty_stacks_filled_by: number = FCS_ES_FILLED_BY_ANY_CARD;
const sequence_move: number = 0;
const sequences_are_built_by_type: number =
FCS_SEQ_BUILT_BY_ALTERNATE_COLOR;

return that._check_if_params_match_preset({
empty_stacks_filled_by: empty_stacks_filled_by,
sequence_move: sequence_move,
sequences_are_built_by_type: sequences_are_built_by_type,
wanted_num_freecells: wanted_num_freecells,
wanted_num_stacks: wanted_num_stacks,
});
Expand Down

0 comments on commit eeb41e0

Please sign in to comment.