Erwan
- "fix" issue 25 - A few AI fixes for Deck 36 (artifact lands deck)
This commit is contained in:
@@ -293,7 +293,7 @@ int AIPlayer::effectBadOrGood(MTGCardInstance * card){
|
||||
|
||||
|
||||
int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
Targetable * potentialTargets[50];
|
||||
vector<Targetable *>potentialTargets;
|
||||
int nbtargets = 0;
|
||||
GameObserver * gameObs = GameObserver::GetInstance();
|
||||
int checkOnly = 0;
|
||||
@@ -313,7 +313,7 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
|
||||
if (!tc->alreadyHasTarget(target) && tc->canTarget(target) && nbtargets < 50){
|
||||
for (int i = 0; i < 3; i++){ //Increase probability to target a player when this is possible
|
||||
potentialTargets[nbtargets] = target;
|
||||
potentialTargets.push_back(target);
|
||||
nbtargets++;
|
||||
}
|
||||
if (checkOnly) return 1;
|
||||
@@ -337,7 +337,7 @@ int AIPlayer::chooseTarget(TargetChooser * tc){
|
||||
}
|
||||
}
|
||||
for (int l=0; l < multiplier; l++){
|
||||
potentialTargets[nbtargets] = card;
|
||||
potentialTargets.push_back(card);
|
||||
nbtargets++;
|
||||
}
|
||||
}
|
||||
@@ -524,29 +524,7 @@ int AIPlayer::combatDamages(){
|
||||
if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS) return orderBlockers();
|
||||
|
||||
if (currentGamePhase != Constants::MTG_PHASE_COMBATDAMAGE) return 0;
|
||||
/*
|
||||
DamageResolverLayer * drl = gameObs->mLayers->combatLayer();
|
||||
|
||||
if (drl->currentChoosingPlayer == this){
|
||||
for (int i = 0; i < drl->mCount; i++){
|
||||
DamagerDamaged * current = (DamagerDamaged *) drl->mObjects[i];
|
||||
if (current->damageSelecter == this){
|
||||
OutputDebugString("YEs, AI IS THE DAMAGE DEALER");
|
||||
MTGCardInstance * attacker = current->card;
|
||||
MTGCardInstance * canardEmissaire = *(attacker->blockers.rbegin());
|
||||
|
||||
while (canardEmissaire && current->damageToDeal){
|
||||
drl->clickDamage(canardEmissaire);
|
||||
}
|
||||
result = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result) return drl->nextPlayer();
|
||||
*/
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -611,6 +589,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c
|
||||
cd.setType(type);
|
||||
card = NULL;
|
||||
while((card = cd.nextmatch(game->hand, card))){
|
||||
if (card->hasType("land") && !this->canPutLandsIntoPlay) continue;
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
if (currentCost > maxCost && potentialMana->canAfford(card->getManaCost())){
|
||||
TargetChooserFactory * tcf = NEW TargetChooserFactory();
|
||||
@@ -676,6 +655,7 @@ int AIPlayerBaka::computeActions(){
|
||||
switch(currentGamePhase){
|
||||
case Constants::MTG_PHASE_FIRSTMAIN:
|
||||
case Constants::MTG_PHASE_SECONDMAIN:
|
||||
{
|
||||
if (canPutLandsIntoPlay){
|
||||
//Attempt to put land into play
|
||||
cd.init();
|
||||
@@ -689,17 +669,21 @@ int AIPlayerBaka::computeActions(){
|
||||
}
|
||||
|
||||
//No mana, try to get some
|
||||
getPotentialMana();
|
||||
if (potentialMana->getConvertedCost() > 0){
|
||||
SAFE_DELETE(potentialMana);
|
||||
ManaCost * currentMana = manaPool;
|
||||
if (!currentMana->getConvertedCost()){
|
||||
currentMana = getPotentialMana();
|
||||
}
|
||||
if (currentMana->getConvertedCost() > 0){
|
||||
|
||||
|
||||
//look for the most expensive creature we can afford
|
||||
nextCardToPlay = FindCardToPlay(potentialMana, "creature");
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "creature");
|
||||
//Let's Try an enchantment maybe ?
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "enchantment");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "artifact");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "instant");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(potentialMana, "sorcery");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||
if (!nextCardToPlay) nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
||||
if (nextCardToPlay){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buffe[4096];
|
||||
@@ -707,7 +691,7 @@ int AIPlayerBaka::computeActions(){
|
||||
OutputDebugString(buffe);
|
||||
#endif
|
||||
|
||||
tapLandsForMana(potentialMana,nextCardToPlay->getManaCost());
|
||||
if (currentMana == potentialMana) tapLandsForMana(currentMana,nextCardToPlay->getManaCost());
|
||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
return 1;
|
||||
@@ -718,6 +702,7 @@ int AIPlayerBaka::computeActions(){
|
||||
selectAbility();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Constants::MTG_PHASE_COMBATATTACKERS:
|
||||
chooseAttackers();
|
||||
break;
|
||||
|
||||
@@ -61,9 +61,9 @@ void GuiPlay::VertStack::Enstack(CardView* card)
|
||||
|
||||
inline float GuiPlay::VertStack::nextX() { return x + CARD_WIDTH; }
|
||||
|
||||
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0) {}
|
||||
GuiPlay::BattleField::BattleField(float width) : HorzStack(width), attackers(0), blockers(0), height(0.0), red(0), colorFlow(0) {}
|
||||
const float GuiPlay::BattleField::HEIGHT = 80.0f;
|
||||
void GuiPlay::BattleField::addAttacker(MTGCardInstance*) { ++attackers; }
|
||||
void GuiPlay::BattleField::addAttacker(MTGCardInstance*) { ++attackers; colorFlow = 1; }
|
||||
void GuiPlay::BattleField::removeAttacker(MTGCardInstance*) { --attackers; }
|
||||
void GuiPlay::BattleField::reset(float x, float y) { HorzStack::reset(x, y); currentAttacker = 1; }
|
||||
void GuiPlay::BattleField::EnstackAttacker(CardView* card)
|
||||
@@ -86,11 +86,17 @@ void GuiPlay::BattleField::Update(float dt)
|
||||
height -= 10 * dt * height;
|
||||
else
|
||||
height += 10 * dt * (HEIGHT - height);
|
||||
|
||||
if (colorFlow){
|
||||
red+= colorFlow * 300 * dt;
|
||||
if (red < 0) red = 0;
|
||||
if (red > 70) red = 70;
|
||||
}
|
||||
}
|
||||
void GuiPlay::BattleField::Render()
|
||||
{
|
||||
if (height > 3)
|
||||
JRenderer::GetInstance()->FillRect(22, SCREEN_HEIGHT / 2 + 10 - height / 2, 250, height, ARGB(127, 0, 0, 0));
|
||||
JRenderer::GetInstance()->FillRect(22, SCREEN_HEIGHT / 2 + 10 - height / 2, 250, height, ARGB(127, red, 0, 0));
|
||||
}
|
||||
|
||||
GuiPlay::GuiPlay(GameObserver* game, CardSelector* cs) : game(game), cs(cs)
|
||||
@@ -207,6 +213,10 @@ int GuiPlay::receiveEventPlus(WEvent * e)
|
||||
event->card->view->actT = event->after ? M_PI / 2 : 0;
|
||||
return 1;
|
||||
}
|
||||
else if (WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e))
|
||||
{
|
||||
if (Constants::MTG_PHASE_COMBATEND == event->to->id) battleField.colorFlow = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int GuiPlay::receiveEventMinus(WEvent * e)
|
||||
|
||||
Reference in New Issue
Block a user