Skip to content

Commit

Permalink
fix gold carryover
Browse files Browse the repository at this point in the history
we need side["income"] + game_config::base_income instead of just
side["income"]
  • Loading branch information
gfgtdf committed Jun 21, 2014
1 parent f8a4347 commit ff11e85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/carryover.cpp
Expand Up @@ -131,8 +131,9 @@ const std::string carryover::to_string(){
return side;
}

void carryover::set_gold(int gold){
void carryover::set_gold(int gold, bool add){
gold_ = gold;
add_ = add;
}

void carryover::to_config(config& cfg){
Expand Down Expand Up @@ -171,11 +172,12 @@ carryover_info::carryover_info(const config& cfg, bool from_snpashot)
if(from_snpashot)
{
//adjust gold
int finishing_bonus_per_turn = cfg["map_villages_num"] * side["village_gold"] + side["income"];
//base_income is side["income"] + game_config::base_income;
int finishing_bonus_per_turn = cfg["map_villages_num"] * side["village_gold"] + side["income"] + game_config::base_income;
int finishing_bonus = std::max(0, finishing_bonus_per_turn * turns_left);
if(end_level_.gold_bonus)
{
carryover_sides_.back().set_gold(div100rounded((finishing_bonus + side["gold"]) * end_level_.carryover_percentage));
carryover_sides_.back().set_gold(div100rounded((finishing_bonus + side["gold"]) * end_level_.carryover_percentage), end_level_.carryover_add);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/carryover.hpp
Expand Up @@ -38,7 +38,9 @@ class carryover{
void initialize_team(config& side_cfg);
const std::string to_string();
void to_config(config& cfg);
void set_gold(int gold);
/// @param gold sets the gold of the team, always overwrites current gold.
/// @param add whether the gold should be added to the next scenario gold.
void set_gold(int gold, bool add);
private:
bool add_;
std::string color_;
Expand Down

0 comments on commit ff11e85

Please sign in to comment.