Adding more changes.
This commit is contained in:
parent
4cd4d1611c
commit
fca82dba2b
257
dbicdh/PostgreSQL/deploy/2/001-auto.sql
Normal file
257
dbicdh/PostgreSQL/deploy/2/001-auto.sql
Normal file
@ -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;
|
||||||
|
|
||||||
|
;
|
256
dbicdh/PostgreSQL/deploy/3/001-auto.sql
Normal file
256
dbicdh/PostgreSQL/deploy/3/001-auto.sql
Normal file
@ -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;
|
||||||
|
|
||||||
|
;
|
48
dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql
Normal file
48
dbicdh/PostgreSQL/upgrade/1-2/001-auto.sql
Normal file
@ -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;
|
||||||
|
|
21
dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql
Normal file
21
dbicdh/PostgreSQL/upgrade/2-3/001-auto.sql
Normal file
@ -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;
|
||||||
|
|
1273
dbicdh/_source/deploy/2/001-auto.yml
Normal file
1273
dbicdh/_source/deploy/2/001-auto.yml
Normal file
File diff suppressed because it is too large
Load Diff
1262
dbicdh/_source/deploy/3/001-auto.yml
Normal file
1262
dbicdh/_source/deploy/3/001-auto.yml
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,20 +21,76 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element
|
|||||||
const shortNameInputRef = React.useRef<HTMLInputElement>(null)
|
const shortNameInputRef = React.useRef<HTMLInputElement>(null)
|
||||||
const nickInputRef = React.useRef<HTMLInputElement>(null)
|
const nickInputRef = React.useRef<HTMLInputElement>(null)
|
||||||
const raceSelectRef = React.useRef<HTMLSelectElement>(null)
|
const raceSelectRef = React.useRef<HTMLSelectElement>(null)
|
||||||
const [playableRaces, setPlayableRaces] = React.useState<Races>({})
|
const [playableRaces, setPlayableRaces] = React.useState<Races | null>(null)
|
||||||
React.useEffect(() => {
|
if (playableRaces === null) {
|
||||||
fetch('/races/playable', {
|
fetch('/races/playable', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
mode: 'same-origin',
|
mode: 'same-origin',
|
||||||
cache: 'no-cache'
|
cache: 'no-cache'
|
||||||
}).then(async (response) => {
|
}).then(async (response) => {
|
||||||
|
const statusCode = response.status
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
if (statusCode !== 200) {
|
||||||
|
props.setError(data.error)
|
||||||
|
return;
|
||||||
|
}
|
||||||
setPlayableRaces(data)
|
setPlayableRaces(data)
|
||||||
|
props.setError(null)
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
props.setError('Imposible conectar al servidor para recibir las razas.')
|
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 <option key={i} value={playableRaces[item].identifier}>
|
||||||
|
{`${playableRaces[item].name_selection} (${playableRaces[item].description})`}
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return ([])
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="login-container">
|
<div className="login-container">
|
||||||
@ -52,20 +108,9 @@ export default function PJCreationMenu (props: PJCreationMenuProps): JSX.Element
|
|||||||
<label>Apodo. (Se usará en las conversaciones más distendidas)</label>
|
<label>Apodo. (Se usará en las conversaciones más distendidas)</label>
|
||||||
<input ref={nickInputRef} type="text"/>
|
<input ref={nickInputRef} type="text"/>
|
||||||
<label>Raza. (Determina tu localización inicial y tus estadísticas)</label>
|
<label>Raza. (Determina tu localización inicial y tus estadísticas)</label>
|
||||||
<select ref={raceSelectRef}>
|
<select ref={raceSelectRef}>{ renderRaces() }</select>
|
||||||
{
|
|
||||||
Object.keys(playableRaces)
|
|
||||||
.map(
|
|
||||||
(item, i) => {
|
|
||||||
return <option key={i} value={playableRaces[item].identifier}>
|
|
||||||
{`${playableRaces[item].name_selection} (${playableRaces[item].description})`}
|
|
||||||
</option>
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
<div className="width-max-content align-self-end">
|
<div className="width-max-content align-self-end">
|
||||||
<button>Crear Personaje</button>
|
<button onClick={createPJ}>Crear Personaje</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,6 +38,8 @@ sub startup ($self) {
|
|||||||
|
|
||||||
# Normal route to controller
|
# Normal route to controller
|
||||||
$r->get('/')->to('Root#index');
|
$r->get('/')->to('Root#index');
|
||||||
|
$r->get('/races/playable')->to('Race#playable');
|
||||||
|
|
||||||
$r->post('/player/register')->to('Player#register');
|
$r->post('/player/register')->to('Player#register');
|
||||||
$r->post('/player/login')->to('Player#login');
|
$r->post('/player/login')->to('Player#login');
|
||||||
$r->post('/player/check_login')->to('Player#check_login');
|
$r->post('/player/check_login')->to('Player#check_login');
|
||||||
|
@ -7,5 +7,5 @@ use warnings;
|
|||||||
|
|
||||||
use Moo::Role;
|
use Moo::Role;
|
||||||
|
|
||||||
requires qw/identifier locations name description parent/;
|
requires qw/identifier locations name parent/;
|
||||||
1;
|
1;
|
||||||
|
@ -7,14 +7,27 @@ 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;
|
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) {
|
sub create ($self) {
|
||||||
my %params = %{ $self->req->json };
|
my %param = %{ $self->req->json };
|
||||||
my $user = $self->user;
|
my $user = $self->user;
|
||||||
if ( !defined $user ) {
|
if ( !defined $user ) {
|
||||||
return $self->render(
|
return $self->render(
|
||||||
@ -23,35 +36,156 @@ sub create($self) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
my @pjs = $user->pjs;
|
my @pjs = $user->pjs;
|
||||||
if (scalar @pjs >= 0) {
|
if ( scalar @pjs >= 3 ) {
|
||||||
return $self->render(
|
return $self->render(
|
||||||
status => 401,
|
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 $uuid = create_uuid_string();
|
||||||
my $owner = $user;
|
my $owner = $user;
|
||||||
my $full_name = $param{full_name};
|
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(
|
return $self->render(
|
||||||
status => 400,
|
status => 400,
|
||||||
json => { error => 'The full_name is too short.', }
|
json => { error => 'The full_name is too short.', }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
my $short_name = $param{full_name};
|
my $short_name = $param{short_name};
|
||||||
if (!defined $short_name || !length $full_name > 3) {
|
if ( !defined $short_name || length $short_name < 3 ) {
|
||||||
return $self->render(
|
return $self->render(
|
||||||
status => 400,
|
status => 400,
|
||||||
json => { error => 'The short_name is too short.', }
|
json => { error => 'The short_name is too short.', }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
my $nick = $param{'nick'};
|
my $nick = $param{'nick'};
|
||||||
if (!defined $nick || !length $nick > 0) {
|
if ( !defined $nick || length $nick <= 0 ) {
|
||||||
return $self->render(
|
return $self->render(
|
||||||
status => 400,
|
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;
|
1;
|
||||||
|
29
lib/LasTres/Controller/Race.pm
Normal file
29
lib/LasTres/Controller/Race.pm
Normal file
@ -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;
|
20
lib/LasTres/DAO/Equipments.pm
Normal file
20
lib/LasTres/DAO/Equipments.pm
Normal file
@ -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;
|
18
lib/LasTres/DAO/Inventories.pm
Normal file
18
lib/LasTres/DAO/Inventories.pm
Normal file
@ -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;
|
23
lib/LasTres/DAO/PJs.pm
Normal file
23
lib/LasTres/DAO/PJs.pm
Normal file
@ -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;
|
@ -9,9 +9,6 @@ use feature 'signatures';
|
|||||||
|
|
||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
use Params::ValidationCompiler qw/validation_for/;
|
|
||||||
use Types::Standard qw/Str Bool/;
|
|
||||||
|
|
||||||
use LasTres::Schema;
|
use LasTres::Schema;
|
||||||
|
|
||||||
my $schema = LasTres::Schema->Schema;
|
my $schema = LasTres::Schema->Schema;
|
||||||
|
18
lib/LasTres/DAO/SkillLikeLists.pm
Normal file
18
lib/LasTres/DAO/SkillLikeLists.pm
Normal file
@ -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;
|
20
lib/LasTres/DAO/Stats.pm
Normal file
20
lib/LasTres/DAO/Stats.pm
Normal file
@ -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;
|
20
lib/LasTres/DAO/Teams.pm
Normal file
20
lib/LasTres/DAO/Teams.pm
Normal file
@ -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;
|
137
lib/LasTres/PJ.pm
Normal file
137
lib/LasTres/PJ.pm
Normal file
@ -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;
|
@ -7,14 +7,35 @@ use warnings;
|
|||||||
|
|
||||||
use Moo;
|
use Moo;
|
||||||
|
|
||||||
with 'LasTres::Planet';
|
|
||||||
|
|
||||||
use Module::Pluggable search_path => ['LasTres::Planet::Bahdder'];
|
use Module::Pluggable search_path => ['LasTres::Planet::Bahdder'];
|
||||||
|
|
||||||
has super_areas => (
|
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',
|
return 'bahdder',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,20 +43,29 @@ sub _build_super_areas {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $hash = {};
|
my $hash = {};
|
||||||
my @super_areas = $self->plugins();
|
my @super_areas = $self->plugins();
|
||||||
for $super_area (@super_areas) {
|
for my $super_area (@super_areas) {
|
||||||
$hash->{$super_area->identifier} = $super_area;
|
$hash->{$super_area->identifier} = $super_area;
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name {
|
sub _build_name {
|
||||||
return 'Bahdder';
|
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 '
|
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. '
|
. '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. '
|
. '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. ';
|
. '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;
|
1;
|
||||||
|
@ -5,17 +5,47 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use feature 'signatures';
|
||||||
|
|
||||||
use Moo;
|
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';
|
with 'LasTres::SuperArea';
|
||||||
|
|
||||||
use Module::Pluggable search_path => ['LasTres::Planet::Bahdder::BosqueDelHeroe'];
|
sub _build_identifier {
|
||||||
|
|
||||||
has areas => (
|
|
||||||
is => 'lazy'
|
|
||||||
);
|
|
||||||
|
|
||||||
sub identifier {
|
|
||||||
return 'bosque_del_heroe';
|
return 'bosque_del_heroe';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,17 +53,17 @@ sub _build_areas {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $hash = {};
|
my $hash = {};
|
||||||
my @areas = $self->plugins();
|
my @areas = $self->plugins();
|
||||||
for $area (@areas) {
|
for my $area (@areas) {
|
||||||
$hash->{$area->identifier} = $area;
|
$hash->{$area->identifier} = $area;
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name {
|
sub _build_name {
|
||||||
return 'Bosque del Héroe';
|
return 'Bosque del Héroe';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub description {
|
sub _build_description {
|
||||||
return 'El Bosque del Héroe es el pulmón del planeta Bahdder. '
|
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. '
|
. '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. '
|
. '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. ';
|
. 'a usar la magia para la guerra. ';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parent {
|
sub _build_parent {
|
||||||
return LasTres::Planet::Bahdder->new;
|
return LasTres::Planet::Bahdder->instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $singleton;
|
||||||
|
sub instance {
|
||||||
|
my $class = shift;
|
||||||
|
if (!defined $singleton) {
|
||||||
|
$singleton = $class->new(@_);
|
||||||
|
}
|
||||||
|
return $singleton;
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -5,15 +5,42 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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 => (
|
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';
|
return 'bosque_del_heroe_i';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,17 +48,26 @@ sub _build_locations {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $hash = {};
|
my $hash = {};
|
||||||
my @locations = $self->plugins();
|
my @locations = $self->plugins();
|
||||||
for $location (@locations) {
|
for my $location (@locations) {
|
||||||
$hash->{$location->identifier} = $location;
|
$hash->{$location->identifier} = $location;
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name {
|
sub _build_name {
|
||||||
return 'Bosque del Héroe (I)';
|
return 'Bosque del Héroe (I)';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parent {
|
sub _build_parent {
|
||||||
return LasTres::Planet::Bahdder::BosqueDelHeroe->new;
|
return LasTres::Planet::Bahdder::BosqueDelHeroe->instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $singleton;
|
||||||
|
sub instance {
|
||||||
|
my $class = shift;
|
||||||
|
if (!defined $singleton) {
|
||||||
|
$singleton = $class->new(@_);
|
||||||
|
}
|
||||||
|
return $singleton;
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -5,31 +5,74 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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';
|
with 'LasTres::Location';
|
||||||
|
|
||||||
sub identifier {
|
sub _build_identifier {
|
||||||
return 'tribu_de_la_lima';
|
return 'tribu_de_la_lima';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name {
|
sub _build_name {
|
||||||
return 'Tribu de la Lima (Exterior)';
|
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í. '
|
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. '
|
. '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. ';
|
. 'Los cultivos de Lima están siempre buscando trabajadores, el sueldo es una parte de lo cosechado. ';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parent {
|
sub _build_parent {
|
||||||
return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI->new;
|
return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI->instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub actions {
|
sub _build_actions {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub npcs {
|
sub _build_npcs {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $singleton;
|
||||||
|
sub instance {
|
||||||
|
my $class = shift;
|
||||||
|
if (!defined $singleton) {
|
||||||
|
$singleton = $class->new(@_);
|
||||||
|
}
|
||||||
|
return $singleton;
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -9,15 +9,15 @@ use feature 'signatures';
|
|||||||
|
|
||||||
use Moo::Role;
|
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) {
|
sub hash($self) {
|
||||||
return {
|
return {
|
||||||
identifier => $self->{identifier},
|
identifier => $self->identifier,
|
||||||
name => $self->{name},
|
name => $self->name,
|
||||||
name_selection => $self->{name_selection},
|
name_selection => $self->name_selection,
|
||||||
description => $self->{description},
|
description => $self->description,
|
||||||
is_playable => $self->{is_playable},
|
is_playable => $self->is_playable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -5,31 +5,87 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use utf8;
|
||||||
|
|
||||||
use Moo;
|
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';
|
with 'LasTres::Race';
|
||||||
|
|
||||||
sub spawn {
|
sub _build_spawn {
|
||||||
return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::TribuDeLaLima->new;
|
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';
|
return 'aldimor';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name {
|
sub _build_name {
|
||||||
return 'Aldimor';
|
return 'Áldimor';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub name_selection {
|
sub _build_name_selection {
|
||||||
return 'Aldimor del Bosque del Héroe.';
|
return 'Áldimor del Bosque del Héroe';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub description {
|
sub _build_description {
|
||||||
return 'La raza de la naturaleza y la magia.';
|
return 'La raza de la naturaleza y la magia';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub is_playable {
|
sub _build_is_playable {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -7,8 +7,13 @@ use warnings;
|
|||||||
|
|
||||||
use feature 'signatures';
|
use feature 'signatures';
|
||||||
|
|
||||||
|
use Module::Pluggable search_path => ['LasTres::Race'],
|
||||||
|
instantiate => 'new',
|
||||||
|
on_require_error => sub ($plugin, $error) {
|
||||||
|
die $error;
|
||||||
|
};
|
||||||
|
|
||||||
use Moo;
|
use Moo;
|
||||||
use Module::Pluggable search_path => ['LasTres::Race'];
|
|
||||||
|
|
||||||
has hash => (
|
has hash => (
|
||||||
is => 'lazy',
|
is => 'lazy',
|
||||||
@ -16,11 +21,15 @@ has hash => (
|
|||||||
|
|
||||||
has hash_playable => (
|
has hash_playable => (
|
||||||
is => 'lazy',
|
is => 'lazy',
|
||||||
)
|
);
|
||||||
|
|
||||||
has hash_all => (
|
has hash_all => (
|
||||||
is => 'lazy',
|
is => 'lazy',
|
||||||
)
|
);
|
||||||
|
|
||||||
|
has hash_all_playable => (
|
||||||
|
is => 'lazy',
|
||||||
|
);
|
||||||
|
|
||||||
sub _build_hash_all($self) {
|
sub _build_hash_all($self) {
|
||||||
return { map { $_ => $self->hash->{$_}->hash } (keys %{$self->hash}) };
|
return { map { $_ => $self->hash->{$_}->hash } (keys %{$self->hash}) };
|
||||||
@ -43,14 +52,14 @@ sub _build_hash {
|
|||||||
my $hash = {};
|
my $hash = {};
|
||||||
my @races = $self->plugins();
|
my @races = $self->plugins();
|
||||||
for my $race (@races) {
|
for my $race (@races) {
|
||||||
$hash{$race->identifier} = $race;
|
$hash->{$race->identifier} = $race;
|
||||||
}
|
}
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _build_hash_playable {
|
sub _build_hash_playable {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $hash = {@{$self->hash}};
|
my $hash = {%{$self->hash}};
|
||||||
for my $identifier_race (keys %$hash) {
|
for my $identifier_race (keys %$hash) {
|
||||||
my $race = $hash->{$identifier_race};
|
my $race = $hash->{$identifier_race};
|
||||||
if (!$race->is_playable) {
|
if (!$race->is_playable) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package LasTres::Schema;
|
package LasTres::Schema;
|
||||||
our $VERSION = 1;
|
our $VERSION = 3;
|
||||||
|
|
||||||
use v5.36.0;
|
use v5.36.0;
|
||||||
|
|
||||||
|
@ -50,12 +50,7 @@ __PACKAGE__->add_columns(
|
|||||||
default_value => \'NOW()',
|
default_value => \'NOW()',
|
||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
},
|
},
|
||||||
level => {
|
experience => {
|
||||||
data_type => 'integer',
|
|
||||||
default_value => \'1',
|
|
||||||
is_nullable => 0,
|
|
||||||
},
|
|
||||||
exp => {
|
|
||||||
data_type => 'integer',
|
data_type => 'integer',
|
||||||
default_value => \'1',
|
default_value => \'1',
|
||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
@ -65,7 +60,12 @@ __PACKAGE__->add_columns(
|
|||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
is_foreign_key => 1,
|
is_foreign_key => 1,
|
||||||
},
|
},
|
||||||
stats => {
|
born_stats => {
|
||||||
|
data_type => 'uuid',
|
||||||
|
is_foreign_key => 1,
|
||||||
|
is_nullable => 0,
|
||||||
|
},
|
||||||
|
training_stats => {
|
||||||
data_type => 'uuid',
|
data_type => 'uuid',
|
||||||
is_foreign_key => 1,
|
is_foreign_key => 1,
|
||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
@ -84,12 +84,13 @@ __PACKAGE__->add_columns(
|
|||||||
data_type => 'uuid',
|
data_type => 'uuid',
|
||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
__PACKAGE__->set_primary_key('uuid');
|
__PACKAGE__->set_primary_key('uuid');
|
||||||
|
|
||||||
__PACKAGE__->has_many('npcs', 'LasTres::Schema::Result::CompanionNPC', 'owner');
|
__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('inventory', 'LasTres::Schema::Result::Inventory');
|
||||||
__PACKAGE__->belongs_to('skills', 'LasTres::Schema::Result::SkillLikeList');
|
__PACKAGE__->belongs_to('skills', 'LasTres::Schema::Result::SkillLikeList');
|
||||||
__PACKAGE__->belongs_to('spells', 'LasTres::Schema::Result::SkillLikeList');
|
__PACKAGE__->belongs_to('spells', 'LasTres::Schema::Result::SkillLikeList');
|
||||||
|
@ -5,6 +5,8 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use feature 'signatures';
|
||||||
|
|
||||||
use parent 'DBIx::Class::Core';
|
use parent 'DBIx::Class::Core';
|
||||||
|
|
||||||
__PACKAGE__->table('stats');
|
__PACKAGE__->table('stats');
|
||||||
@ -42,10 +44,11 @@ __PACKAGE__->add_columns(
|
|||||||
data_type => 'integer',
|
data_type => 'integer',
|
||||||
is_nullable => 0,
|
is_nullable => 0,
|
||||||
},
|
},
|
||||||
charisma => {
|
|
||||||
data_type => 'integer',
|
|
||||||
is_nullable => 0,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
__PACKAGE__->set_primary_key('uuid');
|
__PACKAGE__->set_primary_key('uuid');
|
||||||
|
|
||||||
|
sub model($self) {
|
||||||
|
require LasTres::Stats;
|
||||||
|
return LasTres::Stats->new($self->get_columns);
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -16,7 +16,7 @@ __PACKAGE__->add_columns(
|
|||||||
},
|
},
|
||||||
leader => {
|
leader => {
|
||||||
data_type => 'uuid',
|
data_type => 'uuid',
|
||||||
is_nullable => 0,
|
is_nullable => 1,
|
||||||
is_foreign_key => 1,
|
is_foreign_key => 1,
|
||||||
},
|
},
|
||||||
name => {
|
name => {
|
||||||
|
88
lib/LasTres/Stats.pm
Normal file
88
lib/LasTres/Stats.pm
Normal file
@ -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;
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user