Commit c4aebb7b authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Merge branch 'develop' into 'master'

Develop

See merge request !182
parents b3554f5d 595aafe6
Pipeline #202035 passed with stages
in 62 minutes and 15 seconds
<?xml version="1.0"?>
<!-- tarot implements the rules of the tarot game
Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<test xmlns="http://planete-kraus.eu/tarot">
<status>
<cannot-play card="5C" />
</status>
<game xmlns:tarot="http://planete-kraus.eu/tarot">
<setup n-players="3" with-call="no"/>
<deal to="P2">
<card card="7H"/>
<card card="JH"/>
<card card="CH"/>
<card card="7C"/>
<card card="9C"/>
<card card="KC"/>
<card card="4D"/>
<card card="6D"/>
<card card="8D"/>
<card card="9D"/>
<card card="10D"/>
<card card="JD"/>
<card card="AS"/>
<card card="2S"/>
<card card="7S"/>
<card card="JS"/>
<card card="QS"/>
<card card="3T"/>
<card card="7T"/>
<card card="8T"/>
<card card="9T"/>
<card card="10T"/>
<card card="13T"/>
<card card="16T"/>
</deal>
<bid bid="double-keep"/>
<decl slam="no"/>
<decl slam="no"/>
<decl slam="no"/>
<handful/>
<card card="4H"/>
<handful/>
<card card="7H"/>
<handful/>
<card card="AH"/>
<card card="KC"/>
<card card="AC"/>
<card card="2C"/>
<card card="7C"/>
<card card="3S"/>
<card card="QC"/>
<card card="5H"/>
<card card="CH"/>
<card card="2H"/>
<card card="9C"/>
</game>
</test>
......@@ -4,8 +4,7 @@ Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -4,8 +4,7 @@ Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -4,8 +4,7 @@ Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -4,8 +4,7 @@ Copyright (C) 2019 Vivien Kraus
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -23,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:text>#ifndef HAVE_CONFIG_H&#xA;#include &lt;config.h>&#xA;#endif /* HAVE_CONFIG_H */&#xA;&#xA;#include &lt;tarot.h>&#xA;#include &lt;stdio.h>&#xA;#include &lt;stdlib.h>&#xA;#include &lt;string.h>&#xA;#include &lt;assert.h>&#xA;&#xA;int&#xA;main ()&#xA;{&#xA; if (tarot_init (LOCALEDIR) != 0)&#xA; {&#xA; fprintf (stderr, "Error: could not load libtarot.\n");&#xA; return EXIT_FAILURE;&#xA; }&#xA; {&#xA; TarotGame *game = tarot_game_alloc ();</xsl:text>
<xsl:text>#ifndef HAVE_CONFIG_H&#xA;#include &lt;config.h>&#xA;#endif /* HAVE_CONFIG_H */&#xA;&#xA;#include &lt;tarot.h>&#xA;#include &lt;stdio.h>&#xA;#include &lt;stdlib.h>&#xA;#include &lt;string.h>&#xA;#include &lt;assert.h>&#xA;&#xA;int&#xA;main ()&#xA;{&#xA; tarot_set_datadir (DATADIR);&#xA; if (tarot_init (LOCALEDIR) != 0)&#xA; {&#xA; fprintf (stderr, "Error: could not load libtarot.\n");&#xA; return EXIT_FAILURE;&#xA; }&#xA; {&#xA; TarotGame *game = tarot_game_alloc ();</xsl:text>
<xsl:apply-templates select="/tarot:test/tarot:game" />
<xsl:apply-templates select="/tarot:test/tarot:status" />
<xsl:text>&#xA; tarot_game_free (game);&#xA; }&#xA; tarot_quit ();&#xA; return EXIT_SUCCESS;&#xA;}</xsl:text>
......@@ -158,7 +157,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<xsl:template match="tarot:handful" mode="game">
<xsl:text>&#xA; {&#xA; TarotCard cards[</xsl:text>
<xsl:value-of select="count(tarot:card)" />
<xsl:text>];&#xA; size_t i = 0;</xsl:text>
<xsl:text>];&#xA; size_t i = 0;&#xA; (void) i;</xsl:text>
<xsl:for-each select="tarot:card">
<xsl:text>&#xA; cards[i] = tarot_string_to_card_c (&quot;</xsl:text>
<xsl:value-of select="@card" />
......@@ -169,7 +168,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</xsl:template>
<xsl:template match="tarot:card" mode="game">
<xsl:text>&#xA; {&#xA; TarotCard card = tarot_string_to_card_c (&quot;&quot;)&#xA; assert (card != ((TarotCard) (-1)));&#xA; event = tarot_game_event_alloc_card (card);&#xA; }</xsl:text>
<xsl:text>&#xA; {&#xA; TarotCard card = tarot_string_to_card_c (&quot;</xsl:text>
<xsl:value-of select="@card" />
<xsl:text>&quot;);&#xA; assert (card != ((TarotCard) (-1)));&#xA; event = tarot_game_event_alloc_card (card);&#xA; }</xsl:text>
<xsl:call-template name="add-the-event" />
</xsl:template>
......@@ -498,4 +499,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<xsl:template match="cannot-autoreveal">
<xsl:text>&#xA; {&#xA; size_t n_dog;&#xA; assert (!tarot_game_can_autoreveal (game, &amp;n_dog, 0, 0, NULL));&#xA; }</xsl:text>
</xsl:template>
<xsl:template match="cannot-play">
<xsl:text>&#xA; {&#xA; TarotGameEvent *ev = tarot_game_event_alloc_card (played_card);&#xA; assert (tarot_game_check_event (game, ev) != TAROT_GAME_OK);&#xA; }</xsl:text>
</xsl:template>
</xsl:stylesheet>
......@@ -3,8 +3,7 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -36,6 +35,9 @@ extern "C"
static void trick_initialize (TarotTrickHandle * trick, size_t n_players);
static int trick_copy (TarotTrickHandle * dest,
const TarotTrickHandle * source);
static int trick_copy_until (TarotTrickHandle * dest,
const TarotTrickHandle * source,
TarotPlayer stop);
static size_t trick_n_cards (const TarotTrickHandle * trick);
static int trick_last (const TarotTrickHandle * trick);
static int trick_has_leader (const TarotTrickHandle * trick);
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -19,6 +18,9 @@
#include <tarot/cards_private.h>
#include <assert.h>
#ifndef H_TAROT_TRICK_PRIVATE_IMPL_INCLUDED
#define H_TAROT_TRICK_PRIVATE_IMPL_INCLUDED
static inline size_t
_trick_get_n_cards (const TarotTrickHandle * trick)
{
......@@ -143,6 +145,28 @@ trick_copy (TarotTrickHandle * dest, const TarotTrickHandle * source)
return 0;
}
static inline int
trick_copy_until (TarotTrickHandle * dest, const TarotTrickHandle * source,
TarotPlayer stop)
{
if (trick_copy (dest, source) != 0)
{
return 1;
}
if (trick_has_leader (dest))
{
TarotPlayer leader = trick_leader (dest);
size_t n = dest->n_players;
size_t n_cards = (stop + n - leader) % n;
if (n_cards < dest->trick->n_cards)
{
_trick_set_n_cards (dest, n_cards);
assert (n_cards < n);
}
}
return 0;
}
static inline size_t
trick_n_cards (const TarotTrickHandle * trick)
{
......@@ -451,6 +475,8 @@ trick_check_card_full (const TarotTrickHandle * trick,
if (cnf != NULL && arg_lead_suit != NULL && cno != NULL
&& arg_max_trump != NULL && cnu != NULL)
{
/* We do not use trick_cannot_follow and such because the card
* named /played/ is still not yet added to the trick! */
TarotNumber played_number;
TarotSuit played_suit;
int played_is_excuse = decompose (played, &played_number, &played_suit);
......@@ -601,3 +627,5 @@ trick_add (TarotTrickHandle * trick, TarotCard card, int force_taker)
}
#include <tarot/cards_private_impl.h>
#endif /* not H_TAROT_TRICK_PRIVATE_IMPL_INCLUDED */
......@@ -3,8 +3,7 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -17,6 +16,9 @@
#include <tarot/tricks_private.h>
#ifndef H_TAROT_TRICKS_PRIVATE_IMPL_INCLUDED
#define H_TAROT_TRICKS_PRIVATE_IMPL_INCLUDED
static inline size_t
tricks_get_i_current (const TarotTricksHandle * tricks)
{
......@@ -361,3 +363,5 @@ tricks_add (TarotTricksHandle * tricks, TarotPlayer taker,
}
return error;
}
#endif /* not H_TAROT_TRICKS_PRIVATE_IMPL_INCLUDED */
......@@ -3,8 +3,7 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
......
/* tarot implements the rules of the tarot game
* Copyright (C) 2018, 2019 Vivien Kraus
* Copyright (C) 2018, 2019, 2020 Vivien Kraus
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -49,6 +48,8 @@ unit_test (const char *xml)
abort ();
}
}
tarot_xml_parser_iterator_free (iterator);
tarot_xml_parser_free (parser);
rebuilt = tarot_game_save_to_xml_alloc (game);
if (rebuilt == NULL)
{
......@@ -60,7 +61,7 @@ unit_test (const char *xml)
abort ();
}
free (rebuilt);
free (game);
tarot_game_free (game);
}
static void
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -65,19 +64,19 @@ extern "C"
void tarot_xml_parser_iterator_destruct (TarotXmlParserIterator * parser);
const struct TarotGameEvent *tarot_xml_parser_iterator_next_value
(TarotXmlParserIterator * iterator);
(TarotXmlParserIterator * iterator);
/**
* tarot_xml_save:
* @game: (type TarotGame):
*/
size_t tarot_xml_save (const struct TarotGame * game, size_t start, size_t max,
char *dest);
size_t tarot_xml_save (const struct TarotGame *game, size_t start,
size_t max, char *dest);
TarotXmlParserIterator *tarot_xml_parser_iterator
(const TarotXmlParser * parser);
(const TarotXmlParser * parser);
TarotXmlParserIterator *tarot_xml_parser_iterator_dup
(const TarotXmlParserIterator * source);
(const TarotXmlParserIterator * source);
void tarot_xml_parser_iterator_free (TarotXmlParserIterator * xml_parser);
/**
......@@ -85,7 +84,7 @@ extern "C"
* @mcts: (type TarotMcts):
* @dest_out: (array length=max):
*/
size_t tarot_xml_save_mcts_tree (const struct TarotMcts * mcts, size_t start,
size_t tarot_xml_save_mcts_tree (const struct TarotMcts *mcts, size_t start,
size_t max, char *dest_out);
#ifdef __cplusplus
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -26,3 +25,4 @@ include %reldir%/tarot-stacking.am
include %reldir%/tarot-features.am
include %reldir%/tarot-cnn-features.am
include %reldir%/tarot-cnn.am
include %reldir%/tarot-perceptron-bootstrap.am
......@@ -3,8 +3,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -3,8 +3,7 @@
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
......@@ -68,8 +67,7 @@ namespace TarotCairo {
var font_size = 4;
context.select_font_face ("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.BOLD);
context.set_font_size (font_size);
context.scale (1, -1);
context.translate (1, -card_height + font_size);
context.translate (1, font_size);
context.show_text (number);
context.move_to (0, font_size);
context.show_text (suit);
......
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