mirror of
https://github.com/Relintai/mourne_rcpp_fw.git
synced 2024-12-23 21:16:50 +01:00
Implemented weather data.
This commit is contained in:
parent
379657ced7
commit
3fc63d1a9f
@ -1,27 +1,15 @@
|
||||
#include "weather.h"
|
||||
|
||||
void Weather::set_strings(const String &p_name, const String &p_description, const String &p_icon) {
|
||||
void Weather::set_strings(const String &p_name, const String &p_description, const String &p_art, const String &p_css) {
|
||||
name = p_name;
|
||||
description = p_description;
|
||||
icon = p_icon;
|
||||
art = p_art;
|
||||
css = p_css;
|
||||
}
|
||||
void Weather::set_base_data(int p_rank, int p_next_rank, int p_time_to_build, int p_creates, int p_num_creates, int p_score, int p_defense, int p_ability) {
|
||||
rank = p_rank;
|
||||
next_rank = p_next_rank;
|
||||
time_to_build = p_time_to_build;
|
||||
creates = p_creates;
|
||||
num_creates = p_num_creates;
|
||||
score = p_score;
|
||||
defense = p_defense;
|
||||
ability = p_ability;
|
||||
}
|
||||
void Weather::set_cost(int p_cost_food, int p_cost_wood, int p_cost_stone, int p_cost_iron, int p_cost_mana) {
|
||||
cost_food = p_cost_food;
|
||||
cost_wood = p_cost_wood;
|
||||
cost_stone = p_cost_stone;
|
||||
cost_iron = p_cost_iron;
|
||||
cost_mana = p_cost_mana;
|
||||
void Weather::set_base_data(int p_effect) {
|
||||
effect = p_effect;
|
||||
}
|
||||
|
||||
void Weather::set_mod_max(int p_mod_max_food, int p_mod_max_wood, int p_mod_max_stone, int p_mod_max_iron, int p_mod_max_mana) {
|
||||
mod_max_food = p_mod_max_food;
|
||||
mod_max_wood = p_mod_max_wood;
|
||||
@ -29,13 +17,6 @@ void Weather::set_mod_max(int p_mod_max_food, int p_mod_max_wood, int p_mod_max_
|
||||
mod_max_iron = p_mod_max_iron;
|
||||
mod_max_mana = p_mod_max_mana;
|
||||
}
|
||||
void Weather::set_mod_rate(double p_mod_rate_food, double p_mod_rate_wood, double p_mod_rate_stone, double p_mod_rate_iron, double p_mod_rate_mana) {
|
||||
mod_rate_food = p_mod_rate_food;
|
||||
mod_rate_wood = p_mod_rate_wood;
|
||||
mod_rate_stone = p_mod_rate_stone;
|
||||
mod_rate_iron = p_mod_rate_iron;
|
||||
mod_rate_mana = p_mod_rate_mana;
|
||||
}
|
||||
void Weather::set_mod_percent(int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana) {
|
||||
mod_percent_food = p_mod_percent_food;
|
||||
mod_percent_wood = p_mod_percent_wood;
|
||||
@ -43,56 +24,23 @@ void Weather::set_mod_percent(int p_mod_percent_food, int p_mod_percent_wood, in
|
||||
mod_percent_iron = p_mod_percent_iron;
|
||||
mod_percent_mana = p_mod_percent_mana;
|
||||
}
|
||||
void Weather::set_assignments(int p_assignment1, int p_assignment2, int p_assignment3, int p_assignment4, int p_assignment5) {
|
||||
assignment1 = p_assignment1;
|
||||
assignment2 = p_assignment2;
|
||||
assignment3 = p_assignment3;
|
||||
assignment4 = p_assignment4;
|
||||
assignment5 = p_assignment5;
|
||||
}
|
||||
void Weather::set_technologies(int p_req_tech, int p_tech_group, int p_tech_secondary_group) {
|
||||
req_tech = p_req_tech;
|
||||
tech_group = p_tech_group;
|
||||
tech_secondary_group = p_tech_secondary_group;
|
||||
}
|
||||
|
||||
void Weather::set_all(
|
||||
const String &p_name, const String &p_description, const String &p_icon,
|
||||
int p_rank, int p_next_rank, int p_time_to_build, int p_creates, int p_num_creates, int p_score, int p_defense, int p_ability,
|
||||
int p_cost_food, int p_cost_wood, int p_cost_stone, int p_cost_iron, int p_cost_mana,
|
||||
int p_mod_max_food, int p_mod_max_wood, int p_mod_max_stone, int p_mod_max_iron, int p_mod_max_mana,
|
||||
double p_mod_rate_food, double p_mod_rate_wood, double p_mod_rate_stone, double p_mod_rate_iron, double p_mod_rate_mana,
|
||||
int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana,
|
||||
int p_assignment1, int p_assignment2, int p_assignment3, int p_assignment4, int p_assignment5,
|
||||
int p_req_tech, int p_tech_group, int p_tech_secondary_group) {
|
||||
const String &p_name, const String &p_description, const String &p_icon, const String &p_css,
|
||||
int p_effect,
|
||||
int p_mod_max_food, int p_mod_max_wood, int p_mod_max_stone, int p_mod_max_iron, int p_mod_max_mana,
|
||||
int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana) {
|
||||
|
||||
set_strings(p_name, p_description, p_icon);
|
||||
set_base_data(p_rank, p_next_rank, p_time_to_build, p_creates, p_num_creates, p_score, p_defense, p_ability);
|
||||
set_cost(p_cost_food, p_cost_wood, p_cost_stone, p_cost_iron, p_cost_mana);
|
||||
set_strings(p_name, p_description, p_icon, p_css);
|
||||
set_base_data(p_effect);
|
||||
set_mod_max(p_mod_max_food, p_mod_max_wood, p_mod_max_stone, p_mod_max_iron, p_mod_max_mana);
|
||||
set_mod_rate(p_mod_rate_food, p_mod_rate_wood, p_mod_rate_stone, p_mod_rate_iron, p_mod_rate_mana);
|
||||
set_mod_percent(p_mod_percent_food, p_mod_percent_wood, p_mod_percent_stone, p_mod_percent_iron, p_mod_percent_mana);
|
||||
set_assignments(p_assignment1, p_assignment2, p_assignment3, p_assignment4, p_assignment5);
|
||||
set_technologies(p_req_tech, p_tech_group, p_tech_secondary_group);
|
||||
}
|
||||
|
||||
Weather::Weather() :
|
||||
Resource() {
|
||||
|
||||
rank = 0;
|
||||
next_rank = 0;
|
||||
time_to_build = 0;
|
||||
creates = 0;
|
||||
num_creates = 0;
|
||||
score = 0;
|
||||
defense = 0;
|
||||
ability = 0;
|
||||
|
||||
cost_food = 0;
|
||||
cost_wood = 0;
|
||||
cost_stone = 0;
|
||||
cost_iron = 0;
|
||||
cost_mana = 0;
|
||||
effect = 0;
|
||||
|
||||
mod_max_food = 0;
|
||||
mod_max_wood = 0;
|
||||
@ -100,27 +48,11 @@ Weather::Weather() :
|
||||
mod_max_iron = 0;
|
||||
mod_max_mana = 0;
|
||||
|
||||
mod_rate_food = 0;
|
||||
mod_rate_wood = 0;
|
||||
mod_rate_stone = 0;
|
||||
mod_rate_iron = 0;
|
||||
mod_rate_mana = 0;
|
||||
|
||||
mod_percent_food = 0;
|
||||
mod_percent_wood = 0;
|
||||
mod_percent_stone = 0;
|
||||
mod_percent_iron = 0;
|
||||
mod_percent_mana = 0;
|
||||
|
||||
assignment1 = 0;
|
||||
assignment2 = 0;
|
||||
assignment3 = 0;
|
||||
assignment4 = 0;
|
||||
assignment5 = 0;
|
||||
|
||||
req_tech = 0;
|
||||
tech_group = 0;
|
||||
tech_secondary_group = 0;
|
||||
}
|
||||
|
||||
Weather::~Weather() {
|
||||
|
@ -11,22 +11,10 @@ class Weather : public Resource {
|
||||
public:
|
||||
String name;
|
||||
String description;
|
||||
String icon;
|
||||
String art;
|
||||
String css;
|
||||
|
||||
int rank;
|
||||
int next_rank;
|
||||
int time_to_build;
|
||||
int creates;
|
||||
int num_creates;
|
||||
int score;
|
||||
int defense;
|
||||
int ability;
|
||||
|
||||
int cost_food;
|
||||
int cost_wood;
|
||||
int cost_stone;
|
||||
int cost_iron;
|
||||
int cost_mana;
|
||||
int effect;
|
||||
|
||||
int mod_max_food;
|
||||
int mod_max_wood;
|
||||
@ -34,46 +22,22 @@ public:
|
||||
int mod_max_iron;
|
||||
int mod_max_mana;
|
||||
|
||||
double mod_rate_food;
|
||||
double mod_rate_wood;
|
||||
double mod_rate_stone;
|
||||
double mod_rate_iron;
|
||||
double mod_rate_mana;
|
||||
|
||||
int mod_percent_food;
|
||||
int mod_percent_wood;
|
||||
int mod_percent_stone;
|
||||
int mod_percent_iron;
|
||||
int mod_percent_mana;
|
||||
|
||||
int assignment1;
|
||||
int assignment2;
|
||||
int assignment3;
|
||||
int assignment4;
|
||||
int assignment5;
|
||||
|
||||
int req_tech;
|
||||
int tech_group;
|
||||
int tech_secondary_group;
|
||||
|
||||
void set_strings(const String &p_name, const String &p_description, const String &p_icon);
|
||||
void set_base_data(int p_rank, int p_next_rank, int p_time_to_build, int p_creates, int p_num_creates, int p_score, int p_defense, int p_ability);
|
||||
void set_cost(int p_cost_food, int p_cost_wood, int p_cost_stone, int p_cost_iron, int p_cost_mana);
|
||||
void set_strings(const String &p_name, const String &p_description, const String &p_art, const String &p_css);
|
||||
void set_base_data(int p_effect);
|
||||
void set_mod_max(int p_mod_max_food, int p_mod_max_wood, int p_mod_max_stone, int p_mod_max_iron, int p_mod_max_mana);
|
||||
void set_mod_rate(double p_mod_rate_food, double p_mod_rate_wood, double p_mod_rate_stone, double p_mod_rate_iron, double p_mod_rate_mana);
|
||||
void set_mod_percent(int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana);
|
||||
void set_assignments(int p_assignment1, int p_assignment2, int p_assignment3, int p_assignment4, int p_assignment5);
|
||||
void set_technologies(int p_req_tech, int p_tech_group, int p_tech_secondary_group);
|
||||
|
||||
void set_all(
|
||||
const String &p_name, const String &p_description, const String &p_icon,
|
||||
int p_rank, int p_next_rank, int p_time_to_build, int p_creates, int p_num_creates, int p_score, int p_defense, int p_ability,
|
||||
int p_cost_food, int p_cost_wood, int p_cost_stone, int p_cost_iron, int p_cost_mana,
|
||||
const String &p_name, const String &p_description, const String &p_icon, const String &p_css,
|
||||
int p_effect,
|
||||
int p_mod_max_food, int p_mod_max_wood, int p_mod_max_stone, int p_mod_max_iron, int p_mod_max_mana,
|
||||
double p_mod_rate_food, double p_mod_rate_wood, double p_mod_rate_stone, double p_mod_rate_iron, double p_mod_rate_mana,
|
||||
int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana,
|
||||
int p_assignment1, int p_assignment2, int p_assignment3, int p_assignment4, int p_assignment5,
|
||||
int p_req_tech, int p_tech_group, int p_tech_secondary_group);
|
||||
int p_mod_percent_food, int p_mod_percent_wood, int p_mod_percent_stone, int p_mod_percent_iron, int p_mod_percent_mana);
|
||||
|
||||
Weather();
|
||||
~Weather();
|
||||
|
@ -91,8 +91,6 @@ void WeatherController::admin_render_weather_list(Request *request) {
|
||||
}
|
||||
{
|
||||
b.fdiv(String::num(weather->id), "attr_box");
|
||||
b.fdiv(String::num(weather->rank), "attr_box");
|
||||
b.fdiv(String::num(weather->next_rank), "attr_box");
|
||||
b.fdiv(weather->name, "name");
|
||||
|
||||
b.div("actionbox")->f()->fa(request->get_url_root("edit/" + String::num(weather->id)), "Edit")->cdiv();
|
||||
@ -127,100 +125,13 @@ void WeatherController::admin_render_weather(Request *request, Ref<Weather> weat
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Name:", "name", show_post, weather->name, request->get_parameter("name"));
|
||||
ADMIN_EDIT_INPUT_TEXTAREA("Description:", "description", show_post, weather->description, request->get_parameter("description"));
|
||||
|
||||
b.div("row_edit");
|
||||
b.fdiv("Icon:", "edit_name");
|
||||
//todo I'm not sure yet how this worked originally
|
||||
//b.div("edit_input")->f()->input_image("icon", weather->icon)->f()->cdiv();
|
||||
b.div("edit_input")->f()->w("TODO")->cdiv();
|
||||
b.cdiv();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Rank:", "rank", show_post, String::num(weather->rank), request->get_parameter("rank"));
|
||||
|
||||
Vector<Ref<Weather> > nrbs = WeatherModel::get_singleton()->get_all();
|
||||
b.div("row_edit");
|
||||
b.fdiv("Next Rank:", "edit_name");
|
||||
b.div("edit_input");
|
||||
{
|
||||
b.select("next_rank", "drop");
|
||||
{
|
||||
int current_id = weather->id;
|
||||
int current_nr = weather->next_rank;
|
||||
|
||||
b.foption(String::num(0), "- None -", current_nr == 0);
|
||||
|
||||
for (int i = 0; i < nrbs.size(); ++i) {
|
||||
Ref<Weather> build = nrbs[i];
|
||||
|
||||
int id = build->id;
|
||||
|
||||
if (id == current_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
b.foption(String::num(id), build->name + " R" + String::num(build->rank), current_nr == id);
|
||||
}
|
||||
}
|
||||
b.cselect();
|
||||
}
|
||||
b.cdiv();
|
||||
b.cdiv();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Time to Build:", "time_to_build", show_post, String::num(weather->time_to_build), request->get_parameter("time_to_build"));
|
||||
//I think this was supposed to be an icon
|
||||
ADMIN_EDIT_INPUT_TEXT("Art:", "art", show_post, weather->art, request->get_parameter("art"));
|
||||
ADMIN_EDIT_INPUT_TEXT("CSS:", "css", show_post, weather->css, request->get_parameter("css"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Score:", "score", show_post, String::num(weather->score), request->get_parameter("score"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Defense:", "defense", show_post, String::num(weather->defense), request->get_parameter("defense"));
|
||||
|
||||
//TODO
|
||||
/*
|
||||
int ability;
|
||||
|
||||
<div class="row_edit">
|
||||
<div class="edit_name">
|
||||
Ability:
|
||||
</div>
|
||||
<div class="edit_input">
|
||||
<?=form_dropdown('ability', $opt_ability, $sability, $attr_drop); ?>
|
||||
</div>
|
||||
</div>
|
||||
*/
|
||||
|
||||
b.div("row_edit");
|
||||
b.fdiv("Ability:", "edit_name");
|
||||
b.div("edit_input")->f()->w("TODO")->cdiv();
|
||||
b.cdiv();
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Cost Food:", "cost_food", show_post, String::num(weather->cost_food), request->get_parameter("cost_food"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Cost Wood:", "cost_wood", show_post, String::num(weather->cost_wood), request->get_parameter("cost_wood"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Cost Stone:", "cost_stone", show_post, String::num(weather->cost_stone), request->get_parameter("cost_stone"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Cost Iron:", "cost_iron", show_post, String::num(weather->cost_iron), request->get_parameter("cost_iron"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Cost Mana:", "cost_mana", show_post, String::num(weather->cost_food), request->get_parameter("cost_mana"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
/*
|
||||
int creates;
|
||||
int num_creates;
|
||||
|
||||
<div class="row_edit">
|
||||
<div class="edit_name">
|
||||
Creates:
|
||||
</div>
|
||||
<div class="edit_input">
|
||||
<?=form_dropdown($name_creates, $optcre, $screate, $attr_creates); ?>
|
||||
X (max) <?=form_input($attr_num_creates); ?>
|
||||
</div>
|
||||
</div>
|
||||
*/
|
||||
|
||||
b.div("row_edit");
|
||||
b.fdiv("Creates:", "edit_name");
|
||||
b.div("edit_input")->f()->w("TODO")->cdiv();
|
||||
b.cdiv();
|
||||
ADMIN_EDIT_INPUT_TEXT("Effect:", "effect", show_post, String::num(weather->effect), request->get_parameter("effect"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
@ -232,41 +143,12 @@ void WeatherController::admin_render_weather(Request *request, Ref<Weather> weat
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Rate Food:", "mod_rate_food", show_post, String::num(weather->mod_rate_food), request->get_parameter("mod_rate_food"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Rate Wood:", "mod_rate_wood", show_post, String::num(weather->mod_rate_wood), request->get_parameter("mod_rate_wood"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Rate Stone:", "mod_rate_stone", show_post, String::num(weather->mod_rate_stone), request->get_parameter("mod_rate_stone"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Rate Iron:", "mod_rate_iron", show_post, String::num(weather->mod_rate_iron), request->get_parameter("mod_rate_iron"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Rate Mana:", "mod_rate_mana", show_post, String::num(weather->mod_rate_mana), request->get_parameter("mod_rate_mana"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Percent Food:", "mod_percent_food", show_post, String::num(weather->mod_percent_food), request->get_parameter("mod_percent_food"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Percent Wood:", "mod_percent_wood", show_post, String::num(weather->mod_percent_wood), request->get_parameter("mod_percent_wood"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Percent Stone:", "mod_percent_stone", show_post, String::num(weather->mod_percent_stone), request->get_parameter("mod_percent_stone"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Percent Iron:", "mod_percent_iron", show_post, String::num(weather->mod_percent_iron), request->get_parameter("mod_percent_iron"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Mod Percent Mana:", "mod_percent_mana", show_post, String::num(weather->mod_percent_mana), request->get_parameter("mod_percent_mana"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
//TODO <?=form_dropdown($name_assign1, $optass, $assign1, $attr_assign); ?>
|
||||
|
||||
ADMIN_EDIT_INPUT_TEXT("Assignment 1:", "assignment1", show_post, String::num(weather->assignment1), request->get_parameter("assignment1"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Assignment 2:", "assignment2", show_post, String::num(weather->assignment2), request->get_parameter("assignment2"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Assignment 3:", "assignment3", show_post, String::num(weather->assignment3), request->get_parameter("assignment3"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Assignment 4:", "assignment4", show_post, String::num(weather->assignment4), request->get_parameter("assignment4"));
|
||||
ADMIN_EDIT_INPUT_TEXT("Assignment 5:", "assignment5", show_post, String::num(weather->assignment5), request->get_parameter("assignment5"));
|
||||
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
|
||||
//TODO <?=form_dropdown($name_req_tech, $optreqtech, $selreqtech, $attr_req_tech); ?>
|
||||
ADMIN_EDIT_INPUT_TEXT("Required Technology:", "req_tech", show_post, String::num(weather->req_tech), request->get_parameter("req_tech"));
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
//TODO <?=form_dropdown($name_tech_group, $opttechgroup, $seltechgroup, $attr_assign);?>
|
||||
ADMIN_EDIT_INPUT_TEXT("Technology Group:", "tech_group", show_post, String::num(weather->tech_group), request->get_parameter("tech_group"));
|
||||
ADMIN_EDIT_LINE_SPACER();
|
||||
//TODO <?=form_dropdown($name_tech_secondary_group, $opttechgroup, $seltechsecgroup, $attr_tech_secondary_group); ?>
|
||||
ADMIN_EDIT_INPUT_TEXT("Secondary Technology Group:", "tech_secondary_group", show_post, String::num(weather->tech_secondary_group), request->get_parameter("tech_secondary_group"));
|
||||
|
||||
b.div("edit_submit")->f()->input_submit("Save", "submit")->f()->cdiv();
|
||||
|
||||
b.cform();
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
#define WEATHER_TABLE_NAME "weathers"
|
||||
|
||||
#define WEATHER_TABLE_COLUMNS "id, name, description, icon, rank, next_rank, time_to_build, creates, num_creates, score, defense, ability, cost_food, cost_wood, cost_stone, cost_iron, cost_mana, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_rate_food, mod_rate_wood, mod_rate_stone, mod_rate_iron, mod_rate_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana, assignment1, assignment2, assignment3, assignment4, assignment5, req_tech, tech_group, tech_secondary_group"
|
||||
#define WEATHER_TABLE_COLUMNS_NOID "name, description, icon, rank, next_rank, time_to_build, creates, num_creates, score, defense, ability, cost_food, cost_wood, cost_stone, cost_iron, cost_mana, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_rate_food, mod_rate_wood, mod_rate_stone, mod_rate_iron, mod_rate_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana, assignment1, assignment2, assignment3, assignment4, assignment5, req_tech, tech_group, tech_secondary_group"
|
||||
#define WEATHER_TABLE_COLUMNS "id, name, description, art, css, effect, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana"
|
||||
#define WEATHER_TABLE_COLUMNS_NOID "name, description, art, css, effect, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana"
|
||||
|
||||
Ref<Weather> WeatherModel::get_weather(const int id) {
|
||||
if (id == 0) {
|
||||
@ -77,22 +77,10 @@ void WeatherModel::save_weather(Ref<Weather> &weather) {
|
||||
|
||||
b->val(weather->name);
|
||||
b->val(weather->description);
|
||||
b->val(weather->icon);
|
||||
b->val(weather->art);
|
||||
b->val(weather->css);
|
||||
|
||||
b->val(weather->rank);
|
||||
b->val(weather->next_rank);
|
||||
b->val(weather->time_to_build);
|
||||
b->val(weather->creates);
|
||||
b->val(weather->num_creates);
|
||||
b->val(weather->score);
|
||||
b->val(weather->defense);
|
||||
b->val(weather->ability);
|
||||
|
||||
b->val(weather->cost_food);
|
||||
b->val(weather->cost_wood);
|
||||
b->val(weather->cost_stone);
|
||||
b->val(weather->cost_iron);
|
||||
b->val(weather->cost_mana);
|
||||
b->val(weather->effect);
|
||||
|
||||
b->val(weather->mod_max_food);
|
||||
b->val(weather->mod_max_wood);
|
||||
@ -100,28 +88,12 @@ void WeatherModel::save_weather(Ref<Weather> &weather) {
|
||||
b->val(weather->mod_max_iron);
|
||||
b->val(weather->mod_max_mana);
|
||||
|
||||
b->vald(weather->mod_rate_food);
|
||||
b->vald(weather->mod_rate_wood);
|
||||
b->vald(weather->mod_rate_stone);
|
||||
b->vald(weather->mod_rate_iron);
|
||||
b->vald(weather->mod_rate_mana);
|
||||
|
||||
b->val(weather->mod_percent_food);
|
||||
b->val(weather->mod_percent_wood);
|
||||
b->val(weather->mod_percent_stone);
|
||||
b->val(weather->mod_percent_iron);
|
||||
b->val(weather->mod_percent_mana);
|
||||
|
||||
b->val(weather->assignment1);
|
||||
b->val(weather->assignment2);
|
||||
b->val(weather->assignment3);
|
||||
b->val(weather->assignment4);
|
||||
b->val(weather->assignment5);
|
||||
|
||||
b->val(weather->req_tech);
|
||||
b->val(weather->tech_group);
|
||||
b->val(weather->tech_secondary_group);
|
||||
|
||||
b->cvalues();
|
||||
|
||||
b->end_command();
|
||||
@ -137,22 +109,10 @@ void WeatherModel::save_weather(Ref<Weather> &weather) {
|
||||
|
||||
b->setp("name", weather->name);
|
||||
b->setp("description", weather->description);
|
||||
b->setp("icon", weather->icon);
|
||||
b->setp("art", weather->art);
|
||||
b->setp("css", weather->css);
|
||||
|
||||
b->setp("userankrname", weather->rank);
|
||||
b->setp("next_rank", weather->next_rank);
|
||||
b->setp("time_to_build", weather->time_to_build);
|
||||
b->setp("creates", weather->creates);
|
||||
b->setp("num_creates", weather->num_creates);
|
||||
b->setp("score", weather->score);
|
||||
b->setp("defense", weather->defense);
|
||||
b->setp("ability", weather->ability);
|
||||
|
||||
b->setp("cost_food", weather->cost_food);
|
||||
b->setp("cost_wood", weather->cost_wood);
|
||||
b->setp("cost_stone", weather->cost_stone);
|
||||
b->setp("cost_iron", weather->cost_iron);
|
||||
b->setp("cost_mana", weather->cost_mana);
|
||||
b->setp("effect", weather->effect);
|
||||
|
||||
b->setp("mod_max_food", weather->mod_max_food);
|
||||
b->setp("mod_max_wood", weather->mod_max_wood);
|
||||
@ -160,28 +120,12 @@ void WeatherModel::save_weather(Ref<Weather> &weather) {
|
||||
b->setp("mod_max_iron", weather->mod_max_iron);
|
||||
b->setp("mod_max_mana", weather->mod_max_mana);
|
||||
|
||||
b->setpd("mod_rate_food", weather->mod_rate_food);
|
||||
b->setpd("mod_rate_wood", weather->mod_rate_wood);
|
||||
b->setpd("mod_rate_stone", weather->mod_rate_stone);
|
||||
b->setpd("mod_rate_iron", weather->mod_rate_iron);
|
||||
b->setpd("mod_rate_mana", weather->mod_rate_mana);
|
||||
|
||||
b->setp("mod_percent_food", weather->mod_percent_food);
|
||||
b->setp("mod_percent_wood", weather->mod_percent_wood);
|
||||
b->setp("mod_percent_stone", weather->mod_percent_stone);
|
||||
b->setp("mod_percent_iron", weather->mod_percent_iron);
|
||||
b->setp("mod_percent_mana", weather->mod_percent_mana);
|
||||
|
||||
b->setp("assignment1", weather->assignment1);
|
||||
b->setp("assignment2", weather->assignment2);
|
||||
b->setp("assignment3", weather->assignment3);
|
||||
b->setp("assignment4", weather->assignment4);
|
||||
b->setp("assignment5", weather->assignment5);
|
||||
|
||||
b->setp("req_tech", weather->req_tech);
|
||||
b->setp("tech_group", weather->tech_group);
|
||||
b->setp("tech_secondary_group", weather->tech_secondary_group);
|
||||
|
||||
b->cset();
|
||||
b->where()->wp("id", weather->id);
|
||||
|
||||
@ -197,50 +141,22 @@ void WeatherModel::parse_row(Ref<QueryResult> &result, Ref<Weather> &weather) {
|
||||
|
||||
weather->name = result->get_cell(1);
|
||||
weather->description = result->get_cell(2);
|
||||
weather->icon = result->get_cell(3);
|
||||
weather->art = result->get_cell(3);
|
||||
weather->css = result->get_cell(4);
|
||||
|
||||
weather->rank = result->get_cell_int(4);
|
||||
weather->next_rank = result->get_cell_int(5);
|
||||
weather->time_to_build = result->get_cell_int(6);
|
||||
weather->creates = result->get_cell_int(7);
|
||||
weather->num_creates = result->get_cell_int(8);
|
||||
weather->score = result->get_cell_int(9);
|
||||
weather->defense = result->get_cell_int(10);
|
||||
weather->ability = result->get_cell_int(11);
|
||||
weather->effect = result->get_cell_int(5);
|
||||
|
||||
weather->cost_food = result->get_cell_int(12);
|
||||
weather->cost_wood = result->get_cell_int(13);
|
||||
weather->cost_stone = result->get_cell_int(14);
|
||||
weather->cost_iron = result->get_cell_int(15);
|
||||
weather->cost_mana = result->get_cell_int(16);
|
||||
weather->mod_max_food = result->get_cell_int(6);
|
||||
weather->mod_max_wood = result->get_cell_int(7);
|
||||
weather->mod_max_stone = result->get_cell_int(8);
|
||||
weather->mod_max_iron = result->get_cell_int(9);
|
||||
weather->mod_max_mana = result->get_cell_int(10);
|
||||
|
||||
weather->mod_max_food = result->get_cell_int(17);
|
||||
weather->mod_max_wood = result->get_cell_int(18);
|
||||
weather->mod_max_stone = result->get_cell_int(19);
|
||||
weather->mod_max_iron = result->get_cell_int(20);
|
||||
weather->mod_max_mana = result->get_cell_int(21);
|
||||
|
||||
weather->mod_rate_food = result->get_cell_double(22);
|
||||
weather->mod_rate_wood = result->get_cell_double(23);
|
||||
weather->mod_rate_stone = result->get_cell_double(24);
|
||||
weather->mod_rate_iron = result->get_cell_double(25);
|
||||
weather->mod_rate_mana = result->get_cell_double(26);
|
||||
|
||||
weather->mod_percent_food = result->get_cell_int(27);
|
||||
weather->mod_percent_wood = result->get_cell_int(28);
|
||||
weather->mod_percent_stone = result->get_cell_int(29);
|
||||
weather->mod_percent_iron = result->get_cell_int(30);
|
||||
weather->mod_percent_mana = result->get_cell_int(31);
|
||||
|
||||
weather->assignment1 = result->get_cell_int(32);
|
||||
weather->assignment2 = result->get_cell_int(33);
|
||||
weather->assignment3 = result->get_cell_int(34);
|
||||
weather->assignment4 = result->get_cell_int(35);
|
||||
weather->assignment5 = result->get_cell_int(36);
|
||||
|
||||
weather->req_tech = result->get_cell_int(37);
|
||||
weather->tech_group = result->get_cell_int(38);
|
||||
weather->tech_secondary_group = result->get_cell_int(39);
|
||||
weather->mod_percent_food = result->get_cell_int(11);
|
||||
weather->mod_percent_wood = result->get_cell_int(12);
|
||||
weather->mod_percent_stone = result->get_cell_int(13);
|
||||
weather->mod_percent_iron = result->get_cell_int(14);
|
||||
weather->mod_percent_mana = result->get_cell_int(15);
|
||||
}
|
||||
|
||||
void WeatherModel::create_table() {
|
||||
@ -249,22 +165,10 @@ void WeatherModel::create_table() {
|
||||
tb->create_table(WEATHER_TABLE_NAME);
|
||||
tb->integer("id", 11)->auto_increment()->next_row();
|
||||
tb->varchar("name", 200)->not_null()->next_row();
|
||||
tb->varchar("description", 500)->not_null()->next_row();
|
||||
tb->varchar("icon", 500)->not_null()->next_row();
|
||||
tb->integer("rank", 11)->not_null()->next_row();
|
||||
tb->integer("next_rank", 11)->not_null()->next_row();
|
||||
tb->integer("time_to_build", 11)->not_null()->next_row();
|
||||
tb->integer("creates", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("num_creates", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("score", 11)->not_null()->next_row();
|
||||
tb->integer("defense", 11)->not_null()->next_row();
|
||||
tb->integer("ability", 11)->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->integer("cost_food", 11)->not_null()->next_row();
|
||||
tb->integer("cost_wood", 11)->not_null()->next_row();
|
||||
tb->integer("cost_stone", 11)->not_null()->next_row();
|
||||
tb->integer("cost_iron", 11)->not_null()->next_row();
|
||||
tb->integer("cost_mana", 11)->not_null()->next_row();
|
||||
tb->text("description")->not_null()->next_row();
|
||||
tb->varchar("art", 500)->not_null()->next_row();
|
||||
tb->text("css")->not_null()->next_row();
|
||||
tb->integer("effect", 11)->not_null()->next_row();
|
||||
|
||||
tb->integer("mod_max_food", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_max_wood", 11)->not_null()->defval("0")->next_row();
|
||||
@ -272,28 +176,12 @@ void WeatherModel::create_table() {
|
||||
tb->integer("mod_max_iron", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_max_mana", 11)->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->real_double("mod_rate_food")->not_null()->defval("0")->next_row();
|
||||
tb->real_double("mod_rate_wood")->not_null()->defval("0")->next_row();
|
||||
tb->real_double("mod_rate_stone")->not_null()->defval("0")->next_row();
|
||||
tb->real_double("mod_rate_iron")->not_null()->defval("0")->next_row();
|
||||
tb->real_double("mod_rate_mana")->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->integer("mod_percent_food", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_percent_wood", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_percent_stone", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_percent_iron", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("mod_percent_mana", 11)->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->integer("assignment1", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("assignment2", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("assignment3", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("assignment4", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("assignment5", 11)->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->integer("req_tech", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("tech_group", 11)->not_null()->defval("0")->next_row();
|
||||
tb->integer("tech_secondary_group", 11)->not_null()->defval("0")->next_row();
|
||||
|
||||
tb->primary_key("id");
|
||||
tb->ccreate_table();
|
||||
|
||||
@ -313,21 +201,13 @@ void WeatherModel::migrate() {
|
||||
}
|
||||
|
||||
void WeatherModel::add_default_data() {
|
||||
String table_columns = "id, name, description, icon, rank, next_rank, time_to_build, creates, num_creates, score, defense, ability, cost_food, cost_wood, cost_stone, cost_iron, cost_mana, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_rate_food, mod_rate_wood, mod_rate_stone, mod_rate_iron, mod_rate_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana, assignment1, assignment2, assignment3, assignment4, assignment5, req_tech, tech_group, tech_secondary_group";
|
||||
String table_columns = "id, name, description, art, css, effect, mod_max_food, mod_max_wood, mod_max_stone, mod_max_iron, mod_max_mana, mod_percent_food, mod_percent_wood, mod_percent_stone, mod_percent_iron, mod_percent_mana";
|
||||
|
||||
Ref<QueryBuilder> qb = DatabaseManager::get_singleton()->ddb->get_query_builder();
|
||||
|
||||
qb->begin_transaction()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(1, 'empty', '', 'empty/empty.png', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(2, 'Build in Progress', '', 'bip/bip.png', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(3, 'Corn Field', 'Produces food.', 'corn_field/r1.png', 1, 7, 20, 0, 0, 20, 1, 0, 60, 100, 10, 5, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 3, 0, 0, 2, 3)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(4, 'Lumber Mill', 'Your main wood producing weather.', 'lumber_mill/r1.png', 1, 0, 1000, 0, 0, 20, 0, 0, 30, 40, 50, 10, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 2)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(5, 'Stone Mine', 'Your main stone producing weather.', 'stone_mine/r1.png', 1, 0, 1000, 2, 20, 0, 0, 0, 30, 50, 20, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(6, 'House', 'Can create villagers.', 'house/r1.png', 1, 0, 20, 1, 10, 0, 0, 0, 50, 70, 30, 5, 0, 0, 0, 0, 0, 0, -0.005, -0.001, -0.001, -0.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(7, 'Corn Field', '', 'corn_field/r2.png', 2, 0, 20, 0, 0, 0, 0, 0, 40, 60, 20, 10, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 2, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(8, 'Farm', 'Creates villagers.', 'farm/r1.png', 1, 0, 80, 1, 20, 0, 0, 0, 50, 60, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(9, 'Iron Mine', 'Your main iron producing weather.', 'iron_mine/r1.png', 1, 0, 1000, 2, 100000, 0, 0, 0, 70, 30, 70, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(10, 'School', 'School', 'school/r1.png', 1, 0, 60, 2, 60, 0, 0, 0, 300, 300, 300, 300, 20, 0, 0, 0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 2)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(1, 'Sunny', 'Your maximum food increases by 1000, also increases food production by 10%.', 'E_NOTIMPL', 'sunny', 0, 1000, 0, 0, 0, 0, 10, 0, 0, 0, 0)")->end_command()->nl();
|
||||
qb->insert(WEATHER_TABLE_NAME, table_columns)->nl()->w("VALUES(2, 'Cold', 'Your max iron increases by 1000, also iron production increases by 10%.', 'E_NOTIMPL', 'cold', 0, 0, 0, 0, 1000, 0, 0, 0, 0, 10, 0)")->end_command()->nl();
|
||||
qb->commit();
|
||||
|
||||
qb->run_query();
|
||||
|
Loading…
Reference in New Issue
Block a user