00001
00027 #ifndef HAND_DEFAULT_H
00028 #define HAND_DEFAULT_H 1
00029
00030
00031 #include <dmn/hand.h>
00032 #include <dmn/id.h>
00033 #include <dmn/dominoes.h>
00034
00035 #include <list>
00036
00037 namespace dmn
00038 {
00044 class HandDefault: public Hand
00045 {
00046 private:
00047 struct player_t {
00048 ID id;
00049 Dominoes dominoes;
00050 };
00051
00052 Core *core_;
00053 Dominoes dominoes_;
00054 Dominoes dominoes_played_;
00055 ID player_who_started_;
00056 ID turn_;
00057 std::list<player_t> players_;
00058 bool dominoes_shuffled_;
00059 bool first_hand_of_game_;
00060 Domino domino_started_;
00061 bool is_configured_;
00062
00063
00071 int calcule_number_dominoes(int max);
00072
00080 bool fill_dominoes(Dominoes *dominoes);
00081
00089 int random_number(int max);
00090
00099 player_t *search_player(ID player);
00100
00109 bool shuffle_tile_to_player(ID player, Domino *domino);
00110
00119 bool remove_domino_to_player(ID player, Domino domino);
00120
00128 Points count_points_of_player(player_t player);
00129
00138 Points count_points_of_couple(std::list<player_t> players, ID couple);
00139
00147 Points normalize_points(Points points);
00148
00157 bool new_player(std::list<player_t> *players, ID id);
00158
00167 bool player_can_play(ID player, Dominoes dominoes);
00168
00174 bool is_closed();
00175
00183 ID player_with_less_points(std::list<player_t> players);
00184
00192 ID couple_with_less_points(std::list<player_t> players);
00193
00201 ID player_couple_with_less_points(std::list<player_t> players);
00202
00210 Points count_points_of_players(std::list<player_t> players);
00211
00219 ID player_without_dominoes(std::list<player_t> players);
00220
00229 bool highest_double_domino(Dominoes dominoes, Domino *highest);
00230
00239 bool highest_single_domino(Dominoes dominoes, Domino *highest);
00240
00255 bool domino_to_start(std::list<player_t> players, ID *player,
00256 Domino *domino);
00257
00263 ID next_turn();
00264
00265 public:
00269 HandDefault();
00270
00271 bool configure(Core *core);
00272 ID player_who_started();
00273 void set_player_who_starts(ID player);
00274 ID turn();
00275 int number_dominoes();
00276 HalfDomino max_half_value();
00277 int dominoes_played(Dominoes *dominoes);
00278 int dominoes_has_player(ID player);
00279 bool shuffle_tile(ID *player, Domino *domino);
00280 bool domino_playable(ID player, Domino domino, HalfDomino half);
00281 void set_play_domino(ID player, Domino domino, HalfDomino half);
00282 bool set_player_pass(ID player, Domino *domino);
00283 ID winner(Points *points);
00284 bool is_finished();
00285 };
00286 };
00287
00288 #endif // HAND_DEFAULT_H