diff --git a/Mourne-CI/sql/db_13_04_23.sql b/Mourne-CI/sql/db_13_04_23.sql index e86b958..c154b24 100644 --- a/Mourne-CI/sql/db_13_04_23.sql +++ b/Mourne-CI/sql/db_13_04_23.sql @@ -80,6 +80,7 @@ INSERT INTO `ai_units` (`id`, `name`, `icon`, `ability`, `can_carry`, `attack`, -- Table structure for table `assignments` -- +--done CREATE TABLE IF NOT EXISTS `assignments` ( `id` int(11) NOT NULL AUTO_INCREMENT, `unitid` int(11) NOT NULL, diff --git a/app/assignments/assignment.cpp b/app/assignments/assignment.cpp index f97f715..3c2d20d 100644 --- a/app/assignments/assignment.cpp +++ b/app/assignments/assignment.cpp @@ -1,27 +1,16 @@ #include "assignment.h" -void Assignment::set_strings(const String &p_name, const String &p_description, const String &p_icon) { - name = p_name; +void Assignment::set_strings(const String &p_description) { description = p_description; - icon = p_icon; } -void Assignment::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 Assignment::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 Assignment::set_base_data(int p_unitid, int p_max, int p_bonus_per_assigned, int p_spellid, int p_req_tech) { + unitid = p_unitid; + max = p_max; + bonus_per_assigned = p_bonus_per_assigned; + spellid = p_spellid; + req_tech = p_req_tech; } + void Assignment::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; @@ -43,56 +32,29 @@ void Assignment::set_mod_percent(int p_mod_percent_food, int p_mod_percent_wood, mod_percent_iron = p_mod_percent_iron; mod_percent_mana = p_mod_percent_mana; } -void Assignment::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 Assignment::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 Assignment::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_description, + int p_unitid, int p_max, int p_bonus_per_assigned, int p_spellid, int p_req_tech, + 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) { - 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_description); + set_base_data(p_unitid, p_max, p_bonus_per_assigned, p_spellid, p_req_tech); 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); } Assignment::Assignment() : 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; + unitid = 0; + max = 0; + bonus_per_assigned = 0; + spellid = 0; + req_tech = 0; mod_max_food = 0; mod_max_wood = 0; @@ -111,16 +73,6 @@ Assignment::Assignment() : 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; } Assignment::~Assignment() { diff --git a/app/assignments/assignment.h b/app/assignments/assignment.h index 5e92709..209cfa9 100644 --- a/app/assignments/assignment.h +++ b/app/assignments/assignment.h @@ -9,24 +9,11 @@ class Assignment : public Resource { RCPP_OBJECT(Assignment, Resource); public: - String name; - String description; - String icon; - - 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 unitid; + int max; + int bonus_per_assigned; + int spellid; + int req_tech; int mod_max_food; int mod_max_wood; @@ -46,34 +33,20 @@ public: int mod_percent_iron; int mod_percent_mana; - int assignment1; - int assignment2; - int assignment3; - int assignment4; - int assignment5; + String description; - 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_description); + void set_base_data(int p_unitid, int p_max, int p_bonus_per_assigned, int p_spellid, int p_req_tech); 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_description, + int p_unitid, int p_max, int p_bonus_per_assigned, int p_spellid, int p_req_tech, 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); Assignment(); ~Assignment(); diff --git a/app/assignments/assignment_controller.cpp b/app/assignments/assignment_controller.cpp index 9a6864c..74d6949 100644 --- a/app/assignments/assignment_controller.cpp +++ b/app/assignments/assignment_controller.cpp @@ -91,9 +91,7 @@ void AssignmentController::admin_render_assignment_list(Request *request) { } { b.fdiv(String::num(assignment->id), "attr_box"); - b.fdiv(String::num(assignment->rank), "attr_box"); - b.fdiv(String::num(assignment->next_rank), "attr_box"); - b.fdiv(assignment->name, "name"); + b.fdiv(assignment->description, "name"); b.div("actionbox")->f()->fa(request->get_url_root("edit/" + String::num(assignment->id)), "Edit")->cdiv(); } @@ -125,102 +123,13 @@ void AssignmentController::admin_render_assignment(Request *request, Refget_method() == HTTP_METHOD_POST && validation errors; - ADMIN_EDIT_INPUT_TEXT("Name:", "name", show_post, assignment->name, request->get_parameter("name")); - ADMIN_EDIT_INPUT_TEXTAREA("Description:", "description", show_post, assignment->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", assignment->icon)->f()->cdiv(); - b.div("edit_input")->f()->w("TODO")->cdiv(); - b.cdiv(); - - ADMIN_EDIT_INPUT_TEXT("Rank:", "rank", show_post, String::num(assignment->rank), request->get_parameter("rank")); - - Vector > nrbs = AssignmentModel::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 = assignment->id; - int current_nr = assignment->next_rank; - - b.foption(String::num(0), "- None -", current_nr == 0); - - for (int i = 0; i < nrbs.size(); ++i) { - Ref 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(assignment->time_to_build), request->get_parameter("time_to_build")); - - ADMIN_EDIT_LINE_SPACER(); - - ADMIN_EDIT_INPUT_TEXT("Score:", "score", show_post, String::num(assignment->score), request->get_parameter("score")); - ADMIN_EDIT_INPUT_TEXT("Defense:", "defense", show_post, String::num(assignment->defense), request->get_parameter("defense")); - - //TODO - /* - int ability; - -
-
- Ability: -
-
- -
-
- */ - - 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(assignment->cost_food), request->get_parameter("cost_food")); - ADMIN_EDIT_INPUT_TEXT("Cost Wood:", "cost_wood", show_post, String::num(assignment->cost_wood), request->get_parameter("cost_wood")); - ADMIN_EDIT_INPUT_TEXT("Cost Stone:", "cost_stone", show_post, String::num(assignment->cost_stone), request->get_parameter("cost_stone")); - ADMIN_EDIT_INPUT_TEXT("Cost Iron:", "cost_iron", show_post, String::num(assignment->cost_iron), request->get_parameter("cost_iron")); - ADMIN_EDIT_INPUT_TEXT("Cost Mana:", "cost_mana", show_post, String::num(assignment->cost_food), request->get_parameter("cost_mana")); - - ADMIN_EDIT_LINE_SPACER(); - -/* - int creates; - int num_creates; - -
-
- Creates: -
-
- - X (max) -
-
-*/ - - b.div("row_edit"); - b.fdiv("Creates:", "edit_name"); - b.div("edit_input")->f()->w("TODO")->cdiv(); - b.cdiv(); + //Todo make it a dropdown + ADMIN_EDIT_INPUT_TEXT("Unitid:", "unitid", show_post, String::num(assignment->unitid), request->get_parameter("unitid")); + ADMIN_EDIT_INPUT_TEXT("max:", "max", show_post, String::num(assignment->max), request->get_parameter("max")); + ADMIN_EDIT_INPUT_TEXT("bonus_per_assigned:", "bonus_per_assigned", show_post, String::num(assignment->bonus_per_assigned), request->get_parameter("bonus_per_assigned")); + ADMIN_EDIT_INPUT_TEXT("spellid:", "spellid", show_post, String::num(assignment->spellid), request->get_parameter("spellid")); + //Todo make it a dropdown + ADMIN_EDIT_INPUT_TEXT("req_tech:", "req_tech", show_post, String::num(assignment->req_tech), request->get_parameter("req_tech")); ADMIN_EDIT_LINE_SPACER(); @@ -248,24 +157,7 @@ void AssignmentController::admin_render_assignment(Request *request, Ref - - ADMIN_EDIT_INPUT_TEXT("Assignment 1:", "assignment1", show_post, String::num(assignment->assignment1), request->get_parameter("assignment1")); - ADMIN_EDIT_INPUT_TEXT("Assignment 2:", "assignment2", show_post, String::num(assignment->assignment2), request->get_parameter("assignment2")); - ADMIN_EDIT_INPUT_TEXT("Assignment 3:", "assignment3", show_post, String::num(assignment->assignment3), request->get_parameter("assignment3")); - ADMIN_EDIT_INPUT_TEXT("Assignment 4:", "assignment4", show_post, String::num(assignment->assignment4), request->get_parameter("assignment4")); - ADMIN_EDIT_INPUT_TEXT("Assignment 5:", "assignment5", show_post, String::num(assignment->assignment5), request->get_parameter("assignment5")); - - ADMIN_EDIT_LINE_SPACER(); - - //TODO - ADMIN_EDIT_INPUT_TEXT("Required Technology:", "req_tech", show_post, String::num(assignment->req_tech), request->get_parameter("req_tech")); - ADMIN_EDIT_LINE_SPACER(); - //TODO - ADMIN_EDIT_INPUT_TEXT("Technology Group:", "tech_group", show_post, String::num(assignment->tech_group), request->get_parameter("tech_group")); - ADMIN_EDIT_LINE_SPACER(); - //TODO - ADMIN_EDIT_INPUT_TEXT("Secondary Technology Group:", "tech_secondary_group", show_post, String::num(assignment->tech_secondary_group), request->get_parameter("tech_secondary_group")); + ADMIN_EDIT_INPUT_TEXTAREA("Description:", "description", show_post, assignment->description, request->get_parameter("description")); b.div("edit_submit")->f()->input_submit("Save", "submit")->f()->cdiv(); diff --git a/app/assignments/assignment_model.cpp b/app/assignments/assignment_model.cpp index fe5f5da..1a401f9 100644 --- a/app/assignments/assignment_model.cpp +++ b/app/assignments/assignment_model.cpp @@ -10,10 +10,10 @@ #include "assignment.h" -#define BUILDING_TABLE_NAME "assignments" +#define ASSIGNMENT_TABLE_NAME "assignments" -#define BUILDING_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 BUILDING_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 ASSIGNMENT_TABLE_COLUMNS "id, unitid, max, bonus_per_assigned, spellid, req_tech, 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, description" +#define ASSIGNMENT_TABLE_COLUMNS_NOID "unitid, max, bonus_per_assigned, spellid, req_tech, 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, description" Ref AssignmentModel::get_assignment(const int id) { if (id == 0) { @@ -22,8 +22,8 @@ Ref AssignmentModel::get_assignment(const int id) { Ref b = DatabaseManager::get_singleton()->ddb->get_query_builder(); - b->select(BUILDING_TABLE_COLUMNS); - b->from(BUILDING_TABLE_NAME); + b->select(ASSIGNMENT_TABLE_COLUMNS); + b->from(ASSIGNMENT_TABLE_NAME); b->where()->wp("id", id); @@ -46,8 +46,8 @@ Ref AssignmentModel::get_assignment(const int id) { Vector > AssignmentModel::get_all() { Ref b = DatabaseManager::get_singleton()->ddb->get_query_builder(); - b->select(BUILDING_TABLE_COLUMNS); - b->from(BUILDING_TABLE_NAME); + b->select(ASSIGNMENT_TABLE_COLUMNS); + b->from(ASSIGNMENT_TABLE_NAME); b->end_command(); //b->print(); @@ -71,28 +71,15 @@ void AssignmentModel::save_assignment(Ref &assignment) { Ref b = DatabaseManager::get_singleton()->ddb->get_query_builder(); if (assignment->id == 0) { - b->insert(BUILDING_TABLE_NAME, BUILDING_TABLE_COLUMNS_NOID); + b->insert(ASSIGNMENT_TABLE_NAME, ASSIGNMENT_TABLE_COLUMNS_NOID); b->values(); - b->val(assignment->name); - b->val(assignment->description); - b->val(assignment->icon); - - b->val(assignment->rank); - b->val(assignment->next_rank); - b->val(assignment->time_to_build); - b->val(assignment->creates); - b->val(assignment->num_creates); - b->val(assignment->score); - b->val(assignment->defense); - b->val(assignment->ability); - - b->val(assignment->cost_food); - b->val(assignment->cost_wood); - b->val(assignment->cost_stone); - b->val(assignment->cost_iron); - b->val(assignment->cost_mana); + b->val(assignment->unitid); + b->val(assignment->max); + b->val(assignment->bonus_per_assigned); + b->val(assignment->spellid); + b->val(assignment->req_tech); b->val(assignment->mod_max_food); b->val(assignment->mod_max_wood); @@ -112,15 +99,7 @@ void AssignmentModel::save_assignment(Ref &assignment) { b->val(assignment->mod_percent_iron); b->val(assignment->mod_percent_mana); - b->val(assignment->assignment1); - b->val(assignment->assignment2); - b->val(assignment->assignment3); - b->val(assignment->assignment4); - b->val(assignment->assignment5); - - b->val(assignment->req_tech); - b->val(assignment->tech_group); - b->val(assignment->tech_secondary_group); + b->val(assignment->description); b->cvalues(); @@ -132,27 +111,14 @@ void AssignmentModel::save_assignment(Ref &assignment) { assignment->id = r->get_last_insert_rowid(); } else { - b->update(BUILDING_TABLE_NAME); + b->update(ASSIGNMENT_TABLE_NAME); b->set(); - - b->setp("name", assignment->name); - b->setp("description", assignment->description); - b->setp("icon", assignment->icon); - - b->setp("userankrname", assignment->rank); - b->setp("next_rank", assignment->next_rank); - b->setp("time_to_build", assignment->time_to_build); - b->setp("creates", assignment->creates); - b->setp("num_creates", assignment->num_creates); - b->setp("score", assignment->score); - b->setp("defense", assignment->defense); - b->setp("ability", assignment->ability); - - b->setp("cost_food", assignment->cost_food); - b->setp("cost_wood", assignment->cost_wood); - b->setp("cost_stone", assignment->cost_stone); - b->setp("cost_iron", assignment->cost_iron); - b->setp("cost_mana", assignment->cost_mana); + + b->setp("unitid", assignment->unitid); + b->setp("max", assignment->max); + b->setp("bonus_per_assigned", assignment->bonus_per_assigned); + b->setp("spellid", assignment->spellid); + b->setp("req_tech", assignment->req_tech); b->setp("mod_max_food", assignment->mod_max_food); b->setp("mod_max_wood", assignment->mod_max_wood); @@ -172,15 +138,7 @@ void AssignmentModel::save_assignment(Ref &assignment) { b->setp("mod_percent_iron", assignment->mod_percent_iron); b->setp("mod_percent_mana", assignment->mod_percent_mana); - b->setp("assignment1", assignment->assignment1); - b->setp("assignment2", assignment->assignment2); - b->setp("assignment3", assignment->assignment3); - b->setp("assignment4", assignment->assignment4); - b->setp("assignment5", assignment->assignment5); - - b->setp("req_tech", assignment->req_tech); - b->setp("tech_group", assignment->tech_group); - b->setp("tech_secondary_group", assignment->tech_secondary_group); + b->setp("description", assignment->description); b->cset(); b->where()->wp("id", assignment->id); @@ -195,76 +153,44 @@ void AssignmentModel::parse_row(Ref &result, Ref &assig assignment->id = result->get_cell_int(0); - assignment->name = result->get_cell(1); - assignment->description = result->get_cell(2); - assignment->icon = result->get_cell(3); + assignment->unitid = result->get_cell_int(1); + assignment->max = result->get_cell_int(2); + assignment->bonus_per_assigned = result->get_cell_int(3); + assignment->spellid = result->get_cell_int(4); + assignment->req_tech = result->get_cell_int(5); - assignment->rank = result->get_cell_int(4); - assignment->next_rank = result->get_cell_int(5); - assignment->time_to_build = result->get_cell_int(6); - assignment->creates = result->get_cell_int(7); - assignment->num_creates = result->get_cell_int(8); - assignment->score = result->get_cell_int(9); - assignment->defense = result->get_cell_int(10); - assignment->ability = result->get_cell_int(11); + assignment->mod_max_food = result->get_cell_int(6); + assignment->mod_max_wood = result->get_cell_int(7); + assignment->mod_max_stone = result->get_cell_int(8); + assignment->mod_max_iron = result->get_cell_int(9); + assignment->mod_max_mana = result->get_cell_int(10); - assignment->cost_food = result->get_cell_int(12); - assignment->cost_wood = result->get_cell_int(13); - assignment->cost_stone = result->get_cell_int(14); - assignment->cost_iron = result->get_cell_int(15); - assignment->cost_mana = result->get_cell_int(16); + assignment->mod_rate_food = result->get_cell_double(11); + assignment->mod_rate_wood = result->get_cell_double(12); + assignment->mod_rate_stone = result->get_cell_double(13); + assignment->mod_rate_iron = result->get_cell_double(14); + assignment->mod_rate_mana = result->get_cell_double(15); - assignment->mod_max_food = result->get_cell_int(17); - assignment->mod_max_wood = result->get_cell_int(18); - assignment->mod_max_stone = result->get_cell_int(19); - assignment->mod_max_iron = result->get_cell_int(20); - assignment->mod_max_mana = result->get_cell_int(21); + assignment->mod_percent_food = result->get_cell_int(16); + assignment->mod_percent_wood = result->get_cell_int(17); + assignment->mod_percent_stone = result->get_cell_int(18); + assignment->mod_percent_iron = result->get_cell_int(19); + assignment->mod_percent_mana = result->get_cell_int(20); - assignment->mod_rate_food = result->get_cell_double(22); - assignment->mod_rate_wood = result->get_cell_double(23); - assignment->mod_rate_stone = result->get_cell_double(24); - assignment->mod_rate_iron = result->get_cell_double(25); - assignment->mod_rate_mana = result->get_cell_double(26); - - assignment->mod_percent_food = result->get_cell_int(27); - assignment->mod_percent_wood = result->get_cell_int(28); - assignment->mod_percent_stone = result->get_cell_int(29); - assignment->mod_percent_iron = result->get_cell_int(30); - assignment->mod_percent_mana = result->get_cell_int(31); - - assignment->assignment1 = result->get_cell_int(32); - assignment->assignment2 = result->get_cell_int(33); - assignment->assignment3 = result->get_cell_int(34); - assignment->assignment4 = result->get_cell_int(35); - assignment->assignment5 = result->get_cell_int(36); - - assignment->req_tech = result->get_cell_int(37); - assignment->tech_group = result->get_cell_int(38); - assignment->tech_secondary_group = result->get_cell_int(39); + assignment->description = result->get_cell(21); } void AssignmentModel::create_table() { Ref tb = DatabaseManager::get_singleton()->ddb->get_table_builder(); - tb->create_table(BUILDING_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->create_table(ASSIGNMENT_TABLE_NAME); - 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->integer("id", 11)->auto_increment()->next_row(); + tb->integer("unitid", 11)->not_null()->next_row(); //todo foreign key + tb->integer("max", 11)->not_null()->defval("1")->next_row(); + tb->integer("bonus_per_assigned", 11)->not_null()->defval("1")->next_row(); + tb->integer("spellid", 11)->not_null()->defval("0")->next_row(); //todo foreign key + tb->integer("req_tech", 11)->not_null()->defval("0")->next_row(); //todo foreign key tb->integer("mod_max_food", 11)->not_null()->defval("0")->next_row(); tb->integer("mod_max_wood", 11)->not_null()->defval("0")->next_row(); @@ -284,16 +210,7 @@ void AssignmentModel::create_table() { 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->text("description")->not_null()->next_row(); tb->primary_key("id"); tb->ccreate_table(); @@ -303,7 +220,7 @@ void AssignmentModel::create_table() { void AssignmentModel::drop_table() { Ref tb = DatabaseManager::get_singleton()->ddb->get_table_builder(); - tb->drop_table_if_exists(BUILDING_TABLE_NAME)->cdrop_table(); + tb->drop_table_if_exists(ASSIGNMENT_TABLE_NAME)->cdrop_table(); tb->run_query(); } @@ -313,21 +230,15 @@ void AssignmentModel::migrate() { } void AssignmentModel::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, unitid, max, bonus_per_assigned, spellid, req_tech, 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, description"; Ref qb = DatabaseManager::get_singleton()->ddb->get_query_builder(); qb->begin_transaction()->nl(); - qb->insert(BUILDING_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(BUILDING_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(BUILDING_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(BUILDING_TABLE_NAME, table_columns)->nl()->w("VALUES(4, 'Lumber Mill', 'Your main wood producing assignment.', '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(BUILDING_TABLE_NAME, table_columns)->nl()->w("VALUES(5, 'Stone Mine', 'Your main stone producing assignment.', '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(BUILDING_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(BUILDING_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(BUILDING_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(BUILDING_TABLE_NAME, table_columns)->nl()->w("VALUES(9, 'Iron Mine', 'Your main iron producing assignment.', '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(BUILDING_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(ASSIGNMENT_TABLE_NAME, table_columns)->nl()->w("VALUES(1, 1, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0.001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'This building will produce more food, every 2 villager you assign.')")->end_command()->nl(); + qb->insert(ASSIGNMENT_TABLE_NAME, table_columns)->nl()->w("VALUES(2, 1, 10, 5, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Every 5 Villager you assign, you get +30 Maximum Food.')")->end_command()->nl(); + qb->insert(ASSIGNMENT_TABLE_NAME, table_columns)->nl()->w("VALUES(3, 1, 10, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Assigning 10 Villager will grant you an awesome spell.')")->end_command()->nl(); + qb->insert(ASSIGNMENT_TABLE_NAME, table_columns)->nl()->w("VALUES(4, 1, 10, 10, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Adds a spell, and tests the requirements.')")->end_command()->nl(); qb->commit(); qb->run_query(); diff --git a/app/mourne_application.cpp b/app/mourne_application.cpp index 1a0e9b3..f319d16 100644 --- a/app/mourne_application.cpp +++ b/app/mourne_application.cpp @@ -259,11 +259,13 @@ void MourneApplication::setup_middleware() { void MourneApplication::migrate() { BuildingController::get_singleton()->migrate(); VillageController::get_singleton()->migrate(); + AssignmentController::get_singleton()->migrate(); } void MourneApplication::add_default_data() { BuildingController::get_singleton()->add_default_data(); VillageController::get_singleton()->add_default_data(); + AssignmentController::get_singleton()->add_default_data(); } void MourneApplication::compile_menu() { @@ -305,6 +307,7 @@ MourneApplication::MourneApplication() : _admin_panel = new AdminPanel(); _admin_panel->register_admin_controller("buildings", BuildingController::get_singleton()); + _admin_panel->register_admin_controller("assignments", AssignmentController::get_singleton()); HTMLBuilder b;