added fisher's clock, patch by mtx
This commit is contained in:
parent
eb35dd3467
commit
c9090cbc90
20 changed files with 334 additions and 21 deletions
|
@ -123,6 +123,7 @@ SVN trunk (1.1.x):
|
|||
* unit modifications now round toward original value instead of truncating
|
||||
* changed resilient trait bonus from +7hp to +10%+3hp
|
||||
* decreased strong trait hitpoints bonus from 2 to 1
|
||||
* added a fisher's clock to MP games to limit turn duration
|
||||
* new unit: added the Goblin Rouser
|
||||
* units and balancing changes:
|
||||
* changed Cuttlefish tentacle attack to swarm. changed HP from 52 to 67
|
||||
|
|
|
@ -23,6 +23,8 @@ name=Default
|
|||
#define FONT320_TINY
|
||||
6 #enddef
|
||||
|
||||
{themes/macros.cfg}
|
||||
|
||||
[resolution]
|
||||
id=1024x768
|
||||
width=1024
|
||||
|
@ -120,28 +122,28 @@ height=768
|
|||
id=turn-panel
|
||||
image=misc/status-bg.png
|
||||
ref=actions-menu
|
||||
rect="+5,=+1,+95,+19"
|
||||
rect="+5,=+1,+70,+19"
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/panel]
|
||||
[panel]
|
||||
id=gold-panel
|
||||
image=misc/status-bg.png
|
||||
rect="+5,=,+95,="
|
||||
rect="+5,=,+70,="
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/panel]
|
||||
[panel]
|
||||
id=villages-panel
|
||||
image=misc/status-bg.png
|
||||
rect="+5,=,+85,="
|
||||
rect="+5,=,+70,="
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/panel]
|
||||
[panel]
|
||||
id=units-panel
|
||||
image=misc/status-bg.png
|
||||
rect="+5,=,+85,="
|
||||
rect="+5,=,+70,="
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/panel]
|
||||
|
@ -160,6 +162,8 @@ height=768
|
|||
yanchor=fixed
|
||||
[/panel]
|
||||
|
||||
{COUNTDOWN_THEME}
|
||||
|
||||
# HP/XP
|
||||
[label]
|
||||
id=label-hp
|
||||
|
@ -305,6 +309,9 @@ height=768
|
|||
prefix=
|
||||
prefix_literal=""
|
||||
[/income]
|
||||
|
||||
{COUNTDOWN_THEME_STATUS}
|
||||
|
||||
[terrain]
|
||||
id=status-terrain
|
||||
font_size={FONT_SMALL}
|
||||
|
@ -315,7 +322,7 @@ height=768
|
|||
[position]
|
||||
id=status-position
|
||||
font_size={FONT_SMALL}
|
||||
rect="+5,=,+105,+16"
|
||||
rect="+5,=,+95,+16"
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/position]
|
||||
|
|
|
@ -1,2 +1,34 @@
|
|||
#define REPLAY_THEME
|
||||
#enddef
|
||||
|
||||
#define COUNTDOWN_THEME
|
||||
[panel]
|
||||
id=timeout-panel
|
||||
image=misc/status-bg.png
|
||||
rect="+5,=,+70,="
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/panel]
|
||||
[label]
|
||||
id=time-icon
|
||||
#icon=misc/units.png
|
||||
icon=misc/sand-clock.png
|
||||
text= _ "Time left"
|
||||
ref=timeout-panel
|
||||
rect="=+5,=+1,+16,+16"
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/label]
|
||||
#enddef
|
||||
|
||||
|
||||
#define COUNTDOWN_THEME_STATUS
|
||||
[report_countdown]
|
||||
id=report_timeout
|
||||
font_size={FONT_SMALL}
|
||||
ref=time-icon
|
||||
rect="+5,=,+50,+20"
|
||||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/report_countdown]
|
||||
#enddef
|
||||
|
|
BIN
images/misc/sand-clock.png
Normal file
BIN
images/misc/sand-clock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 971 B |
|
@ -895,6 +895,7 @@ void display::update_display()
|
|||
void display::draw_sidebar()
|
||||
{
|
||||
draw_report(reports::REPORT_CLOCK);
|
||||
draw_report(reports::REPORT_COUNTDOWN);
|
||||
|
||||
if(teams_.empty()) {
|
||||
return;
|
||||
|
|
|
@ -344,7 +344,20 @@ config connect::side::get_config() const
|
|||
if(!parent_->params_.use_map_settings || res["shroud"].empty() || (res["shroud"] != "yes" && res["shroud"] != "no")) {
|
||||
res["shroud"] = parent_->params_.shroud_game ? "yes" : "no";
|
||||
}
|
||||
|
||||
|
||||
if(!parent_->params_.use_map_settings || res["mp_countdown"].empty() || (res["mp_countdown"] != "yes" && res["mp_countdown"] != "no")) {
|
||||
res["mp_countdown"] = parent_->params_.mp_countdown ? "yes" : "no";;
|
||||
}
|
||||
|
||||
if(!parent_->params_.use_map_settings || res["mp_countdown_init_time"].empty()) {
|
||||
res["mp_countdown_init_time"] = lexical_cast<std::string>(parent_->params_.mp_countdown_init_time);
|
||||
}
|
||||
if(!parent_->params_.use_map_settings || res["mp_countdown_turn_bonus"].empty()) {
|
||||
res["mp_countdown_turn_bonus"] = lexical_cast<std::string>(parent_->params_.mp_countdown_turn_bonus);
|
||||
}
|
||||
|
||||
|
||||
res["share_maps"] = parent_->params_.share_maps ? "yes" : "no";
|
||||
res["share_view"] = parent_->params_.share_view ? "yes" : "no";
|
||||
if(!parent_->params_.use_map_settings || res["village_gold"].empty())
|
||||
|
@ -951,7 +964,12 @@ void connect::load_game()
|
|||
} else {
|
||||
level_ = params_.scenario_data;
|
||||
level_["turns"] = lexical_cast_default<std::string>(params_.num_turns, "20");
|
||||
|
||||
level_["mp_countdown"] = params_.mp_countdown ? "yes" : "no";
|
||||
level_["mp_countdown_init_time"] = lexical_cast_default<std::string>(params_.mp_countdown_init_time, "600");
|
||||
level_["mp_countdown_turn_bonus"] = lexical_cast_default<std::string>(params_.mp_countdown_turn_bonus, "100");
|
||||
|
||||
|
||||
|
||||
const std::string& era = params_.era;
|
||||
|
||||
// Initialize the list of sides available for the current era.
|
||||
|
|
|
@ -43,6 +43,11 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
maps_menu_(disp.video(), std::vector<std::string>()),
|
||||
turns_slider_(disp.video()),
|
||||
turns_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
|
||||
countdown_game_(disp.video(), _("Enable time limit"), gui::button::TYPE_CHECK),
|
||||
countdown_init_time_slider_(disp.video()),
|
||||
countdown_init_time_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
|
||||
countdown_turn_bonus_slider_(disp.video()),
|
||||
countdown_turn_bonus_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
|
||||
village_gold_slider_(disp.video()),
|
||||
village_gold_label_(disp.video(), "", font::SIZE_SMALL, font::LOBBY_COLOUR),
|
||||
xp_modifier_slider_(disp.video()),
|
||||
|
@ -94,6 +99,21 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
turns_slider_.set_value(preferences::turns());
|
||||
turns_slider_.set_help_string(_("The maximum number of turns the game can last"));
|
||||
|
||||
countdown_game_.set_check(preferences::countdown());
|
||||
countdown_game_.set_help_string(_("Enables ingame user time limits"));
|
||||
|
||||
countdown_init_time_slider_.set_min(0);
|
||||
countdown_init_time_slider_.set_max(7200);
|
||||
countdown_init_time_slider_.set_increment(30);
|
||||
countdown_init_time_slider_.set_value(preferences::countdown_init_time());
|
||||
countdown_init_time_slider_.set_help_string(_("Initial time available for user at the begining of the match"));
|
||||
|
||||
countdown_turn_bonus_slider_.set_min(0);
|
||||
countdown_turn_bonus_slider_.set_max(1000);
|
||||
countdown_turn_bonus_slider_.set_increment(10);
|
||||
countdown_turn_bonus_slider_.set_value(preferences::countdown_turn_bonus());
|
||||
countdown_turn_bonus_slider_.set_help_string(_("Time added to user's clock at the end of each turn"));
|
||||
|
||||
village_gold_slider_.set_min(1);
|
||||
village_gold_slider_.set_max(5);
|
||||
village_gold_slider_.set_value(preferences::village_gold());
|
||||
|
@ -161,6 +181,9 @@ create::~create()
|
|||
preferences::set_fog(parameters_.fog_game);
|
||||
preferences::set_shroud(parameters_.shroud_game);
|
||||
preferences::set_turns(parameters_.num_turns);
|
||||
preferences::set_countdown(parameters_.mp_countdown);
|
||||
preferences::set_countdown_init_time(parameters_.mp_countdown_init_time);
|
||||
preferences::set_countdown_turn_bonus(parameters_.mp_countdown_turn_bonus);
|
||||
preferences::set_village_gold(parameters_.village_gold);
|
||||
preferences::set_xp_modifier(parameters_.xp_modifier);
|
||||
preferences::set_era(era_combo_.selected()); // FIXME: may be broken if new eras are added
|
||||
|
@ -174,6 +197,11 @@ create::parameters& create::get_parameters()
|
|||
const int turns = turns_slider_.value() < turns_slider_.max_value() ?
|
||||
turns_slider_.value() : -1;
|
||||
|
||||
const int mp_countdown_init_time_val = countdown_init_time_slider_.value() < countdown_init_time_slider_.max_value() ?
|
||||
countdown_init_time_slider_.value() : -1;
|
||||
const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value() < countdown_turn_bonus_slider_.max_value() ?
|
||||
countdown_turn_bonus_slider_.value() : -1;
|
||||
|
||||
// Updates the values in the "parameters_" member to match the values
|
||||
// selected by the user with the widgets:
|
||||
parameters_.name = name_entry_.text();
|
||||
|
@ -182,6 +210,9 @@ create::parameters& create::get_parameters()
|
|||
}
|
||||
parameters_.era = (*era_list[era_combo_.selected()])["id"];
|
||||
parameters_.num_turns = turns;
|
||||
parameters_.mp_countdown_init_time = mp_countdown_init_time_val;
|
||||
parameters_.mp_countdown_turn_bonus = mp_countdown_turn_bonus_val;
|
||||
parameters_.mp_countdown = countdown_game_.checked();
|
||||
parameters_.village_gold = village_gold_slider_.value();
|
||||
parameters_.xp_modifier = xp_modifier_slider_.value();
|
||||
parameters_.use_map_settings = use_map_settings_.checked();
|
||||
|
@ -224,7 +255,22 @@ void create::process_event()
|
|||
buf << _("Unlimited Turns");
|
||||
}
|
||||
turns_label_.set_text(buf.str());
|
||||
|
||||
|
||||
countdown_init_time_label_.hide(!countdown_game_.checked());
|
||||
countdown_init_time_slider_.hide(!countdown_game_.checked());
|
||||
countdown_turn_bonus_label_.hide(!countdown_game_.checked());
|
||||
countdown_turn_bonus_slider_.hide(!countdown_game_.checked());
|
||||
|
||||
const int mp_countdown_init_time_val = countdown_init_time_slider_.value();
|
||||
buf.str("");
|
||||
buf << _("Initial Time: ") << mp_countdown_init_time_val << " seconds";
|
||||
countdown_init_time_label_.set_text(buf.str());
|
||||
|
||||
const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value();
|
||||
buf.str("");
|
||||
buf << _("Turn time bonus: ") << mp_countdown_turn_bonus_val << " seconds";
|
||||
countdown_turn_bonus_label_.set_text(buf.str());
|
||||
|
||||
//Villages can produce between 1 and 10 gold a turn
|
||||
const int village_gold = village_gold_slider_.value();
|
||||
buf.str("");
|
||||
|
@ -375,6 +421,13 @@ void create::hide_children(bool hide)
|
|||
maps_menu_.hide(hide);
|
||||
turns_slider_.hide(hide);
|
||||
turns_label_.hide(hide);
|
||||
|
||||
countdown_init_time_slider_.hide(hide);
|
||||
countdown_init_time_label_.hide(hide);
|
||||
countdown_turn_bonus_slider_.hide(hide);
|
||||
countdown_turn_bonus_label_.hide(hide);
|
||||
countdown_game_.hide(hide);
|
||||
|
||||
village_gold_slider_.hide(hide);
|
||||
village_gold_label_.hide(hide);
|
||||
xp_modifier_slider_.hide(hide);
|
||||
|
@ -483,6 +536,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
turns_slider_.set_location(xpos, ypos);
|
||||
ypos += turns_slider_.height() + border_size;
|
||||
|
||||
|
||||
village_gold_label_.set_location(xpos, ypos);
|
||||
ypos += village_gold_label_.height() + border_size;
|
||||
village_gold_slider_.set_width(ca.w - xpos);
|
||||
|
@ -495,6 +549,18 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
xp_modifier_slider_.set_location(xpos, ypos);
|
||||
ypos += xp_modifier_slider_.height() + border_size;
|
||||
|
||||
countdown_game_.set_location(xpos, ypos);
|
||||
ypos += countdown_game_.height() + border_size;
|
||||
|
||||
countdown_init_time_label_.set_location(xpos, ypos);
|
||||
countdown_turn_bonus_label_.set_location(xpos + (ca.w - xpos)/2 + 5 , ypos);
|
||||
ypos += countdown_init_time_label_.height() + border_size;
|
||||
countdown_init_time_slider_.set_width(((ca.w - xpos)/2)-5);
|
||||
countdown_turn_bonus_slider_.set_width(((ca.w - xpos)/2)-5);
|
||||
countdown_init_time_slider_.set_location(xpos, ypos);
|
||||
countdown_turn_bonus_slider_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
|
||||
ypos += countdown_init_time_slider_.height() + border_size;
|
||||
|
||||
|
||||
use_map_settings_.set_location(xpos, ypos);
|
||||
ypos += use_map_settings_.height() + border_size;
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
num_turns = 0;
|
||||
village_gold = 0;
|
||||
xp_modifier = 0;
|
||||
mp_countdown=false;
|
||||
mp_countdown_init_time=0;
|
||||
mp_countdown_turn_bonus=0;
|
||||
use_map_settings = fog_game = shroud_game = allow_observers = share_view = share_maps = false;
|
||||
|
||||
scenario_data.clear();
|
||||
|
@ -48,6 +51,9 @@ public:
|
|||
int num_turns;
|
||||
int village_gold;
|
||||
int xp_modifier;
|
||||
int mp_countdown_init_time;
|
||||
int mp_countdown_turn_bonus;
|
||||
bool mp_countdown;
|
||||
bool use_map_settings;
|
||||
bool fog_game;
|
||||
bool shroud_game;
|
||||
|
@ -84,6 +90,11 @@ private:
|
|||
gui::menu maps_menu_;
|
||||
gui::slider turns_slider_;
|
||||
gui::label turns_label_;
|
||||
gui::button countdown_game_;
|
||||
gui::slider countdown_init_time_slider_;
|
||||
gui::label countdown_init_time_label_;
|
||||
gui::slider countdown_turn_bonus_slider_;
|
||||
gui::label countdown_turn_bonus_label_;
|
||||
gui::slider village_gold_slider_;
|
||||
gui::label village_gold_label_;
|
||||
gui::slider xp_modifier_slider_;
|
||||
|
|
|
@ -112,6 +112,9 @@ namespace play{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
||||
config const* level, CVideo& video,
|
||||
game_state& state_of_game,
|
||||
|
@ -124,7 +127,6 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
} else {
|
||||
recorder.pre_replay();
|
||||
}
|
||||
|
||||
const set_random_generator generator_setter(&recorder);
|
||||
|
||||
//guarantee the cursor goes back to 'normal' at the end of the level
|
||||
|
@ -149,6 +151,8 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
if(map_data == "" && (*level)["map"] != "") {
|
||||
map_data = read_map((*level)["map"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if the map should be randomly generated
|
||||
if(map_data == "" && (*level)["map_generation"] != "") {
|
||||
|
@ -172,6 +176,8 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
const statistics::scenario_context statistics_context(lvl["name"]);
|
||||
|
||||
const int num_turns = atoi(lvl["turns"].c_str());
|
||||
|
||||
|
||||
gamestatus status(*level,num_turns);
|
||||
|
||||
gamemap map(game_config,map_data);
|
||||
|
@ -343,12 +349,21 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
for(std::vector<team>::iterator t = teams.begin(); t != teams.end(); ++t) {
|
||||
clear_shroud(gui,status,map,gameinfo,units,teams,(t-teams.begin()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!loading_game) {
|
||||
game_events::fire("start");
|
||||
state_of_game.set_variable("turn_number", "1");
|
||||
}
|
||||
|
||||
// Initialize countdown clock.
|
||||
for(std::vector<team>::iterator t = teams.begin(); t != teams.end(); ++t) {
|
||||
std::string countd_enabled = lvl["mp_countdown"].c_str();
|
||||
if ( countd_enabled == "yes" && !loading_game ){
|
||||
t->set_countdown_time(1000 * lexical_cast_default<int>(lvl["mp_countdown_init_time"],0));
|
||||
}
|
||||
}
|
||||
|
||||
gui.recalculate_minimap();
|
||||
}
|
||||
player_number = 0;
|
||||
|
@ -444,7 +459,7 @@ redo_turn:
|
|||
|
||||
if(!replaying && team_it->is_human()) {
|
||||
LOG_NG << "is human...\n";
|
||||
|
||||
|
||||
try {
|
||||
play_turn(gameinfo,state_of_game,status,game_config,
|
||||
*level, key, gui, map, teams, player_number,
|
||||
|
@ -453,10 +468,10 @@ redo_turn:
|
|||
if (end_turn.redo == player_number)
|
||||
goto redo_turn;
|
||||
}
|
||||
|
||||
|
||||
if(game_config::debug)
|
||||
display::clear_debug_highlights();
|
||||
|
||||
|
||||
LOG_NG << "human finished turn...\n";
|
||||
|
||||
} else if(!replaying && team_it->is_ai()) {
|
||||
|
|
|
@ -46,4 +46,5 @@ namespace play{
|
|||
void place_sides_in_preferred_locations(gamemap& map, const config::child_list& sides);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,6 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
gui.invalidate_all();
|
||||
gui.draw();
|
||||
gui.update_display();
|
||||
|
||||
const paths_wiper wiper(gui);
|
||||
|
||||
if(preferences::turn_bell()) {
|
||||
|
@ -114,9 +113,16 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
unit_map::const_iterator ui = units.find(*g);
|
||||
turn_data.move_unit_to_loc(ui,ui->second.get_goto(),false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cur_ticks = SDL_GetTicks();
|
||||
int beep_warning_time = 10000; //Starts beeping each second when time is less than this (millisec)
|
||||
|
||||
turn_data.start_interactive_turn();
|
||||
|
||||
|
||||
|
||||
|
||||
while(!turn_data.turn_over()) {
|
||||
|
||||
try {
|
||||
|
@ -133,12 +139,36 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
turn_data.send_data();
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
if (teams[team_num -1].countdown_time() > 0 && ( level["mp_countdown"] == "yes" ) ){
|
||||
SDL_Delay(1);
|
||||
const int ticks = SDL_GetTicks();
|
||||
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time()-maximum<int>(1,(ticks - cur_ticks)));
|
||||
cur_ticks = ticks;
|
||||
if ( teams[team_num -1].countdown_time() <= beep_warning_time){
|
||||
beep_warning_time=beep_warning_time - 1000;
|
||||
sound::play_sound("bell.wav");
|
||||
}
|
||||
if ( teams[team_num -1].countdown_time() <= 0){
|
||||
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time() + 1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
|
||||
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
|
||||
recorder.end_turn();
|
||||
turn_data.send_data();
|
||||
throw end_turn_exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// gui.invalidate_animations();
|
||||
gui.draw();
|
||||
|
||||
turn_data.send_data();
|
||||
}
|
||||
if ( level["mp_countdown"] == "yes" ){
|
||||
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time() + 1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
|
||||
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
|
||||
}
|
||||
|
||||
//send one more time to make sure network is up-to-date.
|
||||
turn_data.send_data();
|
||||
|
|
|
@ -113,6 +113,9 @@ public:
|
|||
//data will be forwarded to all peers other than 'from', unless 'from' is null, in
|
||||
//which case data will not be forwarded
|
||||
PROCESS_DATA_RESULT process_network_data(const config& cfg,network::connection from,std::deque<config>& backlog);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
//convenience functions
|
||||
|
@ -268,4 +271,5 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
turn_info::floating_textbox& textbox,
|
||||
replay_network_sender& network_sender);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -493,6 +493,60 @@ void set_turns(int value)
|
|||
prefs["mp_turns"] = stream.str();
|
||||
}
|
||||
|
||||
bool countdown()
|
||||
{
|
||||
return prefs["mp_countdown"] == "yes";
|
||||
}
|
||||
|
||||
void set_countdown(bool value)
|
||||
{
|
||||
prefs["mp_countdown"] = value ? "yes" : "no";
|
||||
}
|
||||
|
||||
|
||||
int countdown_init_time()
|
||||
{
|
||||
static const int default_value = 120;
|
||||
int value = 0;
|
||||
const string_map::const_iterator i = prefs.values.find("mp_countdown_init_time");
|
||||
if(i != prefs.values.end() && i->second.empty() == false) {
|
||||
value = atoi(i->second.c_str());
|
||||
}
|
||||
|
||||
if(value < 0 || value > 7200) {
|
||||
value = default_value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void set_countdown_init_time(int value)
|
||||
{
|
||||
prefs["mp_countdown_init_time"] = lexical_cast<std::string>(value);
|
||||
}
|
||||
|
||||
int countdown_turn_bonus()
|
||||
{
|
||||
static const int default_value = 60;
|
||||
int value = 0;
|
||||
const string_map::const_iterator i = prefs.values.find("mp_countdown_turn_bonus");
|
||||
if(i != prefs.values.end() && i->second.empty() == false) {
|
||||
value = atoi(i->second.c_str());
|
||||
}
|
||||
|
||||
if(value < 0 || value > 1000) {
|
||||
value = default_value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void set_countdown_turn_bonus(int value)
|
||||
{
|
||||
prefs["mp_countdown_turn_bonus"] =lexical_cast<std::string>(value);
|
||||
}
|
||||
|
||||
|
||||
int village_gold()
|
||||
{
|
||||
static const int default_value = 2;
|
||||
|
|
|
@ -129,6 +129,13 @@ namespace preferences {
|
|||
int turns();
|
||||
void set_turns(int value);
|
||||
|
||||
bool countdown();
|
||||
void set_countdown(bool value);
|
||||
int countdown_init_time();
|
||||
void set_countdown_init_time(int value);
|
||||
int countdown_turn_bonus();
|
||||
void set_countdown_turn_bonus(int value);
|
||||
|
||||
int village_gold();
|
||||
void set_village_gold(int value);
|
||||
|
||||
|
|
|
@ -265,6 +265,18 @@ void replay::add_disband(int value)
|
|||
cmd->add_child("disband",val);
|
||||
}
|
||||
|
||||
void replay::add_countdown_update(int value, int team)
|
||||
{
|
||||
config* const cmd = add_command();
|
||||
config val;
|
||||
|
||||
val["value"] = lexical_cast_default<std::string>(value);
|
||||
val["team"] = lexical_cast_default<std::string>(team);
|
||||
|
||||
cmd->add_child("countdown_update",val);
|
||||
}
|
||||
|
||||
|
||||
void replay::add_movement(const gamemap::location& a,const gamemap::location& b)
|
||||
{
|
||||
add_pos("move",a,b);
|
||||
|
@ -737,7 +749,18 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
if (!game_config::ignore_replay_errors) throw replay::error();
|
||||
}
|
||||
}
|
||||
|
||||
else if((child = cfg->child("countdown_update")) != NULL) {
|
||||
const std::string& num = (*child)["value"];
|
||||
const int val = lexical_cast_default<int>(num);
|
||||
const std::string& tnum = (*child)["team"];
|
||||
const int tval = lexical_cast_default<int>(tnum,-1);
|
||||
if ( (tval<0) || (tval > teams.size()) ) {
|
||||
ERR_NW << "Illegal countdown update \n" << "Received update for :" << tval << " Current user :" << team_num << "\n" << " Updated value :" << val;
|
||||
if (!game_config::ignore_replay_errors) throw replay::error();
|
||||
} else {
|
||||
teams[tval-1].set_countdown_time(val);
|
||||
}
|
||||
}
|
||||
else if((child = cfg->child("move")) != NULL) {
|
||||
|
||||
const config* const destination = child->child("destination");
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void add_recruit(int unit_index, const gamemap::location& loc);
|
||||
void add_recall(int unit_index, const gamemap::location& loc);
|
||||
void add_disband(int unit_index);
|
||||
void replay::add_countdown_update(int value,int team);
|
||||
void add_movement(const gamemap::location& a, const gamemap::location& b);
|
||||
void add_attack(const gamemap::location& a, const gamemap::location& b,
|
||||
int weapon);
|
||||
|
|
|
@ -36,7 +36,8 @@ namespace {
|
|||
"unit_image","unit_profile","time_of_day",
|
||||
"turn","gold","villages","num_units","upkeep", "expenses",
|
||||
"income", "terrain", "position", "side_playing", "observers",
|
||||
"report_clock","selected_terrain","edit_left_button_function"
|
||||
"report_countdown", "report_clock",
|
||||
"selected_terrain","edit_left_button_function"
|
||||
};
|
||||
std::map<reports::TYPE, std::string> report_contents;
|
||||
}
|
||||
|
@ -462,6 +463,27 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
|
|||
return report();
|
||||
}
|
||||
}
|
||||
case REPORT_COUNTDOWN: {
|
||||
int min;
|
||||
int sec;
|
||||
if (current_team.countdown_time() > 0){
|
||||
sec = current_team.countdown_time() / 1000;
|
||||
|
||||
if(sec < 60)
|
||||
str << "<200,0,0>";
|
||||
else if(sec < 120)
|
||||
str << "<200,200,0>";
|
||||
|
||||
min = sec / 60;
|
||||
str << min << ":";
|
||||
sec = sec % 60;
|
||||
if (sec < 10) {
|
||||
str << "0";
|
||||
}
|
||||
str << sec;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REPORT_CLOCK: {
|
||||
time_t t = time(NULL);
|
||||
struct tm *lt=localtime(&t);
|
||||
|
|
|
@ -34,10 +34,9 @@ namespace reports {
|
|||
UNIT_ADVANCEMENT_OPTIONS, UNIT_MOVES, UNIT_WEAPONS,
|
||||
UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
|
||||
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES,
|
||||
INCOME, TERRAIN, POSITION,
|
||||
SIDE_PLAYING, OBSERVERS, REPORT_CLOCK,
|
||||
SELECTED_TERRAIN, EDIT_LEFT_BUTTON_FUNCTION,
|
||||
NUM_REPORTS};
|
||||
INCOME, TERRAIN, POSITION, SIDE_PLAYING, OBSERVERS,
|
||||
REPORT_COUNTDOWN, REPORT_CLOCK, SELECTED_TERRAIN,
|
||||
EDIT_LEFT_BUTTON_FUNCTION, NUM_REPORTS};
|
||||
|
||||
enum { UNIT_REPORTS_BEGIN=UNIT_DESCRIPTION, UNIT_REPORTS_END=UNIT_PROFILE+1 };
|
||||
enum { STATUS_REPORTS_BEGIN=TIME_OF_DAY, STATUS_REPORTS_END=NUM_REPORTS};
|
||||
|
|
16
src/team.cpp
16
src/team.cpp
|
@ -103,6 +103,8 @@ team::team_info::team_info(const config& cfg)
|
|||
save_id = cfg["description"];
|
||||
}
|
||||
|
||||
countdown_time = cfg["countdown_time"];
|
||||
|
||||
colour = lexical_cast_default<int>(cfg["colour"],-1);
|
||||
if(colour == -1)
|
||||
colour = lexical_cast_default<int>(cfg["side"],-1);
|
||||
|
@ -250,6 +252,7 @@ void team::team_info::write(config& cfg) const
|
|||
cfg["description"] = description;
|
||||
cfg["objectives"] = objectives;
|
||||
cfg["objectives_changed"] = objectives_changed ? "yes" : "no";
|
||||
cfg["countdown_time"]= countdown_time;
|
||||
|
||||
char buf[50];
|
||||
snprintf(buf,sizeof(buf),"%d",income_per_village);
|
||||
|
@ -333,6 +336,8 @@ team::team(const config& cfg, int gold) : gold_(gold), auto_shroud_updates_(true
|
|||
for(config::child_list::const_iterator v = villages.begin(); v != villages.end(); ++v) {
|
||||
villages_.insert(gamemap::location(**v));
|
||||
}
|
||||
|
||||
countdown_time_=lexical_cast_default<int>(cfg["countdown_time"],0);
|
||||
}
|
||||
|
||||
void team::write(config& cfg) const
|
||||
|
@ -351,6 +356,8 @@ void team::write(config& cfg) const
|
|||
}
|
||||
|
||||
cfg["shroud_data"] = shroud_.write();
|
||||
|
||||
cfg["countdown_time"] = lexical_cast_default<std::string>(countdown_time_);
|
||||
}
|
||||
|
||||
bool team::get_village(const gamemap::location& loc)
|
||||
|
@ -443,6 +450,15 @@ void team::set_income(int amount)
|
|||
info_.income = lexical_cast<std::string>(amount);
|
||||
}
|
||||
|
||||
int team::countdown_time() const
|
||||
{
|
||||
return countdown_time_;
|
||||
}
|
||||
void team::set_countdown_time(int amount)
|
||||
{
|
||||
countdown_time_=amount;
|
||||
}
|
||||
|
||||
const std::set<std::string>& team::recruits() const
|
||||
{
|
||||
return info_.can_recruit;
|
||||
|
|
|
@ -73,7 +73,8 @@ public:
|
|||
std::vector<int> enemies;
|
||||
std::string team_name;
|
||||
std::string save_id;
|
||||
|
||||
std::string countdown_time;
|
||||
|
||||
std::string flag;
|
||||
|
||||
std::string description;
|
||||
|
@ -123,6 +124,8 @@ public:
|
|||
void get_shared_maps();
|
||||
void spend_gold(int amount);
|
||||
void set_income(int amount);
|
||||
int countdown_time() const;
|
||||
void set_countdown_time(int amount);
|
||||
|
||||
const std::set<std::string>& recruits() const;
|
||||
std::set<std::string>& recruits();
|
||||
|
@ -245,6 +248,8 @@ private:
|
|||
|
||||
team_info info_;
|
||||
|
||||
int countdown_time_;
|
||||
|
||||
config aiparams_;
|
||||
|
||||
//cached values for ai parameters
|
||||
|
|
Loading…
Add table
Reference in a new issue