Commit 2b4a5504 authored by Vivien Kraus's avatar Vivien Kraus

Implement --dog

parent be7d75cc
......@@ -20,6 +20,7 @@ include = "int tarot_run_deal_random (char *input, const char *seed, int retry,
include = "int tarot_run_bid (char *input, TarotBid bid, char **output);";
include = "int tarot_run_decl (char *input, int decl, char **output);";
include = "int tarot_run_call (char *input, TarotCard card, char **output);";
include = "int tarot_run_dog (char *input, TarotCardArray *cards, char **output);";
include = "int opts_main (int argc, char **argv);";
include = "int main (int argc, char **argv) { setenv (\"SYSCONFDIR\", SYSCONFDIR, 0); return opts_main (argc, argv); }";
include = "static char *read_input ();";
......@@ -285,6 +286,11 @@ main = {
}
res = tarot_run_call (input, card, &output);
break;
case INDEX_OPT_DOG:
input = read_input ();
cards = parse_as_card_array (OPT_ARG (DOG));
res = tarot_run_dog (input, cards, &output);
break;
}
write_output (output);
free (input);
......@@ -362,6 +368,15 @@ flag = {
doc = 'In this mode, the taker calls a card.';
};
flag = {
name = dog;
no-preset;
equivalence = new-game;
arg-type = string;
descrip = "Reveal the dog, as \"AH,2H,3H,...\"";
doc = 'In this mode, the dog is revealed. This action is only required when the deal is not fully known. The argument is a comma-separated list of 6 or 3 cards (3 for the 5-player variant).';
};
flag = {
name = status;
no-preset;
......
......@@ -164,6 +164,25 @@ namespace Tarot {
output = print_status (game);
return 0;
}
public static int run_dog (string input, Tarot.CardArray cards, out string? output) {
var game = new Tarot.Game.alloc ();
output = null;
if (game.load_from_xml (input) != 0) {
stderr.printf ("ERROR: this game is not valid.\n");
return 1;
}
var e = new Tarot.GameEvent.alloc ();
if (e.set_dog (cards) != 0) {
stderr.printf ("ERROR: this is not possible.\n");
return 1;
}
if (game.add_event (e) != 0) {
stderr.printf ("ERROR: this is not possible.\n");
return 1;
}
output = game.save_to_xml ();
return 0;
}
private string print_bid_cell (Tarot.Bid bid) {
switch (bid) {
case Tarot.Bid.PASS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment