Exemplo n.º 1
0
void citizen::init(wml::const_node_ptr node)
{
	survive_formula = game_logic::formula::create_optional_formula(node->attr("survive_formula"));
	reproduce_formula = game_logic::formula::create_optional_formula(node->attr("reproduce_formula"));
	tile_attractiveness_formula.reset(new game_logic::formula(node->attr("tile_attractiveness_formula")));
	wages_wanted_formula = game_logic::formula::create_optional_formula(node->attr("wages_wanted_formula"));

	wml::const_node_ptr produce = node->get_child("produce");
	if(produce) {
		for(wml::node::const_attr_iterator i = produce->begin_attr(); i != produce->end_attr(); ++i) {
			produce_score_formulae[i->first].reset(new game_logic::formula(i->second));
		}
	}

	wml::const_node_ptr use = node->get_child("use");
	if(use) {
		for(wml::node::const_attr_iterator i = use->begin_attr(); i != use->end_attr(); ++i) {
			item_use_map[i->first] = atoi(i->second.c_str());
		}
	}

	wml::const_node_ptr trades = node->get_child("trades");
	if(trades) {
		for(wml::node::const_attr_iterator i = trades->begin_attr(); i != trades->end_attr(); ++i) {
			std::vector<std::string> keys = util::split(i->first, '_');
			if(keys.size() == 2) {
				trade_formula_map[std::pair<std::string,std::string>(keys[0], keys[1])].reset(new game_logic::formula(i->second));
			}
		}
	}

	wml::const_node_ptr buys = node->get_child("buys");
	if(buys) {
		for(wml::node::const_attr_iterator i = buys->begin_attr(); i != buys->end_attr(); ++i) {
			buy_formula_map[i->first].reset(new game_logic::formula(i->second));
		}
	}

	wml::const_node_ptr sells = node->get_child("sells");
	if(sells) {
		for(wml::node::const_attr_iterator i = sells->begin_attr(); i != sells->end_attr(); ++i) {
			sell_formula_map[i->first].reset(new game_logic::formula(i->second));
		}
	}

	wml::const_node_ptr buy_quantities = node->get_child("buy_quantities");
	if(buy_quantities) {
		for(wml::node::const_attr_iterator i = buy_quantities->begin_attr(); i != buy_quantities->end_attr(); ++i) {
			buy_quantity_formula_map[i->first].reset(new game_logic::formula(i->second));
		}
	}

	wml::const_node_ptr sell_quantities = node->get_child("sell_quantities");
	if(sell_quantities) {
		for(wml::node::const_attr_iterator i = sell_quantities->begin_attr(); i != sell_quantities->end_attr(); ++i) {
			sell_quantity_formula_map[i->first].reset(new game_logic::formula(i->second));
		}
	}
}
Exemplo n.º 2
0
Arquivo: world.cpp Projeto: x2f/wesciv
world::world(wml::const_node_ptr node)
  : map_(hex::generate_gamemap(node)),
    weather_x_(0), weather_y_(0),
    weather_next_turn_(game_logic::formula::create_optional_formula(node->attr("weather_next_turn"))),
    weather_function_(game_logic::formula::create_optional_formula(node->attr("weather_function")))
{
	sides_.push_back(government_ptr(new government));
}
Exemplo n.º 3
0
unit_type::unit_type(wml::const_node_ptr node)
  : description_(node->attr("description")),
    texture_(graphics::texture::get(node->attr("image"))),
	movement_(wml::get_int(node, "movement", 10)),
	cost_(wml::get_int(node, "cost", 1))
{
	abilities_ = util::split(node->attr("abilities"));
	ability_build_city_ = has_ability("settle");
}
Exemplo n.º 4
0
level_tile level_object::build_tile(wml::const_node_ptr node)
{
	level_tile res;
	res.x = wml::get_int(node, "x");
	res.y = wml::get_int(node, "y");
	res.zorder = wml::get_int(node, "zorder");
	if(tiles_cache.count(node->attr("tile"))) {
		res.object = tiles_cache[node->attr("tile")];
	}
	res.face_right = wml::get_bool(node, "face_right");
	return res;
}
Exemplo n.º 5
0
frame::frame(wml::const_node_ptr node)
   : id_(node->attr("id")),
     image_(node->attr("image")),
     variant_id_(id_),
     enter_event_id_(get_object_event_id("enter_" + id_ + "_anim")),
	 end_event_id_(get_object_event_id("end_" + id_ + "_anim")),
	 leave_event_id_(get_object_event_id("leave_" + id_ + "_anim")),
	 process_event_id_(get_object_event_id("process_" + id_)),
     texture_(graphics::texture::get(image_, node->attr("image_formula"))),
	 solid_(solid_info::create(node)),
     collide_rect_(node->has_attr("collide") ? rect(node->attr("collide")) :
	               rect(wml::get_int(node, "collide_x"),
                        wml::get_int(node, "collide_y"),
                        wml::get_int(node, "collide_w"),
                        wml::get_int(node, "collide_h"))),
	 hit_rect_(node->has_attr("hit") ? rect(node->attr("hit")) :
	               rect(wml::get_int(node, "hit_x"),
				        wml::get_int(node, "hit_y"),
				        wml::get_int(node, "hit_w"),
				        wml::get_int(node, "hit_h"))),
	 platform_rect_(node->has_attr("platform") ? rect(node->attr("platform")) :
	                rect(wml::get_int(node, "platform_x"),
	                     wml::get_int(node, "platform_y"),
	                     wml::get_int(node, "platform_w"), 1)),
	 img_rect_(node->has_attr("rect") ? rect(node->attr("rect")) :
	           rect(wml::get_int(node, "x"),
	                wml::get_int(node, "y"),
	                wml::get_int(node, "w"),
	                wml::get_int(node, "h"))),
	 feet_x_(wml::get_int(node, "feet_x")),
	 feet_y_(wml::get_int(node, "feet_y")),
	 accel_x_(wml::get_int(node, "accel_x", INT_MIN)),
	 accel_y_(wml::get_int(node, "accel_y", INT_MIN)),
	 velocity_x_(wml::get_int(node, "velocity_x", INT_MIN)),
	 velocity_y_(wml::get_int(node, "velocity_y", INT_MIN)),
	 nframes_(wml::get_int(node, "frames", 1)),
	 nframes_per_row_(wml::get_int(node, "frames_per_row", -1)),
	 frame_time_(wml::get_int(node, "duration", -1)),
	 reverse_frame_(wml::get_bool(node, "reverse")),
	 play_backwards_(wml::get_bool(node, "play_backwards")),
	 scale_(wml::get_int(node, "scale", 2)),
	 pad_(wml::get_int(node, "pad")),
	 rotate_(wml::get_int(node, "rotate")),
	 blur_(wml::get_int(node, "blur")),
	 rotate_on_slope_(wml::get_bool(node, "rotate_on_slope")),
	 damage_(wml::get_int(node, "damage")),
	 sounds_(util::split(node->attr("sound"))),
	 no_remove_alpha_borders_(wml::get_bool(node, "no_remove_alpha_borders", false)),
	 current_palette_(-1)
{
	std::vector<std::string> hit_frames = util::split((*node)["hit_frames"]);
	foreach(const std::string& f, hit_frames) {
		hit_frames_.push_back(boost::lexical_cast<int>(f));
	}
Exemplo n.º 6
0
terrain_improvement::terrain_improvement(wml::const_node_ptr node)
  : id_(node->attr("id")), texture_(graphics::texture::get(node->attr("image"))), cost_(wml::get_int(node, "cost"))
{}