From fca82dba2b3d49b16ca69910cdc863f6aaad0919 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Mon, 5 Jun 2023 02:06:18 +0200 Subject: [PATCH] Adding more changes. --- dbicdh/PostgreSQL/deploy/2/001-auto.sql | 257 ++++ dbicdh/PostgreSQL/deploy/3/001-auto.sql | 256 ++++ dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql | 48 + dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql | 21 + dbicdh/_source/deploy/2/001-auto.yml | 1273 +++++++++++++++++ dbicdh/_source/deploy/3/001-auto.yml | 1262 ++++++++++++++++ js-src/components/pj-creation-menu.tsx | 77 +- lib/LasTres.pm | 2 + lib/LasTres/Area.pm | 2 +- lib/LasTres/Controller/PJ.pm | 174 ++- lib/LasTres/Controller/Race.pm | 29 + lib/LasTres/DAO/Equipments.pm | 20 + lib/LasTres/DAO/Inventories.pm | 18 + lib/LasTres/DAO/PJs.pm | 23 + lib/LasTres/DAO/Players.pm | 3 - lib/LasTres/DAO/SkillLikeLists.pm | 18 + lib/LasTres/DAO/Stats.pm | 20 + lib/LasTres/DAO/Teams.pm | 20 + lib/LasTres/PJ.pm | 137 ++ lib/LasTres/Planet/Bahdder.pm | 44 +- lib/LasTres/Planet/Bahdder/BosqueDelHeroe.pm | 63 +- .../Bahdder/BosqueDelHeroe/BosqueDelHeroeI.pm | 52 +- .../BosqueDelHeroeI/TribuDeLaLima.pm | 57 +- lib/LasTres/Race.pm | 12 +- lib/LasTres/Race/Aldimor.pm | 76 +- lib/LasTres/Races.pm | 19 +- lib/LasTres/Schema.pm | 2 +- lib/LasTres/Schema/Result/PJ.pm | 19 +- lib/LasTres/Schema/Result/Stats.pm | 11 +- lib/LasTres/Schema/Result/Team.pm | 2 +- lib/LasTres/Stats.pm | 88 ++ public/js/bundle.js | 2 +- 32 files changed, 3996 insertions(+), 111 deletions(-) create mode 100644 dbicdh/PostgreSQL/deploy/2/001-auto.sql create mode 100644 dbicdh/PostgreSQL/deploy/3/001-auto.sql create mode 100644 dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql create mode 100644 dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql create mode 100644 dbicdh/_source/deploy/2/001-auto.yml create mode 100644 dbicdh/_source/deploy/3/001-auto.yml create mode 100644 lib/LasTres/Controller/Race.pm create mode 100644 lib/LasTres/DAO/Equipments.pm create mode 100644 lib/LasTres/DAO/Inventories.pm create mode 100644 lib/LasTres/DAO/PJs.pm create mode 100644 lib/LasTres/DAO/SkillLikeLists.pm create mode 100644 lib/LasTres/DAO/Stats.pm create mode 100644 lib/LasTres/DAO/Teams.pm create mode 100644 lib/LasTres/PJ.pm create mode 100644 lib/LasTres/Stats.pm diff --git a/dbicdh/PostgreSQL/deploy/2/001-auto.sql b/dbicdh/PostgreSQL/deploy/2/001-auto.sql new file mode 100644 index 0000000..81a9c4c --- /dev/null +++ b/dbicdh/PostgreSQL/deploy/2/001-auto.sql @@ -0,0 +1,257 @@ +-- +-- Created by SQL::Translator::Producer::PostgreSQL +-- Created on Sun Jun 4 15:33:06 2023 +-- +; +-- +-- Table: equipment +-- +CREATE TABLE "equipment" ( + "uuid" uuid NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: inventories +-- +CREATE TABLE "inventories" ( + "uuid" uuid NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: players +-- +CREATE TABLE "players" ( + "uuid" uuid NOT NULL, + "username" text NOT NULL, + "encrypted_password" text NOT NULL, + "email" text NOT NULL, + "verified" boolean NOT NULL, + "verification_token" text, + "register_date" timestamp DEFAULT NOW() NOT NULL, + "last_activity" timestamp DEFAULT NOW() NOT NULL, + PRIMARY KEY ("uuid"), + CONSTRAINT "unique_constraint_email" UNIQUE ("email"), + CONSTRAINT "unique_constraint_username" UNIQUE ("username") +); + +; +-- +-- Table: skill_like_lists +-- +CREATE TABLE "skill_like_lists" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: stats +-- +CREATE TABLE "stats" ( + "uuid" uuid NOT NULL, + "health" integer NOT NULL, + "mana" integer NOT NULL, + "strength" integer NOT NULL, + "resistance" integer NOT NULL, + "magic" integer NOT NULL, + "speed" integer NOT NULL, + "intelligence" integer NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: equipment_items +-- +CREATE TABLE "equipment_items" ( + "kind" text NOT NULL, + "equipment" uuid NOT NULL, + "identifier" text NOT NULL, + "quantity" integer NOT NULL, + PRIMARY KEY ("kind", "equipment") +); +CREATE INDEX "equipment_items_idx_equipment" on "equipment_items" ("equipment"); + +; +-- +-- Table: inventory_items +-- +CREATE TABLE "inventory_items" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "inventory" uuid NOT NULL, + "identifier" text NOT NULL, + "quantity" integer NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "inventory_items_idx_inventory" on "inventory_items" ("inventory"); + +; +-- +-- Table: skill_like_items +-- +CREATE TABLE "skill_like_items" ( + "identifier" text NOT NULL, + "owner_list" uuid NOT NULL, + "level" integer DEFAULT 1 NOT NULL, + PRIMARY KEY ("identifier", "owner_list") +); +CREATE INDEX "skill_like_items_idx_owner_list" on "skill_like_items" ("owner_list"); + +; +-- +-- Table: teams +-- +CREATE TABLE "teams" ( + "uuid" uuid NOT NULL, + "leader" uuid NOT NULL, + "name" text NOT NULL, + "planet" text NOT NULL, + "super_area" text NOT NULL, + "area" text NOT NULL, + "location" text NOT NULL, + PRIMARY KEY ("uuid"), + CONSTRAINT "u_name" UNIQUE ("name") +); +CREATE INDEX "teams_idx_leader" on "teams" ("leader"); + +; +-- +-- Table: player_pjs +-- +CREATE TABLE "player_pjs" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "owner" uuid NOT NULL, + "full_name" text NOT NULL, + "short_name" text NOT NULL, + "nick" text NOT NULL, + "race" text NOT NULL, + "team" uuid NOT NULL, + "creation_date" timestamp DEFAULT NOW() NOT NULL, + "last_activity" timestamp DEFAULT NOW() NOT NULL, + "level" integer DEFAULT 1 NOT NULL, + "exp" integer DEFAULT 1 NOT NULL, + "equipment" uuid NOT NULL, + "born_stats" uuid NOT NULL, + "training_stats" uuid NOT NULL, + "skills" uuid NOT NULL, + "spells" uuid NOT NULL, + "inventory" uuid NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "player_pjs_idx_born_stats" on "player_pjs" ("born_stats"); +CREATE INDEX "player_pjs_idx_equipment" on "player_pjs" ("equipment"); +CREATE INDEX "player_pjs_idx_inventory" on "player_pjs" ("inventory"); +CREATE INDEX "player_pjs_idx_owner" on "player_pjs" ("owner"); +CREATE INDEX "player_pjs_idx_skills" on "player_pjs" ("skills"); +CREATE INDEX "player_pjs_idx_spells" on "player_pjs" ("spells"); +CREATE INDEX "player_pjs_idx_team" on "player_pjs" ("team"); +CREATE INDEX "player_pjs_idx_training_stats" on "player_pjs" ("training_stats"); + +; +-- +-- Table: player_companion_npcs +-- +CREATE TABLE "player_companion_npcs" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "owner" uuid NOT NULL, + "identifier" text NOT NULL, + "nick" text, + "race" text NOT NULL, + "level" integer DEFAULT 1 NOT NULL, + "exp" integer DEFAULT 1 NOT NULL, + "equipment" uuid NOT NULL, + "stats" uuid NOT NULL, + "skills" uuid NOT NULL, + "spells" uuid NOT NULL, + "inventory" uuid NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "player_companion_npcs_idx_equipment" on "player_companion_npcs" ("equipment"); +CREATE INDEX "player_companion_npcs_idx_inventory" on "player_companion_npcs" ("inventory"); +CREATE INDEX "player_companion_npcs_idx_owner" on "player_companion_npcs" ("owner"); +CREATE INDEX "player_companion_npcs_idx_skills" on "player_companion_npcs" ("skills"); +CREATE INDEX "player_companion_npcs_idx_spells" on "player_companion_npcs" ("spells"); +CREATE INDEX "player_companion_npcs_idx_stats" on "player_companion_npcs" ("stats"); + +; +-- +-- Foreign Key Definitions +-- + +; +ALTER TABLE "equipment_items" ADD CONSTRAINT "equipment_items_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "inventory_items" ADD CONSTRAINT "inventory_items_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "skill_like_items" ADD CONSTRAINT "skill_like_items_fk_owner_list" FOREIGN KEY ("owner_list") + REFERENCES "skill_like_lists" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "teams" ADD CONSTRAINT "teams_fk_leader" FOREIGN KEY ("leader") + REFERENCES "player_pjs" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_born_stats" FOREIGN KEY ("born_stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_owner" FOREIGN KEY ("owner") + REFERENCES "players" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_skills" FOREIGN KEY ("skills") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_spells" FOREIGN KEY ("spells") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_team" FOREIGN KEY ("team") + REFERENCES "teams" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_training_stats" FOREIGN KEY ("training_stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_owner" FOREIGN KEY ("owner") + REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_skills" FOREIGN KEY ("skills") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_spells" FOREIGN KEY ("spells") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_stats" FOREIGN KEY ("stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; diff --git a/dbicdh/PostgreSQL/deploy/3/001-auto.sql b/dbicdh/PostgreSQL/deploy/3/001-auto.sql new file mode 100644 index 0000000..13fbb47 --- /dev/null +++ b/dbicdh/PostgreSQL/deploy/3/001-auto.sql @@ -0,0 +1,256 @@ +-- +-- Created by SQL::Translator::Producer::PostgreSQL +-- Created on Mon Jun 5 01:39:56 2023 +-- +; +-- +-- Table: equipment +-- +CREATE TABLE "equipment" ( + "uuid" uuid NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: inventories +-- +CREATE TABLE "inventories" ( + "uuid" uuid NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: players +-- +CREATE TABLE "players" ( + "uuid" uuid NOT NULL, + "username" text NOT NULL, + "encrypted_password" text NOT NULL, + "email" text NOT NULL, + "verified" boolean NOT NULL, + "verification_token" text, + "register_date" timestamp DEFAULT NOW() NOT NULL, + "last_activity" timestamp DEFAULT NOW() NOT NULL, + PRIMARY KEY ("uuid"), + CONSTRAINT "unique_constraint_email" UNIQUE ("email"), + CONSTRAINT "unique_constraint_username" UNIQUE ("username") +); + +; +-- +-- Table: skill_like_lists +-- +CREATE TABLE "skill_like_lists" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: stats +-- +CREATE TABLE "stats" ( + "uuid" uuid NOT NULL, + "health" integer NOT NULL, + "mana" integer NOT NULL, + "strength" integer NOT NULL, + "resistance" integer NOT NULL, + "magic" integer NOT NULL, + "speed" integer NOT NULL, + "intelligence" integer NOT NULL, + PRIMARY KEY ("uuid") +); + +; +-- +-- Table: equipment_items +-- +CREATE TABLE "equipment_items" ( + "kind" text NOT NULL, + "equipment" uuid NOT NULL, + "identifier" text NOT NULL, + "quantity" integer NOT NULL, + PRIMARY KEY ("kind", "equipment") +); +CREATE INDEX "equipment_items_idx_equipment" on "equipment_items" ("equipment"); + +; +-- +-- Table: inventory_items +-- +CREATE TABLE "inventory_items" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "inventory" uuid NOT NULL, + "identifier" text NOT NULL, + "quantity" integer NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "inventory_items_idx_inventory" on "inventory_items" ("inventory"); + +; +-- +-- Table: skill_like_items +-- +CREATE TABLE "skill_like_items" ( + "identifier" text NOT NULL, + "owner_list" uuid NOT NULL, + "level" integer DEFAULT 1 NOT NULL, + PRIMARY KEY ("identifier", "owner_list") +); +CREATE INDEX "skill_like_items_idx_owner_list" on "skill_like_items" ("owner_list"); + +; +-- +-- Table: teams +-- +CREATE TABLE "teams" ( + "uuid" uuid NOT NULL, + "leader" uuid, + "name" text NOT NULL, + "planet" text NOT NULL, + "super_area" text NOT NULL, + "area" text NOT NULL, + "location" text NOT NULL, + PRIMARY KEY ("uuid"), + CONSTRAINT "u_name" UNIQUE ("name") +); +CREATE INDEX "teams_idx_leader" on "teams" ("leader"); + +; +-- +-- Table: player_pjs +-- +CREATE TABLE "player_pjs" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "owner" uuid NOT NULL, + "full_name" text NOT NULL, + "short_name" text NOT NULL, + "nick" text NOT NULL, + "race" text NOT NULL, + "team" uuid NOT NULL, + "creation_date" timestamp DEFAULT NOW() NOT NULL, + "last_activity" timestamp DEFAULT NOW() NOT NULL, + "experience" integer DEFAULT 1 NOT NULL, + "equipment" uuid NOT NULL, + "born_stats" uuid NOT NULL, + "training_stats" uuid NOT NULL, + "skills" uuid NOT NULL, + "spells" uuid NOT NULL, + "inventory" uuid NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "player_pjs_idx_born_stats" on "player_pjs" ("born_stats"); +CREATE INDEX "player_pjs_idx_equipment" on "player_pjs" ("equipment"); +CREATE INDEX "player_pjs_idx_inventory" on "player_pjs" ("inventory"); +CREATE INDEX "player_pjs_idx_owner" on "player_pjs" ("owner"); +CREATE INDEX "player_pjs_idx_skills" on "player_pjs" ("skills"); +CREATE INDEX "player_pjs_idx_spells" on "player_pjs" ("spells"); +CREATE INDEX "player_pjs_idx_team" on "player_pjs" ("team"); +CREATE INDEX "player_pjs_idx_training_stats" on "player_pjs" ("training_stats"); + +; +-- +-- Table: player_companion_npcs +-- +CREATE TABLE "player_companion_npcs" ( + "uuid" uuid DEFAULT uuid_generate_v4() NOT NULL, + "owner" uuid NOT NULL, + "identifier" text NOT NULL, + "nick" text, + "race" text NOT NULL, + "level" integer DEFAULT 1 NOT NULL, + "exp" integer DEFAULT 1 NOT NULL, + "equipment" uuid NOT NULL, + "stats" uuid NOT NULL, + "skills" uuid NOT NULL, + "spells" uuid NOT NULL, + "inventory" uuid NOT NULL, + PRIMARY KEY ("uuid") +); +CREATE INDEX "player_companion_npcs_idx_equipment" on "player_companion_npcs" ("equipment"); +CREATE INDEX "player_companion_npcs_idx_inventory" on "player_companion_npcs" ("inventory"); +CREATE INDEX "player_companion_npcs_idx_owner" on "player_companion_npcs" ("owner"); +CREATE INDEX "player_companion_npcs_idx_skills" on "player_companion_npcs" ("skills"); +CREATE INDEX "player_companion_npcs_idx_spells" on "player_companion_npcs" ("spells"); +CREATE INDEX "player_companion_npcs_idx_stats" on "player_companion_npcs" ("stats"); + +; +-- +-- Foreign Key Definitions +-- + +; +ALTER TABLE "equipment_items" ADD CONSTRAINT "equipment_items_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "inventory_items" ADD CONSTRAINT "inventory_items_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "skill_like_items" ADD CONSTRAINT "skill_like_items_fk_owner_list" FOREIGN KEY ("owner_list") + REFERENCES "skill_like_lists" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "teams" ADD CONSTRAINT "teams_fk_leader" FOREIGN KEY ("leader") + REFERENCES "player_pjs" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_born_stats" FOREIGN KEY ("born_stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_owner" FOREIGN KEY ("owner") + REFERENCES "players" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_skills" FOREIGN KEY ("skills") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_spells" FOREIGN KEY ("spells") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_team" FOREIGN KEY ("team") + REFERENCES "teams" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_pjs" ADD CONSTRAINT "player_pjs_fk_training_stats" FOREIGN KEY ("training_stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_equipment" FOREIGN KEY ("equipment") + REFERENCES "equipment" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_inventory" FOREIGN KEY ("inventory") + REFERENCES "inventories" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_owner" FOREIGN KEY ("owner") + REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_skills" FOREIGN KEY ("skills") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_spells" FOREIGN KEY ("spells") + REFERENCES "skill_like_lists" ("uuid") DEFERRABLE; + +; +ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_stats" FOREIGN KEY ("stats") + REFERENCES "stats" ("uuid") DEFERRABLE; + +; diff --git a/dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql b/dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql new file mode 100644 index 0000000..2b863f1 --- /dev/null +++ b/dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql @@ -0,0 +1,48 @@ +-- Convert schema '/home/sergio/LasTres/script/../dbicdh/_source/deploy/1/001-auto.yml' to '/home/sergio/LasTres/script/../dbicdh/_source/deploy/2/001-auto.yml':; + +; +BEGIN; + +; +ALTER TABLE player_pjs DROP CONSTRAINT player_pjs_fk_owner; + +; +ALTER TABLE player_pjs DROP CONSTRAINT player_pjs_fk_stats; + +; +DROP INDEX player_pjs_idx_stats; + +; +ALTER TABLE player_pjs DROP COLUMN stats; + +; +ALTER TABLE player_pjs ADD COLUMN born_stats uuid NOT NULL; + +; +ALTER TABLE player_pjs ADD COLUMN training_stats uuid NOT NULL; + +; +CREATE INDEX player_pjs_idx_born_stats on player_pjs (born_stats); + +; +CREATE INDEX player_pjs_idx_training_stats on player_pjs (training_stats); + +; +ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_born_stats FOREIGN KEY (born_stats) + REFERENCES stats (uuid) DEFERRABLE; + +; +ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_owner FOREIGN KEY (owner) + REFERENCES players (uuid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE; + +; +ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_training_stats FOREIGN KEY (training_stats) + REFERENCES stats (uuid) DEFERRABLE; + +; +ALTER TABLE stats DROP COLUMN charisma; + +; + +COMMIT; + diff --git a/dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql b/dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql new file mode 100644 index 0000000..9593ff5 --- /dev/null +++ b/dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql @@ -0,0 +1,21 @@ +-- Convert schema '/home/sergio/LasTres/script/../dbicdh/_source/deploy/2/001-auto.yml' to '/home/sergio/LasTres/script/../dbicdh/_source/deploy/3/001-auto.yml':; + +; +BEGIN; + +; +ALTER TABLE player_pjs DROP COLUMN level; + +; +ALTER TABLE player_pjs DROP COLUMN exp; + +; +ALTER TABLE player_pjs ADD COLUMN experience integer DEFAULT 1 NOT NULL; + +; +ALTER TABLE teams ALTER COLUMN leader DROP NOT NULL; + +; + +COMMIT; + diff --git a/dbicdh/_source/deploy/2/001-auto.yml b/dbicdh/_source/deploy/2/001-auto.yml new file mode 100644 index 0000000..e653779 --- /dev/null +++ b/dbicdh/_source/deploy/2/001-auto.yml @@ -0,0 +1,1273 @@ +--- +schema: + procedures: {} + tables: + equipment: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: equipment + options: [] + order: 1 + equipment_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - kind + - equipment + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: equipment_items_fk_equipment + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + fields: + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: equipment + order: 2 + size: + - 0 + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + kind: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: kind + order: 1 + size: + - 0 + quantity: + data_type: Integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: quantity + order: 4 + size: + - 0 + indices: + - fields: + - equipment + name: equipment_items_idx_equipment + options: [] + type: NORMAL + name: equipment_items + options: [] + order: 6 + inventories: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: inventories + options: [] + order: 2 + inventory_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: inventory_items_fk_inventory + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + fields: + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 2 + size: + - 0 + quantity: + data_type: Integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: quantity + order: 4 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - inventory + name: inventory_items_idx_inventory + options: [] + type: NORMAL + name: inventory_items + options: [] + order: 7 + player_companion_npcs: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: player_companion_npcs_fk_equipment + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: player_companion_npcs_fk_inventory + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - owner + match_type: '' + name: player_companion_npcs_fk_owner + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: player_pjs + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - skills + match_type: '' + name: player_companion_npcs_fk_skills + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - spells + match_type: '' + name: player_companion_npcs_fk_spells + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - stats + match_type: '' + name: player_companion_npcs_fk_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + fields: + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: equipment + order: 8 + size: + - 0 + exp: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: exp + order: 7 + size: + - 0 + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 12 + size: + - 0 + level: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: level + order: 6 + size: + - 0 + nick: + data_type: text + default_value: ~ + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: nick + order: 4 + size: + - 0 + owner: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: owner + order: 2 + size: + - 0 + race: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: race + order: 5 + size: + - 0 + skills: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: skills + order: 10 + size: + - 0 + spells: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: spells + order: 11 + size: + - 0 + stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: stats + order: 9 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - equipment + name: player_companion_npcs_idx_equipment + options: [] + type: NORMAL + - fields: + - inventory + name: player_companion_npcs_idx_inventory + options: [] + type: NORMAL + - fields: + - owner + name: player_companion_npcs_idx_owner + options: [] + type: NORMAL + - fields: + - skills + name: player_companion_npcs_idx_skills + options: [] + type: NORMAL + - fields: + - spells + name: player_companion_npcs_idx_spells + options: [] + type: NORMAL + - fields: + - stats + name: player_companion_npcs_idx_stats + options: [] + type: NORMAL + name: player_companion_npcs + options: [] + order: 11 + player_pjs: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - born_stats + match_type: '' + name: player_pjs_fk_born_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: player_pjs_fk_equipment + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: player_pjs_fk_inventory + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - owner + match_type: '' + name: player_pjs_fk_owner + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: players + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - skills + match_type: '' + name: player_pjs_fk_skills + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - spells + match_type: '' + name: player_pjs_fk_spells + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - team + match_type: '' + name: player_pjs_fk_team + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: teams + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - training_stats + match_type: '' + name: player_pjs_fk_training_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + fields: + born_stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: born_stats + order: 13 + size: + - 0 + creation_date: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: creation_date + order: 8 + size: + - 0 + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: equipment + order: 12 + size: + - 0 + exp: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: exp + order: 11 + size: + - 0 + full_name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: full_name + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 17 + size: + - 0 + last_activity: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: last_activity + order: 9 + size: + - 0 + level: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: level + order: 10 + size: + - 0 + nick: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: nick + order: 5 + size: + - 0 + owner: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: owner + order: 2 + size: + - 0 + race: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: race + order: 6 + size: + - 0 + short_name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: short_name + order: 4 + size: + - 0 + skills: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: skills + order: 15 + size: + - 0 + spells: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: spells + order: 16 + size: + - 0 + team: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: team + order: 7 + size: + - 0 + training_stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: training_stats + order: 14 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - born_stats + name: player_pjs_idx_born_stats + options: [] + type: NORMAL + - fields: + - equipment + name: player_pjs_idx_equipment + options: [] + type: NORMAL + - fields: + - inventory + name: player_pjs_idx_inventory + options: [] + type: NORMAL + - fields: + - owner + name: player_pjs_idx_owner + options: [] + type: NORMAL + - fields: + - skills + name: player_pjs_idx_skills + options: [] + type: NORMAL + - fields: + - spells + name: player_pjs_idx_spells + options: [] + type: NORMAL + - fields: + - team + name: player_pjs_idx_team + options: [] + type: NORMAL + - fields: + - training_stats + name: player_pjs_idx_training_stats + options: [] + type: NORMAL + name: player_pjs + options: [] + order: 10 + players: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - email + match_type: '' + name: unique_constraint_email + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + - deferrable: 1 + expression: '' + fields: + - username + match_type: '' + name: unique_constraint_username + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + fields: + email: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: email + order: 4 + size: + - 0 + encrypted_password: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: encrypted_password + order: 3 + size: + - 0 + last_activity: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: last_activity + order: 8 + size: + - 0 + register_date: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: register_date + order: 7 + size: + - 0 + username: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: username + order: 2 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + verification_token: + data_type: text + default_value: ~ + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: verification_token + order: 6 + size: + - 0 + verified: + data_type: boolean + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: verified + order: 5 + size: + - 0 + indices: [] + name: players + options: [] + order: 3 + skill_like_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - identifier + - owner_list + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - owner_list + match_type: '' + name: skill_like_items_fk_owner_list + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + fields: + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: identifier + order: 1 + size: + - 0 + level: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: level + order: 3 + size: + - 0 + owner_list: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: owner_list + order: 2 + size: + - 0 + indices: + - fields: + - owner_list + name: skill_like_items_idx_owner_list + options: [] + type: NORMAL + name: skill_like_items + options: [] + order: 8 + skill_like_lists: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: skill_like_lists + options: [] + order: 4 + stats: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + health: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: health + order: 2 + size: + - 0 + intelligence: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: intelligence + order: 8 + size: + - 0 + magic: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: magic + order: 6 + size: + - 0 + mana: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: mana + order: 3 + size: + - 0 + resistance: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: resistance + order: 5 + size: + - 0 + speed: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: speed + order: 7 + size: + - 0 + strength: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: strength + order: 4 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: stats + options: [] + order: 5 + teams: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - name + match_type: '' + name: u_name + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + - deferrable: 1 + expression: '' + fields: + - leader + match_type: '' + name: teams_fk_leader + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: player_pjs + type: FOREIGN KEY + fields: + area: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: area + order: 6 + size: + - 0 + leader: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: leader + order: 2 + size: + - 0 + location: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: location + order: 7 + size: + - 0 + name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: name + order: 3 + size: + - 0 + planet: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: planet + order: 4 + size: + - 0 + super_area: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: super_area + order: 5 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - leader + name: teams_idx_leader + options: [] + type: NORMAL + name: teams + options: [] + order: 9 + triggers: {} + views: {} +translator: + add_drop_table: 0 + filename: ~ + no_comments: 0 + parser_args: + sources: + - CompanionNPC + - Equipment + - EquipmentItem + - Inventory + - InventoryItem + - PJ + - Player + - SkillLikeItem + - SkillLikeList + - Stats + - Team + parser_type: SQL::Translator::Parser::DBIx::Class + producer_args: {} + producer_type: SQL::Translator::Producer::YAML + show_warnings: 0 + trace: 0 + version: 1.63 diff --git a/dbicdh/_source/deploy/3/001-auto.yml b/dbicdh/_source/deploy/3/001-auto.yml new file mode 100644 index 0000000..a5356b3 --- /dev/null +++ b/dbicdh/_source/deploy/3/001-auto.yml @@ -0,0 +1,1262 @@ +--- +schema: + procedures: {} + tables: + equipment: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: equipment + options: [] + order: 1 + equipment_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - kind + - equipment + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: equipment_items_fk_equipment + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + fields: + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: equipment + order: 2 + size: + - 0 + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + kind: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: kind + order: 1 + size: + - 0 + quantity: + data_type: Integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: quantity + order: 4 + size: + - 0 + indices: + - fields: + - equipment + name: equipment_items_idx_equipment + options: [] + type: NORMAL + name: equipment_items + options: [] + order: 6 + inventories: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: inventories + options: [] + order: 2 + inventory_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: inventory_items_fk_inventory + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + fields: + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 2 + size: + - 0 + quantity: + data_type: Integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: quantity + order: 4 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - inventory + name: inventory_items_idx_inventory + options: [] + type: NORMAL + name: inventory_items + options: [] + order: 7 + player_companion_npcs: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: player_companion_npcs_fk_equipment + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: player_companion_npcs_fk_inventory + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - owner + match_type: '' + name: player_companion_npcs_fk_owner + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: player_pjs + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - skills + match_type: '' + name: player_companion_npcs_fk_skills + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - spells + match_type: '' + name: player_companion_npcs_fk_spells + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - stats + match_type: '' + name: player_companion_npcs_fk_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + fields: + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: equipment + order: 8 + size: + - 0 + exp: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: exp + order: 7 + size: + - 0 + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: identifier + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 12 + size: + - 0 + level: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: level + order: 6 + size: + - 0 + nick: + data_type: text + default_value: ~ + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: nick + order: 4 + size: + - 0 + owner: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: owner + order: 2 + size: + - 0 + race: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: race + order: 5 + size: + - 0 + skills: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: skills + order: 10 + size: + - 0 + spells: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: spells + order: 11 + size: + - 0 + stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: stats + order: 9 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - equipment + name: player_companion_npcs_idx_equipment + options: [] + type: NORMAL + - fields: + - inventory + name: player_companion_npcs_idx_inventory + options: [] + type: NORMAL + - fields: + - owner + name: player_companion_npcs_idx_owner + options: [] + type: NORMAL + - fields: + - skills + name: player_companion_npcs_idx_skills + options: [] + type: NORMAL + - fields: + - spells + name: player_companion_npcs_idx_spells + options: [] + type: NORMAL + - fields: + - stats + name: player_companion_npcs_idx_stats + options: [] + type: NORMAL + name: player_companion_npcs + options: [] + order: 11 + player_pjs: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - born_stats + match_type: '' + name: player_pjs_fk_born_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - equipment + match_type: '' + name: player_pjs_fk_equipment + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: equipment + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - inventory + match_type: '' + name: player_pjs_fk_inventory + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: inventories + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - owner + match_type: '' + name: player_pjs_fk_owner + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: players + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - skills + match_type: '' + name: player_pjs_fk_skills + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - spells + match_type: '' + name: player_pjs_fk_spells + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - team + match_type: '' + name: player_pjs_fk_team + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: teams + type: FOREIGN KEY + - deferrable: 1 + expression: '' + fields: + - training_stats + match_type: '' + name: player_pjs_fk_training_stats + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: stats + type: FOREIGN KEY + fields: + born_stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: born_stats + order: 12 + size: + - 0 + creation_date: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: creation_date + order: 8 + size: + - 0 + equipment: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: equipment + order: 11 + size: + - 0 + experience: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: experience + order: 10 + size: + - 0 + full_name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: full_name + order: 3 + size: + - 0 + inventory: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: inventory + order: 16 + size: + - 0 + last_activity: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: last_activity + order: 9 + size: + - 0 + nick: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: nick + order: 5 + size: + - 0 + owner: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: owner + order: 2 + size: + - 0 + race: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: race + order: 6 + size: + - 0 + short_name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: short_name + order: 4 + size: + - 0 + skills: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: skills + order: 14 + size: + - 0 + spells: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: spells + order: 15 + size: + - 0 + team: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: team + order: 7 + size: + - 0 + training_stats: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: training_stats + order: 13 + size: + - 0 + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - born_stats + name: player_pjs_idx_born_stats + options: [] + type: NORMAL + - fields: + - equipment + name: player_pjs_idx_equipment + options: [] + type: NORMAL + - fields: + - inventory + name: player_pjs_idx_inventory + options: [] + type: NORMAL + - fields: + - owner + name: player_pjs_idx_owner + options: [] + type: NORMAL + - fields: + - skills + name: player_pjs_idx_skills + options: [] + type: NORMAL + - fields: + - spells + name: player_pjs_idx_spells + options: [] + type: NORMAL + - fields: + - team + name: player_pjs_idx_team + options: [] + type: NORMAL + - fields: + - training_stats + name: player_pjs_idx_training_stats + options: [] + type: NORMAL + name: player_pjs + options: [] + order: 10 + players: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - email + match_type: '' + name: unique_constraint_email + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + - deferrable: 1 + expression: '' + fields: + - username + match_type: '' + name: unique_constraint_username + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + fields: + email: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: email + order: 4 + size: + - 0 + encrypted_password: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: encrypted_password + order: 3 + size: + - 0 + last_activity: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: last_activity + order: 8 + size: + - 0 + register_date: + data_type: timestamp + default_value: !!perl/ref + =: NOW() + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: register_date + order: 7 + size: + - 0 + username: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: username + order: 2 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + verification_token: + data_type: text + default_value: ~ + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: verification_token + order: 6 + size: + - 0 + verified: + data_type: boolean + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: verified + order: 5 + size: + - 0 + indices: [] + name: players + options: [] + order: 3 + skill_like_items: + constraints: + - deferrable: 1 + expression: '' + fields: + - identifier + - owner_list + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - owner_list + match_type: '' + name: skill_like_items_fk_owner_list + on_delete: CASCADE + on_update: CASCADE + options: [] + reference_fields: + - uuid + reference_table: skill_like_lists + type: FOREIGN KEY + fields: + identifier: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: identifier + order: 1 + size: + - 0 + level: + data_type: integer + default_value: !!perl/ref + =: 1 + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: level + order: 3 + size: + - 0 + owner_list: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: owner_list + order: 2 + size: + - 0 + indices: + - fields: + - owner_list + name: skill_like_items_idx_owner_list + options: [] + type: NORMAL + name: skill_like_items + options: [] + order: 8 + skill_like_lists: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + uuid: + data_type: uuid + default_value: !!perl/ref + =: uuid_generate_v4() + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: skill_like_lists + options: [] + order: 4 + stats: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + health: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: health + order: 2 + size: + - 0 + intelligence: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: intelligence + order: 8 + size: + - 0 + magic: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: magic + order: 6 + size: + - 0 + mana: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: mana + order: 3 + size: + - 0 + resistance: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: resistance + order: 5 + size: + - 0 + speed: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: speed + order: 7 + size: + - 0 + strength: + data_type: integer + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: strength + order: 4 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: [] + name: stats + options: [] + order: 5 + teams: + constraints: + - deferrable: 1 + expression: '' + fields: + - uuid + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + - deferrable: 1 + expression: '' + fields: + - name + match_type: '' + name: u_name + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: UNIQUE + - deferrable: 1 + expression: '' + fields: + - leader + match_type: '' + name: teams_fk_leader + on_delete: '' + on_update: '' + options: [] + reference_fields: + - uuid + reference_table: player_pjs + type: FOREIGN KEY + fields: + area: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: area + order: 6 + size: + - 0 + leader: + data_type: uuid + default_value: ~ + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: leader + order: 2 + size: + - 0 + location: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: location + order: 7 + size: + - 0 + name: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 1 + name: name + order: 3 + size: + - 0 + planet: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: planet + order: 4 + size: + - 0 + super_area: + data_type: text + default_value: ~ + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: super_area + order: 5 + size: + - 0 + uuid: + data_type: uuid + default_value: ~ + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: uuid + order: 1 + size: + - 0 + indices: + - fields: + - leader + name: teams_idx_leader + options: [] + type: NORMAL + name: teams + options: [] + order: 9 + triggers: {} + views: {} +translator: + add_drop_table: 0 + filename: ~ + no_comments: 0 + parser_args: + sources: + - CompanionNPC + - Equipment + - EquipmentItem + - Inventory + - InventoryItem + - PJ + - Player + - SkillLikeItem + - SkillLikeList + - Stats + - Team + parser_type: SQL::Translator::Parser::DBIx::Class + producer_args: {} + producer_type: SQL::Translator::Producer::YAML + show_warnings: 0 + trace: 0 + version: 1.63 diff --git a/js-src/components/pj-creation-menu.tsx b/js-src/components/pj-creation-menu.tsx index 72a0127..15313ea 100644 --- a/js-src/components/pj-creation-menu.tsx +++ b/js-src/components/pj-creation-menu.tsx @@ -21,20 +21,76 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element const shortNameInputRef = React.useRef(null) const nickInputRef = React.useRef(null) const raceSelectRef = React.useRef(null) - const [playableRaces, setPlayableRaces] = React.useState({}) - React.useEffect(() => { + const [playableRaces, setPlayableRaces] = React.useState(null) + if (playableRaces === null) { fetch('/races/playable', { method: 'GET', mode: 'same-origin', cache: 'no-cache' }).then(async (response) => { + const statusCode = response.status const data = await response.json() + if (statusCode !== 200) { + props.setError(data.error) + return; + } setPlayableRaces(data) + props.setError(null) }).catch((error) => { console.log(error) props.setError('Imposible conectar al servidor para recibir las razas.') }) - }) + } + function createPJ(): void { + if (longNameInputRef.current === null) { + return + } + if (shortNameInputRef.current === null) { + return + } + if (nickInputRef.current === null) { + return + } + if (raceSelectRef.current === null || raceSelectRef.current.selectedOptions.length < 1) { + return + } + fetch('/pj/create', { + method: 'POST', + mode: 'same-origin', + cache: 'no-cache', + body: JSON.stringify({ + full_name: longNameInputRef.current.value, + short_name: shortNameInputRef.current.value, + nick: nickInputRef.current.value, + race: raceSelectRef.current.selectedOptions[0].value + }) + }).then(async (response) => { + const statusCode = response.status + const data = await response.json() + if (statusCode !== 200) { + props.setError(data.error) + return + } + props.setError(null) + props.setUserWantsToCreatePJ(false) + }).catch((error) => { + console.log(error) + props.setError('Imposible crear pj, no se pudo conectar al servidor.') + }); + } + function renderRaces(): JSX.Element[] { + if (playableRaces !== null) { + return Object.keys(playableRaces) + .map((item, i) => { + return + } + ) + } + return ([]) + } + return ( <>
@@ -52,20 +108,9 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element - +
- +
diff --git a/lib/LasTres.pm b/lib/LasTres.pm index 7e8970c..4327a9b 100644 --- a/lib/LasTres.pm +++ b/lib/LasTres.pm @@ -38,6 +38,8 @@ sub startup ($self) { # Normal route to controller $r->get('/')->to('Root#index'); + $r->get('/races/playable')->to('Race#playable'); + $r->post('/player/register')->to('Player#register'); $r->post('/player/login')->to('Player#login'); $r->post('/player/check_login')->to('Player#check_login'); diff --git a/lib/LasTres/Area.pm b/lib/LasTres/Area.pm index 7466927..fb795ab 100644 --- a/lib/LasTres/Area.pm +++ b/lib/LasTres/Area.pm @@ -7,5 +7,5 @@ use warnings; use Moo::Role; -requires qw/identifier locations name description parent/; +requires qw/identifier locations name parent/; 1; diff --git a/lib/LasTres/Controller/PJ.pm b/lib/LasTres/Controller/PJ.pm index 32a56bd..4fbf6f1 100644 --- a/lib/LasTres/Controller/PJ.pm +++ b/lib/LasTres/Controller/PJ.pm @@ -5,53 +5,187 @@ use v5.36.0; use strict; use warnings; -use UUID::URandom qw/create_uuid_string/; +use UUID::URandom qw/create_uuid_string/; -use LasTres::DAO::Players; +use LasTres::DAO::PJs; +use LasTres::DAO::Equipments; +use LasTres::DAO::Teams; +use LasTres::DAO::Stats; +use LasTres::DAO::SkillLikeLists; +use LasTres::DAO::Inventories; +use LasTres::Schema; +use LasTres::Races; use Mojo::Base 'Mojolicious::Controller', -signatures; -my $result_set_pjs = LasTres::DAO::PJ->ResultSet; +my $schema = LasTres::Schema->Schema; +my $result_set_pjs = LasTres::DAO::PJs->ResultSet; +my $result_set_equipments = LasTres::DAO::Equipments->ResultSet; +my $result_set_teams = LasTres::DAO::Teams->ResultSet; +my $result_set_stats = LasTres::DAO::Stats->ResultSet; +my $result_set_skill_like_list = LasTres::DAO::SkillLikeLists->ResultSet; +my $result_set_inventory = LasTres::DAO::Inventories->ResultSet; -sub create($self) { - my %params = %{ $self->req->json }; - my $user = $self->user; - if (!defined $user) { +sub create ($self) { + my %param = %{ $self->req->json }; + my $user = $self->user; + if ( !defined $user ) { return $self->render( status => 401, - json => { error => 'You must login first.' } + json => { error => 'You must login first.' } ); } my @pjs = $user->pjs; - if (scalar @pjs >= 0) { + if ( scalar @pjs >= 3 ) { return $self->render( status => 401, - json => { error => 'You reached the limit of free pjs, delete one or update to premium.', } + json => { + error => +'You reached the limit of free pjs, delete one or update to premium.', + } ); } - my $uuid = create_uuid_string(); - my $owner = $user; + my $uuid = create_uuid_string(); + my $owner = $user; my $full_name = $param{full_name}; - if (!defined $full_name || !length $full_name > 3) { + if ( !defined $full_name || length $full_name < 3 ) { return $self->render( status => 400, - json => { error => 'The full_name is too short.', } + json => { error => 'The full_name is too short.', } ); } - my $short_name = $param{full_name}; - if (!defined $short_name || !length $full_name > 3) { + my $short_name = $param{short_name}; + if ( !defined $short_name || length $short_name < 3 ) { return $self->render( status => 400, - json => { error => 'The short_name is too short.', } + json => { error => 'The short_name is too short.', } ); } my $nick = $param{'nick'}; - if (!defined $nick || !length $nick > 0) { + if ( !defined $nick || length $nick <= 0 ) { return $self->render( status => 400, - json => { error => 'You must set a nick.', } + json => { error => 'You must set a nick.', } ); } - my $race = $param{'race'}; + my $race_identifier = $param{'race'}; + if ( !defined $race_identifier || !length $race_identifier ) { + return $self->_invalid_race; + } + my $races = LasTres::Races->new; + my $race = $races->hash_playable->{$race_identifier}; + if ( !defined $race ) { + return $self->_invalid_race; + } + eval { + $schema->txn_do( + sub { + $self->_insert_new_player( $owner, $full_name, $short_name, + $nick, $race ); + } + ); + }; + if ($@) { + if ( $@ =~ /Rollback failed/ ) { + say STDERR "Unable to rollback failed transaction:"; + } + say STDERR $@; + return $self->render( + status => 500, + json => { error => 'Database error' }, + ); + } + return $self->render( + status => 200, + json => { info => 'Sucessfully created pj.' }, + ); +} + +sub _insert_new_player ( $self, $owner, $full_name, $short_name, $nick, $race ) +{ + my $uuid_born_stats = create_uuid_string; + my $uuid_training_stats = create_uuid_string; + my $uuid_equipment = create_uuid_string; + my $uuid_skills = create_uuid_string; + my $uuid_spells = create_uuid_string; + my $uuid_pj = create_uuid_string; + my $uuid_inventory = create_uuid_string; + my $uuid_team = create_uuid_string; + my $uuid_owner = $owner->uuid; + + my $born_stats = LasTres::Stats->new( + uuid => $uuid_born_stats, + health => $self->_get_random_born_stat, + strength => $self->_get_random_born_stat, + resistance => $self->_get_random_born_stat, + mana => $self->_get_random_born_stat, + magic => $self->_get_random_born_stat, + speed => $self->_get_random_born_stat, + intelligence => $self->_get_random_born_stat, + ); + $born_stats->insert; + my $training_stats = LasTres::Stats->new( + uuid => $uuid_training_stats, + health => 0, + strength => 0, + resistance => 0, + mana => 0, + magic => 0, + speed => 0, + intelligence => 0, + ); + $training_stats->insert; + $result_set_equipments->new( { uuid => $uuid_equipment } )->insert; + $result_set_skill_like_list->new( { uuid => $uuid_skills } )->insert; + $result_set_skill_like_list->new( { uuid => $uuid_spells } )->insert; + $result_set_inventory->new( { uuid => $uuid_inventory } )->insert; + my $location = $race->spawn; + my $area = $location->parent; + my $super_area = $area->parent; + my $planet = $super_area->parent; + my $team = $result_set_teams->new( + { + uuid => $uuid_team, + leader => undef, + name => $uuid_team, + planet => $planet->identifier, + super_area => $super_area->identifier, + area => $area->identifier, + location => $location->identifier, + + } + ); + $team->insert; + $result_set_pjs->new( + { + uuid => $uuid_pj, + owner => $uuid_owner, + full_name => $full_name, + short_name => $short_name, + nick => $nick, + race => $race->identifier, + team => $uuid_team, + experience => 126, + equipment => $uuid_equipment, + born_stats => $uuid_born_stats, + training_stats => $uuid_training_stats, + skills => $uuid_skills, + spells => $uuid_spells, + inventory => $uuid_inventory, + } + )->insert; + $team->leader($uuid_pj); + $team->update; +} + +sub _get_random_born_stat ($self) { + return int( rand(32) ); +} + +sub _invalid_race ($self) { + return $self->render( + status => 400, + json => { error => 'Invalid race.', } + ); } 1; diff --git a/lib/LasTres/Controller/Race.pm b/lib/LasTres/Controller/Race.pm new file mode 100644 index 0000000..483c657 --- /dev/null +++ b/lib/LasTres/Controller/Race.pm @@ -0,0 +1,29 @@ +package LasTres::Controller::Race; + +use v5.36.0; + +use strict; +use warnings; + +use Mojo::Base 'Mojolicious::Controller', -signatures; + +use LasTres::Races; + +sub playable($self) { + my $races = LasTres::Races->new; + my $hash; + eval { + $hash = $races->hash_all_playable; + }; + if ($@) { + say STDERR $@; + return $self->render( + status => 500, + json => { error => 'Error del servidor procesando las razas.' } + ); + } + return $self->render( + json => $hash + ); +} +1; diff --git a/lib/LasTres/DAO/Equipments.pm b/lib/LasTres/DAO/Equipments.pm new file mode 100644 index 0000000..dea8862 --- /dev/null +++ b/lib/LasTres/DAO/Equipments.pm @@ -0,0 +1,20 @@ +package LasTres::DAO::Equipments; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +use LasTres::Schema; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('Equipment'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/DAO/Inventories.pm b/lib/LasTres/DAO/Inventories.pm new file mode 100644 index 0000000..71a08a8 --- /dev/null +++ b/lib/LasTres/DAO/Inventories.pm @@ -0,0 +1,18 @@ +package LasTres::DAO::Inventories; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('Inventory'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/DAO/PJs.pm b/lib/LasTres/DAO/PJs.pm new file mode 100644 index 0000000..d26ffe8 --- /dev/null +++ b/lib/LasTres/DAO/PJs.pm @@ -0,0 +1,23 @@ +package LasTres::DAO::PJs; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +use Params::ValidationCompiler qw/validation_for/; +use Types::Standard qw/Str Bool/; + +use LasTres::Schema; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('PJ'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/DAO/Players.pm b/lib/LasTres/DAO/Players.pm index 75633d5..3f746ee 100644 --- a/lib/LasTres/DAO/Players.pm +++ b/lib/LasTres/DAO/Players.pm @@ -9,9 +9,6 @@ use feature 'signatures'; use Moo; -use Params::ValidationCompiler qw/validation_for/; -use Types::Standard qw/Str Bool/; - use LasTres::Schema; my $schema = LasTres::Schema->Schema; diff --git a/lib/LasTres/DAO/SkillLikeLists.pm b/lib/LasTres/DAO/SkillLikeLists.pm new file mode 100644 index 0000000..0f378ed --- /dev/null +++ b/lib/LasTres/DAO/SkillLikeLists.pm @@ -0,0 +1,18 @@ +package LasTres::DAO::SkillLikeLists; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('SkillLikeList'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/DAO/Stats.pm b/lib/LasTres/DAO/Stats.pm new file mode 100644 index 0000000..f9a7ef0 --- /dev/null +++ b/lib/LasTres/DAO/Stats.pm @@ -0,0 +1,20 @@ +package LasTres::DAO::Stats; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +use LasTres::Schema; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('Stats'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/DAO/Teams.pm b/lib/LasTres/DAO/Teams.pm new file mode 100644 index 0000000..72947fe --- /dev/null +++ b/lib/LasTres/DAO/Teams.pm @@ -0,0 +1,20 @@ +package LasTres::DAO::Teams; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +use LasTres::Schema; + +my $schema = LasTres::Schema->Schema; +my $result_set = $schema->resultset('Team'); + +sub ResultSet { + return $result_set; +} +1; diff --git a/lib/LasTres/PJ.pm b/lib/LasTres/PJ.pm new file mode 100644 index 0000000..b1c2eb7 --- /dev/null +++ b/lib/LasTres/PJ.pm @@ -0,0 +1,137 @@ +package LasTres::PJ; + +use v5.36.0; +use strict; +use warnings; + +use feature 'signatures'; + +use Scalar::Util qw/blessed/; +use LasTres::DAO::PJs; + +my $result_set = LasTres::DAO::PJs->ResultSet; + +use Moo; + +has uuid => ( + is => 'rw', + required => 1, +); + +has owner => ( + is => 'rw', + required => 1, +); + +has full_name => ( + is => 'rw', + required => 1, +); + +has short_name => ( + is => 'rw', + required => 1, +); + +has nick => ( + is => 'rw', + required => 1, +); + +has race => ( + is => 'rw', + required => 1, +); + +has team => ( + is => 'rw', + required => 1, +); + +has creation_date => ( + is => 'rw', + required => 1, +); + +has last_activity => ( + is => 'rw', + required => 1, +); + +has experience => ( + is => 'rw', + required => 1, +); + +has equipment => ( + is => 'rw', + required => 1, +); + +sub _coerce_stats($attr) { + if (blessed($attr) eq 'LasTres::Schema::Result::Stats') { + return $attr->model; + } +} + +has born_stats => ( + is => 'rw', + required => 1, + coerce => \&_coerce_stats, +); + +has training_stats => ( + is => 'rw', + required => 1, + coerce => \&_coerce_stats, +); + +sub _coerce_skills($attr) { + if (blessed($attr) eq 'LasTres::Schema::Result::SkillLikeList') { + return $attr->model; + } +} + +has skills => ( + is => 'rw', + required => 1, + coerce => \&_coerce_skills, +); + +has spells => ( + is => 'rw', + required => 1, + coerce => \&_coerce_skills, +); + +has inventory => ( + is => 'rw', + required => 1, +); + +sub hash ($self) { + return { + uuid => $self->uuid, + owner => $self->owner, + full_name => $self->full_name, + short_name => $self->short_name, + nick => $self->nick, + race => $self->race, + team => $self->team, + creation_date => $self->creation_date, + last_activity => $self->last_activity, + experience => $self->experience, + equipment => $self->equipment, + born_stats => $self->born_stats, + training_stats => $self->training_stats, + skills => $self->skills, + spells => $self->spells, + inventory => $self->inventory, + + }; +} + +sub result_set ($self) { + return $result_set->new( %{ $self->hash } ); +} +1; diff --git a/lib/LasTres/Planet/Bahdder.pm b/lib/LasTres/Planet/Bahdder.pm index eda0d24..4a01c45 100644 --- a/lib/LasTres/Planet/Bahdder.pm +++ b/lib/LasTres/Planet/Bahdder.pm @@ -7,14 +7,35 @@ use warnings; use Moo; -with 'LasTres::Planet'; - use Module::Pluggable search_path => ['LasTres::Planet::Bahdder']; has super_areas => ( - is => 'lazy' + is => 'ro', + lazy => 1, + builder => \&_build_super_areas, ); -sub identifier { + +has identifier => ( + is => 'ro', + lazy => 1, + builder => \&_build_identifier, +); + +has name => ( + is => 'ro', + lazy => 1, + builder => \&_build_name, +); + +has description => ( + is => 'ro', + lazy => 1, + builder => \&_build_description, +); + +with 'LasTres::Planet'; + +sub _build_identifier { return 'bahdder', } @@ -22,20 +43,29 @@ sub _build_super_areas { my $self = shift; my $hash = {}; my @super_areas = $self->plugins(); - for $super_area (@super_areas) { + for my $super_area (@super_areas) { $hash->{$super_area->identifier} = $super_area; } return $hash; } -sub name { +sub _build_name { return 'Bahdder'; } -sub description { +sub _build_description { return 'Archivo de la Patrulla Galáctica: Bahdder es uno de los planetas con mayor población de la galaxia con una población estimada ' . 'de tres mil millones de individuos pertenecientes a especies consideradas inteligentes. ' . 'Es conocido como el planeta origen de los Yaren; no obstante la presencia de los mismos en este planeta es actualmente simbólica. ' . 'Su población actual esta mayormente compuesta por razas locales como los Áldimor. '; } + +my $singleton; +sub instance { + my $class = shift; + if (!defined $singleton) { + $singleton = $class->new(@_); + } + return $singleton; +} 1; diff --git a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe.pm b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe.pm index eb20309..47a8218 100644 --- a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe.pm +++ b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe.pm @@ -5,17 +5,47 @@ use v5.36.0; use strict; use warnings; +use feature 'signatures'; + use Moo; +use Module::Pluggable search_path => ['LasTres::Planet::Bahdder::BosqueDelHeroe'], + instantiate => 'instance', + on_require_error => sub ($plugin, $error) { + die $error; + }; + +use LasTres::Planet::Bahdder; + +has areas => ( + is => 'ro', + builder => \&_build_areas, + lazy => 1, +); + +has identifier => ( + is => 'ro', + builder => \&_build_identifier, +); + +has name => ( + is => 'ro', + builder => \&_build_name, +); + +has description => ( + is => 'ro', + builder => \&_build_description, +); + +has parent => ( + is => 'ro', + builder => \&_build_parent, +); + with 'LasTres::SuperArea'; -use Module::Pluggable search_path => ['LasTres::Planet::Bahdder::BosqueDelHeroe']; - -has areas => ( - is => 'lazy' -); - -sub identifier { +sub _build_identifier { return 'bosque_del_heroe'; } @@ -23,17 +53,17 @@ sub _build_areas { my $self = shift; my $hash = {}; my @areas = $self->plugins(); - for $area (@areas) { + for my $area (@areas) { $hash->{$area->identifier} = $area; } return $hash; } -sub name { +sub _build_name { return 'Bosque del Héroe'; } -sub description { +sub _build_description { return 'El Bosque del Héroe es el pulmón del planeta Bahdder. ' . 'Se cree que solo una pequeña parte de las especies que viven en el mismo han sido catalogadas. ' . 'Los áldimor viven en este bosque en armonía con la naturaleza. ' @@ -41,7 +71,16 @@ sub description { . 'a usar la magia para la guerra. '; } -sub parent { - return LasTres::Planet::Bahdder->new; +sub _build_parent { + return LasTres::Planet::Bahdder->instance; +} + +my $singleton; +sub instance { + my $class = shift; + if (!defined $singleton) { + $singleton = $class->new(@_); + } + return $singleton; } 1; diff --git a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI.pm b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI.pm index 83504c9..61a36ca 100644 --- a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI.pm +++ b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI.pm @@ -5,15 +5,42 @@ use v5.36.0; use strict; use warnings; -with 'LasTres::Area'; +use feature 'signatures'; -use Module::Pluggable search_path => ['LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI']; +use Module::Pluggable search_path => ['LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI'], + instantiate => 'instance', + on_require_error => sub ($plugin, $error) { + die $error; + }; + +use Moo; + +use LasTres::Planet::Bahdder::BosqueDelHeroe; has locations => ( - is => 'lazy' + is => 'ro', + builder => \&_build_locations, + lazy => 1, ); -sub identifier { +has identifier => ( + is => 'ro', + builder => \&_build_identifier, +); + +has name => ( + is => 'ro', + builder => \&_build_name, +); + +has parent => ( + is => 'ro', + builder => \&_build_parent, +); + +with 'LasTres::Area'; + +sub _build_identifier { return 'bosque_del_heroe_i'; } @@ -21,17 +48,26 @@ sub _build_locations { my $self = shift; my $hash = {}; my @locations = $self->plugins(); - for $location (@locations) { + for my $location (@locations) { $hash->{$location->identifier} = $location; } return $hash; } -sub name { +sub _build_name { return 'Bosque del Héroe (I)'; } -sub parent { - return LasTres::Planet::Bahdder::BosqueDelHeroe->new; +sub _build_parent { + return LasTres::Planet::Bahdder::BosqueDelHeroe->instance; +} + +my $singleton; +sub instance { + my $class = shift; + if (!defined $singleton) { + $singleton = $class->new(@_); + } + return $singleton; } 1; diff --git a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI/TribuDeLaLima.pm b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI/TribuDeLaLima.pm index cc78241..a51c042 100644 --- a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI/TribuDeLaLima.pm +++ b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/BosqueDelHeroeI/TribuDeLaLima.pm @@ -5,31 +5,74 @@ use v5.36.0; use strict; use warnings; +use Moo; + +use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI; + +has identifier => ( + is => 'ro', + builder => \&_build_identifier, +); + +has name => ( + is => 'ro', + builder => \&_build_name, +); + +has description => ( + is => 'ro', + builder => \&_build_description, +); + +has parent => ( + is => 'ro', + builder => \&_build_parent, +); + +has actions => ( + is => 'ro', + builder => \&_build_actions, +); + +has npcs => ( + is => 'ro', + builder => \&_build_npcs, +); + with 'LasTres::Location'; -sub identifier { +sub _build_identifier { return 'tribu_de_la_lima'; } -sub name { +sub _build_name { return 'Tribu de la Lima (Exterior)'; } -sub description { +sub _build_description { return 'La Tribu de la Lima se siente como un hogar seas o no de aquí. ' . 'Las casitas están improvisadas con paja que los aldeanos intercambian con otras tribus. ' . 'Los cultivos de Lima están siempre buscando trabajadores, el sueldo es una parte de lo cosechado. '; } -sub parent { - return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI->new; +sub _build_parent { + return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI->instance; } -sub actions { +sub _build_actions { return []; } -sub npcs { +sub _build_npcs { return []; } + +my $singleton; +sub instance { + my $class = shift; + if (!defined $singleton) { + $singleton = $class->new(@_); + } + return $singleton; +} 1; diff --git a/lib/LasTres/Race.pm b/lib/LasTres/Race.pm index f5bfa0a..851ffb7 100644 --- a/lib/LasTres/Race.pm +++ b/lib/LasTres/Race.pm @@ -9,15 +9,15 @@ use feature 'signatures'; use Moo::Role; -requires qw/spawn identifier name name_selection description is_playable/; +requires qw/spawn identifier name name_selection description is_playable base_stats/; sub hash($self) { return { - identifier => $self->{identifier}, - name => $self->{name}, - name_selection => $self->{name_selection}, - description => $self->{description}, - is_playable => $self->{is_playable}, + identifier => $self->identifier, + name => $self->name, + name_selection => $self->name_selection, + description => $self->description, + is_playable => $self->is_playable, } } 1; diff --git a/lib/LasTres/Race/Aldimor.pm b/lib/LasTres/Race/Aldimor.pm index 6bde2b9..97fbc36 100644 --- a/lib/LasTres/Race/Aldimor.pm +++ b/lib/LasTres/Race/Aldimor.pm @@ -5,31 +5,87 @@ use v5.36.0; use strict; use warnings; +use utf8; + use Moo; +use UUID::URandom qw/create_uuid_string/; + +use LasTres::Stats; +use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima; + +has base_stats => ( + is => 'ro', + builder => \&_build_base_stats +); + +has spawn => ( + is => 'ro', + builder => \&_build_spawn +); + +has identifier => ( + is => 'ro', + builder => \&_build_identifier +); + +has name => ( + is => 'ro', + builder => \&_build_name +); + +has name_selection => ( + is => 'ro', + builder => \&_build_name_selection +); + +has description => ( + is => 'ro', + builder => \&_build_description +); + +has is_playable => ( + is => 'ro', + builder => \&_build_is_playable +); + with 'LasTres::Race'; -sub spawn { - return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima->new; +sub _build_spawn { + return + LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima + ->instance; } -sub identifier { +sub _build_base_stats { + return LasTres::Stats->new( + health => 80, + strength => 90, + resistance => 83, + mana => 100, + magic => 100, + speed => 80, + intelligence => 70 + ); +} + +sub _build_identifier { return 'aldimor'; } -sub name { - return 'Aldimor'; +sub _build_name { + return 'Áldimor'; } -sub name_selection { - return 'Aldimor del Bosque del Héroe.'; +sub _build_name_selection { + return 'Áldimor del Bosque del Héroe'; } -sub description { - return 'La raza de la naturaleza y la magia.'; +sub _build_description { + return 'La raza de la naturaleza y la magia'; } -sub is_playable { +sub _build_is_playable { return 1; } 1; diff --git a/lib/LasTres/Races.pm b/lib/LasTres/Races.pm index e6ed8c4..18b402a 100644 --- a/lib/LasTres/Races.pm +++ b/lib/LasTres/Races.pm @@ -7,8 +7,13 @@ use warnings; use feature 'signatures'; +use Module::Pluggable search_path => ['LasTres::Race'], + instantiate => 'new', + on_require_error => sub ($plugin, $error) { + die $error; + }; + use Moo; -use Module::Pluggable search_path => ['LasTres::Race']; has hash => ( is => 'lazy', @@ -16,11 +21,15 @@ has hash => ( has hash_playable => ( is => 'lazy', -) +); has hash_all => ( is => 'lazy', -) +); + +has hash_all_playable => ( + is => 'lazy', +); sub _build_hash_all($self) { return { map { $_ => $self->hash->{$_}->hash } (keys %{$self->hash}) }; @@ -43,14 +52,14 @@ sub _build_hash { my $hash = {}; my @races = $self->plugins(); for my $race (@races) { - $hash{$race->identifier} = $race; + $hash->{$race->identifier} = $race; } return $hash; } sub _build_hash_playable { my $self = shift; - my $hash = {@{$self->hash}}; + my $hash = {%{$self->hash}}; for my $identifier_race (keys %$hash) { my $race = $hash->{$identifier_race}; if (!$race->is_playable) { diff --git a/lib/LasTres/Schema.pm b/lib/LasTres/Schema.pm index 66edaac..3db6f32 100644 --- a/lib/LasTres/Schema.pm +++ b/lib/LasTres/Schema.pm @@ -1,5 +1,5 @@ package LasTres::Schema; -our $VERSION = 1; +our $VERSION = 3; use v5.36.0; diff --git a/lib/LasTres/Schema/Result/PJ.pm b/lib/LasTres/Schema/Result/PJ.pm index 00cc596..d4eb1fe 100644 --- a/lib/LasTres/Schema/Result/PJ.pm +++ b/lib/LasTres/Schema/Result/PJ.pm @@ -50,12 +50,7 @@ __PACKAGE__->add_columns( default_value => \'NOW()', is_nullable => 0, }, - level => { - data_type => 'integer', - default_value => \'1', - is_nullable => 0, - }, - exp => { + experience => { data_type => 'integer', default_value => \'1', is_nullable => 0, @@ -65,7 +60,12 @@ __PACKAGE__->add_columns( is_nullable => 0, is_foreign_key => 1, }, - stats => { + born_stats => { + data_type => 'uuid', + is_foreign_key => 1, + is_nullable => 0, + }, + training_stats => { data_type => 'uuid', is_foreign_key => 1, is_nullable => 0, @@ -84,12 +84,13 @@ __PACKAGE__->add_columns( data_type => 'uuid', is_nullable => 0, } - ); + __PACKAGE__->set_primary_key('uuid'); __PACKAGE__->has_many('npcs', 'LasTres::Schema::Result::CompanionNPC', 'owner'); -__PACKAGE__->belongs_to('stats', 'LasTres::Schema::Result::Stats'); +__PACKAGE__->belongs_to('born_stats', 'LasTres::Schema::Result::Stats'); +__PACKAGE__->belongs_to('training_stats', 'LasTres::Schema::Result::Stats'); __PACKAGE__->belongs_to('inventory', 'LasTres::Schema::Result::Inventory'); __PACKAGE__->belongs_to('skills', 'LasTres::Schema::Result::SkillLikeList'); __PACKAGE__->belongs_to('spells', 'LasTres::Schema::Result::SkillLikeList'); diff --git a/lib/LasTres/Schema/Result/Stats.pm b/lib/LasTres/Schema/Result/Stats.pm index b1da671..87d02fb 100644 --- a/lib/LasTres/Schema/Result/Stats.pm +++ b/lib/LasTres/Schema/Result/Stats.pm @@ -5,6 +5,8 @@ use v5.36.0; use strict; use warnings; +use feature 'signatures'; + use parent 'DBIx::Class::Core'; __PACKAGE__->table('stats'); @@ -42,10 +44,11 @@ __PACKAGE__->add_columns( data_type => 'integer', is_nullable => 0, }, - charisma => { - data_type => 'integer', - is_nullable => 0, - }, ); __PACKAGE__->set_primary_key('uuid'); + +sub model($self) { + require LasTres::Stats; + return LasTres::Stats->new($self->get_columns); +} 1; diff --git a/lib/LasTres/Schema/Result/Team.pm b/lib/LasTres/Schema/Result/Team.pm index a2b63a1..c24e389 100644 --- a/lib/LasTres/Schema/Result/Team.pm +++ b/lib/LasTres/Schema/Result/Team.pm @@ -16,7 +16,7 @@ __PACKAGE__->add_columns( }, leader => { data_type => 'uuid', - is_nullable => 0, + is_nullable => 1, is_foreign_key => 1, }, name => { diff --git a/lib/LasTres/Stats.pm b/lib/LasTres/Stats.pm new file mode 100644 index 0000000..d5e4d30 --- /dev/null +++ b/lib/LasTres/Stats.pm @@ -0,0 +1,88 @@ +package LasTres::Stats; + +use v5.36.0; + +use strict; +use warnings; + +use feature 'signatures'; + +use Moo; + +use LasTres::DAO::Stats; + +my $result_set = LasTres::DAO::Stats->new->ResultSet; + +has uuid => ( + is => 'rw', + required => 0, +); + +has health => ( + is => 'rw', + required => 1, +); + +has mana => ( + is => 'rw', + required => 1, +); + +has strength => ( + is => 'rw', + required => 1, +); + +has resistance => ( + is => 'rw', + required => 1, +); + +has magic => ( + is => 'rw', + required => 1, +); + +has speed => ( + is => 'rw', + required => 1, +); + +has intelligence => ( + is => 'rw', + required => 1, +); + +sub hash ($self) { + my $uuid = $self->uuid; + return { + ( ( defined $uuid ) ? ( uuid => $uuid ) : () ), + health => $self->health, + mana => $self->mana, + strength => $self->strength, + resistance => $self->resistance, + magic => $self->magic, + speed => $self->speed, + intelligence => $self->intelligence + }; +} + +sub update($self) { + return $self->result_set->update; +} + +sub insert($self) { + return $self->result_set->insert; +} + +sub update_or_insert($self) { + return $self->result_set->update_or_insert; +} + +sub result_set ($self) { + if (!defined $self->uuid) { + die "This Stat has no correlation with db, unable to continue."; + } + $result_set->new( $self->hash ); +} +1; diff --git a/public/js/bundle.js b/public/js/bundle.js index 94ddd7a..ac629d5 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -126,7 +126,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PJCreationMenu)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n\nfunction PJCreationMenu(props) {\n const longNameInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const shortNameInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const nickInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const raceSelectRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const [playableRaces, setPlayableRaces] = react__WEBPACK_IMPORTED_MODULE_0__.useState({});\n react__WEBPACK_IMPORTED_MODULE_0__.useEffect(() => {\n fetch('/races/playable', {\n method: 'GET',\n mode: 'same-origin',\n cache: 'no-cache'\n }).then(async (response) => {\n const data = await response.json();\n setPlayableRaces(data);\n }).catch((error) => {\n console.log(error);\n props.setError('Imposible conectar al servidor para recibir las razas.');\n });\n });\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-container\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-contained\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"h1\", null, \"Crea tu personaje.\"),\n (props.error !== null\n ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", { style: { background: 'red' } }, props.error))\n : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null))),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-form\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Nombre largo. (Se usar\\u00E1 en la historia en situaciones formales)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: longNameInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Nombre corto. (Se usar\\u00E1 de forma coloquial)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: shortNameInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Apodo. (Se usar\\u00E1 en las conversaciones m\\u00E1s distendidas)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: nickInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Raza. (Determina tu localizaci\\u00F3n inicial y tus estad\\u00EDsticas)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"select\", { ref: raceSelectRef }, Object.keys(playableRaces)\n .map((item, i) => {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"option\", { key: i, value: playableRaces[item].identifier }, `${playableRaces[item].name_selection} (${playableRaces[item].description})`);\n })),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"width-max-content align-self-end\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", null, \"Crear Personaje\")))))));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/pj-creation-menu.tsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ PJCreationMenu)\n/* harmony export */ });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n\nfunction PJCreationMenu(props) {\n const longNameInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const shortNameInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const nickInputRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const raceSelectRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(null);\n const [playableRaces, setPlayableRaces] = react__WEBPACK_IMPORTED_MODULE_0__.useState(null);\n if (playableRaces === null) {\n fetch('/races/playable', {\n method: 'GET',\n mode: 'same-origin',\n cache: 'no-cache'\n }).then(async (response) => {\n const statusCode = response.status;\n const data = await response.json();\n if (statusCode !== 200) {\n props.setError(data.error);\n return;\n }\n setPlayableRaces(data);\n props.setError(null);\n }).catch((error) => {\n console.log(error);\n props.setError('Imposible conectar al servidor para recibir las razas.');\n });\n }\n function createPJ() {\n if (longNameInputRef.current === null) {\n return;\n }\n if (shortNameInputRef.current === null) {\n return;\n }\n if (nickInputRef.current === null) {\n return;\n }\n if (raceSelectRef.current === null || raceSelectRef.current.selectedOptions.length < 1) {\n return;\n }\n fetch('/pj/create', {\n method: 'POST',\n mode: 'same-origin',\n cache: 'no-cache',\n body: JSON.stringify({\n full_name: longNameInputRef.current.value,\n short_name: shortNameInputRef.current.value,\n nick: nickInputRef.current.value,\n race: raceSelectRef.current.selectedOptions[0].value\n })\n }).then(async (response) => {\n const statusCode = response.status;\n const data = await response.json();\n if (statusCode !== 200) {\n props.setError(data.error);\n return;\n }\n props.setError(null);\n props.setUserWantsToCreatePJ(false);\n }).catch((error) => {\n console.log(error);\n props.setError('Imposible crear pj, no se pudo conectar al servidor.');\n });\n }\n function renderRaces() {\n if (playableRaces !== null) {\n return Object.keys(playableRaces)\n .map((item, i) => {\n return react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"option\", { key: i, value: playableRaces[item].identifier }, `${playableRaces[item].name_selection} (${playableRaces[item].description})`);\n });\n }\n return ([]);\n }\n return (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-container\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-contained\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"h1\", null, \"Crea tu personaje.\"),\n (props.error !== null\n ? (react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"p\", { style: { background: 'red' } }, props.error))\n : (react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null))),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"login-form\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Nombre largo. (Se usar\\u00E1 en la historia en situaciones formales)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: longNameInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Nombre corto. (Se usar\\u00E1 de forma coloquial)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: shortNameInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Apodo. (Se usar\\u00E1 en las conversaciones m\\u00E1s distendidas)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"input\", { ref: nickInputRef, type: \"text\" }),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"label\", null, \"Raza. (Determina tu localizaci\\u00F3n inicial y tus estad\\u00EDsticas)\"),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"select\", { ref: raceSelectRef }, renderRaces()),\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"div\", { className: \"width-max-content align-self-end\" },\n react__WEBPACK_IMPORTED_MODULE_0__.createElement(\"button\", { onClick: createPJ }, \"Crear Personaje\")))))));\n}\n\n\n//# sourceURL=webpack://LasTres/./js-src/components/pj-creation-menu.tsx?"); /***/ }),