added optimizing of opponents hand if the opponent deck is listed as "easy". slight optimize if listed as "normal" none if listed as "hard" this provides slightly more challange from even poorly constructed Ai decks. taught Ai to pump creatures during combat, and more so if its heading directly at player, taught Ai that its better to use "becomes" and "transforms" during first main. this allow its to actually attack with the manlands ect.
new ability lord...teach(whatever[whatever]) ability. teach is a targeted lord, it takes the cards current target and lords it the ability. im aware of a tiny memleak it contains, but the leak is happening on parser lvl, so i need more eyes to look at it. teach is ideally used for equipment, and was designed to fix issue 244 taught abilities are not given to the source cards. forced Ai to pay for sunburst correctly. it was choosing to pay with all of one type of mana. now it pays either max or 1 from max sunburst. added a tiny double check for Ai to try and find something to use if it suddenly has mana in its pool. it is only a single check in a turn, but i notice it actually does slightly improve the usages of dark ritual and foreach mana producers. ideally i wanted it to check EVERYTIME. but i could not achieve it without putting the game in danger of looping. so once is better then none :/ fixed a bug with affinity where it was not counting duel lands, this is becuase of not setting it up correctly for lands with multiple types SORRY!
This commit is contained in:
@@ -35,6 +35,7 @@ AIPlayer::AIPlayer(MTGDeck * deck, string file, string fileSmall) : Player(deck,
|
||||
stats = NULL;
|
||||
agressivity = 50;
|
||||
forceBestAbilityUse = false;
|
||||
Checked = false;
|
||||
playMode = Player::MODE_AI;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,6 @@ ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -248,11 +248,42 @@ int AIAction::getEfficiency(){
|
||||
}
|
||||
if (currentlevel < _target->MaxLevelUp){
|
||||
efficiency = 85;
|
||||
efficiency += currentlevel;//increase the efficeincy of leveling up by a small amount equal to current level.
|
||||
//increase the efficeincy of leveling up by a small amount equal to current level.
|
||||
efficiency += currentlevel;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case MTGAbility::STANDARD_PUMP:{
|
||||
MTGCardInstance * _target = (MTGCardInstance *)(a->target);
|
||||
//i do not set a starting eff. on this ability, this allows Ai to sometimes randomly do it as it normally does.
|
||||
if(g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBLOCKERS)
|
||||
{
|
||||
if(_target && BAKA_EFFECT_GOOD)
|
||||
{
|
||||
if((_target->defenser || _target->blockers.size())
|
||||
&& ((_target->power < _target->getNextOpponent()->toughness || _target->toughness < _target->getNextOpponent()->power)
|
||||
|| (_target->has(Constants::TRAMPLE)))){
|
||||
//this pump is based on a start eff. of 20 multiplied by how good the creature is.
|
||||
efficiency = 20*_target->DangerRanking();
|
||||
}
|
||||
if(_target->isAttacker() && !_target->blockers.size()){
|
||||
//this means im heading directly for the player, pump this creature as much as possible.
|
||||
efficiency = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MTGAbility::STANDARD_BECOMES:
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *)(a->target);
|
||||
//nothing huge here, just ensuring that Ai makes his noncreature becomers into creatures during first main, so it can actually use them in combat.
|
||||
if(_target && !_target->hasType("Creature") && g->getCurrentGamePhase() == Constants::MTG_PHASE_FIRSTMAIN)
|
||||
{
|
||||
efficiency = 100;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MTGAbility::MANA_PRODUCER: //can't use mana producers right now :/
|
||||
efficiency = 0;
|
||||
break;
|
||||
@@ -684,7 +715,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
if (card->hasType(Subtypes::TYPE_CREATURE) && this->castrestrictedcreature < 0 && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_ENCHANTMENT) && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_ARTIFACT) && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_SORCERY) && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_SORCERY) && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_INSTANT) && this->castrestrictedspell < 0) continue;
|
||||
if (card->hasType(Subtypes::TYPE_LAND) && !this->canPutLandsIntoPlay) continue;
|
||||
if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
||||
@@ -792,18 +823,50 @@ int AIPlayerBaka::computeActions(){
|
||||
if (potential) delete(currentMana);
|
||||
if (nextCardToPlay){
|
||||
if (potential){
|
||||
tapLandsForMana(nextCardToPlay->getManaCost());
|
||||
}
|
||||
/////////////////////////
|
||||
//had to force this on Ai other wise it would pay nothing but 1 color for a sunburst card.
|
||||
//this does not teach it to use manaproducer more effectively, it simply allow it to use the manaproducers it does understand better on sunburst by force.
|
||||
if(nextCardToPlay->has(Constants::SUNBURST)){
|
||||
ManaCost * SunCheck = manaPool;
|
||||
SunCheck = getPotentialMana();
|
||||
for(int i = Constants::MTG_NB_COLORS - 1; i > 0 ;i--){
|
||||
//sunburst for Ai
|
||||
if(SunCheck->hasColor(i)){
|
||||
if(nextCardToPlay->getManaCost()->hasColor(i) > 0){//do nothing if the card already has this color.
|
||||
}else{
|
||||
if(nextCardToPlay->sunburst < nextCardToPlay->getManaCost()->getConvertedCost()){
|
||||
nextCardToPlay->getManaCost()->add(i,1);
|
||||
nextCardToPlay->getManaCost()->remove(0,1);
|
||||
nextCardToPlay->sunburst += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete(SunCheck);
|
||||
}
|
||||
/////////////////////////
|
||||
tapLandsForMana(nextCardToPlay->getManaCost());
|
||||
}
|
||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
return 1;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
if(p->getManaPool()->getConvertedCost() > 0 && Checked == false)//not the best thing ever, but allows the Ai a chance to double check if its mana pool has something before moving on, atleast one time.
|
||||
{
|
||||
Checked = true;
|
||||
computeActions();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Constants::MTG_PHASE_COMBATATTACKERS:
|
||||
chooseAttackers();
|
||||
break;
|
||||
case Constants::MTG_PHASE_ENDOFTURN:
|
||||
Checked = false;
|
||||
break;
|
||||
default:
|
||||
selectAbility();
|
||||
|
||||
@@ -93,7 +93,7 @@ bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCou
|
||||
if (n >= max) return false;
|
||||
AIStat * stat = *it;
|
||||
if (stat->source == id){
|
||||
if (stat->value>=0) return true;
|
||||
if ((stat->value + card->DangerRanking()) >=3) return true;
|
||||
return false;
|
||||
}
|
||||
n++;
|
||||
|
||||
+157
-157
@@ -3,162 +3,162 @@
|
||||
|
||||
// BanishCard implementations
|
||||
|
||||
AABanishCard::AABanishCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost=NULL, int _banishmentType = -1):ActivatedAbility(_id, _source,_cost),banishmentType(_banishmentType) {
|
||||
if (_target) target = _target;
|
||||
}
|
||||
|
||||
const char * AABanishCard::getMenuText()
|
||||
{
|
||||
return "Send to graveyard";
|
||||
}
|
||||
|
||||
int AABanishCard::resolve()
|
||||
{
|
||||
DebugTrace("This is not implemented!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
AABanishCard * AABanishCard::clone() const{
|
||||
AABanishCard * a = NEW AABanishCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Bury
|
||||
|
||||
AABuryCard::AABuryCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL , int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::BURY)
|
||||
{}
|
||||
|
||||
int AABuryCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
return _target->bury();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AABuryCard::getMenuText(){
|
||||
return "Bury";
|
||||
}
|
||||
|
||||
AABuryCard * AABuryCard::clone() const{
|
||||
AABuryCard * a = NEW AABuryCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
// Destroy
|
||||
|
||||
AADestroyCard::AADestroyCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DESTROY)
|
||||
{}
|
||||
|
||||
int AADestroyCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
return _target->destroy();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADestroyCard::getMenuText(){
|
||||
return "Destroy";
|
||||
}
|
||||
|
||||
AADestroyCard * AADestroyCard::clone() const{
|
||||
AADestroyCard * a = NEW AADestroyCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Sacrifice
|
||||
AASacrificeCard::AASacrificeCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::SACRIFICE) {
|
||||
}
|
||||
|
||||
int AASacrificeCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
AABanishCard::AABanishCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost=NULL, int _banishmentType = -1):ActivatedAbility(_id, _source,_cost),banishmentType(_banishmentType) {
|
||||
if (_target) target = _target;
|
||||
}
|
||||
|
||||
const char * AABanishCard::getMenuText()
|
||||
{
|
||||
return "Send to graveyard";
|
||||
}
|
||||
|
||||
int AABanishCard::resolve()
|
||||
{
|
||||
DebugTrace("This is not implemented!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
AABanishCard * AABanishCard::clone() const{
|
||||
AABanishCard * a = NEW AABanishCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Bury
|
||||
|
||||
AABuryCard::AABuryCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL , int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::BURY)
|
||||
{}
|
||||
|
||||
int AABuryCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
return _target->bury();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AABuryCard::getMenuText(){
|
||||
return "Bury";
|
||||
}
|
||||
|
||||
AABuryCard * AABuryCard::clone() const{
|
||||
AABuryCard * a = NEW AABuryCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
// Destroy
|
||||
|
||||
AADestroyCard::AADestroyCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DESTROY)
|
||||
{}
|
||||
|
||||
int AADestroyCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
return _target->destroy();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADestroyCard::getMenuText(){
|
||||
return "Destroy";
|
||||
}
|
||||
|
||||
AADestroyCard * AADestroyCard::clone() const{
|
||||
AADestroyCard * a = NEW AADestroyCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Sacrifice
|
||||
AASacrificeCard::AASacrificeCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::SACRIFICE) {
|
||||
}
|
||||
|
||||
int AASacrificeCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
Player * p = _target->controller();
|
||||
WEvent * e = NEW WEventCardSacrifice(_target);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(_target);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AASacrificeCard::getMenuText(){
|
||||
return "Sacrifice";
|
||||
}
|
||||
|
||||
AASacrificeCard * AASacrificeCard::clone() const{
|
||||
AASacrificeCard * a = NEW AASacrificeCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Discard
|
||||
|
||||
AADiscardCard::AADiscardCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DISCARD) {
|
||||
}
|
||||
|
||||
int AADiscardCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
WEvent * e = NEW WEventCardSacrifice(_target);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(_target);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AASacrificeCard::getMenuText(){
|
||||
return "Sacrifice";
|
||||
}
|
||||
|
||||
AASacrificeCard * AASacrificeCard::clone() const{
|
||||
AASacrificeCard * a = NEW AASacrificeCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
// Discard
|
||||
|
||||
AADiscardCard::AADiscardCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, ManaCost * _cost = NULL, int _banishmentType = 0):AABanishCard(_id, _source, _target, _cost, AABanishCard::DISCARD) {
|
||||
}
|
||||
|
||||
int AADiscardCard::resolve(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target){
|
||||
Player * p = _target->controller();
|
||||
WEvent * e = NEW WEventCardDiscard(_target);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(_target);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADiscardCard::getMenuText(){
|
||||
return "Discard";
|
||||
}
|
||||
|
||||
AADiscardCard * AADiscardCard::clone() const{
|
||||
AADiscardCard * a = NEW AADiscardCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//Mana Redux
|
||||
AManaRedux::AManaRedux(int id, MTGCardInstance * source, MTGCardInstance * target,int amount,int type):MTGAbility(id,source,target),amount(amount),type(type) {
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
}
|
||||
|
||||
int AManaRedux::addToGame(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
if(amount < 0){
|
||||
amount = abs(amount);
|
||||
if(_target->getManaCost()->hasColor(type)){
|
||||
if(_target->getManaCost()->getConvertedCost() >= 1){
|
||||
_target->getManaCost()->remove(type,amount);
|
||||
if(_target->getManaCost()->alternative > 0){
|
||||
_target->getManaCost()->alternative->remove(type,amount);}
|
||||
if(_target->getManaCost()->BuyBack > 0){
|
||||
_target->getManaCost()->BuyBack->remove(type,amount);}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
_target->getManaCost()->add(type,amount);
|
||||
if(_target->getManaCost()->alternative > 0){
|
||||
_target->getManaCost()->alternative->add(type,amount);}
|
||||
if(_target->getManaCost()->BuyBack > 0){
|
||||
_target->getManaCost()->BuyBack->add(type,amount);}
|
||||
}
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
AManaRedux * AManaRedux::clone() const {
|
||||
AManaRedux * a = NEW AManaRedux(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
AManaRedux::~AManaRedux(){}
|
||||
WEvent * e = NEW WEventCardDiscard(_target);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(_target);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADiscardCard::getMenuText(){
|
||||
return "Discard";
|
||||
}
|
||||
|
||||
AADiscardCard * AADiscardCard::clone() const{
|
||||
AADiscardCard * a = NEW AADiscardCard(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//Mana Redux
|
||||
AManaRedux::AManaRedux(int id, MTGCardInstance * source, MTGCardInstance * target,int amount,int type):MTGAbility(id,source,target),amount(amount),type(type) {
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
}
|
||||
|
||||
int AManaRedux::addToGame(){
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
if(amount < 0){
|
||||
amount = abs(amount);
|
||||
if(_target->getManaCost()->hasColor(type)){
|
||||
if(_target->getManaCost()->getConvertedCost() >= 1){
|
||||
_target->getManaCost()->remove(type,amount);
|
||||
if(_target->getManaCost()->alternative > 0){
|
||||
_target->getManaCost()->alternative->remove(type,amount);}
|
||||
if(_target->getManaCost()->BuyBack > 0){
|
||||
_target->getManaCost()->BuyBack->remove(type,amount);}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
_target->getManaCost()->add(type,amount);
|
||||
if(_target->getManaCost()->alternative > 0){
|
||||
_target->getManaCost()->alternative->add(type,amount);}
|
||||
if(_target->getManaCost()->BuyBack > 0){
|
||||
_target->getManaCost()->BuyBack->add(type,amount);}
|
||||
}
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
AManaRedux * AManaRedux::clone() const {
|
||||
AManaRedux * a = NEW AManaRedux(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
AManaRedux::~AManaRedux(){}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include "DeckManager.h"
|
||||
#include "Player.h"
|
||||
#include <JRenderer.h>
|
||||
|
||||
void DeckManager::updateMetaDataList( vector<DeckMetaData *> * refList, bool isAI )
|
||||
@@ -49,3 +50,15 @@ DeckManager* DeckManager::GetInstance()
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
// p1 is assumed to be the player you want stats for
|
||||
// p2 is the opponent
|
||||
int DeckManager::getDifficultyRating( Player *statsPlayer, Player *player )
|
||||
{
|
||||
DeckMetaDataList * metas = DeckMetaDataList::decksMetaData;
|
||||
|
||||
DeckMetaData *meta = metas->get( player->deckFile, statsPlayer );
|
||||
|
||||
return meta->getDifficulty();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void DeckMetaData::loadStatsForPlayer( Player * statsPlayer, string deckStatsFil
|
||||
{
|
||||
_difficulty = HARD;
|
||||
}
|
||||
else if (_percentVictories < 67)
|
||||
else if (_percentVictories < 55)
|
||||
{
|
||||
_difficulty = NORMAL;
|
||||
}
|
||||
|
||||
@@ -603,9 +603,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
|
||||
|
||||
//rather dirty way to stop thises and lords from conflicting with each other.
|
||||
string prelords[] = {"foreach(","lord(","aslongas(", "all("};
|
||||
string prelords[] = {"foreach(","lord(","aslongas(","teach(", "all("};
|
||||
size_t lord = string::npos;
|
||||
for (int j = 0; j < 4; ++j){
|
||||
for (int j = 0; j < 5; ++j){
|
||||
size_t found2 = s.find(prelords[j]);
|
||||
if (found2!=string::npos && ((found == string::npos) || found2 < found)){
|
||||
lord = found2;
|
||||
@@ -674,10 +674,10 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
|
||||
|
||||
//Lord, foreach, aslongas
|
||||
string lords[] = {"lord(","foreach(","aslongas(", "all("};
|
||||
string lords[] = {"lord(","foreach(","aslongas(","teach(", "all("};
|
||||
found = string::npos;
|
||||
i = -1;
|
||||
for (int j = 0; j < 4; ++j){
|
||||
for (int j = 0; j < 5; ++j){
|
||||
size_t found2 = s.find(lords[j]);
|
||||
if (found2!=string::npos && ((found == string::npos) || found2 < found)){
|
||||
found = found2;
|
||||
@@ -721,7 +721,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (found !=string::npos) oneShot = 1;
|
||||
if (activated) oneShot = 1;
|
||||
if (card->hasType("sorcery") || card->hasType("instant")) oneShot = 1;
|
||||
if (i == 3) oneShot = 1;
|
||||
if (i == 4) oneShot = 1;
|
||||
if (a->oneShot) oneShot = 1;
|
||||
Damageable * _target = NULL;
|
||||
if (spell) _target = spell->getNextDamageableTarget();
|
||||
@@ -740,7 +740,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
case 0: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break;
|
||||
case 1: result = NEW AForeach(id, card, _target,lordTargets, lordIncludeSelf, a,mini,maxi); break;
|
||||
case 2: result = NEW AAsLongAs(id, card, _target,lordTargets, lordIncludeSelf, a,mini,maxi); break;
|
||||
case 3: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break;
|
||||
case 3: result = NEW ATeach(id, card, lordTargets,lordIncludeSelf, a); break;
|
||||
case 4: result = NEW ALord(id, card, lordTargets, lordIncludeSelf, a); break;
|
||||
default: result = NULL;
|
||||
}
|
||||
if (result) result->oneShot = oneShot;
|
||||
|
||||
@@ -77,6 +77,84 @@ void MTGPlayerCards::initGame(int shuffle, int draw){
|
||||
}
|
||||
}
|
||||
|
||||
void MTGPlayerCards::OptimizedHand(int amount,int lands,int creatures,int othercards){
|
||||
//give the Ai hand adventage to insure a challanging match.
|
||||
GameObserver * game = game->GetInstance();
|
||||
game->currentPlayerId = game->currentPlayerId;
|
||||
game->currentPlayer = game->currentPlayer;
|
||||
|
||||
if (!game->players[0]->isAI() && game->players[1]->isAI()){
|
||||
Player * p = game->players[1];
|
||||
MTGCardInstance * card = NULL;
|
||||
MTGGameZone * z = p->game->library;
|
||||
MTGGameZone * e = p->game->temp;
|
||||
int optimizedland = 0;
|
||||
int optimizedothercards = 0;
|
||||
int optimizedcreatures = 0;
|
||||
for (int j = 0; j<z->nb_cards; j++){
|
||||
MTGCardInstance * _card = z->cards[j];
|
||||
//-------------
|
||||
if (_card->hasType("Land") && optimizedland < lands){
|
||||
card = _card;
|
||||
if (card){
|
||||
p->game->putInZone(card, p->game->library, p->game->hand);
|
||||
optimizedland += 1;
|
||||
}
|
||||
}
|
||||
//----------------first try to optimize a few cards that cost 2 or less.
|
||||
if (_card->getManaCost()->getConvertedCost() <= 2 && optimizedothercards < othercards && !_card->hasType("Land") && !_card->hasType("Creature")){
|
||||
card = _card;
|
||||
if (card){
|
||||
p->game->putInZone(card, p->game->library, p->game->hand);
|
||||
optimizedothercards += 1;
|
||||
}
|
||||
}
|
||||
if(_card->getManaCost()->getConvertedCost() <= 2 && optimizedcreatures < creatures && _card->hasType("Creature")){
|
||||
card = _card;
|
||||
if (card){
|
||||
p->game->putInZone(card, p->game->library, p->game->hand);
|
||||
optimizedcreatures += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//--------------incase none of them cost 2 or less(which makes for a really poorly crafted Ai deck), try for 3 or less at this point we're accepting anything but lands under 3 mana---
|
||||
for (int k = 0; k < z->nb_cards; k++){
|
||||
MTGCardInstance * _card = z->cards[k];
|
||||
|
||||
if (_card->getManaCost()->getConvertedCost() <= 3 && optimizedothercards < othercards && (!_card->hasType("Land") || _card->hasType("Creature")))
|
||||
{
|
||||
card = _card;
|
||||
if (card)
|
||||
{
|
||||
p->game->putInZone(card, p->game->library, p->game->hand);
|
||||
optimizedothercards += 1;
|
||||
}
|
||||
}
|
||||
if(_card->getManaCost()->getConvertedCost() <= 3 && optimizedcreatures < creatures && (_card->hasType("Creature") || !_card->hasType("Land")))
|
||||
{
|
||||
card = _card;
|
||||
if (card)
|
||||
{
|
||||
p->game->putInZone(card, p->game->library, p->game->hand);
|
||||
optimizedcreatures += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//--------------add up remaining. only 7 cards are optimized, the remaining cards (if rules change amount) are just drawn.
|
||||
int leftover = 0;
|
||||
leftover = amount;
|
||||
leftover -= optimizedland;
|
||||
leftover -= optimizedcreatures;
|
||||
leftover -= optimizedothercards;
|
||||
for(int i = leftover; i > 0;i--)
|
||||
{
|
||||
p->game->drawFromLibrary();
|
||||
}
|
||||
|
||||
}
|
||||
//----------------------------
|
||||
}
|
||||
|
||||
void MTGPlayerCards::drawFromLibrary(){
|
||||
if (!library->nb_cards) {
|
||||
int cantlosers = 0;
|
||||
|
||||
@@ -1454,23 +1454,23 @@ int MTGAffinityRule::receiveEvent(WEvent * event){
|
||||
ok = 0;
|
||||
if (e->to == p->game->battlefield) ok = 2;//card enters play
|
||||
if(ok == 2){//enters play from anywhere
|
||||
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){
|
||||
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->game->temp){
|
||||
//--redux effect
|
||||
MTGGameZone * z = card->controller()->game->hand;
|
||||
int nbcards = z->nb_cards;
|
||||
int colored = 0;
|
||||
string etype = "";
|
||||
MTGCardInstance * card = e->card->previous;
|
||||
if (card && card->hasSubtype("artifact")){etype = "art";}
|
||||
if (card && card->hasSubtype("swamp")){etype = "swa";}
|
||||
if (card && card->hasSubtype("mountain")){etype = "mou";}
|
||||
if (card && card->hasSubtype("plains")){etype = "pla";}
|
||||
if (card && card->hasSubtype("island")){etype = "isl";}
|
||||
if (card && card->hasSubtype("forest")){etype = "for";}
|
||||
if (card && card->hasSubtype("creature") && card->hasColor(1)){etype = "cre"; colored = 1;}
|
||||
if (card && card->hasSubtype("artifact")){etype.append("art");}
|
||||
if (card && card->hasSubtype("swamp")){etype.append("swa");}
|
||||
if (card && card->hasSubtype("mountain")){etype.append("mou");}
|
||||
if (card && card->hasSubtype("plains")){etype.append("pla");}
|
||||
if (card && card->hasSubtype("island")){etype.append("isl");}
|
||||
if (card && card->hasSubtype("forest")){etype.append("for");}
|
||||
if (card && card->hasSubtype("creature") && card->hasColor(1)){etype.append("cre"); colored = 1;}
|
||||
for (int j = 0; j < nbcards; ++j){
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if ((c->has(Constants::AFFINITYARTIFACTS) && etype == "art") || ( c->has(Constants::AFFINITYSWAMP) && etype == "swa") || ( c->has(Constants::AFFINITYMOUNTAIN) && etype == "mou") ||( c->has(Constants::AFFINITYPLAINS) && etype == "pla") || ( c->has(Constants::AFFINITYISLAND) && etype == "isl") || ( c->has(Constants::AFFINITYFOREST) && etype == "for") || ( c->has(Constants::AFFINITYGREENCREATURES) && etype == "cre")){
|
||||
if ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art")) || ( c->has(Constants::AFFINITYSWAMP) && etype.find("swa")) || ( c->has(Constants::AFFINITYMOUNTAIN) && etype.find("mou")) ||( c->has(Constants::AFFINITYPLAINS) && etype.find("pla")) || ( c->has(Constants::AFFINITYISLAND) && etype.find("isl")) || ( c->has(Constants::AFFINITYFOREST) && etype.find("for")) || ( c->has(Constants::AFFINITYGREENCREATURES) && etype.find("cre"))){
|
||||
if(c->getManaCost()->getConvertedCost() > 0){
|
||||
c->getManaCost()->remove(colored,1);//one less colorless to cast
|
||||
}else{
|
||||
@@ -1490,16 +1490,16 @@ int MTGAffinityRule::receiveEvent(WEvent * event){
|
||||
int nbcards = z->nb_cards;
|
||||
string etype = "";
|
||||
MTGCardInstance * card = e->card->previous;
|
||||
if (card && card->hasSubtype("artifact")){etype = "art";}
|
||||
if (card && card->hasSubtype("swamp")){etype = "swa";}
|
||||
if (card && card->hasSubtype("mountain")){etype = "mou";}
|
||||
if (card && card->hasSubtype("plains")){etype = "pla";}
|
||||
if (card && card->hasSubtype("island")){etype = "isl";}
|
||||
if (card && card->hasSubtype("forest")){etype = "for";}
|
||||
if (card && card->hasSubtype("creature") && card->hasColor(1)){etype = "cre"; colored = 1;}
|
||||
if (card && card->hasSubtype("artifact")){etype.append("art");}
|
||||
if (card && card->hasSubtype("swamp")){etype.append("swa");}
|
||||
if (card && card->hasSubtype("mountain")){etype.append("mou");}
|
||||
if (card && card->hasSubtype("plains")){etype.append("pla");}
|
||||
if (card && card->hasSubtype("island")){etype.append("isl");}
|
||||
if (card && card->hasSubtype("forest")){etype.append("for");}
|
||||
if (card && card->hasSubtype("creature") && card->hasColor(1)){etype.append("cre"); colored = 1;}
|
||||
for (int j = 0; j < nbcards; ++j){
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if (c && ((c->has(Constants::AFFINITYARTIFACTS) && etype == "art") || ( c->has(Constants::AFFINITYSWAMP) && etype == "swa") || ( c->has(Constants::AFFINITYMOUNTAIN) && etype == "mou") ||( c->has(Constants::AFFINITYPLAINS) && etype == "pla") || ( c->has(Constants::AFFINITYISLAND) && etype == "isl") || ( c->has(Constants::AFFINITYFOREST) && etype == "for") || ( c->has(Constants::AFFINITYGREENCREATURES) && etype == "cre"))){
|
||||
if (c && ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art")) || ( c->has(Constants::AFFINITYSWAMP) && etype.find("swa")) || ( c->has(Constants::AFFINITYMOUNTAIN) && etype.find("mou")) ||( c->has(Constants::AFFINITYPLAINS) && etype.find("pla")) || ( c->has(Constants::AFFINITYISLAND) && etype.find("isl")) || ( c->has(Constants::AFFINITYFOREST) && etype.find("for")) || ( c->has(Constants::AFFINITYGREENCREATURES) && etype.find("cre")))){
|
||||
if(c->reduxamount > 0){
|
||||
c->reduxamount -= 1;
|
||||
}else{
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "MTGGameZones.h"
|
||||
#include "MTGAbility.h"
|
||||
#include "DeckManager.h"
|
||||
#include "AIPlayer.h"
|
||||
|
||||
int Rules::getMTGId(string cardName){
|
||||
int cardnb = atoi(cardName.c_str());
|
||||
@@ -133,17 +135,39 @@ void Rules::addExtraRules(){
|
||||
MTGCardInstance::ExtraRules[i].lastController = p;
|
||||
for (size_t j = 0; j< initState.playerData[i].extraRules.size(); ++j){
|
||||
AbilityFactory af;
|
||||
MTGPlayerCards * hand = NULL;
|
||||
int handsize = 7;
|
||||
int difficultyRating = 0;
|
||||
MTGAbility * a = af.parseMagicLine(initState.playerData[i].extraRules[j], id++, NULL,&MTGCardInstance::ExtraRules[i]);
|
||||
if (a){
|
||||
if(p->playMode != Player::MODE_TEST_SUITE && g->mRules->gamemode != GAME_TYPE_MOMIR && g->mRules->gamemode != GAME_TYPE_RANDOM1 && g->mRules->gamemode != GAME_TYPE_RANDOM2 && g->mRules->gamemode != GAME_TYPE_STORY)//keep this out of mimor and other game modes.
|
||||
{
|
||||
difficultyRating = DeckManager::getDifficultyRating( g->players[0], g->players[1] );
|
||||
}
|
||||
|
||||
if (a){
|
||||
if (a->oneShot){
|
||||
if(p->isAI() && a->aType == MTGAbility::STANDARD_DRAW && difficultyRating == EASY && p->playMode != Player::MODE_TEST_SUITE && g->mRules->gamemode != GAME_TYPE_MOMIR && g->mRules->gamemode != GAME_TYPE_RANDOM1 && g->mRules->gamemode != GAME_TYPE_RANDOM2 && g->mRules->gamemode != GAME_TYPE_STORY)//stupid protections to keep this out of mimor and other game modes.
|
||||
{
|
||||
handsize = a->nbcardAmount;
|
||||
((AIPlayer *)p)->forceBestAbilityUse = true;
|
||||
((AIPlayer *)p)->agressivity += 100;
|
||||
hand->OptimizedHand(handsize,3,1,3);//easy decks get a major boost, open hand is 2lands,1 creature under 3 mana,3spells under 3 mana.
|
||||
}
|
||||
else if(p->isAI() && a->aType == MTGAbility::STANDARD_DRAW && difficultyRating == NORMAL && p->playMode != Player::MODE_TEST_SUITE && g->mRules->gamemode != GAME_TYPE_MOMIR && g->mRules->gamemode != GAME_TYPE_RANDOM1 && g->mRules->gamemode != GAME_TYPE_RANDOM2 && g->mRules->gamemode != GAME_TYPE_STORY)//stupid protections to keep this out of mimor and other game modes.
|
||||
{
|
||||
handsize = a->nbcardAmount;
|
||||
hand->OptimizedHand(handsize,1,0,2);//give the Ai deck a tiny boost by giving it 1 land and 2 spells under 3 manacost.
|
||||
}else{//resolve normally if the deck is listed as hard.
|
||||
a->resolve();
|
||||
}
|
||||
delete(a);
|
||||
}else{
|
||||
a->addToGame();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t j = 0; j< extraRules.size(); ++j){
|
||||
AbilityFactory af;
|
||||
|
||||
@@ -289,8 +289,8 @@ void StoryDuel::init(){
|
||||
|
||||
GameObserver::Init(players, 2);
|
||||
game = GameObserver::GetInstance();
|
||||
rules->gamemode = GAME_TYPE_STORY;
|
||||
game->startGame(rules);
|
||||
|
||||
}
|
||||
StoryDuel::StoryDuel(TiXmlElement* root,StoryFlow * mParent): StoryPage(mParent) {
|
||||
game = NULL;
|
||||
|
||||
Reference in New Issue
Block a user