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 "../basetypes.h"
31 class Game;
32 
33 /**
34  ** a structure for the management of specialpoints in tricks, gamepoints and
35  ** gamepointstable
36  **/
37 struct Specialpoint {
38     enum class Type {
39       nospecialpoint,
40       caught_fox,
41       caught_fox_last_trick,
42       fox_last_trick,
43       //double_fox_last_trick,
44       charlie,
45       caught_charlie,
46       //double_charlie,
47       //caught_double_charlie,
48       dulle_caught_dulle,
49       heart_trick,
50       doppelkopf,
51       won,
52       no90,
53       no60,
54       no30,
55       no0,
56       no120_said,
57       no90_said,
58       no60_said,
59       no30_said,
60       no0_said,
61       no90_said_120_got,
62       no60_said_90_got,
63       no30_said_60_got,
64       no0_said_30_got,
65       no120_reply,
66       no90_reply,
67       no60_reply,
68       no30_reply,
69       no0_reply,
70       contra_won,
71       solo,
72       bock
73     }; // enum class Type
74     static constexpr Type types[] = {
75       Type::nospecialpoint,
76       Type::caught_fox,
77       Type::caught_fox_last_trick,
78       Type::fox_last_trick,
79       //Type::double_fox_last_trick,
80       Type::charlie,
81       Type::caught_charlie,
82       //Type::double_charlie,
83       //Type::caught_double_charlie,
84       Type::dulle_caught_dulle,
85       Type::heart_trick,
86       Type::doppelkopf,
87       Type::won,
88       Type::no90,
89       Type::no60,
90       Type::no30,
91       Type::no0,
92       Type::no120_said,
93       Type::no90_said,
94       Type::no60_said,
95       Type::no30_said,
96       Type::no0_said,
97       Type::no90_said_120_got,
98       Type::no60_said_90_got,
99       Type::no30_said_60_got,
100       Type::no0_said_30_got,
101       Type::no120_reply,
102       Type::no90_reply,
103       Type::no60_reply,
104       Type::no30_reply,
105       Type::no0_reply,
106       Type::contra_won,
107       Type::solo,
108       Type::bock
109     };
110     Specialpoint(Type type, Team team) noexcept;
111     Specialpoint(Type type, Team team, Team counting_team) noexcept;
112     Specialpoint(Type type, int value) noexcept;
113     explicit Specialpoint(istream& istr);
114 
115     bool is_valid(vector<Team> const& team) const;
116 
117     Type type = Type::nospecialpoint;
118     Team team = Team::noteam; // team which has made the point
119     Team counting_team = Team::noteam; // team, which gets the point
120     // the player who get the special point
121     // (i.e. the player who has caught a fox)
122     unsigned player_get_no = UINT_MAX;
123     // the player who has 'lost' the special point
124     // (i.e. the player whose fox has been caught)
125     unsigned player_of_no = UINT_MAX;
126     // the value of the specialpoint (used for bock rounds)
127     int value = 0;
128 }; // struct Specialpoint
129 
130 using Specialpoints = vector<Specialpoint>;
131 
132 
133 bool is_winning(Specialpoint::Type sp) noexcept;
134 bool is_announcement(Specialpoint::Type sp) noexcept;
135 
136 int value(Specialpoint::Type sp) noexcept;
137 string to_string(Specialpoint::Type sp) noexcept;
138 Specialpoint::Type specialpoint_type_from_string(string const& name);
139 ostream& operator<<(ostream& ostr, Specialpoint::Type sp);
140 ostream& operator<<(ostream& ostr, Specialpoint const& sp);
141 ostream& operator<<(ostream& ostr, Specialpoints const& spv);
142 
143 #if 0
144 // sets the counting team
145 Specialpoints& counting_team_set(Specialpoints& sp, Team const winner);
146 #endif
147 
148 int sum(Specialpoints const& spv, Team winner, Game const& g);
149 
150 string gettext(Specialpoint::Type sp);
151 string gettext(Specialpoint const& sp);
152