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:
|
case EDiggingStatus::WRONG_TERRAIN:
|
||||||
msgToShow = 60; ////Try looking on land!
|
msgToShow = 60; ////Try looking on land!
|
||||||
break;
|
break;
|
||||||
|
case EDiggingStatus::BACKPACK_IS_FULL:
|
||||||
|
msgToShow = 247; //Searching for the Grail is fruitless...
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
|
|||||||
}
|
}
|
||||||
else
|
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());
|
ArtifactPosition freeSlot = ArtifactUtils::getArtBackpackPosition(commanderOwner, ourArt->getTypeId());
|
||||||
if(freeSlot == ArtifactPosition::PRE_FIRST)
|
if(freeSlot == ArtifactPosition::PRE_FIRST)
|
||||||
{
|
{
|
||||||
LOCPLINT->showInfoDialog("no free slots");
|
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.152"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -806,7 +806,7 @@ void CMarketplaceWindow::makeDeal()
|
|||||||
if(!sliderValue)
|
if(!sliderValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
madeTransaction = true;
|
bool allowDeal = true;
|
||||||
int leftIdToSend = hLeft->id;
|
int leftIdToSend = hLeft->id;
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
@ -819,15 +819,15 @@ void CMarketplaceWindow::makeDeal()
|
|||||||
case EMarketMode::RESOURCE_ARTIFACT:
|
case EMarketMode::RESOURCE_ARTIFACT:
|
||||||
if(!ArtifactID(hRight->id).toArtifact()->canBePutAt(hero))
|
if(!ArtifactID(hRight->id).toArtifact()->canBePutAt(hero))
|
||||||
{
|
{
|
||||||
LOCPLINT->showInfoDialog("no available slots");
|
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.326"));
|
||||||
madeTransaction = false;
|
allowDeal = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(madeTransaction)
|
if(allowDeal)
|
||||||
{
|
{
|
||||||
if(slider)
|
if(slider)
|
||||||
{
|
{
|
||||||
@ -839,6 +839,8 @@ void CMarketplaceWindow::makeDeal()
|
|||||||
LOCPLINT->cb->trade(market->o, mode, leftIdToSend, hRight->id, r2, hero);
|
LOCPLINT->cb->trade(market->o, mode, leftIdToSend, hRight->id, r2, hero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
madeTransaction = true;
|
||||||
hLeft = nullptr;
|
hLeft = nullptr;
|
||||||
hRight = nullptr;
|
hRight = nullptr;
|
||||||
selectionChanged(true);
|
selectionChanged(true);
|
||||||
|
@ -967,7 +967,8 @@ public:
|
|||||||
CAN_DIG = 0,
|
CAN_DIG = 0,
|
||||||
LACK_OF_MOVEMENT,
|
LACK_OF_MOVEMENT,
|
||||||
WRONG_TERRAIN,
|
WRONG_TERRAIN,
|
||||||
TILE_OCCUPIED
|
TILE_OCCUPIED,
|
||||||
|
BACKPACK_IS_FULL
|
||||||
};
|
};
|
||||||
|
|
||||||
EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)
|
EDiggingStatus(EEDiggingStatus _num = UNKNOWN) : num(_num)
|
||||||
|
@ -1124,7 +1124,8 @@ EDiggingStatus CGHeroInstance::diggingStatus() const
|
|||||||
{
|
{
|
||||||
if(static_cast<int>(movement) < maxMovePoints(true))
|
if(static_cast<int>(movement) < maxMovePoints(true))
|
||||||
return EDiggingStatus::LACK_OF_MOVEMENT;
|
return EDiggingStatus::LACK_OF_MOVEMENT;
|
||||||
|
if(!VLC->arth->objects[ArtifactID::GRAIL]->canBePutAt(this))
|
||||||
|
return EDiggingStatus::BACKPACK_IS_FULL;
|
||||||
return cb->getTileDigStatus(visitablePos());
|
return cb->getTileDigStatus(visitablePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,7 +1331,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iw.text << "no slots";
|
iw.text.addTxt(MetaString::ADVOB_TXT, 2);
|
||||||
}
|
}
|
||||||
cb->showInfoDialog(&iw);
|
cb->showInfoDialog(&iw);
|
||||||
pick(h);
|
pick(h);
|
||||||
|
@ -758,7 +758,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
|
|||||||
{
|
{
|
||||||
auto sendMoveArtifact = [&](const CArtifactInstance *art, MoveArtifact *ma)
|
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)
|
if(slot != ArtifactPosition::PRE_FIRST)
|
||||||
{
|
{
|
||||||
arts.push_back(art);
|
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
|
if (h->diggingStatus() != EDiggingStatus::CAN_DIG) //checks for terrain and movement
|
||||||
COMPLAIN_RETF("Hero cannot dig (error code %d)!", h->diggingStatus());
|
COMPLAIN_RETF("Hero cannot dig (error code %d)!", h->diggingStatus());
|
||||||
|
|
||||||
const auto isHeroAbleGet = VLC->arth->objects[ArtifactID::GRAIL]->canBePutAt(h);
|
//create a hole
|
||||||
|
NewObject no;
|
||||||
if(isHeroAbleGet)
|
no.ID = Obj::HOLE;
|
||||||
{
|
no.pos = h->visitablePos();
|
||||||
//create a hole
|
no.subID = 0;
|
||||||
NewObject no;
|
sendAndApply(&no);
|
||||||
no.ID = Obj::HOLE;
|
|
||||||
no.pos = h->visitablePos();
|
|
||||||
no.subID = 0;
|
|
||||||
sendAndApply(&no);
|
|
||||||
}
|
|
||||||
|
|
||||||
//take MPs
|
//take MPs
|
||||||
SetMovePoints smp;
|
SetMovePoints smp;
|
||||||
smp.hid = h->id;
|
smp.hid = h->id;
|
||||||
@ -5901,25 +5896,17 @@ bool CGameHandler::dig(const CGHeroInstance *h)
|
|||||||
iw.player = h->tempOwner;
|
iw.player = h->tempOwner;
|
||||||
if (gs->map->grailPos == h->visitablePos())
|
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.text.addTxt(MetaString::GENERAL_TXT, 58); //"Congratulations! After spending many hours digging here, your hero has uncovered the "
|
iw.soundID = soundBase::ULTIMATEARTIFACT;
|
||||||
iw.text.addTxt(MetaString::ART_NAMES, ArtifactID::GRAIL);
|
giveHeroNewArtifact(h, VLC->arth->objects[ArtifactID::GRAIL], ArtifactPosition::PRE_FIRST); //give grail
|
||||||
iw.soundID = soundBase::ULTIMATEARTIFACT;
|
sendAndApply(&iw);
|
||||||
giveHeroNewArtifact(h, VLC->arth->objects[ArtifactID::GRAIL], ArtifactPosition::FIRST_AVAILABLE); //give grail
|
|
||||||
sendAndApply(&iw);
|
|
||||||
|
|
||||||
iw.soundID = soundBase::invalid;
|
iw.soundID = soundBase::invalid;
|
||||||
iw.components.emplace_back(Component::EComponentType::ARTIFACT, ArtifactID::GRAIL, 0, 0);
|
iw.components.emplace_back(Component::EComponentType::ARTIFACT, ArtifactID::GRAIL, 0, 0);
|
||||||
iw.text.clear();
|
iw.text.clear();
|
||||||
iw.text.addTxt(MetaString::ART_DESCR, ArtifactID::GRAIL);
|
iw.text.addTxt(MetaString::ART_DESCR, ArtifactID::GRAIL);
|
||||||
sendAndApply(&iw);
|
sendAndApply(&iw);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iw.text << "found but no free slots";
|
|
||||||
sendAndApply(&iw);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -6870,7 +6857,7 @@ void CGameHandler::putArtifact(const ArtifactLocation &al, const CArtifactInstan
|
|||||||
bool CGameHandler::giveHeroNewArtifact(const CGHeroInstance * h, const CArtifact * artType, ArtifactPosition pos)
|
bool CGameHandler::giveHeroNewArtifact(const CGHeroInstance * h, const CArtifact * artType, ArtifactPosition pos)
|
||||||
{
|
{
|
||||||
assert(artType);
|
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!");
|
COMPLAIN_RET_FALSE_IF(!artType->canBePutAt(h, pos, false), "Cannot put artifact in that slot!");
|
||||||
|
|
||||||
CArtifactInstance * newArtInst = nullptr;
|
CArtifactInstance * newArtInst = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user