Skip to content

Commit

Permalink
Merge pull request #182 from vmarkovtsev/issue/1916
Browse files Browse the repository at this point in the history
Fix 1916 water wheel reward
  • Loading branch information
DjWarmonger authored and DjWarmonger committed Jan 30, 2016
2 parents b0d9b8b + eb4331b commit ab27464
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/mapObjects/CRewardableObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void CRewardableObject::setPropertyDer(ui8 what, ui32 val)

void CRewardableObject::newTurn() const
{
if (resetDuration != 0 && cb->getDate(Date::DAY) > 1 && cb->getDate(Date::DAY) % (resetDuration) == 1)
if (resetDuration != 0 && cb->getDate(Date::DAY) > 1 && (cb->getDate(Date::DAY) % resetDuration) == 1)
cb->setObjProperty(id, ObjProperty::REWARD_RESET, 0);
}

Expand Down Expand Up @@ -1003,16 +1003,30 @@ void CGVisitableOPW::initObj()
soundID = soundBase::GENIE;
onEmpty.addTxt(MetaString::ADVOB_TXT, 165);

info.resize(2);
info[0].limiter.dayOfWeek = 7; // double amount on sunday
info[0].reward.resources[Res::GOLD] = 1000;
info[1].reward.resources[Res::GOLD] = 500;
info.resize(1);
info[0].reward.resources[Res::GOLD] = 500;
info[0].message.addTxt(MetaString::ADVOB_TXT, 164);
info[1].message.addTxt(MetaString::ADVOB_TXT, 164);
break;
}
}

void CGVisitableOPW::setPropertyDer(ui8 what, ui32 val)
{
if(ID == Obj::WATER_WHEEL && what == ObjProperty::REWARD_RESET)
{
auto& reward = info[0].reward.resources[Res::GOLD];
if(info[0].numOfGrants == 0)
{
reward = 1000;
}
else
{
reward = 500;
}
}
CRewardableObject::setPropertyDer(what, val);
}

///////////////////////////////////////////////////////////////////////////////////////////////////

void CGMagicSpring::initObj()
Expand Down
2 changes: 2 additions & 0 deletions lib/mapObjects/CRewardableObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ class DLL_LINKAGE CGVisitableOPW : public CRewardableObject //objects visitable

CGVisitableOPW();

void setPropertyDer(ui8 what, ui32 val) override;

template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CRewardableObject&>(*this);
Expand Down

0 comments on commit ab27464

Please sign in to comment.