Side-specific recall cost

This commit is contained in:
Alexander van Gessel 2010-04-09 00:53:41 +01:00
parent dd54c4ead3
commit 64db5cd41d
10 changed files with 28 additions and 13 deletions

View file

@ -36,6 +36,7 @@ Version 1.9.0-svn:
* Add ~DARKEN() counterpart to ~BRIGHTEN()
* Implement min_value for [illuminates]
* Added lua functions wesnoth.get_side_count() and wesnoth.is_enemy(a,b)
* Add 'recall_cost' key for [side], to override [game_config]'s default
* Miscellaneous and bug fixes:
* Defaulted log level to warning again
* New option to auto-set delay shroud update on game start

View file

@ -64,6 +64,7 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
gold=2000
team_name="1"
shroud=yes
recall_cost=42
[village]
x,y=9,7
[/village]
@ -347,7 +348,7 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
>>
[args]
side=1
gold=500
gold=-1900
[/args]
[/lua]
[set_menu_item]

View file

@ -589,7 +589,7 @@ bool recall_result::test_available_for_recalling(const team &my_team, bool)
bool recall_result::test_enough_gold(const team &my_team, bool)
{
if (my_team.gold() < game_config::recall_cost ) {
if (my_team.gold() < my_team.recall_cost() ) {
set_error(E_NO_GOLD);
return false;
}
@ -754,7 +754,7 @@ void recall_result::do_execute()
recorder.add_recall(un.id(), recall_location_);
place_recruit(un, recall_location_, true, true);
statistics::recall_unit(un);
my_team.spend_gold(game_config::recall_cost);
my_team.spend_gold(my_team.recall_cost());
my_team.recall_list().erase(rec);
if (resources::screen!=NULL) {

View file

@ -1698,7 +1698,7 @@ static void debug_print_recall_list_scores(const std::vector< std::pair<std::str
bool ai_default_recruitment_stage::analyze_recall_list()
{
if (current_team().gold() < game_config::recall_cost ) {
if (current_team().gold() < current_team().recall_cost() ) {
return false;
}

View file

@ -906,8 +906,8 @@ protected:
"flag", "flag_icon", "objectives", "objectives_changed",
"disallow_observers", "allow_player", "no_leader",
"hidden", "music", "colour", "ai_config", "gold",
"start_gold", "team_rgb", "village_gold", "controller",
"persistent", "share_view",
"start_gold", "team_rgb", "village_gold", "recall_cost",
"controller", "persistent", "share_view",
"share_maps", "recruit", "fog", "shroud", "shroud_data",
// Multiplayer attributes.
"income_lock", "gold_lock", "team_lock", "leader",

View file

@ -933,13 +933,13 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
if (res < 0) return;
}
if (current_team.gold() < game_config::recall_cost) {
if (current_team.gold() < current_team.recall_cost()) {
utils::string_map i18n_symbols;
i18n_symbols["cost"] = lexical_cast<std::string>(game_config::recall_cost);
i18n_symbols["cost"] = lexical_cast<std::string>(current_team.recall_cost());
std::string msg = vngettext(
"You must have at least 1 gold piece to recall a unit",
"You must have at least $cost gold pieces to recall a unit",
game_config::recall_cost, i18n_symbols);
current_team.recall_cost(), i18n_symbols);
gui2::show_transient_message(gui_->video(), "", msg);
return;
}
@ -957,7 +957,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
recorder.add_recall(un.id(), loc);
place_recruit(un, loc, true, true);
statistics::recall_unit(un);
current_team.spend_gold(game_config::recall_cost);
current_team.spend_gold(current_team.recall_cost());
bool shroud_cleared = clear_shroud(side_num);
if (shroud_cleared) {
@ -1005,7 +1005,7 @@ void menu_handler::undo(int side_num)
const unit &un = *units_.find(action.recall_loc);
statistics::un_recall_unit(un);
current_team.spend_gold(-game_config::recall_cost);
current_team.spend_gold(-current_team.recall_cost());
current_team.recall_list().push_back(un);
// invalidate before erasing allow us
@ -1127,7 +1127,7 @@ void menu_handler::redo(int side_num)
unit un = action.affected_unit;
place_recruit(un, loc, true, true);
statistics::recall_unit(un);
current_team.spend_gold(game_config::recall_cost);
current_team.spend_gold(current_team.recall_cost());
//remove the unit from the recall list
std::vector<unit>::iterator unit_it = std::find_if(current_team.recall_list().begin(),

View file

@ -975,7 +975,7 @@ bool do_replay_handle(int side_num, const std::string &do_untill)
statistics::recall_unit(*recall_unit);
place_recruit(*recall_unit, loc, true, !get_replay_source().is_skipping());
current_team.recall_list().erase(recall_unit);
current_team.spend_gold(game_config::recall_cost);
current_team.spend_gold(current_team.recall_cost());
fix_shroud = !get_replay_source().is_skipping();
} else {
replay::process_error("illegal recall: unit_id '" + unit_id + "' could not be found within the recall list.\n");

View file

@ -1318,6 +1318,7 @@ static int impl_side_get(lua_State *L)
return_int_attrib("gold", t.gold());
return_tstring_attrib("objectives", t.objectives());
return_int_attrib("village_gold", t.village_gold());
return_int_attrib("recall_cost", t.recall_cost());
return_int_attrib("base_income", t.base_income());
return_int_attrib("total_income", t.total_income());
return_bool_attrib("objectives_changed", t.objectives_changed());
@ -1361,6 +1362,7 @@ static int impl_side_set(lua_State *L)
modify_int_attrib("gold", t.set_gold(value));
modify_tstring_attrib("objectives", t.set_objectives(value, true));
modify_int_attrib("village_gold", t.set_village_gold(value));
modify_int_attrib("recall_cost", t.set_recall_cost(value));
modify_int_attrib("base_income", t.set_base_income(value));
modify_bool_attrib("objectives_changed", t.set_objectives_changed(value != 0));
modify_tstring_attrib("user_team_name", t.change_team(t.team_name(), value));

View file

@ -53,6 +53,7 @@ team::team_info::team_info(const config& cfg) :
gold_add(false),
income(lexical_cast_default<int>(cfg["income"])),
income_per_village(0),
recall_cost(0),
average_price(0),
can_recruit(),
team_name(cfg["team_name"]),
@ -129,6 +130,12 @@ team::team_info::team_info(const config& cfg) :
else
income_per_village = lexical_cast_default<int>(village_income, game_config::village_income);
const std::string& recall_price = cfg["recall_cost"];
if(recall_price.empty())
recall_cost = game_config::recall_cost;
else
recall_cost = lexical_cast_default<int>(recall_price, game_config::recall_cost);
std::string control = cfg["controller"];
//by default, persistence of a team is set depending on the controller
persistent = true;
@ -186,6 +193,7 @@ void team::team_info::write(config& cfg) const
cfg["countdown_time"]= countdown_time;
cfg["action_bonus_count"]= action_bonus_count;
cfg["village_gold"] = income_per_village;
cfg["recall_cost"] = recall_cost;
cfg["disallow_observers"] = disallow_observers;
cfg["allow_player"] = allow_player;
cfg["no_leader"] = no_leader;

View file

@ -70,6 +70,7 @@ public:
bool gold_add;
int income;
int income_per_village;
int recall_cost;
mutable int average_price;
std::set<std::string> can_recruit;
std::string team_name;
@ -130,7 +131,9 @@ public:
bool gold_add() const { return info_.gold_add; }
int base_income() const { return info_.income + game_config::base_income; }
int village_gold() const { return info_.income_per_village; }
int recall_cost() const { return info_.recall_cost; }
void set_village_gold(int income) { info_.income_per_village = income; }
void set_recall_cost(int cost) { info_.recall_cost = cost; }
int total_income() const { return base_income() + villages_.size() * info_.income_per_village; }
void new_turn() { gold_ += total_income(); }
void get_shared_maps();