mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Allow merging stack on recruitment to give place for recruited unit
This commit is contained in:
@@ -161,6 +161,15 @@ void CRecruitmentWindow::buy()
|
|||||||
SlotID dstslot = dst->getSlotFor(crid);
|
SlotID dstslot = dst->getSlotFor(crid);
|
||||||
|
|
||||||
if(!dstslot.validSlot() && (selected->creature->warMachine == ArtifactID::NONE)) //no available slot
|
if(!dstslot.validSlot() && (selected->creature->warMachine == ArtifactID::NONE)) //no available slot
|
||||||
|
{
|
||||||
|
std::pair<SlotID, SlotID> toMerge;
|
||||||
|
bool allowMerge = CGI->settings()->getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED);
|
||||||
|
|
||||||
|
if (allowMerge && dst->mergableStacks(toMerge))
|
||||||
|
{
|
||||||
|
LOCPLINT->cb->mergeStacks( dst, dst, toMerge.first, toMerge.second);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::string txt;
|
std::string txt;
|
||||||
if(dst->ID == Obj::HERO)
|
if(dst->ID == Obj::HERO)
|
||||||
@@ -176,6 +185,7 @@ void CRecruitmentWindow::buy()
|
|||||||
LOCPLINT->showInfoDialog(txt);
|
LOCPLINT->showInfoDialog(txt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onRecruit(crid, slider->getValue());
|
onRecruit(crid, slider->getValue());
|
||||||
if(level >= 0)
|
if(level >= 0)
|
||||||
|
@@ -311,6 +311,8 @@
|
|||||||
"accumulateWhenNeutral" : false,
|
"accumulateWhenNeutral" : false,
|
||||||
// if enabled, dwellings owned by players will accumulate creatures
|
// if enabled, dwellings owned by players will accumulate creatures
|
||||||
"accumulateWhenOwned" : false
|
"accumulateWhenOwned" : false
|
||||||
|
// if enabled, game will attempt to merge slots in army on recruit if all slots in hero army are in use
|
||||||
|
"mergeOnRecruit" : true
|
||||||
},
|
},
|
||||||
|
|
||||||
"markets" :
|
"markets" :
|
||||||
|
@@ -68,6 +68,7 @@ void GameSettings::load(const JsonNode & input)
|
|||||||
{EGameSettings::CREATURES_WEEKLY_GROWTH_PERCENT, "creatures", "weeklyGrowthPercent" },
|
{EGameSettings::CREATURES_WEEKLY_GROWTH_PERCENT, "creatures", "weeklyGrowthPercent" },
|
||||||
{EGameSettings::DWELLINGS_ACCUMULATE_WHEN_NEUTRAL, "dwellings", "accumulateWhenNeutral" },
|
{EGameSettings::DWELLINGS_ACCUMULATE_WHEN_NEUTRAL, "dwellings", "accumulateWhenNeutral" },
|
||||||
{EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED, "dwellings", "accumulateWhenOwned" },
|
{EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED, "dwellings", "accumulateWhenOwned" },
|
||||||
|
{EGameSettings::DWELLINGS_MERGE_ON_RECRUIT, "dwellings", "mergeOnRecruit" },
|
||||||
{EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP, "heroes", "perPlayerOnMapCap" },
|
{EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP, "heroes", "perPlayerOnMapCap" },
|
||||||
{EGameSettings::HEROES_PER_PLAYER_TOTAL_CAP, "heroes", "perPlayerTotalCap" },
|
{EGameSettings::HEROES_PER_PLAYER_TOTAL_CAP, "heroes", "perPlayerTotalCap" },
|
||||||
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
|
{EGameSettings::HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS, "heroes", "retreatOnWinWithoutTroops" },
|
||||||
|
@@ -32,6 +32,7 @@ enum class EGameSettings
|
|||||||
CREATURES_WEEKLY_GROWTH_PERCENT,
|
CREATURES_WEEKLY_GROWTH_PERCENT,
|
||||||
DWELLINGS_ACCUMULATE_WHEN_NEUTRAL,
|
DWELLINGS_ACCUMULATE_WHEN_NEUTRAL,
|
||||||
DWELLINGS_ACCUMULATE_WHEN_OWNED,
|
DWELLINGS_ACCUMULATE_WHEN_OWNED,
|
||||||
|
DWELLINGS_MERGE_ON_RECRUIT,
|
||||||
HEROES_PER_PLAYER_ON_MAP_CAP,
|
HEROES_PER_PLAYER_ON_MAP_CAP,
|
||||||
HEROES_PER_PLAYER_TOTAL_CAP,
|
HEROES_PER_PLAYER_TOTAL_CAP,
|
||||||
HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS,
|
HEROES_RETREAT_ON_WIN_WITHOUT_TROOPS,
|
||||||
|
@@ -324,6 +324,21 @@ void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h) const
|
|||||||
{
|
{
|
||||||
if(count) //there are available creatures
|
if(count) //there are available creatures
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (VLC->settings()->getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_OWNED))
|
||||||
|
{
|
||||||
|
SlotID testSlot = h->getSlotFor(crid);
|
||||||
|
if(!testSlot.validSlot()) //no available slot - try merging army of visiting hero
|
||||||
|
{
|
||||||
|
std::pair<SlotID, SlotID> toMerge;
|
||||||
|
if (h->mergableStacks(toMerge))
|
||||||
|
{
|
||||||
|
cb->moveStack(StackLocation(h, toMerge.first), StackLocation(h, toMerge.second), -1); //merge toMerge.first into toMerge.second
|
||||||
|
assert(!h->hasStackAtSlot(toMerge.first)); //we have now a new free slot
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SlotID slot = h->getSlotFor(crid);
|
SlotID slot = h->getSlotFor(crid);
|
||||||
if(!slot.validSlot()) //no available slot
|
if(!slot.validSlot()) //no available slot
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user