1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Merge pull request #2814 from SoundSSGood/arts-counter-impovements

Artifacts counter impovements
This commit is contained in:
Ivan Savenko
2023-10-01 17:53:51 +03:00
committed by GitHub
10 changed files with 75 additions and 66 deletions

View File

@@ -2738,7 +2738,7 @@ bool CGameHandler::moveArtifact(const ArtifactLocation &al1, const ArtifactLocat
}
MoveArtifact ma(&src, &dst);
if(dst.slot == ArtifactPosition::TRANSITION_POS)
if(src.artHolder == dst.artHolder)
ma.askAssemble = false;
sendAndApply(&ma);
}
@@ -2853,7 +2853,7 @@ bool CGameHandler::bulkMoveArtifacts(ObjectInstanceID srcHero, ObjectInstanceID
* @param assembleTo If assemble is true, this represents the artifact ID of the combination
* artifact to assemble to. Otherwise it's not used.
*/
bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo)
bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo)
{
const CGHeroInstance * hero = getHero(heroID);
const CArtifactInstance * destArtifact = hero->getArt(artifactSlot);
@@ -2861,23 +2861,27 @@ bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition
if(!destArtifact)
COMPLAIN_RET("assembleArtifacts: there is no such artifact instance!");
const auto dstLoc = ArtifactLocation(hero, artifactSlot);
if(assemble)
{
CArtifact * combinedArt = VLC->arth->objects[assembleTo];
if(!combinedArt->isCombined())
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to assemble is not a combined artifacts!");
if (!vstd::contains(ArtifactUtils::assemblyPossibilities(hero, destArtifact->getTypeId(),
ArtifactUtils::isSlotEquipment(artifactSlot)), combinedArt))
if(!vstd::contains(ArtifactUtils::assemblyPossibilities(hero, destArtifact->getTypeId()), combinedArt))
{
COMPLAIN_RET("assembleArtifacts: It's impossible to assemble requested artifact!");
}
if(!destArtifact->canBePutAt(dstLoc)
&& !destArtifact->canBePutAt(ArtifactLocation(hero, ArtifactPosition::BACKPACK_START)))
{
COMPLAIN_RET("assembleArtifacts: It's impossible to give the artholder requested artifact!");
}
if(ArtifactUtils::checkSpellbookIsNeeded(hero, assembleTo, artifactSlot))
giveHeroNewArtifact(hero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
AssembledArtifact aa;
aa.al = ArtifactLocation(hero, artifactSlot);
aa.al = dstLoc;
aa.builtArt = combinedArt;
sendAndApply(&aa);
}
@@ -2891,7 +2895,7 @@ bool CGameHandler::assembleArtifacts (ObjectInstanceID heroID, ArtifactPosition
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to disassemble but backpack is full!");
DisassembledArtifact da;
da.al = ArtifactLocation(hero, artifactSlot);
da.al = dstLoc;
sendAndApply(&da);
}