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