forked from townforge/townforge
Give small boost in hunting for players with a military building
This commit is contained in:
parent
2b2a42728b
commit
3f8b45895f
@ -29,11 +29,22 @@ TBLayout: axis: y, distribution-position: "left top", distribution: "gravity"
|
||||
TBTextField: text: "military buildings in the city, giving you"
|
||||
TBLayout: axis: x, distribution-position: "left"
|
||||
TBTextField: text: "an extra"
|
||||
TBTextField: id: "bonus", text: "00"
|
||||
TBTextField: text: "% bonus in bear hunting"
|
||||
TBTextField: id: "bonus-bear-attack", text: "00"
|
||||
TBTextField: text: "% bonus in repelling bear attacks"
|
||||
TBSeparator
|
||||
TBSeparator
|
||||
|
||||
TBToggleContainer: id: "military-container", toggle: "expanded"
|
||||
TBLayout: axis: y, position: "left"
|
||||
TBLayout: axis: x, distribution-position: "left"
|
||||
TBTextField: text: "You have at least one military building in the city,"
|
||||
TBLayout: axis: x, distribution-position: "left"
|
||||
TBTextField: text: "giving you an extra "
|
||||
TBTextField: id: "bonus-no-bear-attack", text: "00"
|
||||
TBTextField: text: "% wilderness hunt bonus"
|
||||
TBSeparator
|
||||
TBSeparator
|
||||
|
||||
TBLayout: axis: x, distribution-position: "left"
|
||||
TBTextField: text: "A hunt will need"
|
||||
TBTextField: id: "labour": text: "00000"
|
||||
|
@ -251,7 +251,8 @@ the more meat a hunt will yield, but the lower the population, the more time it
|
||||
it to grow back. Moose popoulation is larger, and thus moose hunts yied more meat, but if
|
||||
the moose population goes too low to support the bear population, hungry bears will start
|
||||
venturing into town in search of food, causing damage and eating what they can find.
|
||||
Players with military buildings in a town overrun by bears have a bonus in bear hunting.
|
||||
Players with military buildings have a large bonus when hunting bears attacking a town,
|
||||
and a small one for hunting otherwise.
|
||||
|
||||
<h3> Influence </h3>
|
||||
|
||||
|
@ -85,7 +85,9 @@ bool cc_command_handler_hunt::execute(cryptonote::BlockchainDB &db, const crypto
|
||||
if (fd.role == ROLE_MILITARY)
|
||||
++n_mil;
|
||||
}
|
||||
const uint32_t bonus = cc::get_bonus_from_military_buildings(n_mil);
|
||||
special_event_data_t special_event_data;
|
||||
bool is_bear_attack = cc::get_active_special_event(db, hunt.city, special_event_data) && special_event_data.special_event == cc::SPECIAL_EVENT_BEAR_ATTACK;
|
||||
const uint32_t bonus = cc::get_hunt_bonus_from_military_buildings(n_mil, !is_moose && is_bear_attack);
|
||||
ad.item_balances[ITEM_LABOUR] -= HUNT_LABOUR_COST;
|
||||
CHECK_AND_ASSERT_MES(db.get_cc_city_data(hunt.city, cd), false, "Failed to get city data");
|
||||
uint32_t &population = hunt.target == cryptonote::cc_command_hunt_t::hunt_target_moose ? cd.moose : cd.bears;
|
||||
@ -132,7 +134,6 @@ bool cc_command_handler_hunt::revert(cryptonote::BlockchainDB &db, const crypton
|
||||
if (fd.role == ROLE_MILITARY)
|
||||
++n_mil;
|
||||
}
|
||||
const uint32_t bonus = cc::get_bonus_from_military_buildings(n_mil);
|
||||
ad.item_balances[ITEM_LABOUR] += HUNT_LABOUR_COST;
|
||||
CHECK_AND_ASSERT_MES(db.get_cc_city_data(hunt.city, cd), false, "Failed to get city data");
|
||||
uint32_t &population = hunt.target == cryptonote::cc_command_hunt_t::hunt_target_moose ? cd.moose : cd.bears;
|
||||
|
@ -34,9 +34,12 @@ static uint32_t get_hunt_random_number(const crypto::hash &block_hash, uint8_t t
|
||||
namespace cc
|
||||
{
|
||||
|
||||
uint32_t get_bonus_from_military_buildings(uint32_t buildings)
|
||||
uint32_t get_hunt_bonus_from_military_buildings(uint32_t buildings, bool bear_attack)
|
||||
{
|
||||
return std::min<uint32_t>(20, buildings * 3);
|
||||
if (bear_attack)
|
||||
return std::min<uint32_t>(200, buildings * 25);
|
||||
else
|
||||
return buildings > 0 ? 10 : 0;
|
||||
}
|
||||
|
||||
void get_hunt_population_ceiling(const cryptonote::BlockchainDB &db, uint32_t city, uint32_t &moose, uint32_t &bears)
|
||||
|
@ -11,7 +11,7 @@ namespace cryptonote
|
||||
namespace cc
|
||||
{
|
||||
|
||||
uint32_t get_bonus_from_military_buildings(uint32_t buildings);
|
||||
uint32_t get_hunt_bonus_from_military_buildings(uint32_t buildings, bool bear_attack);
|
||||
void get_hunt_population_ceiling(const cryptonote::BlockchainDB &db, uint32_t city, uint32_t &moose, uint32_t &bears);
|
||||
void update_hunt_population(const cryptonote::BlockchainDB &db, uint32_t city, int32_t &dmoose, int32_t &dbears);
|
||||
uint32_t get_moose_hunt_kills_raw(const crypto::hash &top_hash, uint32_t city, uint32_t moose, uint64_t nonce);
|
||||
|
@ -23,8 +23,10 @@ UIHuntDialog::UIHuntDialog(Context *ctx, const GameState *game):
|
||||
cityWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("city"));
|
||||
labourWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("labour"));
|
||||
bearAttackContainer = GetWidgetByIDAndType<TBToggleContainer>(TBIDC("bear-attack-container"));
|
||||
militaryContainer = GetWidgetByIDAndType<TBToggleContainer>(TBIDC("military-container"));
|
||||
militaryWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("military"));
|
||||
bonusWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("bonus"));
|
||||
bonusBearAttackWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("bonus-bear-attack"));
|
||||
bonusNoBearAttackWidget = GetWidgetByIDAndType<TBTextField>(TBIDC("bonus-no-bear-attack"));
|
||||
|
||||
SubscribeToEvent(this, E_TB_WIDGET_EVENT, URHO3D_HANDLER(UIHuntDialog, HandleTBMessage));
|
||||
SubscribeToEvent(this, E_TB_WINDOW_CLOSED, URHO3D_HANDLER(UIHuntDialog, HandleClose));
|
||||
@ -48,9 +50,11 @@ void UIHuntDialog::UpdateData(const std::shared_ptr<GameWallet> &w)
|
||||
if (flag && flag->role == ROLE_MILITARY)
|
||||
++n_mil;
|
||||
}
|
||||
const uint32_t bonus = cc::get_bonus_from_military_buildings(n_mil);
|
||||
militaryContainer->SetValue(n_mil > 0);
|
||||
const uint32_t bonus = cc::get_hunt_bonus_from_military_buildings(n_mil, game->cityState.special_event == cc::SPECIAL_EVENT_BEAR_ATTACK);
|
||||
militaryWidget->SetText(String(n_mil).CString());
|
||||
bonusWidget->SetText(String(bonus).CString());
|
||||
bonusBearAttackWidget->SetText(String(bonus).CString());
|
||||
bonusNoBearAttackWidget->SetText(String(bonus).CString());
|
||||
}
|
||||
|
||||
void UIHuntDialog::Update(const std::shared_ptr<GameWallet> &w)
|
||||
|
@ -49,8 +49,10 @@ private:
|
||||
tb::TBTextField *cityWidget;
|
||||
tb::TBTextField *labourWidget;
|
||||
tb::TBToggleContainer *bearAttackContainer;
|
||||
tb::TBToggleContainer *militaryContainer;
|
||||
tb::TBTextField *militaryWidget;
|
||||
tb::TBTextField *bonusWidget;
|
||||
tb::TBTextField *bonusBearAttackWidget;
|
||||
tb::TBTextField *bonusNoBearAttackWidget;
|
||||
bool refresh;
|
||||
std::string last_refresh_stop_hash;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user