Fix a bug.
This commit is contained in:
parent
dc72d7b67e
commit
301e0d5d43
2 changed files with 14 additions and 9 deletions
|
@ -105,7 +105,7 @@
|
||||||
engine=cpp
|
engine=cpp
|
||||||
name=standard_aspect
|
name=standard_aspect
|
||||||
[value]
|
[value]
|
||||||
active=yes
|
active=2
|
||||||
begin=1.0
|
begin=1.0
|
||||||
end=0.7
|
end=0.7
|
||||||
spend_all_gold=-1
|
spend_all_gold=-1
|
||||||
|
|
|
@ -198,7 +198,7 @@ double recruitment::evaluate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void recruitment::execute() {
|
void recruitment::execute() {
|
||||||
LOG_AI_RECRUITMENT << "\n\n\n------------FLIX RECRUITMENT BEGIN ------------\n\n";
|
LOG_AI_RECRUITMENT << "\n\n\n------------AI RECRUITMENT BEGIN---------------\n\n";
|
||||||
LOG_AI_RECRUITMENT << "TURN: " << resources::tod_manager->turn() <<
|
LOG_AI_RECRUITMENT << "TURN: " << resources::tod_manager->turn() <<
|
||||||
" SIDE: " << current_team().side() << "\n";
|
" SIDE: " << current_team().side() << "\n";
|
||||||
|
|
||||||
|
@ -338,14 +338,16 @@ void recruitment::execute() {
|
||||||
config* job = NULL;
|
config* job = NULL;
|
||||||
do { // Recruitment loop
|
do { // Recruitment loop
|
||||||
recruit_situation_change_observer_.reset_gamestate_changed();
|
recruit_situation_change_observer_.reset_gamestate_changed();
|
||||||
|
|
||||||
|
// Check if we may want to save gold by not recruiting.
|
||||||
update_state();
|
update_state();
|
||||||
|
int save_gold_turn = get_recruitment_save_gold()["active"].to_int(2); // From aspect.
|
||||||
// Retrieve from aspect.
|
int current_turn = resources::tod_manager->turn();
|
||||||
bool save_gold_active = get_recruitment_save_gold()["active"].to_bool(true);
|
bool save_gold_active = save_gold_turn > 0 && save_gold_turn <= current_turn;
|
||||||
|
|
||||||
if (state_ == SAVE_GOLD && save_gold_active) {
|
if (state_ == SAVE_GOLD && save_gold_active) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
job = get_most_important_job();
|
job = get_most_important_job();
|
||||||
if (!job) {
|
if (!job) {
|
||||||
LOG_AI_RECRUITMENT << "All recruitment jobs (recruitment_instructions) done.\n";
|
LOG_AI_RECRUITMENT << "All recruitment jobs (recruitment_instructions) done.\n";
|
||||||
|
@ -391,7 +393,7 @@ void recruitment::execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the current job.
|
// Update the current job.
|
||||||
if (!job->operator[]("total").to_bool()) {
|
if (!job->operator[]("total").to_bool(false)) {
|
||||||
job->operator[]("number") = job->operator[]("number").to_int(99999) - 1;
|
job->operator[]("number") = job->operator[]("number").to_int(99999) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1467,8 +1469,8 @@ double recruitment::get_estimated_village_gain() const {
|
||||||
*/
|
*/
|
||||||
double recruitment::get_unit_ratio() const {
|
double recruitment::get_unit_ratio() const {
|
||||||
const unit_map& units = *resources::units;
|
const unit_map& units = *resources::units;
|
||||||
double own_total_value;
|
double own_total_value = 0.;
|
||||||
double enemy_total_value;
|
double enemy_total_value = 0.;
|
||||||
BOOST_FOREACH(const unit& unit, units) {
|
BOOST_FOREACH(const unit& unit, units) {
|
||||||
if (unit.incapacitated() || unit.total_movement() <= 0) {
|
if (unit.incapacitated() || unit.total_movement() <= 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1480,6 +1482,9 @@ double recruitment::get_unit_ratio() const {
|
||||||
own_total_value += value;
|
own_total_value += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (enemy_total_value == 0) {
|
||||||
|
return 999.; // Should never happen
|
||||||
|
}
|
||||||
return own_total_value / enemy_total_value;
|
return own_total_value / enemy_total_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue