Erwan
- fixed sfx issues on the psp - removed a few debug strings
This commit is contained in:
@@ -55,34 +55,22 @@ void AIPlayer::tapLandsForMana(ManaCost * potentialMana, ManaCost * cost){
|
||||
|
||||
MTGCardInstance * card = NULL;
|
||||
while((card = cd.nextmatch(game->inPlay, card))){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Found mana card\n");
|
||||
#endif
|
||||
|
||||
int doTap = 1;
|
||||
for (int i=MTG_NB_COLORS-1; i>= 0; i--){
|
||||
if (diff->getCost(i) && card->hasSubtype(MTG_LAND_TEXTS[i]) ){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Not Gonna Tap\n");
|
||||
#endif
|
||||
diff->remove(i,1);
|
||||
doTap = 0;
|
||||
break;
|
||||
diff->remove(i,1);
|
||||
doTap = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (doTap){
|
||||
gameObs->cardClick(card);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Tapped\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delete(diff);
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("ok land tapped");
|
||||
#endif
|
||||
}
|
||||
//TODO a better function that does not take into account only basic lands
|
||||
ManaCost * AIPlayer::getPotentialMana(){
|
||||
@@ -95,24 +83,12 @@ ManaCost * AIPlayer::getPotentialMana(){
|
||||
while((card = cd.nextmatch(game->inPlay, card))){
|
||||
|
||||
if (card->hasSubtype("plains")){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Found Potential plain\n");
|
||||
#endif
|
||||
potentialMana->add(MTG_COLOR_WHITE,1);
|
||||
}else if(card->hasSubtype("swamp")){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Found Potential swamp\n");
|
||||
#endif
|
||||
potentialMana->add(MTG_COLOR_BLACK,1);
|
||||
}else if(card->hasSubtype("forest")){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Found Potential forestn\n");
|
||||
#endif
|
||||
potentialMana->add(MTG_COLOR_GREEN,1);
|
||||
}else if(card->hasSubtype("mountain")){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Found Potential Mountain\n");
|
||||
#endif
|
||||
potentialMana->add(MTG_COLOR_RED,1);
|
||||
}else if(card->hasSubtype("island")){
|
||||
potentialMana->add(MTG_COLOR_BLUE,1);
|
||||
@@ -504,21 +480,7 @@ int AIPlayerBaka::Act(float dt){
|
||||
return 0;
|
||||
}
|
||||
initTimer();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("==========\nNew Act CALL\n================\n");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("==========\nCombat Damages ?\n================\n");
|
||||
#endif
|
||||
if (combatDamages()) return 0;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("==========\nChoose Target ?\n================\n");
|
||||
#endif
|
||||
if (chooseTarget()) return 0;
|
||||
|
||||
|
||||
@@ -552,12 +514,6 @@ int AIPlayerBaka::Act(float dt){
|
||||
|
||||
//No mana, try to get some
|
||||
getPotentialMana();
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buffe[4096];
|
||||
|
||||
sprintf(buffe,"potentail mana %i\n",potentialMana->getConvertedCost() );
|
||||
OutputDebugString(buffe);
|
||||
#endif
|
||||
if (potentialMana->getConvertedCost() > 0){
|
||||
|
||||
|
||||
@@ -570,6 +526,7 @@ int AIPlayerBaka::Act(float dt){
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "sorcery");
|
||||
if (nextCardToPlay){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buffe[4096];
|
||||
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName());
|
||||
OutputDebugString(buffe);
|
||||
#endif
|
||||
|
||||
@@ -33,28 +33,16 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
|
||||
}
|
||||
|
||||
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
|
||||
#ifdef WIN32
|
||||
OutputDebugString("Match AND\n");
|
||||
#endif
|
||||
|
||||
MTGCardInstance * match = card;
|
||||
for (int i = 0; i< nb_types; i++){
|
||||
|
||||
if (!card->hasSubtype(types[i])){
|
||||
#ifdef WIN32
|
||||
OutputDebugString(card->name.c_str());
|
||||
OutputDebugString("Subtype No Match\n");
|
||||
#endif
|
||||
match = NULL;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i< MTG_NB_COLORS; i++){
|
||||
if ((colors[i] == 1 && !card->hasColor(i))||(colors[i] == -1 && card->hasColor(i))){
|
||||
match = NULL;
|
||||
#ifdef WIN32
|
||||
OutputDebugString(card->name.c_str());
|
||||
OutputDebugString("Color No Match\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return match;
|
||||
@@ -116,11 +104,6 @@ MTGCardInstance * CardDescriptor::nextmatch(MTGGameZone * zone, MTGCardInstance
|
||||
if (NULL == previous) found = 1;
|
||||
for(int i=0; i < zone->nb_cards; i++){
|
||||
if(found && match(zone->cards[i])){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf,"Card Descriptor MATCH!: %s \n" ,(zone->cards[i])->getName());
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
return zone->cards[i];
|
||||
}
|
||||
if (zone->cards[i] == previous){
|
||||
|
||||
@@ -126,22 +126,40 @@ SampleCache * SampleCache::GetInstance(){
|
||||
}
|
||||
|
||||
JSample * SampleCache::getSample(string filename){
|
||||
map<string,JSample *>::iterator it = cache.find(filename);
|
||||
map<string,SampleCached *>::iterator it = cache.find(filename);
|
||||
if (it == cache.end()){
|
||||
if (cache.size() >10) cleanCache(); //Poor man's limit
|
||||
if (cache.size() >10) cleanOldest(); //Poor man's limit
|
||||
JSample * sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||
if (!sample && fileExists(filename.c_str())){ //Out of Ram ??
|
||||
cleanCache();
|
||||
sample = JSoundSystem::GetInstance()->LoadSample(filename.c_str());
|
||||
}
|
||||
lastTime++;
|
||||
cache[filename] = NEW SampleCached(lastTime, sample);
|
||||
return sample;
|
||||
}else{
|
||||
return (it->second);
|
||||
return (it->second->sample);
|
||||
}
|
||||
}
|
||||
|
||||
void SampleCache::cleanOldest(){
|
||||
int smallest = lastTime;
|
||||
map<string,SampleCached *>::iterator found = cache.end();
|
||||
map<string,SampleCached *>::iterator it;
|
||||
for (it = cache.begin(); it != cache.end(); it++){
|
||||
if(it->second->lastTime <= smallest){
|
||||
smallest = it->second->lastTime;
|
||||
found = it;
|
||||
}
|
||||
}
|
||||
if (found != cache.end()){
|
||||
delete (found->second);
|
||||
cache.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
void SampleCache::cleanCache(){
|
||||
map<string,JSample *>::iterator it;
|
||||
map<string,SampleCached *>::iterator it;
|
||||
for (it = cache.begin(); it != cache.end(); it++){
|
||||
delete(it->second);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user