1 /**********************************************************************
2  *
3  *   FreeDoko a Doppelkopf-Game
4  *
5  *   Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders
6  *
7  *   This program is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU General Public License as
9  *   published by the Free Software Foundation; either version 2 of
10  *   the License, or (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *   You can find this license in the file 'gpl.txt'.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  *   MA  02111-1307  USA
22  *
23  *  Contact:
24  *    Diether Knof dknof@posteo.de
25  *
26  **********************************************************************/
27 
28 #pragma once
29 
30 #include "../card/hand_cards.h"
31 class Game;
32 class Player;
33 
34 /**
35  ** The poverty part of a game
36  **/
37 class GamePoverty {
38   friend class Game;
39   public:
40   explicit GamePoverty(Game& game) noexcept;
41   GamePoverty(GamePoverty const& poverty, Game& game);
42 
43   GamePoverty(GamePoverty const&) = delete;
44   GamePoverty& operator=(GamePoverty const&) = delete;
45 
46   bool shifted() const noexcept;
47   unsigned shifted_cardno() const noexcept;
48   unsigned returned_cardno() const noexcept;
49   unsigned returned_trumpno() const noexcept;
50   HandCards const& shifted_cards() const;
51   HandCards const& returned_cards() const;
52 
53   void reset() noexcept;
54   void shift();
55 
56   Signal<void(Player const&)>& signal_shifting() noexcept;
57   Signal<void(Player const&, unsigned)>& signal_shift() noexcept;
58   Signal<void(Player const&, unsigned)>& signal_ask() noexcept;
59   Signal<void(Player const&)>& signal_take_denied() noexcept;
60   Signal<void()>& signal_take_denied_by_all() noexcept;
61   Signal<void(Player const&, unsigned, unsigned)>& signal_take_accepted() noexcept;
62   Signal<void(Player const&)>& signal_get_cards_to_shift() noexcept;
63   Signal<void(Player const&, unsigned)>& signal_get_take_accept() noexcept;
64   Signal<void(Player const&, HandCards)>& signal_get_exchanged_cards() noexcept;
65   Signal<void(Player const&, HandCards)>& signal_cards_get_back() noexcept;
66 
67   private:
68   Game* const game_;
69   HandCards shifted_cards_;
70   HandCards returned_cards_;
71   bool shifted_ = false;
72 
73   Signal<void(Player const&)> signal_shifting_;
74   Signal<void(Player const&, unsigned)> signal_shift_;
75   Signal<void(Player const&, unsigned)> signal_ask_;
76   Signal<void(Player const&)> signal_take_denied_;
77   Signal<void()> signal_take_denied_by_all_;
78   Signal<void(Player const&, unsigned, unsigned)> signal_take_accepted_;
79   Signal<void(Player const&)> signal_get_cards_to_shift_;
80   Signal<void(Player const&, unsigned)> signal_get_take_accept_;
81   Signal<void(Player const&, HandCards)> signal_get_exchanged_cards_;
82   Signal<void(Player const&, HandCards)> signal_cards_get_back_;
83 }; // class GamePoverty
84