1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Backpack limit. Amount of fixes.

This commit is contained in:
SoundSSGood 2023-03-21 20:02:58 +02:00
parent f0f9eecf97
commit 19096f39f0
7 changed files with 35 additions and 41 deletions

View File

@ -1768,6 +1768,9 @@ void CPlayerInterface::tryDiggging(const CGHeroInstance * h)
case EDiggingStatus::WRONG_TERRAIN:
msgToShow = 60; ////Try looking on land!
break;
case EDiggingStatus::BACKPACK_IS_FULL:
msgToShow = 247; //Searching for the Grail is fruitless...
break;
default:
assert(0);
}

View File

@ -179,7 +179,7 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
}
else
{
LOCPLINT->showInfoDialog("limit");
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.152"));
}
}
}
@ -1008,7 +1008,7 @@ void CCommanderArtPlace::returnArtToHeroCallback()
ArtifactPosition freeSlot = ArtifactUtils::getArtBackpackPosition(commanderOwner, ourArt->getTypeId());
if(freeSlot == ArtifactPosition::PRE_FIRST)
{
LOCPLINT->showInfoDialog("no free slots");
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.152"));
}
else
{

View File

@ -806,7 +806,7 @@ void CMarketplaceWindow::makeDeal()
if(!sliderValue)
return;
madeTransaction = true;
bool allowDeal = true;
int leftIdToSend = hLeft->id;
switch (mode)
{
@ -819,15 +819,15 @@ void CMarketplaceWindow::makeDeal()
case EMarketMode::RESOURCE_ARTIFACT:
if(!ArtifactID(hRight->id).toArtifact()->canBePutAt(hero))
{
LOCPLINT->showInfoDialog("no available slots");
madeTransaction = false;
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.326"));
allowDeal = false;
}
break;
default:
break;
}
if(madeTransaction)
if(allowDeal)
{
if(slider)
{
@ -839,6 +839,8 @@ void CMarketplaceWindow::makeDeal()
LOCPLINT->cb->trade(market->o, mode, leftIdToSend, hRight->id, r2, hero);
}
}
madeTransaction = true;
hLeft = nullptr;
hRight = nullptr;
selectionChanged(true);

View File

@ -967,7 +967,8 @@ public:
CAN_DIG = 0,
LACK_OF_MOVEMENT,
WRONG_TERRAIN,
TILE_OCCUPIED
TILE_OCCUPIED,
BACKPACK_IS_FULL
};
EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)

View File

@ -1124,7 +1124,8 @@ EDiggingStatus CGHeroInstance::diggingStatus() const
{
if(static_cast<int>(movement) < maxMovePoints(true))
return EDiggingStatus::LACK_OF_MOVEMENT;
if(!VLC->arth->objects[ArtifactID::GRAIL]->canBePutAt(this))
return EDiggingStatus::BACKPACK_IS_FULL;
return cb->getTileDigStatus(visitablePos());
}

View File

@ -1331,7 +1331,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
}
else
{
iw.text << "no slots";
iw.text.addTxt(MetaString::ADVOB_TXT, 2);
}
cb->showInfoDialog(&iw);
pick(h);

View File

@ -758,7 +758,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
{
auto sendMoveArtifact = [&](const CArtifactInstance *art, MoveArtifact *ma)
{
const auto slot = ArtifactUtils::getArtAnyPosition(finishingBattle->winnerHero, art->artType->getId());
const auto slot = ArtifactUtils::getArtAnyPosition(finishingBattle->winnerHero, art->getTypeId());
if(slot != ArtifactPosition::PRE_FIRST)
{
arts.push_back(art);
@ -5878,18 +5878,13 @@ bool CGameHandler::dig(const CGHeroInstance *h)
if (h->diggingStatus() != EDiggingStatus::CAN_DIG) //checks for terrain and movement
COMPLAIN_RETF("Hero cannot dig (error code %d)!", h->diggingStatus());
const auto isHeroAbleGet = VLC->arth->objects[ArtifactID::GRAIL]->canBePutAt(h);
if(isHeroAbleGet)
{
//create a hole
NewObject no;
no.ID = Obj::HOLE;
no.pos = h->visitablePos();
no.subID = 0;
sendAndApply(&no);
}
//create a hole
NewObject no;
no.ID = Obj::HOLE;
no.pos = h->visitablePos();
no.subID = 0;
sendAndApply(&no);
//take MPs
SetMovePoints smp;
smp.hid = h->id;
@ -5901,25 +5896,17 @@ bool CGameHandler::dig(const CGHeroInstance *h)
iw.player = h->tempOwner;
if (gs->map->grailPos == h->visitablePos())
{
if(isHeroAbleGet)
{
iw.text.addTxt(MetaString::GENERAL_TXT, 58); //"Congratulations! After spending many hours digging here, your hero has uncovered the "
iw.text.addTxt(MetaString::ART_NAMES, ArtifactID::GRAIL);
iw.soundID = soundBase::ULTIMATEARTIFACT;
giveHeroNewArtifact(h, VLC->arth->objects[ArtifactID::GRAIL], ArtifactPosition::FIRST_AVAILABLE); //give grail
sendAndApply(&iw);
iw.text.addTxt(MetaString::GENERAL_TXT, 58); //"Congratulations! After spending many hours digging here, your hero has uncovered the "
iw.text.addTxt(MetaString::ART_NAMES, ArtifactID::GRAIL);
iw.soundID = soundBase::ULTIMATEARTIFACT;
giveHeroNewArtifact(h, VLC->arth->objects[ArtifactID::GRAIL], ArtifactPosition::PRE_FIRST); //give grail
sendAndApply(&iw);
iw.soundID = soundBase::invalid;
iw.components.emplace_back(Component::EComponentType::ARTIFACT, ArtifactID::GRAIL, 0, 0);
iw.text.clear();
iw.text.addTxt(MetaString::ART_DESCR, ArtifactID::GRAIL);
sendAndApply(&iw);
}
else
{
iw.text << "found but no free slots";
sendAndApply(&iw);
}
iw.soundID = soundBase::invalid;
iw.components.emplace_back(Component::EComponentType::ARTIFACT, ArtifactID::GRAIL, 0, 0);
iw.text.clear();
iw.text.addTxt(MetaString::ART_DESCR, ArtifactID::GRAIL);
sendAndApply(&iw);
}
else
{
@ -6870,7 +6857,7 @@ void CGameHandler::putArtifact(const ArtifactLocation &al, const CArtifactInstan
bool CGameHandler::giveHeroNewArtifact(const CGHeroInstance * h, const CArtifact * artType, ArtifactPosition pos)
{
assert(artType);
if(pos != ArtifactPosition::FIRST_AVAILABLE && pos != GameConstants::BACKPACK_START)
if(pos != ArtifactPosition::FIRST_AVAILABLE && !ArtifactUtils::isSlotBackpack(pos))
COMPLAIN_RET_FALSE_IF(!artType->canBePutAt(h, pos, false), "Cannot put artifact in that slot!");
CArtifactInstance * newArtInst = nullptr;