mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Backpack limit. Amount of fixes.
This commit is contained in:
parent
f0f9eecf97
commit
19096f39f0
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,17 +5878,12 @@ 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);
|
||||
}
|
||||
|
||||
//take MPs
|
||||
SetMovePoints smp;
|
||||
@ -5900,13 +5895,11 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
iw.type = EInfoWindowMode::AUTO;
|
||||
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
|
||||
giveHeroNewArtifact(h, VLC->arth->objects[ArtifactID::GRAIL], ArtifactPosition::PRE_FIRST); //give grail
|
||||
sendAndApply(&iw);
|
||||
|
||||
iw.soundID = soundBase::invalid;
|
||||
@ -5916,12 +5909,6 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
||||
sendAndApply(&iw);
|
||||
}
|
||||
else
|
||||
{
|
||||
iw.text << "found but no free slots";
|
||||
sendAndApply(&iw);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iw.text.addTxt(MetaString::GENERAL_TXT, 59); //"Nothing here. \n Where could it be?"
|
||||
iw.soundID = soundBase::Dig;
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user