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 
31 namespace GameplayActions {
32 
33 enum class Type {
34   // cards_distributed,
35   reservation,
36   poverty_shift,
37   poverty_accepted,
38   poverty_returned,
39   poverty_denied,
40   poverty_denied_by_all,
41   card_played,
42   announcement,
43   swines,
44   hyperswines,
45   marriage,
46   genscher,
47   trick_open,
48   trick_full,
49   trick_taken,
50   check,
51   print,
52   quit
53 }; // enum class Type
54 enum class Discrepancy {
55   future = -1,
56   none = 0,
57   skipped = 1,
58   player,
59   card,
60   other
61 }; // enum class Discrepancy
62 
63 
64 /** base class for gameplay actions
65  **/
66 class GameplayAction {
67   public:
68     static unique_ptr<GameplayAction> create(string const& line);
69     static unique_ptr<GameplayAction> create(string const& line,
70                                              istream& istr);
71   protected:
72     GameplayAction() = default;
73 
74   public:
75     virtual ~GameplayAction() = default;
76 
77     unique_ptr<GameplayAction> clone() const;
78 
79     virtual bool equal(GameplayAction const& action) const;
80 
81     virtual void write(ostream& ostr) const = 0;
82 
83     virtual Type type() const = 0;
84 
85     virtual string data_translation() const = 0;
86 }; // class GameplayAction
87 unsigned player(GameplayAction const& action);
88 
89 }; // namespace GameplayActions
90 
91 using GameplayAction = GameplayActions::GameplayAction;
92 
93 string to_string(GameplayActions::Type type);
94 string gettext(GameplayActions::Type type);
95 ostream& operator<<(ostream& ostr, GameplayActions::Type type);
96 string to_string(GameplayActions::Discrepancy discrepancy);
97 ostream& operator<<(ostream& ostr, GameplayActions::Discrepancy discrepancy);
98 
99 bool operator!(GameplayActions::Discrepancy discrepancy);
100 bool operator||(GameplayActions::Discrepancy lhs, bool rhs);
101 
102 string to_string(GameplayAction const& action);
103 ostream& operator<<(ostream& ostr, GameplayAction const& action);
104 
105 bool operator==(GameplayAction const& lhs, GameplayAction const& rhs);
106 bool operator!=(GameplayAction const& lhs, GameplayAction const& rhs);
107