1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +02:00

- Hopefully fixed possibleActions for every case

- better algorithm for looting artifacts, yet buggy
This commit is contained in:
DjWarmonger
2012-05-01 13:56:32 +00:00
parent f767216b2e
commit 5d311fb3ed
2 changed files with 49 additions and 49 deletions

View File

@ -1387,6 +1387,8 @@ void CBattleInterface::newRound(int number)
void CBattleInterface::giveCommand(ui8 action, BattleHex tile, ui32 stackID, si32 additional, si32 selected) void CBattleInterface::giveCommand(ui8 action, BattleHex tile, ui32 stackID, si32 additional, si32 selected)
{ {
possibleActions.clear(); //no checks allowed before action is resolved
const CStack *stack = curInt->cb->battleGetStackByID(stackID); const CStack *stack = curInt->cb->battleGetStackByID(stackID);
if(!stack && action != BattleAction::HERO_SPELL && action != BattleAction::RETREAT && action != BattleAction::SURRENDER) if(!stack && action != BattleAction::HERO_SPELL && action != BattleAction::RETREAT && action != BattleAction::SURRENDER)
{ {

View File

@ -455,55 +455,53 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
} }
//TODO: check if hero surrended / fled //TODO: check if hero surrended / fled
//TODO: display loot in window //TODO: display loot in window
//if (result < BattleResult::SURRENDER && winnerHero) if (result < BattleResult::SURRENDER && winnerHero)
//{ {
// if (loserHero) if (loserHero)
// { {
// BOOST_FOREACH (auto art, loserHero->artifactsWorn) auto artifactsWorn = loserHero->artifactsWorn;
// { BOOST_FOREACH (auto artSlot, artifactsWorn)
// if (art.second.artifact) {
// { MoveArtifact ma; //TODO: put into a function?
// MoveArtifact ma; //TODO: put into a function? ma.src = ArtifactLocation (loserHero, artSlot.first);
// ma.src = ArtifactLocation (loserHero, art.first); const CArtifactInstance * art = ma.src.getArt();
// ma.dst = ArtifactLocation (winnerHero, art.second.artifact->firstAvailableSlot(winnerHero)); if (art && !art->artType->isBig()) // don't move war machines or locked arts (spellbook)
// sendAndApply(&ma); {
// } ma.dst = ArtifactLocation (winnerHero, art->firstAvailableSlot(winnerHero));
// } sendAndApply(&ma);
// BOOST_FOREACH (auto art, loserHero->artifactsInBackpack) }
// { }
// if (art.artifact) while (!loserHero->artifactsInBackpack.empty())
// { {
// MoveArtifact ma; //we assume that no big artifatcs cna be found
// ma.src = ArtifactLocation (loserHero, loserHero->getArtPos (art.artifact->artType->id, false)); //I smell trouble? MoveArtifact ma;
// ma.dst = ArtifactLocation (winnerHero, art.artifact->firstAvailableSlot(winnerHero)); ma.src = ArtifactLocation (loserHero, GameConstants::BACKPACK_START); //backpack automatically shifts arts to beginning
// sendAndApply(&ma); const CArtifactInstance * art = ma.src.getArt();
// } ma.dst = ArtifactLocation (winnerHero, art->firstAvailableSlot(winnerHero));
// } sendAndApply(&ma);
// if (loserHero->commander) //TODO: what if commanders belong to no hero? }
// { //if (loserHero->commander) //TODO: what if commanders belong to no hero?
// BOOST_FOREACH (auto art, loserHero->commander->artifactsWorn) //{
// { // BOOST_FOREACH (auto art, loserHero->commander->artifactsWorn)
// if (art.second.artifact) // {
// { // MoveArtifact ma; //FIXME: boost::variant vs pointer casting is bad solution
// MoveArtifact ma; //FIXME: boost::variant vs pointer casting is bad solution // ma.src = ArtifactLocation (loserHero->commander.get(), art.first);
// ma.src = ArtifactLocation (ConstTransitivePtr <CStackInstance> (loserHero->commander), art.first); // ma.dst = ArtifactLocation (winnerHero, art.second.artifact->firstAvailableSlot(winnerHero));
// ma.dst = ArtifactLocation (winnerHero, art.second.artifact->firstAvailableSlot(winnerHero)); // sendAndApply(&ma);
// sendAndApply(&ma); // }
// } //}
// } }
// } //BOOST_FOREACH (auto armySlot, gs->curB->belligerents[loser]->stacks)
// } //{
// BOOST_FOREACH (auto armySlot, gs->curB->belligerents[loser]->stacks) // MoveArtifact ma;
// { // ma.src = ArtifactLocation (armySlot.second, (ArtifactPosition::CREATURE_SLOT));
// MoveArtifact ma; // {
// ma.src = ArtifactLocation (armySlot.second, (ArtifactPosition::CREATURE_SLOT)); // if (CArtifactInstance * art = ma.src.getArt())
// { // ma.dst = ArtifactLocation (winnerHero, art->firstAvailableSlot(winnerHero));
// if (CArtifactInstance * art = ma.src.getArt()) // sendAndApply(&ma);
// ma.dst = ArtifactLocation (winnerHero, art->firstAvailableSlot(winnerHero)); // }
// sendAndApply(&ma); //}
// } }
// }
//}
if (necroSlot != -1) if (necroSlot != -1)
{ {