mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Fix 1810 suggest artifact assembly
This commit is contained in:
@@ -2510,10 +2510,20 @@ void CPlayerInterface::stacksRebalanced(const StackLocation &src, const StackLoc
|
|||||||
garrisonsChanged(objects);
|
garrisonsChanged(objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlayerInterface::askToAssembleArtifact(const ArtifactLocation &al)
|
||||||
|
{
|
||||||
|
auto hero = dynamic_cast<const CGHeroInstance*>(al.relatedObj());
|
||||||
|
if(hero)
|
||||||
|
{
|
||||||
|
CArtPlace::askToAssemble(hero->getArt(al.slot), al.slot, hero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CPlayerInterface::artifactPut(const ArtifactLocation &al)
|
void CPlayerInterface::artifactPut(const ArtifactLocation &al)
|
||||||
{
|
{
|
||||||
EVENT_HANDLER_CALLED_BY_CLIENT;
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
||||||
adventureInt->infoBar.showSelection();
|
adventureInt->infoBar.showSelection();
|
||||||
|
askToAssembleArtifact(al);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
|
void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
|
||||||
@@ -2538,6 +2548,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
|
|||||||
if(artWin)
|
if(artWin)
|
||||||
artWin->artifactMoved(src, dst);
|
artWin->artifactMoved(src, dst);
|
||||||
}
|
}
|
||||||
|
askToAssembleArtifact(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
|
void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
|
||||||
|
@@ -296,6 +296,7 @@ private:
|
|||||||
|
|
||||||
void doMoveHero(const CGHeroInstance *h, CGPath path);
|
void doMoveHero(const CGHeroInstance *h, CGPath path);
|
||||||
void setMovementStatus(bool value);
|
void setMovementStatus(bool value);
|
||||||
|
void askToAssembleArtifact(const ArtifactLocation &al);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CPlayerInterface * LOCPLINT;
|
extern CPlayerInterface * LOCPLINT;
|
||||||
|
@@ -214,6 +214,32 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CArtPlace::askToAssemble(const CArtifactInstance *art, ArtifactPosition slot,
|
||||||
|
const CGHeroInstance *hero)
|
||||||
|
{
|
||||||
|
std::vector<const CArtifact *> assemblyPossibilities = art->assemblyPossibilities(hero);
|
||||||
|
|
||||||
|
// If the artifact can be assembled, display dialog.
|
||||||
|
for(const CArtifact *combination : assemblyPossibilities)
|
||||||
|
{
|
||||||
|
LOCPLINT->showArtifactAssemblyDialog(
|
||||||
|
art->artType->id,
|
||||||
|
combination->id,
|
||||||
|
true,
|
||||||
|
std::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), hero, slot, true, combination->id),
|
||||||
|
0);
|
||||||
|
|
||||||
|
if(assemblyPossibilities.size() > 2)
|
||||||
|
{
|
||||||
|
logGlobal->warnStream() << boost::format(
|
||||||
|
"More than one possibility of assembling on %s... taking only first")
|
||||||
|
% art->artType->Name();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CArtPlace::clickRight(tribool down, bool previousState)
|
void CArtPlace::clickRight(tribool down, bool previousState)
|
||||||
{
|
{
|
||||||
if(down && ourArt && !locked && text.size() && !picked) //if there is no description or it's a lock, do nothing ;]
|
if(down && ourArt && !locked && text.size() && !picked) //if there is no description or it's a lock, do nothing ;]
|
||||||
@@ -225,20 +251,8 @@ void CArtPlace::clickRight(tribool down, bool previousState)
|
|||||||
std::vector<const CArtifact *> assemblyPossibilities = ourArt->assemblyPossibilities(ourOwner->curHero);
|
std::vector<const CArtifact *> assemblyPossibilities = ourArt->assemblyPossibilities(ourOwner->curHero);
|
||||||
|
|
||||||
// If the artifact can be assembled, display dialog.
|
// If the artifact can be assembled, display dialog.
|
||||||
for(const CArtifact *combination : assemblyPossibilities)
|
if (askToAssemble(ourArt, slotID, ourOwner->curHero))
|
||||||
{
|
{
|
||||||
LOCPLINT->showArtifactAssemblyDialog(
|
|
||||||
ourArt->artType->id,
|
|
||||||
combination->id,
|
|
||||||
true,
|
|
||||||
std::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), ourOwner->curHero, slotID, true, combination->id),
|
|
||||||
0);
|
|
||||||
|
|
||||||
if(assemblyPossibilities.size() > 2)
|
|
||||||
{
|
|
||||||
logGlobal->warnStream() << "More than one possibility of assembling... taking only first";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,15 +74,17 @@ public:
|
|||||||
|
|
||||||
void setMeAsDest(bool backpackAsVoid = true);
|
void setMeAsDest(bool backpackAsVoid = true);
|
||||||
void setArtifact(const CArtifactInstance *art);
|
void setArtifact(const CArtifactInstance *art);
|
||||||
|
static bool askToAssemble(const CArtifactInstance *art, ArtifactPosition slot,
|
||||||
|
const CGHeroInstance *hero);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Contains artifacts of hero. Distincts which artifacts are worn or backpacked
|
/// Contains artifacts of hero. Distincts which artifacts are worn or backpacked
|
||||||
class CArtifactsOfHero : public CIntObject
|
class CArtifactsOfHero : public CIntObject
|
||||||
{
|
{
|
||||||
const CGHeroInstance * curHero;
|
const CGHeroInstance * curHero;
|
||||||
|
|
||||||
std::map<ArtifactPosition, CArtPlace *> artWorn;
|
std::map<ArtifactPosition, CArtPlace *> artWorn;
|
||||||
|
|
||||||
std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
|
std::vector<CArtPlace *> backpack; //hero's visible backpack (only 5 elements!)
|
||||||
int backpackPos; //number of first art visible in backpack (in hero's vector)
|
int backpackPos; //number of first art visible in backpack (in hero's vector)
|
||||||
|
|
||||||
|
@@ -926,13 +926,16 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
|
|||||||
{
|
{
|
||||||
const bool result = apply->applyOnGH(this,&c,pack, player);
|
const bool result = apply->applyOnGH(this,&c,pack, player);
|
||||||
if(!result)
|
if(!result)
|
||||||
complain("Got false in applying... that request must have been fishy!");
|
{
|
||||||
logGlobal->traceStream() << "Message successfully applied (result=" << result << ")!";
|
complain((boost::format("Got false in applying %s... that request must have been fishy!")
|
||||||
|
% typeid(*pack).name()).str());
|
||||||
|
}
|
||||||
|
logGlobal->traceStream() << "Message successfully applied (result=" << result << ")!";
|
||||||
sendPackageResponse(true);
|
sendPackageResponse(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logGlobal->errorStream() << "Message cannot be applied, cannot find applier (unregistered type)!";
|
logGlobal->errorStream() << "Message cannot be applied, cannot find applier (unregistered type)!";
|
||||||
sendPackageResponse(false);
|
sendPackageResponse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3038,7 +3041,7 @@ bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition
|
|||||||
sendAndApply(&da);
|
sendAndApply(&da);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameHandler::buyArtifact( ObjectInstanceID hid, ArtifactID aid )
|
bool CGameHandler::buyArtifact( ObjectInstanceID hid, ArtifactID aid )
|
||||||
|
Reference in New Issue
Block a user