106
|
0 |
0 |
unless &GetOptionsFromArray($argv, 'g|game|variant=s', sub {
my(undef, $game) = @_;
$variant_params = $variant_map->get_variant_by_id($game);
if (not defined $variant_params) {
die "Unknown variant '${game}'!\n";
};
}
, 'freecells-num=i', sub {
my(undef, $n) = @_;
$variant_params->num_freecells($n);
}
, 'stacks-num=i', sub {
my(undef, $n) = @_;
$variant_params->num_columns($n);
}
, 'decks-num=i', sub {
my(undef, $n) = @_;
unless ($n == 1 or $n == 2) {
die 'Decks should be 1 or 2.';
};
$variant_params->num_decks($n);
}
, 'sequences-are-built-by=s', sub {
my(undef, $val) = @_;
my(%seqs_build_by) = (map({$_, $_;} 'alt_color', 'suit', 'rank'), 'alternate_color', 'alt_color');
my $proc_val = $seqs_build_by{$val};
unless (defined $proc_val) {
die "Unknown sequences-are-built-by '${val}'!";
};
$variant_params->seqs_build_by($proc_val);
}
, 'empty-stacks-filled-by=s', sub {
my(undef, $val) = @_;
my(%empty_stacks_filled_by_map) = map({$_, 1;} 'kings', 'any', 'none');
unless (exists $empty_stacks_filled_by_map{$val}) {
die "Unknown empty stacks filled by '${val}'!";
};
$variant_params->empty_stacks_filled_by($val);
}
, 'sequence-move=s', sub {
my(undef, $val) = @_;
my(%seq_moves) = map({$_, 1;} 'limited', 'unlimited');
unless (exists $seq_moves{$val}) {
die "Unknown sequence move '${val}'!";
};
$variant_params->sequence_move($val);
}
) |