reformatting code according to guidelines defined at

http://wololo.net/forum/viewtopic.php?f=35&t=2235&start=10
This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-16 00:55:16 +00:00
parent c79fdcbf50
commit acd7bb1aa4
103 changed files with 38044 additions and 31222 deletions

View File

@@ -5,122 +5,137 @@
#include "DeckStats.h"
#include "ManaCost.h"
Player::Player(MTGDeck * deck, string file, string fileSmall) : Damageable(20){
deckFile = file;
deckFileSmall = fileSmall;
manaPool = NEW ManaPool(this);
canPutLandsIntoPlay = 1;
nomaxhandsize = 0;
castedspellsthisturn = 0;
castrestrictedspell = 0;
castrestrictedcreature = 0;
onlyonecast = 0;
castcount = 0;
nocreatureinstant = 0;
nospellinstant = 0;
onlyoneinstant = 0;
poisonCount = 0;
damageCount = 0;
preventable = 0;
mAvatar = NULL;
mAvatarTex = NULL;
type_as_damageable = DAMAGEABLE_PLAYER;
playMode = MODE_HUMAN;
if ( deck != NULL )
{
game = NEW MTGPlayerCards( deck );
game->setOwner(this);
deckName = deck->meta_name;
}
Player::Player(MTGDeck * deck, string file, string fileSmall) :
Damageable(20)
{
deckFile = file;
deckFileSmall = fileSmall;
manaPool = NEW ManaPool(this);
canPutLandsIntoPlay = 1;
nomaxhandsize = 0;
castedspellsthisturn = 0;
castrestrictedspell = 0;
castrestrictedcreature = 0;
onlyonecast = 0;
castcount = 0;
nocreatureinstant = 0;
nospellinstant = 0;
onlyoneinstant = 0;
poisonCount = 0;
damageCount = 0;
preventable = 0;
mAvatar = NULL;
mAvatarTex = NULL;
type_as_damageable = DAMAGEABLE_PLAYER;
playMode = MODE_HUMAN;
if (deck != NULL)
{
game = NEW MTGPlayerCards(deck);
game->setOwner(this);
deckName = deck->meta_name;
}
}
/*Method to call at the end of a game, before all objects involved in the game are destroyed */
void Player::End(){
DeckStats::GetInstance()->saveStats(this, opponent(),GameObserver::GetInstance());
void Player::End()
{
DeckStats::GetInstance()->saveStats(this, opponent(), GameObserver::GetInstance());
}
Player::~Player(){
SAFE_DELETE(manaPool);
SAFE_DELETE(game);
resources.Release(mAvatarTex);
mAvatar = NULL;
mAvatarTex = NULL;
}
void Player::loadAvatar(string file){
if (mAvatarTex) {
Player::~Player()
{
SAFE_DELETE(manaPool);
SAFE_DELETE(game);
resources.Release(mAvatarTex);
mAvatar = NULL;
mAvatarTex = NULL;
}
mAvatarTex = resources.RetrieveTexture(file,RETRIEVE_LOCK,TEXTURE_SUB_AVATAR);
if (mAvatarTex)
mAvatar = resources.RetrieveQuad(file,0,0,35,50,"playerAvatar",RETRIEVE_NORMAL,TEXTURE_SUB_AVATAR);
else
mAvatar = NULL;
}
const string Player::getDisplayName() const {
GameObserver * g = GameObserver::GetInstance();
if (this == g->players[0]) return "Player 1";
return "Player 2";
void Player::loadAvatar(string file)
{
if (mAvatarTex)
{
resources.Release(mAvatarTex);
mAvatar = NULL;
mAvatarTex = NULL;
}
mAvatarTex = resources.RetrieveTexture(file, RETRIEVE_LOCK, TEXTURE_SUB_AVATAR);
if (mAvatarTex)
mAvatar = resources.RetrieveQuad(file, 0, 0, 35, 50, "playerAvatar", RETRIEVE_NORMAL, TEXTURE_SUB_AVATAR);
else
mAvatar = NULL;
}
MTGInPlay * Player::inPlay(){
return game->inPlay;
const string Player::getDisplayName() const
{
GameObserver * g = GameObserver::GetInstance();
if (this == g->players[0]) return "Player 1";
return "Player 2";
}
int Player::getId(){
GameObserver * game = GameObserver::GetInstance();
for (int i= 0; i < 2; i++){
if (game->players[i] == this) return i;
}
return -1;
MTGInPlay * Player::inPlay()
{
return game->inPlay;
}
JQuad * Player::getIcon(){
return mAvatar;
int Player::getId()
{
GameObserver * game = GameObserver::GetInstance();
for (int i = 0; i < 2; i++)
{
if (game->players[i] == this) return i;
}
return -1;
}
Player * Player::opponent(){
GameObserver * game = GameObserver::GetInstance();
if (!game) return NULL;
return this == game->players[0] ? game->players[1] : game->players[0];
JQuad * Player::getIcon()
{
return mAvatar;
}
HumanPlayer::HumanPlayer(MTGDeck * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
loadAvatar("avatar.jpg");
playMode = MODE_HUMAN;
Player * Player::opponent()
{
GameObserver * game = GameObserver::GetInstance();
if (!game) return NULL;
return this == game->players[0] ? game->players[1] : game->players[0];
}
ManaPool * Player::getManaPool(){
return manaPool;
HumanPlayer::HumanPlayer(MTGDeck * deck, string file, string fileSmall) :
Player(deck, file, fileSmall)
{
loadAvatar("avatar.jpg");
playMode = MODE_HUMAN;
}
int Player::afterDamage(){
return life;
ManaPool * Player::getManaPool()
{
return manaPool;
}
int Player::poisoned(){
return poisonCount;
int Player::afterDamage()
{
return life;
}
int Player::damaged(){
return damageCount;
int Player::poisoned()
{
return poisonCount;
}
int Player::prevented(){
return preventable;
int Player::damaged()
{
return damageCount;
}
int Player::prevented()
{
return preventable;
}
//Cleanup phase at the end of a turn
void Player::cleanupPhase(){
game->inPlay->cleanupPhase();
game->graveyard->cleanupPhase();
void Player::cleanupPhase()
{
game->inPlay->cleanupPhase();
game->graveyard->cleanupPhase();
}
ostream& operator<<(ostream& out, const Player& p)
{
return out << p.getDisplayName();
return out << p.getDisplayName();
}