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 
32 enum class Counting {
33   plus,
34   minus,
35   plusminus
36 }; // enum class Counting
37 
38 struct RuleType {
39   enum Bool {
40     first,
41     bool_first = first,
42 
43     // mutate the rules after each game
44     // default: false
45     // is always 'false' in a release
46     mutate = bool_first,
47 
48     // with or without 9
49     // default: true
50     with_nines,
51 
52     // bock rounds (t.i. the points are doubled)
53     // default: true
54     bock,
55     // append bock rounds (or sum them up)
56     // default: false
57     bock_append,
58     // bock after 120-120 points
59     // default: true
60     bock_120,
61     // bock after a lost solo game
62     // default: false
63     bock_solo_lost,
64     // bock after a lost re/contra game (only re/contra is announced)
65     // default: false
66     bock_re_lost,
67     // bock after a real heart trick
68     // default: false
69     bock_heart_trick,
70     // bock after a black game (a team got no trick)
71     // default: false
72     bock_black,
73 
74     // throw with nines (-> min_number_of_throwing_nines)
75     // default: true
76     throw_with_nines,
77     // throw with kings (-> min_number_of_throwing_kings)
78     // default: false
79     throw_with_kings,
80     // throw with nines and kings (-> min_number_of_throwing_nines_and_kings)
81     // default: false
82     throw_with_nines_and_kings,
83     // throw with too many points (-> min_richness_for_throwing)
84     // default: false
85     throw_with_richness,
86     // force a redistribute without explicit reason
87     // default: true
88     force_redistribute,
89 
90     // poverty (<= 3 trump)
91     // default: true
92     poverty,
93     // to shift the trump (or give the cards again)
94     // default: true
95     poverty_shift,
96     // to shift only the trump
97     // default: false
98     poverty_shift_only_trump,
99     // fox do not count for the poverty trump number
100     // default: false
101     poverty_fox_do_not_count,
102     // shift the fox extra
103     // default: false
104     poverty_fox_shift_extra,
105     // shift the fox open
106     // default: false
107     poverty_fox_shift_open,
108     // to throw with at max one trump
109     // default: false
110     throw_with_one_trump,
111 
112     // to throw when the diamond ace is the highest trump
113     // default: false
114     throw_when_fox_highest_trump,
115 
116     // whether you can make the announcement
117     // default: true
118     marriage_first_foreign,
119     // whether you can make the announcement
120     // default: true
121     marriage_first_color,
122     // whether you can make the announcement
123     // default: true
124     marriage_first_single_color,
125     // whether you can make the announcement
126     // default: true
127     marriage_first_trump,
128     // whether the first trick decides the marriage, also if it goes to the bride
129     // default: false
130     marriage_first_one_decides,
131     // whether the marriage goes before the poverty
132     // default: false
133     marriage_before_poverty,
134 
135     // if a player has both diamond kings, he can decide, with whom he builds
136     // a team, when he is playing the first diamond king
137     // default: false
138     genscher,
139 
140     // if the solo games are allowed
141     // default: true
142     solo,
143     // default: true
144     solo_jack,
145     // default: true
146     solo_queen,
147     // default: true
148     solo_king,
149     // default: true
150     solo_queen_jack,
151     // default: true
152     solo_king_jack,
153     // default: true
154     solo_king_queen,
155     // default: true
156     solo_koehler,
157     // default: true
158     solo_color,
159     // default: true
160     solo_meatless,
161     // default: false
162     throwing_before_solo,
163 
164     // the hearts tens are trump
165     // default: true
166     dullen,
167     // in the same trick is the second hearts ten is greater than the first
168     // default: true
169     dullen_second_over_first,
170     // ... but not in the last trick
171     // default: false
172     dullen_contrary_in_last_trick,
173     // if swines are announced the first dulle goes over the second always
174     // default: false
175     dullen_first_over_second_with_swines,
176 
177     // both diamond ace are the highest
178     // default: true
179     swines,
180     // when to make the announcement
181     // (start of the game, or when the first is played)
182     // dafault: true
183     swines_announcement_begin,
184     // when the first diamond ace is home, the second becomes a Schwein
185     // default: false
186     swine_only_second,
187     // when there are swines in a solo
188     // default: true
189     swines_in_solo,
190     // when there are swines in a poverty
191     // default: true
192     swines_in_poverty,
193     // both diamond nine are above the Schweine
194     // default: false
195     hyperswines,
196     // when to make the announcement
197     // (start of the game, or when the first is played)
198     // default: true
199     hyperswines_announcement_begin,
200     // when there are hyperswines in a solo
201     // default: true
202     hyperswines_in_solo,
203     // when there are hyperswines in a povert
204     // default: true
205     hyperswines_in_poverty,
206     // whether it is allowed that a player has swines and hyperswines
207     // default: false
208     swines_and_hyperswines_joint,
209 
210     // catching the diamond ace of the other team: +1 point
211     // default: true
212     extrapoint_catch_fox,
213     // catching the diamond ace of the other team in the last trick: +1 point
214     // default: false
215     extrapoint_catch_fox_last_trick,
216     // the fox gets the last trick: +1 point
217     // default: false
218     extrapoint_fox_last_trick,
219     // the double_fox gets the last trick: +1 points
220     // (+ the point from 'fox_last_trick')
221     // default: false
222     extrapoint_double_fox_last_trick,
223 
224     // club jack gets the last trick: +1 point
225     // default: true
226     extrapoint_charlie,
227     // club jack of the other team is catched in the last trick: +1 point
228     // default: true
229     extrapoint_catch_charlie,
230     // both club jack of the same team get the last trick: +2 point
231     // default: false
232     extrapoint_double_charlie,
233     // both club jack of the same team is catched in the last trick: +2 point
234     // default: false
235     extrapoint_catch_double_charlie,
236     // jab a charlie only with a diamond queen
237     // default: false
238     extrapoint_catch_charlie_only_with_diamond_queen,
239 
240     // the second dulle jabs the first
241     // default: false
242     extrapoint_dulle_jabs_dulle,
243     // if there is a heart trick
244     // default: false
245     extrapoint_heart_trick,
246 
247     // whether an announcement gives the information, which team the player is
248     // default: false
249     knocking,
250     // whether an announcement can be made without the ones before being
251     // in the limit
252     // default: false
253     announcement_limit_only_for_current,
254     // whether the announcement can be made till the trick is full
255     // that is the played (open) card does count, too
256     // default: false
257     announcement_till_full_trick,
258     // if the winner of the first trick has to make an announcement,
259     // when the trick has at least thirty points
260     // default: true
261     announcement_first_trick_thirty_points,
262     // the duty announcement in the first trick has only got to be made
263     // when no announcement has been made so far
264     // default: false
265     announcement_first_trick_thirty_points_only_first,
266     // the duty announcement in the first trick has only got to be made
267     // when it is a re/contra
268     // default: true
269     announcement_first_trick_thirty_points_only_re_contra,
270     // the duty announcement in the first trick has also to be made
271     // in a marriage
272     // default: true
273     announcement_first_trick_thirty_points_in_marriage,
274     // whether you can reply with re/contra to an announcement
275     // default: true
276     announcement_reply,
277     // whether with an announcement re/contra 120 points must be get and the replies also set the points to get
278     // default: true
279     announcement_strict_limit,
280 
281     // whether the announcement re/contra doubles the points
282     // default: true
283     announcement_re_doubles,
284 
285     // whether the announcement contra doubles the point 'against re'
286     // default: false
287     announcement_contra_doubles_against_re,
288 
289     // whether the numbe of rounds is limited
290     // default: true
291     number_of_rounds_limited,
292     // whether the points (for the tournament) are limited
293     // default: false
294     points_limited,
295 
296     // offer the duty solo to the other players
297     // default: false
298     offer_duty_solo,
299 
300     // whether the soloplayer of a lust-solo plays the first card
301     // default: true
302     lustsolo_player_leads,
303 
304     // whether solo games always count 3* points (also when lost)
305     // default: false
306     solo_always_counts_triple,
307 
308     bool_last = solo_always_counts_triple
309   }; // enum Bool
310   static unsigned constexpr bool_number = bool_last - bool_first + 1;
311 
312   enum Unsigned {
313     unsigned_first = bool_last + 1,
314 
315     // bock multiplier
316     // default: 2
317     bock_multiplier = unsigned_first,
318 
319     // minimum number of nines for throwing
320     // default: 5
321     min_number_of_throwing_nines,
322     // minimum number of kings for throwing
323     // default: 5
324     min_number_of_throwing_kings,
325     // minimum number of nines and kings for throwing
326     // default: 7
327     min_number_of_throwing_nines_and_kings,
328 
329     // minimum number of points for throwing
330     // default: 70
331     min_richness_for_throwing,
332 
333     // the number of tricks, after which you have to play alone
334     // if you have not found a partner
335     marriage_determination,
336 
337     // announcements:
338     // -1 for not allowed,
339     // 1-12: as long as you have at least so many cards on the hand
340     // default: 10
341     announcement_no_120,
342     // default: 9
343     announcement_no_90,
344     // default: 6
345     announcement_no_60,
346     // default: 3
347     announcement_no_30,
348     // default: 3
349     announcement_no_0,
350     // the last time, an announcement can be made
351     // default: 3
352     announcement_last,
353 
354     // the number of rounds to play
355     // default: 20
356     number_of_rounds,
357 
358     // the number of points in a tournament
359     // default: 40
360     points,
361     // the number of duty soli
362     // default: 0
363     number_of_duty_soli,
364     // the number of duty color soli
365     // default: 0
366     number_of_duty_color_soli,
367     // the number of duty picture soli
368     // default: 0
369     number_of_duty_picture_soli,
370 
371     // number of players
372     // default: 4
373     number_of_players,
374 
375     // number of players in a game
376     // default: 4
377     number_of_players_in_game,
378 
379     unsigned_last = number_of_players_in_game,
380   }; // enum Unsigned
381   static unsigned constexpr unsigned_number = unsigned_last - unsigned_first + 1;
382 
383   // these values are calculated, not set
384   enum UnsignedExtra {
385     unsigned_extra_first = unsigned_last + 1,
386 
387     // number of cards colors, values and cards
388     // how often a card is in the game
389     // 2
390     number_of_same_cards = unsigned_extra_first,
391     // the number of colors
392     // 4
393     number_of_card_colors,
394     // the number of colors, with trump as an extra color
395     // 5
396     number_of_card_tcolors,
397     // the number of card values
398     // 5/6
399     number_of_card_values,
400     // the number of cards (each (color, value) exists two times)
401     // 24
402     number_of_cards,
403 
404     // the number of teams (two)
405     // 2
406     number_of_teams,
407     // the number of players in a team
408     // (number_of_players_in_game / number_of_teams)
409     number_of_players_per_team,
410 
411     // the number of games per round
412     // equals the number of players
413     number_of_games_per_round,
414 
415     max_number_of_tricks_in_game,
416     // number_of_cards / number_of_players
417     number_of_tricks_in_game,
418     number_of_cards_on_hand = number_of_tricks_in_game,
419 
420     // the points needed for a 'Doppelkopf' extrapoint
421     // 40
422     points_for_doppelkopf,
423 
424     // the maximum number of trumps for a poverty
425     // 3
426     max_number_of_poverty_trumps,
427 
428     unsigned_extra_last = max_number_of_poverty_trumps
429   }; // enum UnsignedExtra
430 
431   // ToDo: Type::Card (p.e. for swines card)
432 
433   enum Counting {
434     counting = unsigned_extra_last + 1,
435     last = counting
436   }; // enum Counting
437 }; // struct RuleType
438 
439 string to_string(RuleType::Bool type);
440 string to_string(RuleType::Unsigned type);
441 string to_string(RuleType::UnsignedExtra type);
442 string to_string(RuleType::Counting type);
443 string to_string(Counting counting);
444 
445 string gettext(RuleType::Bool type);
446 string gettext(RuleType::Bool type, string const& text);
447 string gettext(RuleType::Unsigned type);
448 string gettext(RuleType::Unsigned type, string const& text);
449 string gettext(RuleType::Counting type);
450 string gettext(Counting counting);
451 
452 ostream& operator<<(ostream& ostr, RuleType::Bool type);
453 ostream& operator<<(ostream& ostr, RuleType::Unsigned type);
454 ostream& operator<<(ostream& ostr, RuleType::UnsignedExtra type);
455 ostream& operator<<(ostream& ostr, RuleType::Counting type);
456 ostream& operator<<(ostream& ostr, Counting counting);
457 
458