|
/* **************************************************************************************
File: Cards.h
By Mauro Mindoli January 2003
***************************************************************************************** */
#ifndef _CARDS_H_
#define _CARDS_H_
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <time.h>
namespace game
{
enum {GAME_LOST = 0, GAME_OK, GAME_WON};
enum {ME, PC};
enum {COPPE, DENARI, SPADE, BASTONI, END};
}
class CGameCard
{
public:
CGameCard(int fam, int val) : mVal(val), mFam(fam) {}
void SetFamVal(int fam, int val) {mFam = fam; mVal = val;}
void GetFamVal (int &fam, int &val) const {fam = mFam; val = mVal;}
int GetIdCard();
virtual ~CGameCard() {}
CGameCard();
protected:
int mVal;
int mFam;
private :
};
class CGameCardNapoletano : public CGameCard
{
public:
CGameCardNapoletano() : CGameCard(1, game::BASTONI) {}
CGameCardNapoletano(int fam, int val) : CGameCard(fam, val) {}
bool isJolly ()
{
if ((mVal == 10) && (mFam == game::DENARI))
return true;
else return false;
}
~CGameCardNapoletano() {}
};
typedef std::vector<CGameCard *> VecPCards;
class CDeck
{
public:
CDeck(int numCards, int numFams);
void ShuffleDeck();
int GetNumCards() const {return mNumCards;}
bool GiveMeACard (const CGameCard* &card);
virtual ~CDeck() {}
VecPCards shuffledDeck;
protected :
int mNumCards;
int mNumFams;
int mCurPos;
VecPCards mDeck;
private :
CDeck();
};
class CDeckNapoletano: public CDeck
{
public:
CDeckNapoletano();
~CDeckNapoletano();
void Reshuffle(VecPCards &outCards);
private:
enum {NCARDS = 40, NFAMS = 4};
};
class CPlayer
{
public:
CPlayer(std::string name);
virtual ~CPlayer() {}
inline double GetPoints() const {return mPoints;}
inline void SetPoints(double points) {mPoints = points;}
virtual int AddCard(CGameCard *pCard) = 0;
virtual void AddHand(CGameCard *pCard) = 0;
virtual void ResetHand() = 0;
protected:
std::string mName;
double mPoints;
private:
};
class CPlayerNapoletano : public CPlayer
{
public:
CPlayerNapoletano(std::string name) :
CPlayer(name), mEstimatedCard(5), mJollyValue(0.0) {}
~CPlayerNapoletano() {}
int AddCard(CGameCard *pCard);
void AddHand(CGameCard *pCard);
void ResetHand();
double GetEstimatedPoints() const;
VecPCards mHand;
private:
double mEstimatedCard;
double mJollyValue;
};
class GameNapoletano
{
public:
int Play(int who);
void ResetPoints();
void Init();
int Try(CPlayer *pp);
void GiveTheCard(CGameCard &card) const {card = *pCard;}
void GetPoints(double &myPoints, double &pcPoints) const
{myPoints = pMe->GetPoints(); pcPoints = pPc->GetPoints();}
GameNapoletano();
~GameNapoletano() {delete pMe; delete pPc;}
private:
int gameResult;
CGameCardNapoletano *pCard;
CDeckNapoletano dn;
CPlayerNapoletano *pMe;
CPlayerNapoletano *pPc;
void Reshuffle();
VecPCards mOutCards;
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am born in 1965 in Ascoli Piceno (Italy).
My email is maurus@rocketmail.com
HIGHER EDUCATION:
Degree in Computer Science with a mark of 95/110,
University of Pisa in July 1992.
KNOWLEDGE OF FOREIGN LANGUAGES:
Mother tongue Italian.
Very good knowledge of both English and French.
COMPUTER KNOWLEDGE:
Operating systems:
Windows, Windows CE.
real time systems on micro.
Programming languages:
C, C++, VisualC++, Pascal, Basic, Coral, Assembly, Win32.
Libraries:
Qt, STL, Roguewave, OpenGL, MFC.
Tools
Cycle V, Design Patterns
Frameworks:
Visual Studio, DevC++, Qt Creator, Codewarrior
Micro: Mitsubishi, Texas DSP, Intel.
WORKING EXPERIENCES:
From april 1994 to march 2000 I worked in Gem Elettronica (http://www.gemrad.com) in San Benedetto del Tronto (Italy), a company that produce real time systems, naval radars, geographical position system (G.P.S.), cartographical consoles in civil and military environment (Custom Officers, Italian Militar Navy, Carabinieri).
I developed software in C/C++ inside a team work environment for international naval radar sites. I cooperated with other programmers of the Lockheed Martin Company, the Rohde & Schwarze and the Alenia Marconi Systems.
I mainly worked with real time systems, localisation radio and GPS systems.
From march 2000 to july 2001 I worked in Ericsson Cables (http://www.ericsson.com/networktechnologies) in Sundbyberg (Sweden).
I developed software for fusion splicers in a Windows CE environment in C++, Win32, MFC.
Video analyses, micro motor motion and micro cameras.
From August 2001 to February 2003
I worked in France, Paris developing in C++ under Windows, for a French company that produced software to share informations.
From March 2003
I am actually working in my first company Gem Elettronica.
I also develop Vessel Traffic Systems and Laser Gyrosteps interfaces.
My current job is to manage projects with naval and river radars.
We used Qt, Win32, MFC, C++, STL, DLL, OpenGL