Commit 347c66df authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Refuse cards of the called suit even if we do not know the cards

parent f4019a8c
Pipeline #174792 passed with stages
in 33 minutes and 24 seconds
......@@ -116,6 +116,7 @@
/src/libtarot/pkgconfig/libtarot.pc
/src/libtarot/semantic-api/api.sxml
/src/libtarot/semantic-api/api.xml
/src/libtarot/test/cheating-called-suit.c
/src/libtarot/test/cheating.c
/src/libtarot/test/dog-impossible
/src/libtarot/test/dog-impossible.c
......
......@@ -1785,9 +1785,46 @@ game_check_card_full_aux (const TarotGame * game_for_counter,
* Fortunately, the counter API does not call this function
* during its construction. */
TarotCounter validator;
TarotCard call;
counter_initialize (&validator);
counter_load_from_game (&validator, game_for_counter);
ok = (counter_may_own (&validator, 1, &next, played));
if (game_get_call (game_for_counter, &call) == TAROT_GAME_OK)
{
size_t current_trick;
if (game_get_current_trick (game_for_counter, &current_trick) ==
TAROT_GAME_OK)
{
if (current_trick == 0)
{
TarotCard first_trick_lead_suit;
if (game_get_lead_suit
(game_for_counter, current_trick,
&first_trick_lead_suit) == TAROT_GAME_NA)
{
/* We do not allow cards of the call suit,
* except the called card itself */
TarotNumber played_number;
TarotCard played_suit;
TarotNumber call_number;
TarotCard call_suit;
if (decompose (call, &call_number, &call_suit) != 0)
{
assert (0);
}
if (decompose (played, &played_number, &played_suit) ==
0)
{
if (played_suit == call_suit
&& played_number != call_number)
{
ok = 0;
}
}
}
}
}
}
}
if (ok)
{
......
......@@ -20,25 +20,30 @@ check_PROGRAMS += \
%reldir%/empty-status \
%reldir%/no-slam \
%reldir%/dog-impossible \
%reldir%/cheating
%reldir%/cheating \
%reldir%/cheating-called-suit
EXTRA_DIST += \
%reldir%/empty-status.tarottest \
%reldir%/no-slam.tarottest \
%reldir%/dog-impossible.tarottest \
%reldir%/cheating.tarottest
%reldir%/cheating.tarottest \
%reldir%/cheating-called-suit.tarottest
MAINTAINERCLEANFILES += \
$(srcdir)/%reldir%/empty-status.c \
$(srcdir)/%reldir%/no-slam.c \
$(srcdir)/%reldir%/dog-impossible.c \
$(srcdir)/%reldir%/cheating.c
$(srcdir)/%reldir%/cheating.c \
$(srcdir)/%reldir%/cheating-called-suit.c
%canon_reldir%_empty_status_LDADD = src/libtarot/libtarot.la
%canon_reldir%_no_slam_LDADD = src/libtarot/libtarot.la
%canon_reldir%_dog_impossible_LDADD = src/libtarot/libtarot.la
%canon_reldir%_cheating_LDADD = src/libtarot/libtarot.la
%canon_reldir%_cheating_called_suit_LDADD = src/libtarot/libtarot.la
%canon_reldir%_empty_status_SOURCES = $(srcdir)/%reldir%/empty-status.c
%canon_reldir%_no_slam_SOURCES = $(srcdir)/%reldir%/no-slam.c
%canon_reldir%_dog_impossible_SOURCES = $(srcdir)/%reldir%/dog-impossible.c
%canon_reldir%_cheating_SOURCES = $(srcdir)/%reldir%/cheating.c
%canon_reldir%_cheating_called_suit_SOURCES = $(srcdir)/%reldir%/cheating-called-suit.c
SUFFIXES += .c .tarottest
......
<?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, either version 3 of the License, or (at
your option) any later version.
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="8H" />
</status>
<game xmlns:tarot="http://planete-kraus.eu/tarot">
<setup n-players="5" with-call="yes"/>
<deal to="P5">
<card card="AH"/>
<card card="CH"/>
<card card="8C"/>
<card card="2D"/>
<card card="9D"/>
<card card="10D"/>
<card card="3S"/>
<card card="5S"/>
<card card="8S"/>
<card card="9S"/>
<card card="3T"/>
<card card="4T"/>
<card card="7T"/>
<card card="11T"/>
<card card="13T"/>
</deal>
<bid bid="double-keep"/>
<decl slam="no"/>
<decl slam="no"/>
<decl slam="no"/>
<decl slam="no"/>
<decl slam="no"/>
<call card="KH"/>
</game>
</test>
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