Erwan
-reduced SFX Quality. This seems to fix the Bug with samples getting silent on the PSP (issue 112), and improves loading times. If you think this is unacceptable, let's discuss it - AI now should play fetchlands' ability, although still not "efficiently" - Fix a bug where the game would crash if a card has a valid alias to a hardcoded card that is in no _cards.dat (starwars mod cards aliasing a MTG card)
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -56,7 +56,7 @@ class AIPlayer: public Player{
|
||||
int chooseAttackers();
|
||||
int chooseBlockers();
|
||||
int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
|
||||
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY);
|
||||
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
|
||||
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
|
||||
AIStats * getStats();
|
||||
public:
|
||||
|
||||
@@ -644,6 +644,11 @@ public:
|
||||
if (_target) target = _target;
|
||||
}
|
||||
|
||||
MTGGameZone * destinationZone(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
return MTGGameZone::stringToZone(destination, source,_target);
|
||||
}
|
||||
|
||||
int resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(target){
|
||||
@@ -651,7 +656,7 @@ public:
|
||||
if (p){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
MTGGameZone * fromZone = _target->getCurrentZone();
|
||||
MTGGameZone * destZone = MTGGameZone::stringToZone(destination, source,_target);
|
||||
MTGGameZone * destZone = destinationZone();
|
||||
|
||||
//inplay is a special zone !
|
||||
for (int i=0; i < 2; i++){
|
||||
|
||||
@@ -204,8 +204,8 @@ class AbilityFactory{
|
||||
TriggeredAbility * parseTrigger(string s, int id, Spell * spell, MTGCardInstance *card, Targetable * target);
|
||||
public:
|
||||
MTGAbility * parseMagicLine(string s, int id, Spell * spell, MTGCardInstance *card, int activated = 0, int forceUEOT = 0);
|
||||
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY);
|
||||
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY);
|
||||
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
|
||||
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
|
||||
static int computeX(Spell * spell, MTGCardInstance * card);
|
||||
int destroyAllInPlay(TargetChooser * tc, int bury = 0);
|
||||
int moveAll(TargetChooser * tc, string destinationZone);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "WCachedResource.h"
|
||||
|
||||
#define HUGE_CACHE_LIMIT 6000000 // Size of the cache for Windows and Linux
|
||||
#define SAMPLES_CACHE_SIZE 1000000 // Size in bytes of the cached samples
|
||||
#define SAMPLES_CACHE_SIZE 1500000 // Size in bytes of the cached samples
|
||||
#define PSI_CACHE_SIZE 500000 // Size in bytes of the cahed particles
|
||||
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this
|
||||
#define OPERATIONAL_SIZE 5000000 // Size required by Wagic for operational stuff. 3MB is not enough. The cache will usually try to take (Total Ram - Operational size)
|
||||
@@ -27,7 +27,7 @@
|
||||
#define MAX_CACHE_OBJECTS 300
|
||||
#define MAX_CACHE_ATTEMPTS 10
|
||||
#define MAX_CACHE_MISSES 200
|
||||
#define MAX_CACHED_SAMPLES 10
|
||||
#define MAX_CACHED_SAMPLES 50
|
||||
#define MAX_CACHE_GARBAGE 10
|
||||
|
||||
|
||||
|
||||
@@ -291,10 +291,10 @@ int AIPlayer::interruptIfICan(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AIPlayer::effectBadOrGood(MTGCardInstance * card, int mode){
|
||||
int AIPlayer::effectBadOrGood(MTGCardInstance * card, int mode, TargetChooser * tc){
|
||||
int id = card->getMTGId();
|
||||
AbilityFactory * af = NEW AbilityFactory();
|
||||
int autoGuess = af->magicText(id,NULL,card, mode);
|
||||
int autoGuess = af->magicText(id,NULL,card, mode, tc);
|
||||
delete af;
|
||||
if (autoGuess) return autoGuess;
|
||||
return BAKA_EFFECT_DONTKNOW;
|
||||
@@ -315,7 +315,7 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
if (!tc) return 0;
|
||||
if (!(gameObs->currentlyActing() == this)) return 0;
|
||||
Player * target = this;
|
||||
int cardEffect = effectBadOrGood(tc->source, MODE_TARGET);
|
||||
int cardEffect = effectBadOrGood(tc->source, MODE_TARGET, tc);
|
||||
if (cardEffect != BAKA_EFFECT_GOOD){
|
||||
target = this->opponent();
|
||||
}
|
||||
|
||||
@@ -698,28 +698,28 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
|
||||
//Tells the AI if the ability should target itself or an ennemy
|
||||
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
||||
int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, TargetChooser * tc){
|
||||
if (!a) return BAKA_EFFECT_DONTKNOW;
|
||||
|
||||
if (GenericTargetAbility * abi = dynamic_cast<GenericTargetAbility*>(a)) {
|
||||
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
||||
return abilityEfficiency(abi->ability,p, mode);
|
||||
return abilityEfficiency(abi->ability,p, mode, abi->tc);
|
||||
}
|
||||
if (GenericActivatedAbility * abi = dynamic_cast<GenericActivatedAbility*>(a)) {
|
||||
if (mode == MODE_PUTINTOPLAY) return BAKA_EFFECT_GOOD;
|
||||
return abilityEfficiency(abi->ability,p, mode);
|
||||
return abilityEfficiency(abi->ability,p, mode,tc);
|
||||
}
|
||||
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a)) return abilityEfficiency(abi->abilities[0],p, mode);
|
||||
if (MayAbility * abi = dynamic_cast<MayAbility*>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a)) return abilityEfficiency(abi->abilities[0],p, mode,tc );
|
||||
if (MayAbility * abi = dynamic_cast<MayAbility*>(a)) return abilityEfficiency(abi->ability,p, mode,tc);
|
||||
if (ALord * abi = dynamic_cast<ALord *>(a)) {
|
||||
int myCards = countCards(abi->tc, p);
|
||||
int theirCards = countCards(abi->tc, p->opponent());
|
||||
int efficiency = abilityEfficiency(abi->ability,p, mode);
|
||||
int efficiency = abilityEfficiency(abi->ability,p, mode,tc);
|
||||
if (myCards > theirCards) return efficiency;
|
||||
return -efficiency;
|
||||
}
|
||||
if (AAsLongAs * abi = dynamic_cast<AAsLongAs *>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||
if (AForeach * abi = dynamic_cast<AForeach *>(a)) return abilityEfficiency(abi->ability,p, mode);
|
||||
if (AAsLongAs * abi = dynamic_cast<AAsLongAs *>(a)) return abilityEfficiency(abi->ability,p, mode,tc);
|
||||
if (AForeach * abi = dynamic_cast<AForeach *>(a)) return abilityEfficiency(abi->ability,p, mode,tc);
|
||||
if (dynamic_cast<AAFizzler *>(a)) return BAKA_EFFECT_BAD;
|
||||
if (dynamic_cast<AAUntapper *>(a)) return BAKA_EFFECT_GOOD;
|
||||
if (dynamic_cast<AATapper *>(a)) return BAKA_EFFECT_BAD;
|
||||
@@ -729,7 +729,15 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
||||
return BAKA_EFFECT_GOOD ;
|
||||
}
|
||||
if (dynamic_cast<ATokenCreator *>(a)) return BAKA_EFFECT_GOOD;
|
||||
if (dynamic_cast<AAMover *>(a)) return BAKA_EFFECT_BAD; //TODO
|
||||
|
||||
if (AAMover * aam = dynamic_cast<AAMover *>(a)) {
|
||||
MTGGameZone * z = aam->destinationZone();
|
||||
if (tc && tc->targetsZone(p->game->library)){
|
||||
if (z == p->game->hand || z == p->game->inPlay) return BAKA_EFFECT_GOOD;
|
||||
}
|
||||
return BAKA_EFFECT_BAD; //TODO
|
||||
}
|
||||
|
||||
if (dynamic_cast<AACopier *>(a)) return BAKA_EFFECT_GOOD;
|
||||
if (dynamic_cast<AADestroyer *>(a)) return BAKA_EFFECT_BAD;
|
||||
if (dynamic_cast<AStandardRegenerate *>(a)) return BAKA_EFFECT_GOOD;
|
||||
@@ -741,7 +749,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode){
|
||||
if (dynamic_cast<ARampageAbility *>(a)) return BAKA_EFFECT_GOOD;
|
||||
if (AInstantPowerToughnessModifierUntilEOT * abi = dynamic_cast<AInstantPowerToughnessModifierUntilEOT *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
|
||||
if (APowerToughnessModifier * abi = dynamic_cast<APowerToughnessModifier *>(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD;
|
||||
if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a)) return abilityEfficiency(abi->ability, p, mode);
|
||||
if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast<APowerToughnessModifierUntilEndOfTurn *>(a)) return abilityEfficiency(abi->ability, p, mode,tc);
|
||||
|
||||
map<int,bool> badAbilities;
|
||||
badAbilities[Constants::CANTATTACK] = true;
|
||||
@@ -780,7 +788,7 @@ int AbilityFactory::computeX(Spell * spell, MTGCardInstance * card){
|
||||
* - target (if there ie a "target(" in the string, then this is a TargetAbility)
|
||||
* - doTap (a dirty way to know if tapping is included in the cost...
|
||||
*/
|
||||
int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int mode){
|
||||
int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int mode, TargetChooser * tc){
|
||||
int dryMode = 0;
|
||||
if (!spell) dryMode = 1;
|
||||
|
||||
@@ -791,7 +799,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
|
||||
string magicText = card->magicText;
|
||||
if (card->alias && magicText.size() == 0){
|
||||
//An awful way to get access to the aliasedcard
|
||||
magicText = GameObserver::GetInstance()->players[0]->game->collection->getCardById(card->alias)->magicText;
|
||||
MTGCard * c = GameObserver::GetInstance()->players[0]->game->collection->getCardById(card->alias);
|
||||
if (!c) return 0;
|
||||
magicText = c->magicText;
|
||||
}
|
||||
string line;
|
||||
int size = magicText.size();
|
||||
@@ -812,7 +822,7 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card, int
|
||||
|
||||
MTGAbility * a = parseMagicLine(line, result, spell, card);
|
||||
if (dryMode){
|
||||
result = abilityEfficiency(a, card->controller(),mode);
|
||||
result = abilityEfficiency(a, card->controller(),mode,tc);
|
||||
SAFE_DELETE(a);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
case 0:
|
||||
start = s.find_first_of("{");
|
||||
if (start == string::npos){
|
||||
return manaCost;
|
||||
return manaCost;
|
||||
}else{
|
||||
state = 1;
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user