-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgiocatore.h
64 lines (59 loc) · 3.83 KB
/
giocatore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**********************************************************************************
* Copyright (C) 2022 by Giulio Sorrentino *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
**********************************************************************************/
#ifndef _GIOCATORE_H_
#define _GIOCATORE_H_
#include "carta.h"
#include "mazzo.h"
#include "giocatoreHelper.h"
#include "stringHelper.h"
#include <wx/dcbuffer.h>
#include <vector>
/** Classie che identifica generalmente un qualsiasi giocatore */
class giocatore {
private:
wxString nome; //nome del giocatore
vector<carta *> mano; //carte in suo possesso
bool ordinaMano; //se le carte in mano al giocatore devono essere ordinate o se devono essere messe cosi' come escono
size_t numeroCarte, //numero di carte in mano al giocatore
iCartaGiocata, //indice della carta giocata dal giocatore
punteggio; //punteggio costantemente aggiornato del giocatore
giocatoreHelper *helper; //helper per personalizzare il comportamento della classe
public:
enum CARTA_GIOCATA {NESSUNA_CARTA_GIOCATA=static_cast<size_t> (-1)}; //come indice per indicare che non e' stata ancora effettuata la giocata si usa il massimo valore rappresentabile nel size_t
giocatore(giocatoreHelper *h, wxString n=wxT(""), bool ordina=true, size_t carte=3);
~giocatore();
wxString& getNome() {return nome;}
void setNome(wxString n) {nome=n;}
bool getFlagOrdina() {return ordinaMano;} //se la mano deve essere ordinata o meno
void setFlagOrdina(bool ordina) {ordinaMano=ordina;}
void addCarta(mazzo *m); //aggiunge una carta alla mano del giocatore
carta *getCartaGiocata(); //restituisce la carta giocata
size_t getPunteggio() {return punteggio;}
wxString getPunteggioStr() {return stringHelper::IntToWxStr(punteggio);} //restituisce il punteggio sotto forma di stringa
void gioca(int i); //gioca una carta col giocatore primo di mano
void gioca(giocatore *g1, int i); //gioca una carta col giocatore secondo di mano
bool hasCartaGiocata() {return iCartaGiocata!=NESSUNA_CARTA_GIOCATA;} //se il giocatore ha giocato
void aggiornaPunteggio(giocatore *g);
wxPoint paint(wxPaintDC &dc, wxCoord c) {return helper->paint(dc, nome, mano, iCartaGiocata);} //disegna i dati del giocatore sul frame
bool stessoSemeCartaGiocata(giocatore *g); //se la carta giocata dal giocatore ha lo stesso seme
bool stessoSeme(carta *c); //confronta due carte per sapere se hanno lo stesso seme
giocatoreHelper *getHelper() {return helper;}
};
#endif