* Split constants file to have them in a single place.
This commit is contained in:
jean.chalard
2009-01-06 13:07:28 +00:00
parent 9024cf7cf5
commit 3bb2c431c9
33 changed files with 512 additions and 597 deletions
+16 -16
View File
@@ -50,14 +50,14 @@ void AIPlayer::tapLandsForMana(ManaCost * potentialMana, ManaCost * cost){
int currentCost = 0;
GameObserver * gameObs = GameObserver::GetInstance();
CardDescriptor cd;
cd.setColor(MTG_COLOR_LAND);
cd.setColor(Constants::MTG_COLOR_LAND);
cd.tapped = -1;
MTGCardInstance * card = NULL;
while((card = cd.nextmatch(game->inPlay, card))){
int doTap = 1;
for (int i=MTG_NB_COLORS-1; i>= 0; i--){
for (int i=Constants::MTG_NB_COLORS-1; i>= 0; i--){
if (diff->getCost(i) && card->hasSubtype(MTG_LAND_TEXTS[i]) ){
diff->remove(i,1);
doTap = 0;
@@ -77,21 +77,21 @@ ManaCost * AIPlayer::getPotentialMana(){
SAFE_DELETE(potentialMana);
potentialMana = NEW ManaCost();
CardDescriptor cd;
cd.setColor(MTG_COLOR_LAND);
cd.setColor(Constants::MTG_COLOR_LAND);
cd.tapped = -1;
MTGCardInstance * card = NULL;
while((card = cd.nextmatch(game->inPlay, card))){
if (card->hasSubtype("plains")){
potentialMana->add(MTG_COLOR_WHITE,1);
potentialMana->add(Constants::MTG_COLOR_WHITE,1);
}else if(card->hasSubtype("swamp")){
potentialMana->add(MTG_COLOR_BLACK,1);
potentialMana->add(Constants::MTG_COLOR_BLACK,1);
}else if(card->hasSubtype("forest")){
potentialMana->add(MTG_COLOR_GREEN,1);
potentialMana->add(Constants::MTG_COLOR_GREEN,1);
}else if(card->hasSubtype("mountain")){
potentialMana->add(MTG_COLOR_RED,1);
potentialMana->add(Constants::MTG_COLOR_RED,1);
}else if(card->hasSubtype("island")){
potentialMana->add(MTG_COLOR_BLUE,1);
potentialMana->add(Constants::MTG_COLOR_BLUE,1);
}else{
#if defined (WIN32) || defined (LINUX)
OutputDebugString("WTF ????\n");
@@ -309,7 +309,7 @@ int AIPlayer::combatDamages(){
GameObserver * gameObs = GameObserver::GetInstance();
Player * currentPlayer = gameObs->currentPlayer;
int currentGamePhase = gameObs->getCurrentGamePhase();
if (currentGamePhase != MTG_PHASE_COMBATDAMAGE) return 0;
if (currentGamePhase != Constants::MTG_PHASE_COMBATDAMAGE) return 0;
DamageResolverLayer * drl = gameObs->mLayers->combatLayer();
#if defined (WIN32) || defined (LINUX)
OutputDebugString("AI Combat Phase START\n");
@@ -345,7 +345,7 @@ int AIPlayer::combatDamages(){
}
}
}
if (canardEmissaire && !current->card->has(TRAMPLE)){
if (canardEmissaire && !current->card->has(Constants::TRAMPLE)){
while(current->dealOneDamage(canardEmissaire)){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("==========\nDealing damage to Canard Emissaire\n================\n");
@@ -464,7 +464,7 @@ int AIPlayerBaka::Act(float dt){
GameObserver * gameObs = GameObserver::GetInstance();
int currentGamePhase = gameObs->getCurrentGamePhase();
if (currentGamePhase == MTG_PHASE_CLEANUP && currentGamePhase != oldGamePhase){
if (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentGamePhase != oldGamePhase){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("updating stats\n");
#endif
@@ -496,13 +496,13 @@ int AIPlayerBaka::Act(float dt){
if (currentPlayer == this){
MTGCardInstance * card = NULL;
switch(currentGamePhase){
case MTG_PHASE_FIRSTMAIN:
case MTG_PHASE_SECONDMAIN:
case Constants::MTG_PHASE_FIRSTMAIN:
case Constants::MTG_PHASE_SECONDMAIN:
if (canPutLandsIntoPlay){
//Attempt to put land into play
cd.init();
cd.setColor(MTG_COLOR_LAND);
cd.setColor(Constants::MTG_COLOR_LAND);
card = cd.match(game->hand);
if (card){
gameObs->cardClick(card);
@@ -556,7 +556,7 @@ int AIPlayerBaka::Act(float dt){
gameObs->userRequestNextGamePhase();
}
break;
case MTG_PHASE_COMBATATTACKERS:
case Constants::MTG_PHASE_COMBATATTACKERS:
chooseAttackers();
gameObs->userRequestNextGamePhase();
break;
@@ -566,7 +566,7 @@ int AIPlayerBaka::Act(float dt){
}
}else{
switch(currentGamePhase){
case MTG_PHASE_COMBATBLOCKERS:
case Constants::MTG_PHASE_COMBATBLOCKERS:
chooseBlockers();
gameObs->userRequestNextGamePhase();
break;
+1 -1
View File
@@ -163,7 +163,7 @@ void ActionLayer::setMenuObject(Targetable * object){
SAFE_DELETE(abilitiesMenu);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100);
for (int i=0;i<mCount;i++){
+9 -9
View File
@@ -19,14 +19,14 @@ int NextGamePhase::resolve(){
}
void NextGamePhase::Render(){
int nextPhase = (GameObserver::GetInstance()->getCurrentGamePhase() + 1) % MTG_PHASE_CLEANUP;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
int nextPhase = (GameObserver::GetInstance()->getCurrentGamePhase() + 1) % Constants::MTG_PHASE_CLEANUP;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
char buffer[200];
int playerId = 1;
if (GameObserver::GetInstance()->currentActionPlayer == GameObserver::GetInstance()->players[1]) playerId = 2;
sprintf(buffer, "Player %i : -> %s", playerId, MTGPhaseNames[nextPhase]);
sprintf(buffer, "Player %i : -> %s", playerId, Constants::MTGPhaseNames[nextPhase]);
mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT);
}
@@ -41,7 +41,7 @@ int StackAbility::resolve(){
return (ability->resolve());
}
void StackAbility::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
char buffer[200];
@@ -102,7 +102,7 @@ int Spell::resolve(){
}
void Spell::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
char buffer[200];
@@ -148,7 +148,7 @@ int PutInGraveyard::resolve(){
}
void PutInGraveyard::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
if (!removeFromGame){
@@ -180,7 +180,7 @@ int DrawAction::resolve(){
}
void DrawAction::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
char buffer[200];
@@ -640,7 +640,7 @@ void ActionStack::Render(){
if (current->state==NOT_RESOLVED) height += current->mHeight;
}
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
@@ -686,7 +686,7 @@ void ActionStack::Render(){
if (current->display) height += current->mHeight;
}
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
+4 -4
View File
@@ -23,7 +23,7 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
}
if (!found) return NULL;
for (int i = 0; i< MTG_NB_COLORS; i++){
for (int i = 0; i< Constants::MTG_NB_COLORS; i++){
if (colors[i] == 1){
found = 0;
if(card->hasColor(i)){
@@ -44,7 +44,7 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
match = NULL;
}
}
for (int i = 0; i< MTG_NB_COLORS; i++){
for (int i = 0; i< Constants::MTG_NB_COLORS; i++){
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
match = NULL;
}
@@ -65,14 +65,14 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){
//Abilities
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
if ((basicAbilities[j] == 1 && !card->basicAbilities[j]) || (basicAbilities[j] == -1 && card->basicAbilities[j])){
match = NULL;
}
}
if ((tapped == -1 && card->isTapped()) || (tapped == 1 && !card->isTapped())){
if ((tapped == -1 && card->isTapped()) || (tapped == 1 && !card->isTapped())){
match = NULL;
}
+19 -19
View File
@@ -5,13 +5,13 @@
void CardGui::alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcons, float x, float y, float rotation, float scale){
JQuad * mIcons[7];
if (!manaIcons){
mIcons[MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
mIcons[MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
mIcons[MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
mIcons[MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red");
mIcons[MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black");
mIcons[MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue");
mIcons[MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green");
mIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
mIcons[Constants::MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
mIcons[Constants::MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
mIcons[Constants::MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red");
mIcons[Constants::MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black");
mIcons[Constants::MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue");
mIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green");
for (int i=0; i < 7; i++){
mIcons[i]->SetHotSpot(16,16);
}
@@ -47,7 +47,7 @@ void CardGui::alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcon
}
if (rotation == 0){
renderer->FillRoundRect(x+points[0].x + 2 ,y+points[0].y +2 ,width*scale-8,height*scale-8,2,ARGB(255,_r[color],_g[color],_b[color]));
renderer->FillRoundRect(x+points[0].x + 2 ,y+points[0].y +2 ,width*scale-8,height*scale-8,2,ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
renderer->FillRect(x+points[0].x + 6 ,y+points[0].y + 6 ,width*scale-12,height*scale-12,bgcolor2);
}else{
for (int i=0; i < 4; i++){
@@ -58,7 +58,7 @@ void CardGui::alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcon
ManaCost * manacost = card->getManaCost();
int nbicons = 0;
for (int i = 1; i < MTG_NB_COLORS - 1; i++){
for (int i = 1; i < Constants::MTG_NB_COLORS - 1; i++){
int cost = manacost->getCost(i);
for (int j=0; j < cost; j++){
@@ -135,7 +135,7 @@ void CardGui::alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcon
multiply = 1.1;
}
mFont->SetScale(scale * multiply);
mFont->SetColor(ARGB(255,_r[color],_g[color],_b[color]));
mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->DrawString(card->getName(),x+v.x,y+v.y);
mFont->SetScale(scale);
mFont->SetColor(ARGB(255,255,255,255));
@@ -162,15 +162,15 @@ CardGui::CardGui(int id, MTGCardInstance * _card, float desiredHeight,float _x,
alpha = 255;
mParticleSys = NULL;
if (card->hasColor(MTG_COLOR_RED)){
if (card->hasColor(Constants::MTG_COLOR_RED)){
mParticleSys = GameApp::Particles[3];
}else if (card->hasColor(MTG_COLOR_BLUE)){
}else if (card->hasColor(Constants::MTG_COLOR_BLUE)){
mParticleSys = GameApp::Particles[1];
}else if (card->hasColor(MTG_COLOR_GREEN)){
}else if (card->hasColor(Constants::MTG_COLOR_GREEN)){
mParticleSys = GameApp::Particles[2];
}else if (card->hasColor(MTG_COLOR_BLACK)){
}else if (card->hasColor(Constants::MTG_COLOR_BLACK)){
mParticleSys = GameApp::Particles[4];
}else if (card->hasColor(MTG_COLOR_WHITE)){
}else if (card->hasColor(Constants::MTG_COLOR_WHITE)){
mParticleSys = GameApp::Particles[0];
}else{
mParticleSys = GameApp::Particles[5];
@@ -239,7 +239,7 @@ void CardGui::RenderBig(float xpos, float ypos, int alternate){
void CardGui::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = card->getThumb();
@@ -289,15 +289,15 @@ void CardGui::Render(){
char buffer[200];
sprintf(buffer, "%s",card->getName());
mFont->SetColor(ARGB(255,_r[color],_g[color],_b[color]));
mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
if (card->isTapped()){
renderer->FillRect(myX - 64 * mScale , myY , 64 * mScale, 40 * mScale, ARGB(255,0,0,0));
renderer->DrawRect(myX - 64 * mScale , myY , 64 * mScale, 40 * mScale, ARGB(255,_r[color],_g[color],_b[color]));
renderer->DrawRect(myX - 64 * mScale , myY , 64 * mScale, 40 * mScale, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->SetScale(0.20);
mFont->DrawString(buffer,myX - (64 * mScale)+4,myY + 1);
}else{
renderer->FillRect(myX , myY , 40 * mScale, 64 * mScale, ARGB(255,0,0,0));
renderer->DrawRect(myX , myY , 40 * mScale, 64 * mScale, ARGB(255,_r[color],_g[color],_b[color]));
renderer->DrawRect(myX , myY , 40 * mScale, 64 * mScale, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->SetScale(0.40);
mFont->DrawString(buffer,myX+4,myY + 1);
}
+4 -4
View File
@@ -34,7 +34,7 @@ int Damage::resolve(){
state = RESOLVED_NOK;
return 0;
}
if (source->has(WITHER)){
if (source->has(Constants::WITHER)){
for (int i = 0; i < damage; i++){
_target->counters->addCounter(-1, -1);
}
@@ -48,7 +48,7 @@ int Damage::resolve(){
}
void Damage::Render(){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
char buffer[200];
@@ -91,7 +91,7 @@ int DamageStack::CombatDamages(int strike){
MTGCardInstance * attacker = attackers->getNextAttacker(NULL);
while (attacker != NULL){
int nbdefensers = defensers->nbDefensers(attacker);
if ((!strike && !attacker->has(FIRSTSTRIKE)) || (strike && attacker->has(FIRSTSTRIKE)) || attacker->has(DOUBLESTRIKE)){
if ((!strike && !attacker->has(Constants::FIRSTSTRIKE)) || (strike && attacker->has(Constants::FIRSTSTRIKE)) || attacker->has(Constants::DOUBLESTRIKE)){
if (nbdefensers == 0){
Damage * damage = NEW Damage (mCount, attacker, game->opponent());
Add(damage);
@@ -106,7 +106,7 @@ int DamageStack::CombatDamages(int strike){
}
MTGCardInstance * defenser = defensers->getNextDefenser(NULL, attacker);
while (defenser != NULL){
if ((!strike && !defenser->has(FIRSTSTRIKE)) || (strike && defenser->has(FIRSTSTRIKE)) || defenser->has(DOUBLESTRIKE)){
if ((!strike && !defenser->has(Constants::FIRSTSTRIKE)) || (strike && defenser->has(Constants::FIRSTSTRIKE)) || defenser->has(Constants::DOUBLESTRIKE)){
Damage * damage = NEW Damage (mCount,defenser, attacker);
Add(damage);
}
+8 -8
View File
@@ -15,7 +15,7 @@ DamageResolverLayer::DamageResolverLayer(int id, GameObserver * _game):PlayGuiOb
}
void DamageResolverLayer::Update(float dt){
int newPhase = game->getCurrentGamePhase();
if (newPhase == MTG_PHASE_COMBATDAMAGE){
if (newPhase == Constants::MTG_PHASE_COMBATDAMAGE){
if (!game->mLayers->stackLayer()->getNext(NULL,0,NOT_RESOLVED)){
if (newPhase != currentPhase){
@@ -38,10 +38,10 @@ Player * DamageResolverLayer::whoSelectsDamagesDealtBy(MTGCardInstance * card){
MTGInPlay * defensers = game->opponent()->game->inPlay;
int nbdefensers = defensers->nbDefensers(card);
if (nbdefensers == 0) return NULL;
if(nbdefensers == 1 && !card->has(TRAMPLE)) return NULL;
if(nbdefensers == 1 && !card->has(Constants::TRAMPLE)) return NULL;
MTGCardInstance * defenser = defensers->getNextDefenser(NULL, card);
while (defenser != NULL){
if (defenser->has(BANDING)) return game->opponent();
if (defenser->has(Constants::BANDING)) return game->opponent();
defenser = defensers->getNextDefenser(defenser, card);
}
return game->currentPlayer;
@@ -143,7 +143,7 @@ int DamageResolverLayer::initResolve(){
sprintf(buf, "attacker : %s \n", attacker->getName());
OutputDebugString(buf);
#endif
if ((!strike && !attacker->has(FIRSTSTRIKE)) || (strike && attacker->has(FIRSTSTRIKE)) || attacker->has(DOUBLESTRIKE)){
if ((!strike && !attacker->has(Constants::FIRSTSTRIKE)) || (strike && attacker->has(Constants::FIRSTSTRIKE)) || attacker->has(Constants::DOUBLESTRIKE)){
Player * selecter = whoSelectsDamagesDealtBy(attacker);
if (!selecter){
addAutoDamageToOpponents(attacker);
@@ -153,7 +153,7 @@ int DamageResolverLayer::initResolve(){
}
MTGCardInstance * defenser = defensers->getNextDefenser(NULL, attacker);
while (defenser != NULL){
if ((!strike && !defenser->has(FIRSTSTRIKE)) || (strike && defenser->has(FIRSTSTRIKE)) || defenser->has(DOUBLESTRIKE)){
if ((!strike && !defenser->has(Constants::FIRSTSTRIKE)) || (strike && defenser->has(Constants::FIRSTSTRIKE)) || defenser->has(Constants::DOUBLESTRIKE)){
Player * selecterb = whoSelectsDamagesDealtBy(defenser);
if (!selecterb){
addAutoDamageToOpponents(defenser);
@@ -201,7 +201,7 @@ int DamageResolverLayer::canStopDealDamages(){
if (current->damageSelecter==currentChoosingPlayer && current->damageToDeal > 0){
MTGCardInstance * card = current->card;
if (card->controller() == game->currentPlayer){ //Attacker
if (card->has(TRAMPLE)){
if (card->has(Constants::TRAMPLE)){
MTGInPlay * defensers = game->opponent()->game->inPlay;
MTGCardInstance * defenser = defensers->getNextDefenser(NULL, card);
while (defenser != NULL){
@@ -226,7 +226,7 @@ int DamageResolverLayer::trampleDamage(){
if (current->damageToDeal > 0){
MTGCardInstance * card = current->card;
if (card->controller() == game->currentPlayer){ //Attacker
if (card->has(TRAMPLE)){
if (card->has(Constants::TRAMPLE)){
Damage * damage = NEW Damage(0, card, game->opponent(), current->damageToDeal);
damageStack->Add(damage);
}
@@ -334,7 +334,7 @@ bool DamageResolverLayer::CheckUserInput(u32 key){
void DamageResolverLayer::Render(){
if (!mCount) return;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
+2 -2
View File
@@ -13,7 +13,7 @@ DamagerDamaged::DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _
DamagerDamaged::~DamagerDamaged(){
for (int i = 0; i < mCount; i++){
SAFE_DELETE(damages[i]);
}
}
@@ -72,7 +72,7 @@ int DamagerDamaged::removeDamagesFrom(DamagerDamaged * source){
}
void DamagerDamaged::Render(Player * currentPlayer){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
mFont->SetScale(0.75);
CardGui::Render();
+7 -9
View File
@@ -3,7 +3,7 @@
DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
parent = deck;
for (int i = 0; i <= MTG_NB_COLORS; i++){
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++){
colors[i] = 0;
}
for (int i = 0; i < deck->totalCards(); i++){
@@ -33,22 +33,22 @@ DeckDataWrapper::~DeckDataWrapper(){
void DeckDataWrapper::updateCounts(MTGCard * card, int removed){
if (!card){
for (int i = 0; i < MTG_NB_COLORS+1; i++){
for (int i = 0; i < Constants::MTG_NB_COLORS+1; i++){
colors[i] = 0;
}
map<MTGCard *,int,Cmp1>::iterator it;
for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCard * current = (*it).first;
colors[MTG_NB_COLORS] += (*it).second;
for (int i = 0; i < MTG_NB_COLORS; i++){
colors[Constants::MTG_NB_COLORS] += (*it).second;
for (int i = 0; i < Constants::MTG_NB_COLORS; i++){
if (current->hasColor(i)) colors[i]+=(*it).second;
}
}
}else{
int increment = 1;
if (removed) increment = -1;
colors[MTG_NB_COLORS] += increment;
for (int i = 0; i < MTG_NB_COLORS; i++){
colors[Constants::MTG_NB_COLORS] += increment;
for (int i = 0; i < Constants::MTG_NB_COLORS; i++){
if (card->hasColor(i)) colors[i]+=increment;
}
}
@@ -75,7 +75,6 @@ MTGCard * DeckDataWrapper::getNext(MTGCard * previous, int color){
map<MTGCard *,int,Cmp1>::iterator it;
it = cards.find(previous);
int found = 0;
while(1){
if (it == cards.end()){
@@ -95,7 +94,6 @@ MTGCard * DeckDataWrapper::getNext(MTGCard * previous, int color){
MTGCard * DeckDataWrapper::getPrevious(MTGCard * next, int color){
map<MTGCard *,int,Cmp1>::iterator it;
it = cards.find(next);
int found = 0;
while(1){
if (it == cards.begin()){
@@ -126,6 +124,6 @@ void DeckDataWrapper::updateCurrentPosition(MTGCard * currentCard, int color){
}
int DeckDataWrapper::getCount(int color){
if (color == -1) return colors[MTG_NB_COLORS];
if (color == -1) return colors[Constants::MTG_NB_COLORS];
return colors[color];
}
+17 -17
View File
@@ -83,24 +83,24 @@ void GameObserver::nextGamePhase(){
if (currentPlayer != cPhase->player) nextPlayer();
//init begin of turn
if (currentGamePhase == MTG_PHASE_BEFORE_BEGIN){
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
cleanupPhase();
currentPlayer->canPutLandsIntoPlay = 1;
mLayers->actionLayer()->Update(0);
return nextGamePhase();
}
//manaBurn
if (currentGamePhase == MTG_PHASE_UNTAP ||
currentGamePhase == MTG_PHASE_FIRSTMAIN ||
currentGamePhase == MTG_PHASE_COMBATBEGIN ||
currentGamePhase == MTG_PHASE_SECONDMAIN ||
currentGamePhase == MTG_PHASE_ENDOFTURN
if (currentGamePhase == Constants::MTG_PHASE_UNTAP ||
currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN ||
currentGamePhase == Constants::MTG_PHASE_COMBATBEGIN ||
currentGamePhase == Constants::MTG_PHASE_SECONDMAIN ||
currentGamePhase == Constants::MTG_PHASE_ENDOFTURN
){
currentPlayer->manaBurn();
}
//After End of turn
if (currentGamePhase == MTG_PHASE_AFTER_EOT){
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT){
//Auto Hand cleaning, in case the player didn't do it himself
while(currentPlayer->game->hand->nb_cards > 7){
currentPlayer->game->putInGraveyard(currentPlayer->game->hand->cards[0]);
@@ -112,10 +112,10 @@ void GameObserver::nextGamePhase(){
//Phase Specific actions
switch(currentGamePhase){
case MTG_PHASE_UNTAP:
case Constants::MTG_PHASE_UNTAP:
untapPhase();
break;
case MTG_PHASE_DRAW:
case Constants::MTG_PHASE_DRAW:
mLayers->stackLayer()->addDraw(currentPlayer,1);
break;
default:
@@ -147,8 +147,8 @@ void GameObserver::startGame(int shuffle, int draw){
for (i=0; i<nbPlayers; i++){
players[i]->game->initGame(shuffle, draw);
}
phaseRing->goToPhase(MTG_PHASE_FIRSTMAIN, players[0]);
currentGamePhase = MTG_PHASE_FIRSTMAIN;
phaseRing->goToPhase(Constants::MTG_PHASE_FIRSTMAIN, players[0]);
currentGamePhase = Constants::MTG_PHASE_FIRSTMAIN;
}
void GameObserver::addObserver(MTGAbility * observer){
@@ -176,9 +176,9 @@ GameObserver::~GameObserver(){
void GameObserver::Update(float dt){
Player * player = currentPlayer;
if (currentGamePhase == MTG_PHASE_COMBATBLOCKERS){
if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS){
player = opponent();
}else if (currentGamePhase == MTG_PHASE_COMBATDAMAGE){
}else if (currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE){
DamageResolverLayer * drl = mLayers->combatLayer();
if (drl->currentChoosingPlayer && drl->mCount) player = drl->currentChoosingPlayer;
}
@@ -315,7 +315,7 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
currentPlayer->canPutLandsIntoPlay--;
}
}else if (currentPlayer->game->hand->hasCard(card)){ //Current player's hand
if (currentGamePhase == MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){
if (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){
currentPlayer->game->putInGraveyard(card);
}
}
@@ -326,7 +326,7 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
mLayers->actionLayer()->setMenuObject(object);
}
}else if (card->isTapped() && card->controller() == currentPlayer){
int a = ConstraintResolver::untap(this, card);
// int a = ConstraintResolver::untap(this, card);
}
}
@@ -349,11 +349,11 @@ int GameObserver::canPutInPlay(MTGCardInstance * card){
LOG("CANPUTINPLAY- check if card is land or can be played\n");
if (card->hasType("land")){
LOG("CANPUTINPLAY- card is land - check if can be played\n");
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (currentGamePhase == MTG_PHASE_FIRSTMAIN || currentGamePhase == MTG_PHASE_SECONDMAIN)){
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
LOG("CANPUTINPLAY- Land, ok\n");
return 1;
}
}else if ((card->hasType("instant")) || card->has(FLASH) || (player == currentPlayer && (currentGamePhase == MTG_PHASE_FIRSTMAIN || currentGamePhase == MTG_PHASE_SECONDMAIN))){
}else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && (currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))){
LOG("CANPUTINPLAY- correct time to play\n");
if (checkManaCost(card)){
LOG("CANPUTINPLAY- ManaCost ok\n");
+16 -16
View File
@@ -300,20 +300,20 @@ void GameStateMenu::createUsersFirstDeck(int setId){
#endif
MTGDeck *mCollection = NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache, mParent->collection);
//10 lands of each
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Forest")){
mCollection->addRandomCards(10, -1,RARITY_L,"Forest");
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Forest")){
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Forest");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Plains")){
mCollection->addRandomCards(10, -1,RARITY_L,"Plains");
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Plains")){
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Plains");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Swamp")){
mCollection->addRandomCards(10, -1,RARITY_L,"Swamp");
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Swamp")){
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Swamp");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Mountain")){
mCollection->addRandomCards(10, -1,RARITY_L,"Mountain");
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Mountain")){
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Mountain");
}
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Island")){
mCollection->addRandomCards(10, -1,RARITY_L,"Island");
if (!mCollection->addRandomCards(10, setId,Constants::RARITY_L,"Island")){
mCollection->addRandomCards(10, -1,Constants::RARITY_L,"Island");
}
@@ -322,18 +322,18 @@ void GameStateMenu::createUsersFirstDeck(int setId){
#endif
//Starter Deck
mCollection->addRandomCards(3, setId,RARITY_R,NULL);
mCollection->addRandomCards(9, setId,RARITY_U,NULL);
mCollection->addRandomCards(48, setId,RARITY_C,NULL);
mCollection->addRandomCards(3, setId,Constants::RARITY_R,NULL);
mCollection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
mCollection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
#if defined (WIN32) || defined (LINUX)
OutputDebugString("2\n");
#endif
//Boosters
for (int i = 0; i< 2; i++){
mCollection->addRandomCards(1, setId,RARITY_R);
mCollection->addRandomCards(3, setId,RARITY_U);
mCollection->addRandomCards(11, setId,RARITY_C);
mCollection->addRandomCards(1, setId,Constants::RARITY_R);
mCollection->addRandomCards(3, setId,Constants::RARITY_U);
mCollection->addRandomCards(11, setId,Constants::RARITY_C);
}
mCollection->save();
SAFE_DELETE(mCollection);
+78 -78
View File
@@ -86,8 +86,8 @@ Trigger * AbilityFactory::parseTrigger(string magicText){
//Next Time...
found = magicText.find("next");
if (found != string::npos){
for (int i = 0; i < NB_MTG_PHASES; i++){
found = magicText.find(MTGPhaseCodeNames[i]);
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
found = magicText.find(Constants::MTGPhaseCodeNames[i]);
if (found != string::npos){
return NEW TriggerNextPhase(i);
}
@@ -242,7 +242,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
end = s.find(",",previous);
string spt = s.substr(previous,end - previous);
int power, toughness;
int havePowertoughness = parsePowerToughness(spt,&power, &toughness);
//int havePowertoughness = parsePowerToughness(spt,&power, &toughness);
string sabilities = s.substr(end+1);
ManaCost * cost = ManaCost::parseManaCost(s);
int multiplier = 1;
@@ -499,13 +499,13 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
}
//Gain/loose Ability
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
found = s.find(MTGBasicAbilities[j]);
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
found = s.find(Constants::MTGBasicAbilities[j]);
if (found!= string::npos){
int modifier = 1;
if (found > 0 && s[found-1] == '-') modifier = 0;
if (dryMode){
if (j == DEFENDER){
if (j == Constants::DEFENDER){
if (modifier == 1) return BAKA_EFFECT_BAD;
return BAKA_EFFECT_GOOD;
}else{
@@ -610,7 +610,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1096: //Basalt Monolith
{
int cost[] = {MTG_COLOR_ARTIFACT, 3};
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 3};
AManaProducer * ability = NEW AManaProducer(_id, card, NEW ManaCost(cost,1));
AUntapManaBlocker * ability2 = NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1));
AUnBlocker * ability3 = NEW AUnBlocker(_id+1, card,card, NEW ManaCost(cost,1));
@@ -622,7 +622,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1097: //Black Vise
{
game->addObserver( NEW ALifeZoneLink(_id ,card, MTG_PHASE_UPKEEP, 4));
game->addObserver( NEW ALifeZoneLink(_id ,card, Constants::MTG_PHASE_UPKEEP, 4));
break;
}
case 1191: //Blue Elemental Blast
@@ -637,7 +637,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1099: //Brass Man
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
game->addObserver(NEW AUntapManaBlocker(_id, card, NEW ManaCost(cost,1)));
break;
}
@@ -649,36 +649,36 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1282: //Chaoslace
{
if (card->target){
card->target->setColor(MTG_COLOR_RED, 1);
card->target->setColor(Constants::MTG_COLOR_RED, 1);
}else{
Spell * starget = spell->getNextSpellTarget();
starget->source->setColor(MTG_COLOR_RED, 1);
starget->source->setColor(Constants::MTG_COLOR_RED, 1);
}
break;
}
case 1335: //Circle of protection : black
{
game->addObserver(NEW ACircleOfProtection( _id,card, MTG_COLOR_BLACK));
game->addObserver(NEW ACircleOfProtection( _id,card, Constants::MTG_COLOR_BLACK));
break;
}
case 1336: //Circle of protection : blue
{
game->addObserver(NEW ACircleOfProtection( _id,card, MTG_COLOR_BLUE));
game->addObserver(NEW ACircleOfProtection( _id,card, Constants::MTG_COLOR_BLUE));
break;
}
case 1337: //Circle of protection : green
{
game->addObserver(NEW ACircleOfProtection( _id,card, MTG_COLOR_GREEN));
game->addObserver(NEW ACircleOfProtection( _id,card, Constants::MTG_COLOR_GREEN));
break;
}
case 1338: //Circle of protection : red
{
game->addObserver(NEW ACircleOfProtection( _id,card, MTG_COLOR_RED));
game->addObserver(NEW ACircleOfProtection( _id,card, Constants::MTG_COLOR_RED));
break;
}
case 1339: //Circle of protection : white
{
game->addObserver(NEW ACircleOfProtection( _id,card, MTG_COLOR_WHITE));
game->addObserver(NEW ACircleOfProtection( _id,card, Constants::MTG_COLOR_WHITE));
break;
}
case 1101: //clockwork Beast
@@ -704,24 +704,24 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1103: //Crystal Rod
{
int cost[] = {MTG_COLOR_BLUE, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, MTG_COLOR_WHITE,NEW ManaCost(cost,1) , 1);
int cost[] = {Constants::MTG_COLOR_BLUE, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_WHITE,NEW ManaCost(cost,1) , 1);
game->addObserver(ability);
break;
}
case 1151: //Deathgrip
{
int _cost[] = {MTG_COLOR_BLACK, 2};
game->addObserver(NEW ASpellCounterEnchantment(_id, card, NEW ManaCost(_cost, 1),MTG_COLOR_GREEN));
int _cost[] = {Constants::MTG_COLOR_BLACK, 2};
game->addObserver(NEW ASpellCounterEnchantment(_id, card, NEW ManaCost(_cost, 1),Constants::MTG_COLOR_GREEN));
break;
}
case 1152: //Deathlace
{
if (card->target){
card->target->setColor(MTG_COLOR_BLACK, 1);
card->target->setColor(Constants::MTG_COLOR_BLACK, 1);
}else{
Spell * starget = spell->getNextSpellTarget();
starget->source->setColor(MTG_COLOR_BLACK, 1);
starget->source->setColor(Constants::MTG_COLOR_BLACK, 1);
}
break;
}
@@ -782,8 +782,8 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1113: //Iron Star
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, MTG_COLOR_RED,NEW ManaCost(cost,1) , 1);
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_RED,NEW ManaCost(cost,1) , 1);
game->addObserver(ability);
break;
}
@@ -794,14 +794,14 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1114: //Ivory cup
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, MTG_COLOR_WHITE,NEW ManaCost(cost,1) , 1);
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_WHITE,NEW ManaCost(cost,1) , 1);
game->addObserver(ability);
break;
}
case 1115: //Ivory Tower
{
game->addObserver(NEW ALifeZoneLink(_id ,card, MTG_PHASE_UPKEEP, 4, 1, 1));
game->addObserver(NEW ALifeZoneLink(_id ,card, Constants::MTG_PHASE_UPKEEP, 4, 1, 1));
break;
}
case 1117: //Jandors Ring
@@ -821,17 +821,17 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1256: //LifeForce
{
int _cost[] = {MTG_COLOR_GREEN, 2};
game->addObserver(NEW ASpellCounterEnchantment(_id, card, NEW ManaCost(_cost, 1),MTG_COLOR_BLACK));
int _cost[] = {Constants::MTG_COLOR_GREEN, 2};
game->addObserver(NEW ASpellCounterEnchantment(_id, card, NEW ManaCost(_cost, 1),Constants::MTG_COLOR_BLACK));
break;
}
case 1257: //Lifelace
{
if (card->target){
card->target->setColor(MTG_COLOR_GREEN, 1);
card->target->setColor(Constants::MTG_COLOR_GREEN, 1);
}else{
Spell * starget = spell->getNextSpellTarget();
starget->source->setColor(MTG_COLOR_GREEN, 1);
starget->source->setColor(Constants::MTG_COLOR_GREEN, 1);
}
break;
}
@@ -847,11 +847,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1124: //Mana Vault
{
int output[] = {MTG_COLOR_ARTIFACT, 3};
int output[] = {Constants::MTG_COLOR_ARTIFACT, 3};
game->addObserver(NEW AManaProducer(_id,card,NEW ManaCost(output,1)));
int cost[] = {MTG_COLOR_ARTIFACT, 4};
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
game->addObserver(NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1)));
game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, MTG_PHASE_DRAW, -1, 1));
game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, Constants::MTG_PHASE_DRAW, -1, 1));
break;
}
case 1126:// Millstone
@@ -872,10 +872,10 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1358: //Purelace
{
if (card->target){
card->target->setColor(MTG_COLOR_WHITE, 1);
card->target->setColor(Constants::MTG_COLOR_WHITE, 1);
}else{
Spell * starget = spell->getNextSpellTarget();
starget->source->setColor(MTG_COLOR_WHITE, 1);
starget->source->setColor(Constants::MTG_COLOR_WHITE, 1);
}
break;
}
@@ -896,20 +896,20 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1139: //The Rack
{
game->addObserver( NEW ALifeZoneLink(_id ,card, MTG_PHASE_UPKEEP, -3));
game->addObserver( NEW ALifeZoneLink(_id ,card, Constants::MTG_PHASE_UPKEEP, -3));
break;
}
case 1140: //Throne of bones
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, MTG_COLOR_BLACK,NEW ManaCost(cost,1) , 1);
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_BLACK,NEW ManaCost(cost,1) , 1);
game->addObserver(ability);
break;
}
case 1142: //Wooden Sphere
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, MTG_COLOR_GREEN,NEW ManaCost(cost,1) , 1);
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
ASpellCastLife* ability = NEW ASpellCastLife(_id, card, Constants::MTG_COLOR_GREEN,NEW ManaCost(cost,1) , 1);
game->addObserver(ability);
break;
}
@@ -1004,7 +1004,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1171: //Paralysis
{
int cost[] = {MTG_COLOR_ARTIFACT, 4};
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
game->addObserver(NEW AUntapManaBlocker(_id, card,card->target, NEW ManaCost(cost,1)));
card->target->tapped = 1;
break;
@@ -1042,7 +1042,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1185: //Warp Artifact
{
game->addObserver(NEW ARegularLifeModifierAura(_id, card, card->target, MTG_PHASE_UPKEEP, -1));
game->addObserver(NEW ARegularLifeModifierAura(_id, card, card->target, Constants::MTG_PHASE_UPKEEP, -1));
break;
}
case 1192: //BrainGeyser
@@ -1067,7 +1067,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 129601: //Icy Manipulator
{
int cost[] = {MTG_COLOR_ARTIFACT, 1};
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 1};
TypeTargetChooser * tc = new TypeTargetChooser("artifact",card);
tc->addType("land");
tc->addType("creature");
@@ -1077,7 +1077,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1203: //Island Fish
{
int cost[] = {MTG_COLOR_BLUE, 3};
int cost[] = {Constants::MTG_COLOR_BLUE, 3};
game->addObserver(NEW AUntapManaBlocker(_id, card, NEW ManaCost(cost,1)));
game->addObserver(NEW AStrongLandLinkCreature(_id, card, "island"));
break;
@@ -1116,7 +1116,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1228: //Unstable mutation
{
game->addObserver(NEW APowerToughnessModifier(_id, card, card->target, 3, 3));
game->addObserver(NEW APowerToughnessModifierRegularCounter(_id, card, card->target, MTG_PHASE_UPKEEP, -1, -1));
game->addObserver(NEW APowerToughnessModifierRegularCounter(_id, card, card->target, Constants::MTG_PHASE_UPKEEP, -1, -1));
break;
}
case 1229: //Unsummon
@@ -1133,7 +1133,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1236: //Birds of Paradise
{
for (int i = MTG_COLOR_GREEN; i <= MTG_COLOR_WHITE; i++){
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; i++){
int output[]={i,1};
game->addObserver(NEW AManaProducer(_id + i, card, NEW ManaCost(output,1)));
}
@@ -1152,7 +1152,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (current->basicAbilities[FLYING] && current->isACreature()){
if (current->basicAbilities[Constants::FLYING] && current->isACreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
@@ -1161,7 +1161,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1262: //Regeneration
{
int cost[] = {MTG_COLOR_GREEN, 1};
int cost[] = {Constants::MTG_COLOR_GREEN, 1};
game->addObserver(NEW AStandardRegenerate(_id,card,card->target,NEW ManaCost(cost,1)));
break;
}
@@ -1204,7 +1204,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1278: //Web
{
game->addObserver(NEW APowerToughnessModifier(_id, card, card->target, 0,2));
game->addObserver(NEW ABasicAbilityModifier(_id + 1, card, card->target, REACH));
game->addObserver(NEW ABasicAbilityModifier(_id + 1, card, card->target, Constants::REACH));
break;
}
case 1280: //Atog
@@ -1216,7 +1216,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
{
CreatureTargetChooser * tc = NEW CreatureTargetChooser(card);
tc->maxpower = 2;
game->addObserver(NEW ABasicAbilityModifierUntilEOT(_id, card, UNBLOCKABLE, NULL,tc));
game->addObserver(NEW ABasicAbilityModifierUntilEOT(_id, card, Constants::UNBLOCKABLE, NULL,tc));
break;
}
case 1288: //EarthBind
@@ -1231,7 +1231,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (!current->basicAbilities[FLYING] && current->isACreature()){
if (!current->basicAbilities[Constants::FLYING] && current->isACreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
@@ -1275,7 +1275,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1326: //Wheel of fortune
{
for (int i = 0; i < 2; i++){
MTGLibrary * library = game->players[i]->game->library;
// MTGLibrary * library = game->players[i]->game->library;
MTGHand * hand = game->players[i]->game->hand;
for (int j = hand->nb_cards-1; j>=0; j--){
game->players[i]->game->putInGraveyard(hand->cards[j]);
@@ -1288,12 +1288,12 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1331: //Black Ward
{
game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_BLACK));
game->addObserver(NEW AProtectionFrom( _id,card, card->target, Constants::MTG_COLOR_BLACK));
break;
}
case 1333: //Blue Ward
{
game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_BLUE));
game->addObserver(NEW AProtectionFrom( _id,card, card->target, Constants::MTG_COLOR_BLUE));
break;
}
case 1334: //Castle
@@ -1308,7 +1308,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1346: //Green Ward
{
game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_GREEN));
game->addObserver(NEW AProtectionFrom( _id,card, card->target, Constants::MTG_COLOR_GREEN));
break;
}
case 1352: //Karma
@@ -1323,7 +1323,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1359: //Red Ward
{
game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_RED));
game->addObserver(NEW AProtectionFrom( _id,card, card->target, Constants::MTG_COLOR_RED));
break;
}
case 1360: //Resurrection
@@ -1361,7 +1361,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 1182: //Terror
{
if (card->target->hasColor(MTG_COLOR_BLACK) || card->target->hasSubtype("artifact")){
if (card->target->hasColor(Constants::MTG_COLOR_BLACK) || card->target->hasSubtype("artifact")){
}else{
card->target->controller()->game->putInGraveyard(card->target);
}
@@ -1375,16 +1375,16 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 1227: //Toughtlace
{
if (card->target){
card->target->setColor(MTG_COLOR_BLUE, 1);
card->target->setColor(Constants::MTG_COLOR_BLUE, 1);
}else{
Spell * starget = spell->getNextSpellTarget();
starget->source->setColor(MTG_COLOR_BLUE, 1);
starget->source->setColor(Constants::MTG_COLOR_BLUE, 1);
}
break;
}
case 1371: //White Ward
{
game->addObserver(NEW AProtectionFrom( _id,card, card->target, MTG_COLOR_WHITE));
game->addObserver(NEW AProtectionFrom( _id,card, card->target, Constants::MTG_COLOR_WHITE));
break;
}
@@ -1457,7 +1457,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
case 2443: //Dark Banishing
{
if (card->target->hasColor(MTG_COLOR_BLACK)){
if (card->target->hasColor(Constants::MTG_COLOR_BLACK)){
}else{
card->target->controller()->game->putInGraveyard(card->target);
}
@@ -1471,7 +1471,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
case 2484: //Songs of the Damned
{
int mana = card->controller()->game->graveyard->countByType("creature");
game->currentlyActing()->getManaPool()->add(MTG_COLOR_BLACK, mana);
game->currentlyActing()->getManaPool()->add(Constants::MTG_COLOR_BLACK, mana);
break;
}
@@ -1490,21 +1490,21 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
int mana_cr = game->opponent()->game->graveyard->countByType("creature");
int mana_ar = game->opponent()->game->graveyard->countByType("artifact");
int spoil = mana_ar + mana_cr;
game->currentlyActing()->getManaPool()->add(MTG_COLOR_ARTIFACT, spoil);
game->currentlyActing()->getManaPool()->add(Constants::MTG_COLOR_ARTIFACT, spoil);
game->currentlyActing()->life+= spoil;
break;
}
case 2435: //Whalebone Glider
{
int cost[] = {MTG_COLOR_ARTIFACT,2};
int cost[] = {Constants::MTG_COLOR_ARTIFACT,2};
CreatureTargetChooser * tc = NEW CreatureTargetChooser(card);
tc->maxpower = 3;
game->addObserver(NEW ABasicAbilityModifierUntilEOT(_id, card, FLYING, NEW ManaCost(cost,1),tc));
game->addObserver(NEW ABasicAbilityModifierUntilEOT(_id, card, Constants::FLYING, NEW ManaCost(cost,1),tc));
break;
}
case 2393: //Aegis of the Meek work but work also for 0/1 creatures... :D
{
int cost[] = {MTG_COLOR_ARTIFACT,1};
int cost[] = {Constants::MTG_COLOR_ARTIFACT,1};
CreatureTargetChooser * tc = NEW CreatureTargetChooser(card);
tc->maxpower = 1;
tc->maxtoughness =1;
@@ -1527,41 +1527,41 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
* For example, setting LIFELINK for a creature is not enough right now...
* It shouldn't be necessary to add an object. State based abilities could do the trick
*/
if (card->basicAbilities[LIFELINK]){
if (card->basicAbilities[Constants::LIFELINK]){
ALifeLink * ability = NEW ALifeLink(_id, card);
game->addObserver(ability);
}
for (int i=PROTECTIONGREEN; i <= PROTECTIONWHITE; i++){
for (int i=Constants::PROTECTIONGREEN; i <= Constants::PROTECTIONWHITE; i++){
if (card->basicAbilities[i]){
game->addObserver(NEW AProtectionFrom(_id, card, card, i - PROTECTIONGREEN + MTG_COLOR_GREEN));
game->addObserver(NEW AProtectionFrom(_id, card, card, i - Constants::PROTECTIONGREEN + Constants::MTG_COLOR_GREEN));
}
}
if (card->basicAbilities[EXALTED]){
if (card->basicAbilities[Constants::EXALTED]){
game->addObserver(NEW AExalted(_id, card));
}
// Tested works the first r10 did not function because of the mistake in the array of the definition
if (card->basicAbilities[FORESTHOME]){
if (card->basicAbilities[Constants::FORESTHOME]){
game->addObserver(NEW AStrongLandLinkCreature(_id, card, "forest"));
}
if (card->basicAbilities[ISLANDHOME]){
if (card->basicAbilities[Constants::ISLANDHOME]){
game->addObserver(NEW AStrongLandLinkCreature(_id, card, "island"));
}
if (card->basicAbilities[MOUNTAINHOME]){
if (card->basicAbilities[Constants::MOUNTAINHOME]){
game->addObserver(NEW AStrongLandLinkCreature(_id, card,"moutain"));
}
if (card->basicAbilities[SWAMPHOME]){
if (card->basicAbilities[Constants::SWAMPHOME]){
game->addObserver(NEW AStrongLandLinkCreature(_id, card,"swamp"));
}
if (card->basicAbilities[PLAINSHOME]){
if (card->basicAbilities[Constants::PLAINSHOME]){
game->addObserver(NEW AStrongLandLinkCreature(_id, card,"plains"));
}
// New Abilities Flanking and Rampage
if (card->basicAbilities [RAMPAGE1]){
if (card->basicAbilities [Constants::RAMPAGE1]){
game->addObserver (NEW ARampageAbility(_id, card, 1, 1));
}
@@ -1751,7 +1751,7 @@ InstantAbility::InstantAbility(int _id, MTGCardInstance * source, Damageable * _
//Instant abilities last generally until the end of the turn
int InstantAbility::testDestroy(){
int newPhase = game->getCurrentGamePhase();
if (newPhase != currentPhase && newPhase == MTG_PHASE_UNTAP) return 1;
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP) return 1;
currentPhase = newPhase;
return 0;
+7 -7
View File
@@ -33,14 +33,14 @@ const char * MTGCard::getSetName(){
MTGCard::MTGCard(MTGCard * source){
mCache = source->mCache;
for (int i = 0; i< NB_BASIC_ABILITIES; i++){
for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){
basicAbilities[i] = source->basicAbilities[i];
}
for (int i = 0; i< MAX_TYPES_PER_CARD; i++){
types[i] = source->types[i];
}
nb_types = source->nb_types;
for (int i = 0; i< MTG_NB_COLORS; i++){
for (int i = 0; i< Constants::MTG_NB_COLORS; i++){
colors[i] = source->colors[i];
}
manaCost.copy(source->getManaCost());
@@ -62,13 +62,13 @@ MTGCard::MTGCard(MTGCard * source){
int MTGCard::init(){
nb_types = 0;
for (int i = 0; i< NB_BASIC_ABILITIES; i++){
for (int i = 0; i< Constants::NB_BASIC_ABILITIES; i++){
basicAbilities[i] = 0;
}
for (int i = 0; i< MAX_TYPES_PER_CARD; i++){
types[i] = 0;
}
for (int i = 0; i< MTG_NB_COLORS; i++){
for (int i = 0; i< Constants::MTG_NB_COLORS; i++){
colors[i] = 0;
}
setId = 0;
@@ -104,7 +104,7 @@ int MTGCard::isACreature(){
void MTGCard::setColor(int _color, int removeAllOthers){
if (removeAllOthers){
for (int i=0; i<MTG_NB_COLORS; i++){
for (int i=0; i<Constants::MTG_NB_COLORS; i++){
colors[i] = 0;
}
}
@@ -113,7 +113,7 @@ void MTGCard::setColor(int _color, int removeAllOthers){
int MTGCard::getColor(){
int i = 0;
for (int i=0; i<MTG_NB_COLORS; i++){
for (int i=0; i<Constants::MTG_NB_COLORS; i++){
if (colors[i]){
return i;
}
@@ -128,7 +128,7 @@ int MTGCard::hasColor(int color){
void MTGCard::setManaCost(string s){
ManaCost::parseManaCost(s, &manaCost);
for (int i = MTG_COLOR_GREEN; i <=MTG_COLOR_WHITE; i++){
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; i++){
if (manaCost.hasColor(i)){
setColor(i);
}
+15 -15
View File
@@ -175,7 +175,7 @@ int MTGCardInstance::cleanup(){
*/
int MTGCardInstance::hasSummoningSickness(){
if (!summoningSickness) return 0;
if (basicAbilities[HASTE]) return 0;
if (basicAbilities[Constants::HASTE]) return 0;
if (!isACreature()) return 0;
return 1;
}
@@ -211,7 +211,7 @@ Player * MTGCardInstance::controller(){
}
int MTGCardInstance::canAttack(){
if (!hasSummoningSickness() && !tapped && isACreature() && basicAbilities[DEFENSER] !=1)
if (!hasSummoningSickness() && !tapped && isACreature() && basicAbilities[Constants::DEFENSER] !=1)
return 1;
return 0;
}
@@ -242,18 +242,18 @@ int MTGCardInstance::canBlock(MTGCardInstance * opponent){
if (!opponent->isAttacker()) return 0;
// Comprehensive rule 502.7f : If a creature with protection attacks, it can't be blocked by creatures that have the stated quality.
if (opponent->protectedAgainst(this)) return 0;
if (opponent->basicAbilities[UNBLOCKABLE]) return 0;
if (opponent->basicAbilities[FEAR] && !(hasColor(MTG_COLOR_ARTIFACT) || hasColor(MTG_COLOR_BLACK))) return 0;
if (opponent->basicAbilities[FLYING] && !( basicAbilities[FLYING] || basicAbilities[REACH])) return 0;
if (opponent->basicAbilities[Constants::UNBLOCKABLE]) return 0;
if (opponent->basicAbilities[Constants::FEAR] && !(hasColor(Constants::MTG_COLOR_ARTIFACT) || hasColor(Constants::MTG_COLOR_BLACK))) return 0;
if (opponent->basicAbilities[Constants::FLYING] && !( basicAbilities[Constants::FLYING] || basicAbilities[Constants::REACH])) return 0;
// If opponent has shadow and a creature does not have either shadow or reachshadow it cannot be blocked
if (opponent->basicAbilities[SHADOW] && !( basicAbilities[SHADOW] || basicAbilities[REACHSHADOW])) return 0;
if (opponent->basicAbilities[Constants::SHADOW] && !( basicAbilities[Constants::SHADOW] || basicAbilities[Constants::REACHSHADOW])) return 0;
// If opponent does not have shadow and a creature has shadow it cannot be blocked
if (!opponent->basicAbilities[SHADOW] && basicAbilities[SHADOW]) return 0;
if (opponent->basicAbilities[SWAMPWALK] && controller()->game->inPlay->hasType("swamp")) return 0;
if (opponent->basicAbilities[FORESTWALK] && controller()->game->inPlay->hasType("forest")) return 0;
if (opponent->basicAbilities[ISLANDWALK] && controller()->game->inPlay->hasType("island")) return 0;
if (opponent->basicAbilities[MOUNTAINWALK] && controller()->game->inPlay->hasType("mountain")) return 0;
if (opponent->basicAbilities[PLAINSWALK] && controller()->game->inPlay->hasType("plains")) return 0;
if (!opponent->basicAbilities[Constants::SHADOW] && basicAbilities[Constants::SHADOW]) return 0;
if (opponent->basicAbilities[Constants::SWAMPWALK] && controller()->game->inPlay->hasType("swamp")) return 0;
if (opponent->basicAbilities[Constants::FORESTWALK] && controller()->game->inPlay->hasType("forest")) return 0;
if (opponent->basicAbilities[Constants::ISLANDWALK] && controller()->game->inPlay->hasType("island")) return 0;
if (opponent->basicAbilities[Constants::MOUNTAINWALK] && controller()->game->inPlay->hasType("mountain")) return 0;
if (opponent->basicAbilities[Constants::PLAINSWALK] && controller()->game->inPlay->hasType("plains")) return 0;
return 1;
}
@@ -261,7 +261,7 @@ MTGCardInstance * MTGCardInstance::getNextPartner(){
MTGInPlay * inplay = controller()->game->inPlay;
MTGCardInstance * bandingPartner = inplay->getNextAttacker(banding);
while (bandingPartner){
if (basicAbilities[BANDING] || bandingPartner->basicAbilities[BANDING]) return bandingPartner;
if (basicAbilities[Constants::BANDING] || bandingPartner->basicAbilities[Constants::BANDING]) return bandingPartner;
bandingPartner = inplay->getNextAttacker(bandingPartner);
}
return NULL;
@@ -422,9 +422,9 @@ JSample * MTGCardInstance::getSample(){
}
}
if (!sample.size()){
for (int i = 0; i < NB_BASIC_ABILITIES; i++){
for (int i = 0; i < Constants::NB_BASIC_ABILITIES; i++){
if (!basicAbilities[i]) continue;
string type = MTGBasicAbilities[i];
string type = Constants::MTGBasicAbilities[i];
type = "sound/sfx/" + type + ".wav";
if (fileExists(type.c_str())){
sample = type;
+8 -8
View File
@@ -52,8 +52,8 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
}else if (key.compare("abilities")==0){
//Specific Abilities
std::transform( value.begin(), value.end(), value.begin(),::tolower );
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
unsigned int found = value.find(MTGBasicAbilities[j]);
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
unsigned int found = value.find(Constants::MTGBasicAbilities[j]);
if (found != string::npos){
card->basicAbilities[j] = 1;
}
@@ -74,7 +74,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
break;
case 'A':
card->setType( "Artifact");
card->setColor(MTG_COLOR_ARTIFACT);
card->setColor(Constants::MTG_COLOR_ARTIFACT);
if (value.c_str()[8] == ' ' && value.c_str()[9] == 'C')
card->setSubtype("Creature");
break;
@@ -85,11 +85,11 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
card->setType( "Sorcery");
break;
case 'B'://Basic Land
card->setColor(MTG_COLOR_LAND);
card->setColor(Constants::MTG_COLOR_LAND);
card->setType("Land");
break;
case 'L':
card->setColor(MTG_COLOR_LAND);
card->setColor(Constants::MTG_COLOR_LAND);
card->setType( "Land");
break;
case 'I':
@@ -115,7 +115,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
}
void MTGAllCards::initCounters(){
for (int i=0; i< MTG_NB_COLORS; i++){
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
colorsCount[i] = NULL;
}
}
@@ -209,7 +209,7 @@ int MTGAllCards::countByType(const char * _type){
int MTGAllCards::countByColor(int color){
if (colorsCount[color] == 0){
for (int i=0; i< MTG_NB_COLORS; i++){
for (int i=0; i< Constants::MTG_NB_COLORS; i++){
colorsCount[i] = 0;
}
for (int i=0; i< total_cards; i++){
@@ -309,7 +309,7 @@ int MTGDeck::addRandomCards(int howmany, int setId, int rarity, const char * _su
sprintf(subtype, _subtype);
int subcollection[TOTAL_NUMBER_OF_CARDS];
int subcollection[Constants::TOTAL_NUMBER_OF_CARDS];
int subtotal = 0;
for (int i = 0; i < collectionTotal; i++){
MTGCard * card = allcards->_(i);
+9 -9
View File
@@ -38,13 +38,13 @@ MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id,
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
//load all the icon images
mIcons[MTG_COLOR_ARTIFACT] = NEW JQuad(mIconsTexture, 2+6*36, 38, 32, 32);
mIcons[MTG_COLOR_LAND] = NEW JQuad(mIconsTexture, 2+5*36, 38, 32, 32);
mIcons[MTG_COLOR_WHITE] = NEW JQuad(mIconsTexture, 2+4*36, 38, 32, 32);
mIcons[MTG_COLOR_RED] = NEW JQuad(mIconsTexture, 2+3*36, 38, 32, 32);
mIcons[MTG_COLOR_BLACK] = NEW JQuad(mIconsTexture, 2+2*36, 38, 32, 32);
mIcons[MTG_COLOR_BLUE] = NEW JQuad(mIconsTexture, 2+1*36, 38, 32, 32);
mIcons[MTG_COLOR_GREEN] = NEW JQuad(mIconsTexture, 2+0*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_ARTIFACT] = NEW JQuad(mIconsTexture, 2+6*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_LAND] = NEW JQuad(mIconsTexture, 2+5*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_WHITE] = NEW JQuad(mIconsTexture, 2+4*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_RED] = NEW JQuad(mIconsTexture, 2+3*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_BLACK] = NEW JQuad(mIconsTexture, 2+2*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_BLUE] = NEW JQuad(mIconsTexture, 2+1*36, 38, 32, 32);
mIcons[Constants::MTG_COLOR_GREEN] = NEW JQuad(mIconsTexture, 2+0*36, 38, 32, 32);
for (int i=0; i < 7; i++){
mIcons[i]->SetHotSpot(16,16);
}
@@ -311,7 +311,7 @@ void MTGGuiPlay::RenderPhaseBar(){
}else{
mFont->SetColor(ARGB(255,255,255,255));
}
mFont->DrawString(MTGPhaseNames[currentPhase], 375, 0);
mFont->DrawString(Constants::MTGPhaseNames[currentPhase], 375, 0);
}
void MTGGuiPlay::Render(){
@@ -323,7 +323,7 @@ void MTGGuiPlay::Render(){
//mBg2->SetColor(ARGB(alphaBg[0], alphaBg[1],alphaBg[2],alphaBg[3]));
renderer->RenderQuad(mBg2,0,17);
if (game->currentGamePhase >=MTG_PHASE_COMBATBEGIN && game->currentGamePhase < MTG_PHASE_COMBATEND){
if (game->currentGamePhase >= Constants::MTG_PHASE_COMBATBEGIN && game->currentGamePhase < Constants::MTG_PHASE_COMBATEND){
if (alphaBg[0] < 50){
alphaBg[3]-=12;
alphaBg[2]-=12;
+3 -3
View File
@@ -5,7 +5,7 @@ MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){
}
int MTGAttackRule::isReactingToClick(MTGCardInstance * card){
if (currentPhase == MTG_PHASE_COMBATATTACKERS && card->controller() == game->currentPlayer && !card->isAttacker()){
if (currentPhase == Constants::MTG_PHASE_COMBATATTACKERS && card->controller() == game->currentPlayer && !card->isAttacker()){
if (card->canAttack()) return 1;
}
return 0;
@@ -14,7 +14,7 @@ int MTGAttackRule::isReactingToClick(MTGCardInstance * card){
int MTGAttackRule::reactToClick(MTGCardInstance * card){
if (!isReactingToClick(card)) return 0;
card->attacker = 1;
if (!card->basicAbilities[VIGILANCE]) card->tapped = 1;
if (!card->basicAbilities[Constants::VIGILANCE]) card->tapped = 1;
return 1;
}
@@ -29,7 +29,7 @@ MTGBlockRule::MTGBlockRule(int _id):MTGAbility(_id,NULL){
}
int MTGBlockRule::isReactingToClick(MTGCardInstance * card){
if (currentPhase == MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting && card->controller() == game->opponent()){
if (currentPhase == Constants::MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting && card->controller() == game->opponent()){
if (card->canBlock()) return 1;
}
return 0;
+28 -28
View File
@@ -38,15 +38,15 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost){
}else{
string value = s.substr(start+1, end - 1 - start);
if (value == "u"){
manaCost->add(MTG_COLOR_BLUE, 1);
manaCost->add(Constants::MTG_COLOR_BLUE, 1);
}else if (value == "b"){
manaCost->add(MTG_COLOR_BLACK, 1);
manaCost->add(Constants::MTG_COLOR_BLACK, 1);
}else if (value == "w"){
manaCost->add(MTG_COLOR_WHITE, 1);
manaCost->add(Constants::MTG_COLOR_WHITE, 1);
}else if (value == "g"){
manaCost->add(MTG_COLOR_GREEN, 1);
manaCost->add(Constants::MTG_COLOR_GREEN, 1);
}else if (value == "r"){
manaCost->add(MTG_COLOR_RED, 1);
manaCost->add(Constants::MTG_COLOR_RED, 1);
}else if (value == "x"){
manaCost->x();
}else if (value == "t"){
@@ -61,11 +61,11 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost){
for (int i = 0; i < 2; i++){
char c = value[i];
if (c >='0' && c <='9'){
colors[i] = MTG_COLOR_ARTIFACT;
colors[i] = Constants::MTG_COLOR_ARTIFACT;
values[i] = c - '0';
}else{
for (int j = 0; j < MTG_NB_COLORS; j++){
if (c == MTGColorChars[j]){
for (int j = 0; j < Constants::MTG_NB_COLORS; j++){
if (c == Constants::MTGColorChars[j]){
colors[i] = j;
values[i] = 1;
}
@@ -74,7 +74,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost){
}
manaCost->addHybrid(colors[0], values[0], colors[1], values[1]);
}else{
manaCost->add(MTG_COLOR_ARTIFACT, intvalue);
manaCost->add(Constants::MTG_COLOR_ARTIFACT, intvalue);
}
}
s = s.substr(end + 1);
@@ -109,7 +109,7 @@ ManaCost::ManaCost(int _cost[], int nb_elems){
ManaCost::ManaCost(ManaCost * _manaCost){
init();
int i;
for (i=0; i<= MTG_NB_COLORS; i++){
for (i=0; i<= Constants::MTG_NB_COLORS; i++){
cost[i] = _manaCost->getCost(i);
}
}
@@ -122,12 +122,12 @@ ManaCost::~ManaCost(){
}
void ManaCost::x(){
cost[MTG_NB_COLORS] = 1;
cost[Constants::MTG_NB_COLORS] = 1;
}
void ManaCost::init(){
int i;
for (i=0; i<= MTG_NB_COLORS; i++){
for (i=0; i<= Constants::MTG_NB_COLORS; i++){
cost[i] = 0;
}
nbhybrids = 0;
@@ -135,7 +135,7 @@ void ManaCost::init(){
void ManaCost::copy(ManaCost * _manaCost){
for (int i=0; i<= MTG_NB_COLORS; i++){
for (int i=0; i<= Constants::MTG_NB_COLORS; i++){
cost[i] = _manaCost->getCost(i);
}
for (int i=0; i< _manaCost->nbhybrids; i++){
@@ -149,7 +149,7 @@ int ManaCost::getCost(int color){
}
int ManaCost::getMainColor(){
for (int i=0; i< MTG_NB_COLORS; i++){
for (int i=0; i< Constants::MTG_NB_COLORS; i++){
if (cost[i]) return i;
}
return 0;
@@ -165,7 +165,7 @@ int ManaCost::hasColor(int color){
int ManaCost::getConvertedCost(){
int result = 0;
for (int i=0; i< MTG_NB_COLORS; i++){
for (int i=0; i< Constants::MTG_NB_COLORS; i++){
result += cost[i];
}
for (int i = 0; i < nbhybrids; i++){
@@ -186,7 +186,7 @@ int ManaCost::add(int color, int value){
int ManaCost::add(ManaCost * _cost){
if(!_cost) return 0;
for (int i=0; i< MTG_NB_COLORS; i++){
for (int i=0; i< Constants::MTG_NB_COLORS; i++){
cost[i]+= _cost->getCost(i);
}
for (int i=0; i< _cost->nbhybrids; i++){
@@ -210,7 +210,7 @@ int ManaCost::addHybrid(int c1, int v1, int c2, int v2){
int ManaCost::pay(ManaCost * _cost){
ManaCost * diff = Diff(_cost);
for (int i=0; i < MTG_NB_COLORS; i++){
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
cost[i] = diff->getCost(i);
}
delete diff;
@@ -233,7 +233,7 @@ int ManaCost::canAfford(ManaCost * _cost){
}
int ManaCost::isPositive(){
for (int i=0; i < MTG_NB_COLORS; i++){
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
if (cost[i] < 0){
return 0;
@@ -273,9 +273,9 @@ int ManaCost::tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int d
//compute the difference between two mana costs
ManaCost * ManaCost::Diff(ManaCost * _cost){
int diff[(MTG_NB_COLORS + 1 )* 2];
diff[MTG_NB_COLORS * 2] = MTG_NB_COLORS;
for (int i=0; i < MTG_NB_COLORS; i++){
int diff[(Constants::MTG_NB_COLORS + 1 )* 2];
diff[Constants::MTG_NB_COLORS * 2] = Constants::MTG_NB_COLORS;
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
diff[i*2] = i;
diff[i*2 +1] = cost[i] - _cost->getCost(i);
}
@@ -283,14 +283,14 @@ ManaCost * ManaCost::Diff(ManaCost * _cost){
if (!hybridResult) randomDiffHybrids(_cost,diff);
//Colorless mana, special case
int colorless_idx = MTG_COLOR_ARTIFACT * 2 + 1;
int colorless_idx = Constants::MTG_COLOR_ARTIFACT * 2 + 1;
if (diff[colorless_idx] < 0){
#if defined (WIN32) || defined (LINUX)
//char buf[4096], *p = buf;
//sprintf(buf, "--Diff color TEST %i : %i\n", i, cost[i]);
OutputDebugString("Colorless mana not enough\n");
#endif
for (int i=0; i < MTG_NB_COLORS; i++){
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
if (diff[i*2 + 1] > 0){
if (diff[i*2 + 1] + diff[colorless_idx] > 0){
diff[i*2 + 1] += diff[colorless_idx];
@@ -305,17 +305,17 @@ ManaCost * ManaCost::Diff(ManaCost * _cost){
}
//Cost X
if (_cost->getCost(MTG_NB_COLORS)){
diff[MTG_NB_COLORS * 2 + 1] = 0;
for (int i=0; i < MTG_NB_COLORS; i++){
if (_cost->getCost(Constants::MTG_NB_COLORS)){
diff[Constants::MTG_NB_COLORS * 2 + 1] = 0;
for (int i=0; i < Constants::MTG_NB_COLORS; i++){
if (diff[i*2 + 1] > 0){
diff[MTG_NB_COLORS * 2 + 1] += diff[i*2 + 1];
diff[Constants::MTG_NB_COLORS * 2 + 1] += diff[i*2 + 1];
diff[i*2 + 1] = 0;
}
}
}
ManaCost * result = NEW ManaCost(diff, MTG_NB_COLORS +1);
ManaCost * result = NEW ManaCost(diff, Constants::MTG_NB_COLORS +1);
return result;
}
+1 -1
View File
@@ -8,7 +8,7 @@
/* Creates a new phase ring with the default rules */
PhaseRing::PhaseRing(Player* players[], int nbPlayers){
for (int i = 0; i < nbPlayers; i++){
for (int j = 0; j <NB_MTG_PHASES; j++){
for (int j = 0; j < Constants::NB_MTG_PHASES; j++){
Phase * phase = NEW Phase(j,players[i]);
addPhase(phase);
}
+2 -2
View File
@@ -45,7 +45,7 @@ void GuiAvatar::Render(){
GameObserver * game = GameObserver::GetInstance();
JRenderer * r = JRenderer::GetInstance();
int life = player->life;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetScale(0.75);
//Avatar
@@ -111,7 +111,7 @@ void GuiGameZone::Render(){
JRenderer::GetInstance()->FillRect(x,y,quad->mWidth*scale,quad->mHeight*scale,ARGB(abs(wave-128), 255,255,255));
}
//Number of cards
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
char buffer[512];
sprintf(buffer,"%i", zone->nb_cards);
mFont->SetScale(0.75);
+5 -5
View File
@@ -52,19 +52,19 @@ int PriceList::getPrice(int cardId){
}
char rarity = collection->getCardById(cardId)->getRarity();
switch(rarity){
case RARITY_M:
case Constants::RARITY_M:
return 3000;
break;
case RARITY_R:
case Constants::RARITY_R:
return 500;
break;
case RARITY_U:
case Constants::RARITY_U:
return 100;
break;
case RARITY_C:
case Constants::RARITY_C:
return 20;
break;
case RARITY_L:
case Constants::RARITY_L:
return 5;
break;
default:
+7 -7
View File
@@ -34,7 +34,7 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFoc
card = collection->getCardById(_cardid);
quantity = 1;
if (card->getRarity() == RARITY_L) quantity = 50;
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
quad = NULL;
thumb = NULL;
}
@@ -229,14 +229,14 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
int curNbcards = playerdata->collection->totalCards();
if (showPriceDialog == 0){
//Starter Deck
playerdata->collection->addRandomCards(3,setId,RARITY_R,NULL);
playerdata->collection->addRandomCards(9, setId,RARITY_U,NULL);
playerdata->collection->addRandomCards(48, setId,RARITY_C,NULL);
playerdata->collection->addRandomCards(3,setId,Constants::RARITY_R,NULL);
playerdata->collection->addRandomCards(9, setId,Constants::RARITY_U,NULL);
playerdata->collection->addRandomCards(48, setId,Constants::RARITY_C,NULL);
}else{
//Booster
playerdata->collection->addRandomCards(1, setId,RARITY_R);
playerdata->collection->addRandomCards(3, setId,RARITY_U);
playerdata->collection->addRandomCards(11, setId,RARITY_C);
playerdata->collection->addRandomCards(1, setId,Constants::RARITY_R);
playerdata->collection->addRandomCards(3, setId,Constants::RARITY_U);
playerdata->collection->addRandomCards(11, setId,Constants::RARITY_C);
}
int newNbCards = playerdata->collection->totalCards();;
for (int i = curNbcards; i < newNbCards ; i++){
+7 -7
View File
@@ -152,8 +152,8 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
}else{
int attributefound = 0;
//Colors
for (int cid = 0; cid < MTG_NB_COLORS; cid++){
if (attribute.find(MTGColorStrings[cid]) != string::npos){
for (int cid = 0; cid < Constants::MTG_NB_COLORS; cid++){
if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos){
attributefound = 1;
if (minus){
cd->colors[cid] = -1;
@@ -167,8 +167,8 @@ OutputDebugString("COLOR FOUND !!!");
}
if (!attributefound){
//Abilities
for (int j = 0; j < NB_BASIC_ABILITIES; j++){
if (attribute.find(MTGBasicAbilities[j]) != string::npos){
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
if (attribute.find(Constants::MTGBasicAbilities[j]) != string::npos){
attributefound = 1;
if (minus){
cd->basicAbilities[j] = -1;
@@ -254,12 +254,12 @@ TargetChooser * TargetChooserFactory::createTargetChooser(MTGCardInstance * card
//Red Spell or Permanent
case 1191: //Blue Elemental Blast
{
return NEW SpellOrPermanentTargetChooser(card,MTG_COLOR_RED);
return NEW SpellOrPermanentTargetChooser(card,Constants::MTG_COLOR_RED);
}
//Blue Spell or Permanent
case 1312: //Red Elemental Blast
{
return NEW SpellOrPermanentTargetChooser(card,MTG_COLOR_BLUE);
return NEW SpellOrPermanentTargetChooser(card,Constants::MTG_COLOR_BLUE);
}
//Damage History
case 1344: //Eye for an Eye
@@ -285,7 +285,7 @@ TargetChooser::TargetChooser(MTGCardInstance * card, int _maxtargets): TargetsLi
int TargetChooser::canTarget(Targetable * target){
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
if (source && (card->protectedAgainst(source) || card->has(SHROUD))) return 0;
if (source && (card->protectedAgainst(source) || card->has(Constants::SHROUD))) return 0;
return 1;
}
return 0;