mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
This commit is contained in:
parent
66d6aebe32
commit
b36be10e30
@ -6,7 +6,7 @@ void CEmptyAI::init(shared_ptr<CCallback> CB)
|
|||||||
cb = CB;
|
cb = CB;
|
||||||
human=false;
|
human=false;
|
||||||
playerID = *cb->getMyColor();
|
playerID = *cb->getMyColor();
|
||||||
logAi->infoStream() << "EmptyAI initialized.";
|
//logAi->infoStream() << "EmptyAI initialized.";
|
||||||
}
|
}
|
||||||
void CEmptyAI::yourTurn()
|
void CEmptyAI::yourTurn()
|
||||||
{
|
{
|
||||||
|
@ -2118,29 +2118,6 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
//used when l-clicking -> action to be called upon the click
|
//used when l-clicking -> action to be called upon the click
|
||||||
std::function<void()> realizeAction;
|
std::function<void()> realizeAction;
|
||||||
|
|
||||||
//helper lambda that appropriately realizes action / sets cursor and tooltip
|
|
||||||
auto realizeThingsToDo = [&]()
|
|
||||||
{
|
|
||||||
if(eventType == MOVE)
|
|
||||||
{
|
|
||||||
if(setCursor)
|
|
||||||
CCS->curh->changeGraphic(cursorType, cursorFrame);
|
|
||||||
this->console->alterText(consoleMsg);
|
|
||||||
this->console->whoSetAlter = 0;
|
|
||||||
}
|
|
||||||
if(eventType == LCLICK && realizeAction)
|
|
||||||
{
|
|
||||||
//opening creature window shouldn't affect myTurn...
|
|
||||||
if(currentAction != CREATURE_INFO)
|
|
||||||
{
|
|
||||||
myTurn = false; //tends to crash with empty calls
|
|
||||||
}
|
|
||||||
realizeAction();
|
|
||||||
CCS->curh->changeGraphic(ECursor::COMBAT, ECursor::COMBAT_POINTER);
|
|
||||||
this->console->alterText("");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const CStack * const sactive = activeStack;
|
const CStack * const sactive = activeStack;
|
||||||
//Get stack on the hex - first try to grab the alive one, if not found -> allow dead stacks.
|
//Get stack on the hex - first try to grab the alive one, if not found -> allow dead stacks.
|
||||||
const CStack *shere = curInt->cb->battleGetStackByPos(myNumber, true);
|
const CStack *shere = curInt->cb->battleGetStackByPos(myNumber, true);
|
||||||
@ -2165,7 +2142,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
|
|
||||||
for (PossibleActions action : possibleActions)
|
for (PossibleActions action : possibleActions)
|
||||||
{
|
{
|
||||||
bool legalAction = false; //this action is legal and can't be performed
|
bool legalAction = false; //this action is legal and can be performed
|
||||||
bool notLegal = false; //this action is not legal and should display message
|
bool notLegal = false; //this action is not legal and should display message
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
@ -2409,7 +2386,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
{
|
{
|
||||||
case SpellID::SACRIFICE:
|
case SpellID::SACRIFICE:
|
||||||
case SpellID::TELEPORT:
|
case SpellID::TELEPORT:
|
||||||
selectedStack = shere; //remember firts target
|
selectedStack = shere; //remember first target
|
||||||
secondaryTarget = true;
|
secondaryTarget = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2428,15 +2405,17 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
break;
|
break;
|
||||||
case TELEPORT:
|
case TELEPORT:
|
||||||
consoleMsg = CGI->generaltexth->allTexts[25]; //Teleport Here
|
consoleMsg = CGI->generaltexth->allTexts[25]; //Teleport Here
|
||||||
|
cursorFrame = ECursor::COMBAT_TELEPORT;
|
||||||
isCastingPossible = true;
|
isCastingPossible = true;
|
||||||
break;
|
break;
|
||||||
case OBSTACLE:
|
case OBSTACLE:
|
||||||
consoleMsg = CGI->generaltexth->allTexts[550];
|
consoleMsg = CGI->generaltexth->allTexts[550];
|
||||||
|
//TODO: remove obstacle cursor
|
||||||
isCastingPossible = true;
|
isCastingPossible = true;
|
||||||
break;
|
break;
|
||||||
case SACRIFICE:
|
case SACRIFICE:
|
||||||
cursorFrame = ECursor::COMBAT_SACRIFICE;
|
|
||||||
consoleMsg = (boost::format(CGI->generaltexth->allTexts[549]) % shere->getName()).str(); //sacrifice the %s
|
consoleMsg = (boost::format(CGI->generaltexth->allTexts[549]) % shere->getName()).str(); //sacrifice the %s
|
||||||
|
cursorFrame = ECursor::COMBAT_SACRIFICE;
|
||||||
spellToCast->selectedStack = shere->ID; //sacrificed creature is selected
|
spellToCast->selectedStack = shere->ID; //sacrificed creature is selected
|
||||||
isCastingPossible = true;
|
isCastingPossible = true;
|
||||||
break;
|
break;
|
||||||
@ -2479,6 +2458,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
consoleMsg = CGI->generaltexth->allTexts[23];
|
consoleMsg = CGI->generaltexth->allTexts[23];
|
||||||
break;
|
break;
|
||||||
case TELEPORT:
|
case TELEPORT:
|
||||||
|
cursorFrame = ECursor::COMBAT_BLOCKED;
|
||||||
consoleMsg = CGI->generaltexth->allTexts[24]; //Invalid Teleport Destination
|
consoleMsg = CGI->generaltexth->allTexts[24]; //Invalid Teleport Destination
|
||||||
break;
|
break;
|
||||||
case SACRIFICE:
|
case SACRIFICE:
|
||||||
@ -2499,10 +2479,18 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
|
|
||||||
if (isCastingPossible) //common part
|
if (isCastingPossible) //common part
|
||||||
{
|
{
|
||||||
|
switch (currentAction) //don't use that with teleport / sacrifice
|
||||||
|
{
|
||||||
|
case TELEPORT: //FIXME: more generic solution?
|
||||||
|
case SACRIFICE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
cursorType = ECursor::SPELLBOOK;
|
cursorType = ECursor::SPELLBOOK;
|
||||||
cursorFrame = 0;
|
cursorFrame = 0;
|
||||||
if(consoleMsg.empty() && sp)
|
if(consoleMsg.empty() && sp)
|
||||||
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
|
consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[26]) % sp->name); //Cast %s
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
realizeAction = [=]
|
realizeAction = [=]
|
||||||
{
|
{
|
||||||
@ -2552,6 +2540,30 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
//helper lambda that appropriately realizes action / sets cursor and tooltip
|
||||||
|
auto realizeThingsToDo = [&]()
|
||||||
|
{
|
||||||
|
if(eventType == MOVE)
|
||||||
|
{
|
||||||
|
if(setCursor)
|
||||||
|
CCS->curh->changeGraphic(cursorType, cursorFrame);
|
||||||
|
this->console->alterText(consoleMsg);
|
||||||
|
this->console->whoSetAlter = 0;
|
||||||
|
}
|
||||||
|
if(eventType == LCLICK && realizeAction)
|
||||||
|
{
|
||||||
|
//opening creature window shouldn't affect myTurn...
|
||||||
|
if ((currentAction != CREATURE_INFO) && !secondaryTarget)
|
||||||
|
{
|
||||||
|
myTurn = false; //tends to crash with empty calls
|
||||||
|
}
|
||||||
|
realizeAction();
|
||||||
|
if (!secondaryTarget) //do not replace teleport or sacrifice cursor
|
||||||
|
CCS->curh->changeGraphic(ECursor::COMBAT, ECursor::COMBAT_POINTER);
|
||||||
|
this->console->alterText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
realizeThingsToDo();
|
realizeThingsToDo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ si8 CBattleInfoCallback::battleHasWallPenalty(const IBonusBearer *bonusBearer, B
|
|||||||
si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, BattleHex destHex, int telportLevel) const
|
si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, BattleHex destHex, int telportLevel) const
|
||||||
{
|
{
|
||||||
RETURN_IF_NOT_BATTLE(false);
|
RETURN_IF_NOT_BATTLE(false);
|
||||||
if(getAccesibility(stack).accessible(destHex, stack))
|
if (!getAccesibility(stack).accessible(destHex, stack))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (battleGetSiegeLevel() && telportLevel < 2) //check for wall
|
if (battleGetSiegeLevel() && telportLevel < 2) //check for wall
|
||||||
|
Loading…
Reference in New Issue
Block a user