mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Creature weeks now work fine. Castle interface still needs to be updated.
This commit is contained in:
parent
630dc7f7f2
commit
ea966a3d21
@ -137,9 +137,9 @@ void CCreature::addBonus(int val, int type, int subtype /*= -1*/)
|
||||
Bonus added(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
|
||||
bonuses.push_back(added);
|
||||
}
|
||||
void CCreature::getParents(TNodes &out, const CBonusSystemNode *root /*= NULL*/) const
|
||||
void CCreature::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const
|
||||
{
|
||||
out.insert(VLC->creh->globalEffects);
|
||||
out.insert (VLC->creh->globalEffects);
|
||||
}
|
||||
bool CCreature::isMyUpgrade(const CCreature *anotherCre) const
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
ui32 getMaxDamage() const;
|
||||
|
||||
void addBonus(int val, int type, int subtype = -1);
|
||||
void getParents(TNodes &out, const CBonusSystemNode *root /*= NULL*/) const;
|
||||
void getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL*/) const;
|
||||
|
||||
template<typename RanGen>
|
||||
int getRandomAmount(RanGen &ranGen)
|
||||
|
@ -4201,8 +4201,8 @@ void PlayerState::getParents(TCNodes &out, const CBonusSystemNode *root /*= NULL
|
||||
}
|
||||
|
||||
void PlayerState::getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root /*= NULL*/) const
|
||||
{//temporary
|
||||
//CBonusSystemNode::getBonuses(out, selector, root);
|
||||
{
|
||||
CBonusSystemNode::getBonuses(out, selector, root);
|
||||
}
|
||||
|
||||
InfoAboutHero::InfoAboutHero()
|
||||
|
@ -63,55 +63,6 @@ int DLL_EXPORT BonusList::totalValue() const
|
||||
else
|
||||
return valFirst;
|
||||
}
|
||||
|
||||
int DLL_EXPORT BonusList::valPercent(Bonus::BonusType type, const CSelector &selector, int val) const
|
||||
{
|
||||
int base = val;
|
||||
int percentToBase = 0;
|
||||
int percentToAll = 0;
|
||||
int additive = 0;
|
||||
int indepMax = 0;
|
||||
bool hasIndepMax = false;
|
||||
|
||||
for(const_iterator i = begin(); i != end(); i++)
|
||||
{
|
||||
switch(i->valType)
|
||||
{
|
||||
case Bonus::BASE_NUMBER:
|
||||
base += i->val;
|
||||
break;
|
||||
case Bonus::PERCENT_TO_ALL:
|
||||
percentToAll += i->val;
|
||||
break;
|
||||
case Bonus::PERCENT_TO_BASE:
|
||||
percentToBase += i->val;
|
||||
break;
|
||||
case Bonus::ADDITIVE_VALUE:
|
||||
additive += i->val;
|
||||
break;
|
||||
case Bonus::INDEPENDENT_MAX:
|
||||
if (!indepMax)
|
||||
{
|
||||
indepMax = i->val;
|
||||
hasIndepMax = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
amax(indepMax, i->val);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
int modifiedBase = base + (base * percentToBase) / 100;
|
||||
modifiedBase += additive;
|
||||
int valFirst = (modifiedBase * (100 + percentToAll)) / 100;
|
||||
if (hasIndepMax)
|
||||
return std::max(valFirst, indepMax);
|
||||
else
|
||||
return valFirst;
|
||||
}
|
||||
|
||||
const DLL_EXPORT Bonus * BonusList::getFirst(const CSelector &selector) const
|
||||
{
|
||||
for (const_iterator i = begin(); i != end(); i++)
|
||||
@ -170,6 +121,10 @@ limit_start:
|
||||
}
|
||||
}
|
||||
|
||||
int CBonusSystemNode::valOfBonuses(Bonus::BonusType type, const CSelector &selector) const
|
||||
{
|
||||
return valOfBonuses(Selector::type(type) && selector);
|
||||
}
|
||||
int CBonusSystemNode::valOfBonuses(Bonus::BonusType type, int subtype /*= -1*/) const
|
||||
{
|
||||
CSelector s = Selector::type(type);
|
||||
@ -178,19 +133,12 @@ int CBonusSystemNode::valOfBonuses(Bonus::BonusType type, int subtype /*= -1*/)
|
||||
|
||||
return valOfBonuses(s);
|
||||
}
|
||||
|
||||
int CBonusSystemNode::valOfBonuses(Bonus::BonusType type, const CSelector &selector) const
|
||||
{
|
||||
return valOfBonuses(Selector::type(type) && selector);
|
||||
}
|
||||
|
||||
int CBonusSystemNode::valOfBonuses(const CSelector &selector, const CBonusSystemNode *root/* = NULL*/) const
|
||||
{
|
||||
BonusList hlp;
|
||||
getBonuses(hlp, selector, root);
|
||||
return hlp.totalValue();
|
||||
}
|
||||
|
||||
bool CBonusSystemNode::hasBonus(const CSelector &selector, const CBonusSystemNode *root/* = NULL*/) const
|
||||
{
|
||||
return getBonuses(selector).size() > 0;
|
||||
@ -545,7 +493,7 @@ bool CCreatureTypeLimiter::limit(const Bonus &b, const CBonusSystemNode &node) c
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
return false; //don't delete it if it's other type of node
|
||||
}
|
||||
}
|
||||
CCreatureTypeLimiter::CCreatureTypeLimiter(const CCreature &Creature, ui8 IncludeUpgrades /*= true*/)
|
||||
|
@ -299,7 +299,6 @@ class BonusList : public std::list<Bonus>
|
||||
{
|
||||
public:
|
||||
int DLL_EXPORT totalValue() const; //subtype -> subtype of bonus, if -1 then any
|
||||
int DLL_EXPORT valPercent(Bonus::BonusType type, const CSelector &selector, int val) const;
|
||||
void DLL_EXPORT getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *source = NULL) const;
|
||||
void DLL_EXPORT getBonuses(BonusList &out, const CSelector &selector, const CSelector &limit, const CBonusSystemNode *source = NULL) const;
|
||||
void DLL_EXPORT getModifiersWDescr(TModDescr &out) const;
|
||||
@ -355,7 +354,7 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//legacy interface
|
||||
int valOfBonuses(Bonus::BonusType type, const CSelector &selector) const;
|
||||
int valOfBonuses(Bonus::BonusType type, int subtype = -1) const; //subtype -> subtype of bonus, if -1 then any
|
||||
int valOfBonuses(Bonus::BonusType type, int subtype = -1) const; //subtype -> subtype of bonus, if -1 then anyt;
|
||||
bool hasBonusOfType(Bonus::BonusType type, int subtype = -1) const;//determines if hero has a bonus of given type (and optionally subtype)
|
||||
bool hasBonusFrom(ui8 source, ui32 sourceID) const;
|
||||
void getModifiersWDescr( TModDescr &out, Bonus::BonusType type, int subtype = -1 ) const; //out: pairs<modifier value, modifier description>
|
||||
|
@ -649,7 +649,7 @@ DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
||||
b.val = 100;
|
||||
b.type = Bonus::CREATURE_GROWTH_PERCENT;
|
||||
b.limiter = new CCreatureTypeLimiter(*VLC->creh->creatures[creatureid], false);
|
||||
b.valType = Bonus::PERCENT_TO_ALL;
|
||||
b.valType = Bonus::BASE_NUMBER; //certainly not intuitive
|
||||
break;
|
||||
case BONUS_GROWTH:
|
||||
b.val = 5;
|
||||
@ -660,7 +660,7 @@ DLL_EXPORT void NewTurn::applyGs( CGameState *gs )
|
||||
case PLAGUE:
|
||||
b.val = -50;
|
||||
b.type = Bonus::CREATURE_GROWTH_PERCENT;
|
||||
b.valType = Bonus::PERCENT_TO_ALL;
|
||||
b.valType = Bonus::BASE_NUMBER;
|
||||
break;
|
||||
default:
|
||||
b.val = 0;
|
||||
|
@ -1013,7 +1013,7 @@ void CGameHandler::newTurn()
|
||||
if(getDate(4) == 28) //new month
|
||||
{
|
||||
newmonth = true;
|
||||
if (monthType < 100) //double growth
|
||||
if (monthType < 60) //double growth
|
||||
{
|
||||
//spawn wandering monsters
|
||||
n.specialWeek = NewTurn::DOUBLE_GROWTH;
|
||||
|
Loading…
Reference in New Issue
Block a user