Adding first implementation of known_places.
This commit is contained in:
parent
5ab2381ad3
commit
12e6fb8524
@ -1,6 +1,6 @@
|
|||||||
--
|
--
|
||||||
-- Created by SQL::Translator::Producer::PostgreSQL
|
-- Created by SQL::Translator::Producer::PostgreSQL
|
||||||
-- Created on Mon Jun 19 20:00:51 2023
|
-- Created on Wed Jun 21 03:04:31 2023
|
||||||
--
|
--
|
||||||
;
|
;
|
||||||
--
|
--
|
||||||
@ -193,6 +193,20 @@ CREATE TABLE "player_pjs_flags" (
|
|||||||
CREATE INDEX "player_pjs_flags_idx_owner" on "player_pjs_flags" ("owner");
|
CREATE INDEX "player_pjs_flags_idx_owner" on "player_pjs_flags" ("owner");
|
||||||
CREATE INDEX "index_flag" on "player_pjs_flags" ("owner", "name");
|
CREATE INDEX "index_flag" on "player_pjs_flags" ("owner", "name");
|
||||||
|
|
||||||
|
;
|
||||||
|
--
|
||||||
|
-- Table: player_pjs_known_places
|
||||||
|
--
|
||||||
|
CREATE TABLE "player_pjs_known_places" (
|
||||||
|
"owner" uuid NOT NULL,
|
||||||
|
"planet" text NOT NULL,
|
||||||
|
"super_area" text NOT NULL,
|
||||||
|
"area" text NOT NULL,
|
||||||
|
"location" text NOT NULL,
|
||||||
|
PRIMARY KEY ("owner", "planet", "super_area", "area", "location")
|
||||||
|
);
|
||||||
|
CREATE INDEX "player_pjs_known_places_idx_owner" on "player_pjs_known_places" ("owner");
|
||||||
|
|
||||||
;
|
;
|
||||||
--
|
--
|
||||||
-- Table: player_pjs_log
|
-- Table: player_pjs_log
|
||||||
@ -288,6 +302,10 @@ ALTER TABLE "player_companion_npcs" ADD CONSTRAINT "player_companion_npcs_fk_sta
|
|||||||
ALTER TABLE "player_pjs_flags" ADD CONSTRAINT "player_pjs_flags_fk_owner" FOREIGN KEY ("owner")
|
ALTER TABLE "player_pjs_flags" ADD CONSTRAINT "player_pjs_flags_fk_owner" FOREIGN KEY ("owner")
|
||||||
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
||||||
|
|
||||||
|
;
|
||||||
|
ALTER TABLE "player_pjs_known_places" ADD CONSTRAINT "player_pjs_known_places_fk_owner" FOREIGN KEY ("owner")
|
||||||
|
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
||||||
|
|
||||||
;
|
;
|
||||||
ALTER TABLE "player_pjs_log" ADD CONSTRAINT "player_pjs_log_fk_owner" FOREIGN KEY ("owner")
|
ALTER TABLE "player_pjs_log" ADD CONSTRAINT "player_pjs_log_fk_owner" FOREIGN KEY ("owner")
|
||||||
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
||||||
|
@ -4,251 +4,20 @@
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
;
|
;
|
||||||
CREATE TABLE "equipment" (
|
CREATE TABLE "player_pjs_known_places" (
|
||||||
"uuid" uuid NOT NULL,
|
|
||||||
PRIMARY KEY ("uuid")
|
|
||||||
);
|
|
||||||
|
|
||||||
;
|
|
||||||
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");
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "inventories" (
|
|
||||||
"uuid" uuid NOT NULL,
|
|
||||||
PRIMARY KEY ("uuid")
|
|
||||||
);
|
|
||||||
|
|
||||||
;
|
|
||||||
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"),
|
|
||||||
CONSTRAINT "inventory_items_unique_item" UNIQUE ("inventory", "identifier")
|
|
||||||
);
|
|
||||||
CREATE INDEX "inventory_items_idx_inventory" on "inventory_items" ("inventory");
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "player_companion_npcs" (
|
|
||||||
"uuid" uuid DEFAULT uuid_generate_v4() NOT NULL,
|
|
||||||
"owner" uuid 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");
|
|
||||||
|
|
||||||
;
|
|
||||||
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,
|
|
||||||
"health" integer NOT NULL,
|
|
||||||
"mana" integer 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");
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "player_pjs_flags" (
|
|
||||||
"name" text NOT NULL,
|
|
||||||
"owner" uuid NOT NULL,
|
|
||||||
PRIMARY KEY ("name", "owner")
|
|
||||||
);
|
|
||||||
CREATE INDEX "player_pjs_flags_idx_owner" on "player_pjs_flags" ("owner");
|
|
||||||
CREATE INDEX "index_flag" on "player_pjs_flags" ("owner", "name");
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "player_pjs_log" (
|
|
||||||
"uuid" uuid NOT NULL,
|
|
||||||
"content" jsonb NOT NULL,
|
|
||||||
"owner" uuid NOT NULL,
|
|
||||||
"date" timestamp DEFAULT NOW() NOT NULL,
|
|
||||||
PRIMARY KEY ("uuid")
|
|
||||||
);
|
|
||||||
CREATE INDEX "player_pjs_log_idx_owner" on "player_pjs_log" ("owner");
|
|
||||||
CREATE INDEX "index_log" on "player_pjs_log" ("owner", "date");
|
|
||||||
|
|
||||||
;
|
|
||||||
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")
|
|
||||||
);
|
|
||||||
|
|
||||||
;
|
|
||||||
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");
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "skill_like_lists" (
|
|
||||||
"uuid" uuid DEFAULT uuid_generate_v4() NOT NULL,
|
|
||||||
PRIMARY KEY ("uuid")
|
|
||||||
);
|
|
||||||
|
|
||||||
;
|
|
||||||
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")
|
|
||||||
);
|
|
||||||
|
|
||||||
;
|
|
||||||
CREATE TABLE "teams" (
|
|
||||||
"uuid" uuid NOT NULL,
|
|
||||||
"is_exploring" boolean DEFAULT false NOT NULL,
|
|
||||||
"explore_frame" integer DEFAULT 0 NOT NULL,
|
|
||||||
"leader" uuid,
|
|
||||||
"name" text NOT NULL,
|
|
||||||
"planet" text NOT NULL,
|
"planet" text NOT NULL,
|
||||||
"super_area" text NOT NULL,
|
"super_area" text NOT NULL,
|
||||||
"area" text NOT NULL,
|
"area" text NOT NULL,
|
||||||
"location" text NOT NULL,
|
"location" text NOT NULL,
|
||||||
PRIMARY KEY ("uuid"),
|
PRIMARY KEY ("owner", "planet", "super_area", "area", "location")
|
||||||
CONSTRAINT "u_name" UNIQUE ("name")
|
|
||||||
);
|
);
|
||||||
CREATE INDEX "teams_idx_leader" on "teams" ("leader");
|
CREATE INDEX "player_pjs_known_places_idx_owner" on "player_pjs_known_places" ("owner");
|
||||||
|
|
||||||
;
|
;
|
||||||
ALTER TABLE "equipment_items" ADD CONSTRAINT "equipment_items_fk_equipment" FOREIGN KEY ("equipment")
|
ALTER TABLE "player_pjs_known_places" ADD CONSTRAINT "player_pjs_known_places_fk_owner" FOREIGN KEY ("owner")
|
||||||
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 "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;
|
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;
|
|
||||||
|
|
||||||
;
|
|
||||||
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_pjs_flags" ADD CONSTRAINT "player_pjs_flags_fk_owner" FOREIGN KEY ("owner")
|
|
||||||
REFERENCES "player_pjs" ("uuid") ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;
|
|
||||||
|
|
||||||
;
|
|
||||||
ALTER TABLE "player_pjs_log" ADD CONSTRAINT "player_pjs_log_fk_owner" FOREIGN KEY ("owner")
|
|
||||||
REFERENCES "player_pjs" ("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;
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
@ -890,6 +890,97 @@ schema:
|
|||||||
name: player_pjs_flags
|
name: player_pjs_flags
|
||||||
options: []
|
options: []
|
||||||
order: 12
|
order: 12
|
||||||
|
player_pjs_known_places:
|
||||||
|
constraints:
|
||||||
|
- deferrable: 1
|
||||||
|
expression: ''
|
||||||
|
fields:
|
||||||
|
- owner
|
||||||
|
- planet
|
||||||
|
- super_area
|
||||||
|
- area
|
||||||
|
- location
|
||||||
|
match_type: ''
|
||||||
|
name: ''
|
||||||
|
on_delete: ''
|
||||||
|
on_update: ''
|
||||||
|
options: []
|
||||||
|
reference_fields: []
|
||||||
|
reference_table: ''
|
||||||
|
type: PRIMARY KEY
|
||||||
|
- deferrable: 1
|
||||||
|
expression: ''
|
||||||
|
fields:
|
||||||
|
- owner
|
||||||
|
match_type: ''
|
||||||
|
name: player_pjs_known_places_fk_owner
|
||||||
|
on_delete: CASCADE
|
||||||
|
on_update: CASCADE
|
||||||
|
options: []
|
||||||
|
reference_fields:
|
||||||
|
- uuid
|
||||||
|
reference_table: player_pjs
|
||||||
|
type: FOREIGN KEY
|
||||||
|
fields:
|
||||||
|
area:
|
||||||
|
data_type: text
|
||||||
|
default_value: ~
|
||||||
|
is_nullable: 0
|
||||||
|
is_primary_key: 1
|
||||||
|
is_unique: 0
|
||||||
|
name: area
|
||||||
|
order: 4
|
||||||
|
size:
|
||||||
|
- 0
|
||||||
|
location:
|
||||||
|
data_type: text
|
||||||
|
default_value: ~
|
||||||
|
is_nullable: 0
|
||||||
|
is_primary_key: 1
|
||||||
|
is_unique: 0
|
||||||
|
name: location
|
||||||
|
order: 5
|
||||||
|
size:
|
||||||
|
- 0
|
||||||
|
owner:
|
||||||
|
data_type: uuid
|
||||||
|
default_value: ~
|
||||||
|
is_nullable: 0
|
||||||
|
is_primary_key: 1
|
||||||
|
is_unique: 0
|
||||||
|
name: owner
|
||||||
|
order: 1
|
||||||
|
size:
|
||||||
|
- 0
|
||||||
|
planet:
|
||||||
|
data_type: text
|
||||||
|
default_value: ~
|
||||||
|
is_nullable: 0
|
||||||
|
is_primary_key: 1
|
||||||
|
is_unique: 0
|
||||||
|
name: planet
|
||||||
|
order: 2
|
||||||
|
size:
|
||||||
|
- 0
|
||||||
|
super_area:
|
||||||
|
data_type: text
|
||||||
|
default_value: ~
|
||||||
|
is_nullable: 0
|
||||||
|
is_primary_key: 1
|
||||||
|
is_unique: 0
|
||||||
|
name: super_area
|
||||||
|
order: 3
|
||||||
|
size:
|
||||||
|
- 0
|
||||||
|
indices:
|
||||||
|
- fields:
|
||||||
|
- owner
|
||||||
|
name: player_pjs_known_places_idx_owner
|
||||||
|
options: []
|
||||||
|
type: NORMAL
|
||||||
|
name: player_pjs_known_places
|
||||||
|
options: []
|
||||||
|
order: 13
|
||||||
player_pjs_log:
|
player_pjs_log:
|
||||||
constraints:
|
constraints:
|
||||||
- deferrable: 1
|
- deferrable: 1
|
||||||
@ -973,7 +1064,7 @@ schema:
|
|||||||
type: NORMAL
|
type: NORMAL
|
||||||
name: player_pjs_log
|
name: player_pjs_log
|
||||||
options: []
|
options: []
|
||||||
order: 13
|
order: 14
|
||||||
players:
|
players:
|
||||||
constraints:
|
constraints:
|
||||||
- deferrable: 1
|
- deferrable: 1
|
||||||
@ -1453,6 +1544,7 @@ translator:
|
|||||||
- InventoryItem
|
- InventoryItem
|
||||||
- PJ
|
- PJ
|
||||||
- PJFlag
|
- PJFlag
|
||||||
|
- PJKnownPlaces
|
||||||
- PJLog
|
- PJLog
|
||||||
- Player
|
- Player
|
||||||
- SkillLikeItem
|
- SkillLikeItem
|
||||||
|
@ -10,13 +10,27 @@ use feature 'signatures';
|
|||||||
use Moo::Role;
|
use Moo::Role;
|
||||||
|
|
||||||
requires qw/identifier locations name parent/;
|
requires qw/identifier locations name parent/;
|
||||||
|
|
||||||
has children => (
|
has children => (
|
||||||
is => 'ro',
|
is => 'ro',
|
||||||
lazy => 1,
|
lazy => 1,
|
||||||
builder => \&_build_children,
|
builder => \&_build_children,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
## OVERRIDE
|
||||||
|
sub get_auto_discover($self) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
## OVERRIDE
|
||||||
|
sub frames_to_move($self) {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
## OVERRIDE
|
||||||
|
sub frames_to_explore($self) {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
sub _build_children($self) {
|
sub _build_children($self) {
|
||||||
my $locations = $self->locations;
|
my $locations = $self->locations;
|
||||||
my @locations = map { $locations->{$_} } keys %$locations;
|
my @locations = map { $locations->{$_} } keys %$locations;
|
||||||
|
@ -64,6 +64,7 @@ sub handle ( $self, $ws, $session, $data ) {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
$pj->location->show_intro($pj);
|
$pj->location->show_intro($pj);
|
||||||
|
$pj->set_known_location($pj->location);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $info_packet_to_send =
|
my $info_packet_to_send =
|
||||||
|
@ -44,6 +44,13 @@ sub handle ( $self, $ws, $session, $data ) {
|
|||||||
return $ws->send( to_json( { error => "The location is malformed" } ) );
|
return $ws->send( to_json( { error => "The location is malformed" } ) );
|
||||||
}
|
}
|
||||||
my $pj = $session->{pj};
|
my $pj = $session->{pj};
|
||||||
|
if ( !defined $pj ) {
|
||||||
|
return $ws->send(
|
||||||
|
to_json(
|
||||||
|
{ error => 'You have not set a pj yet for this websocket.' }
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
my $team = $pj->team;
|
my $team = $pj->team;
|
||||||
my $leader = $team->leader;
|
my $leader = $team->leader;
|
||||||
if ( $leader->uuid ne $pj->uuid ) {
|
if ( $leader->uuid ne $pj->uuid ) {
|
||||||
|
@ -54,9 +54,6 @@ sub loop($self) {
|
|||||||
|
|
||||||
sub _work_frame($self) {
|
sub _work_frame($self) {
|
||||||
my $schema = $self->_schema;
|
my $schema = $self->_schema;
|
||||||
say 'Starting frame work.';
|
|
||||||
sleep int(rand(30));
|
|
||||||
say 'Ending frame work.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _real_loop($self) {
|
sub _real_loop($self) {
|
||||||
|
@ -16,6 +16,32 @@ requires qw/identifier name description parent actions npcs/;
|
|||||||
|
|
||||||
my $planets = LasTres::Planets->new;
|
my $planets = LasTres::Planets->new;
|
||||||
|
|
||||||
|
## OVERRIDE
|
||||||
|
sub can_visit($self, $pj) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
## OVERRIDE (Always use $self->SUPER::on_team_arrival.)
|
||||||
|
sub on_team_arrival($self, $team) {
|
||||||
|
$team = $team->get_from_storage;
|
||||||
|
for my $pj ($team->members) {
|
||||||
|
$self->on_pj_arrival($pj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
## OVERRIDE (Always use $self->SUPER::on_pj_arrival.)
|
||||||
|
sub on_pj_arrival($self, $pj) {
|
||||||
|
require LasTres::Redis;
|
||||||
|
$pj = $pj->get_from_storage;
|
||||||
|
my $redis = LasTres::Redis->new;
|
||||||
|
if (!$pj->knows_location($self)) {
|
||||||
|
$pj->set_known_location($self);
|
||||||
|
}
|
||||||
|
$self->show_intro($pj);
|
||||||
|
$redis->publish( $redis->pj_subscription($pj), to_json({ command => 'update-location' }));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub show_intro ( $self, $pj ) {
|
sub show_intro ( $self, $pj ) {
|
||||||
$pj->append_log_line(
|
$pj->append_log_line(
|
||||||
[
|
[
|
||||||
@ -28,29 +54,22 @@ sub show_intro ( $self, $pj ) {
|
|||||||
$pj->append_log_line( [ { text => $pj->location->description }, ] );
|
$pj->append_log_line( [ { text => $pj->location->description }, ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub notify_arrival($self, $team) {
|
|
||||||
require LasTres::Redis;
|
|
||||||
my $redis = LasTres::Redis->new;
|
|
||||||
for my $pj ($team->members) {
|
|
||||||
$self->show_intro($pj);
|
|
||||||
$redis->publish( $redis->pj_subscription($pj), to_json({ command => 'update-location' }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub place_team($self, $team) {
|
sub place_team($self, $team) {
|
||||||
$team->location($self);
|
$team->location($self);
|
||||||
$team->update;
|
$team->update;
|
||||||
$self->notify_arrival($team);
|
$self->on_team_arrival($team);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub to_array ($self) {
|
||||||
|
my $hash = $self->hash;
|
||||||
|
return [
|
||||||
|
$hash->{planet}{identifier}, $hash->{super_area}{identifier},
|
||||||
|
$hash->{area}{identifier}, $hash->{location}{identifier}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub to_json_array ($self) {
|
sub to_json_array ($self) {
|
||||||
my $hash = $self->hash;
|
return to_json($self->to_array);
|
||||||
return to_json(
|
|
||||||
[
|
|
||||||
$hash->{planet}{identifier}, $hash->{super_area}{identifier},
|
|
||||||
$hash->{area}{identifier}, $hash->{location}{identifier}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub is_connected_by_move ( $self, $otherLocation, $pj = undef ) {
|
sub is_connected_by_move ( $self, $otherLocation, $pj = undef ) {
|
||||||
@ -66,21 +85,32 @@ sub is_connected_by_move ( $self, $otherLocation, $pj = undef ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_available_locations_to_move_to ( $self, $pj ) {
|
sub get_available_locations_to_move_to ( $self, $pj = undef ) {
|
||||||
my $team = $pj->team;
|
my $location = $self;
|
||||||
my $location = $team->location;
|
|
||||||
|
|
||||||
my $connected_places = [];
|
my $connected_places = [];
|
||||||
if ( $location->can('connected_places') ) {
|
if ( $location->can('connected_places') ) {
|
||||||
@$connected_places = ( @{ $team->location->connected_places } );
|
@$connected_places = ( @{ $self->connected_places } );
|
||||||
}
|
}
|
||||||
@$connected_places =
|
@$connected_places =
|
||||||
( @$connected_places, @{ $location->parent->children } );
|
( @$connected_places, @{$self->_get_neighbour_locations_accesible($pj)} );
|
||||||
@$connected_places =
|
@$connected_places =
|
||||||
grep { $_->identifier ne $location->identifier } @$connected_places;
|
grep { $_->identifier ne $location->identifier } @$connected_places;
|
||||||
|
if (defined $pj) {
|
||||||
|
@$connected_places = grep { $_->can_visit($pj) } @$connected_places;
|
||||||
|
}
|
||||||
return $connected_places;
|
return $connected_places;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _get_neighbour_locations_accesible($self, $pj) {
|
||||||
|
my $places = [];
|
||||||
|
@$places = @{ $self->parent->children };
|
||||||
|
if (!$self->parent->get_auto_discover && defined $pj) {
|
||||||
|
@$places = grep { $pj->knows_location($_) } @$places;
|
||||||
|
}
|
||||||
|
return $places;
|
||||||
|
}
|
||||||
|
|
||||||
sub get ( $planet_id, $super_area_id, $area_id, $location_id ) {
|
sub get ( $planet_id, $super_area_id, $area_id, $location_id ) {
|
||||||
my $planet = $planets->hash->{$planet_id};
|
my $planet = $planets->hash->{$planet_id};
|
||||||
if ( !defined $planet ) {
|
if ( !defined $planet ) {
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI::Llano;
|
||||||
|
|
||||||
|
use v5.36.0;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
|
||||||
|
use Moo;
|
||||||
|
|
||||||
|
use LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI;
|
||||||
|
|
||||||
|
with 'LasTres::Location';
|
||||||
|
|
||||||
|
sub identifier {
|
||||||
|
return 'llano';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub name {
|
||||||
|
return 'Llano de las liebres';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub description {
|
||||||
|
return 'En el llano de las liebres suelen encontrarse roedores comestibles, y también sus depredadores...';
|
||||||
|
}
|
||||||
|
sub parent {
|
||||||
|
return LasTres::Planet::Bahdder::BosqueDelHeroe::BosqueDelHeroeI->instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub actions {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub npcs {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub connected_places {
|
||||||
|
return [
|
||||||
|
LasTres::Planet::Bahdder::BosqueDelHeroe::TribuDeLaLima::Entrada->instance,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
my $singleton;
|
||||||
|
sub instance {
|
||||||
|
my $class = shift;
|
||||||
|
if (!defined $singleton) {
|
||||||
|
$singleton = $class->new(@_);
|
||||||
|
}
|
||||||
|
return $singleton;
|
||||||
|
}
|
||||||
|
1;
|
@ -5,7 +5,7 @@ use v5.36.0;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
our $VERSION = 6;
|
our $VERSION = 7;
|
||||||
|
|
||||||
use feature 'signatures';
|
use feature 'signatures';
|
||||||
|
|
||||||
|
@ -112,6 +112,8 @@ __PACKAGE__->set_primary_key('uuid');
|
|||||||
__PACKAGE__->has_many( 'npcs', 'LasTres::Schema::Result::CompanionNPC',
|
__PACKAGE__->has_many( 'npcs', 'LasTres::Schema::Result::CompanionNPC',
|
||||||
'owner' );
|
'owner' );
|
||||||
__PACKAGE__->has_many( 'logs', 'LasTres::Schema::Result::PJLog', 'owner' );
|
__PACKAGE__->has_many( 'logs', 'LasTres::Schema::Result::PJLog', 'owner' );
|
||||||
|
__PACKAGE__->has_many( 'known_places',
|
||||||
|
'LasTres::Schema::Result::PJKnownPlaces', 'owner' );
|
||||||
__PACKAGE__->has_many( 'flags', 'LasTres::Schema::Result::PJFlag', 'owner' );
|
__PACKAGE__->has_many( 'flags', 'LasTres::Schema::Result::PJFlag', 'owner' );
|
||||||
__PACKAGE__->belongs_to( 'born_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( 'training_stats', 'LasTres::Schema::Result::Stats' );
|
||||||
@ -122,6 +124,44 @@ __PACKAGE__->belongs_to( 'equipment', 'LasTres::Schema::Result::Equipment' );
|
|||||||
__PACKAGE__->belongs_to( 'team', 'LasTres::Schema::Result::Team' );
|
__PACKAGE__->belongs_to( 'team', 'LasTres::Schema::Result::Team' );
|
||||||
__PACKAGE__->belongs_to( 'owner', 'LasTres::Schema::Result::Player' );
|
__PACKAGE__->belongs_to( 'owner', 'LasTres::Schema::Result::Player' );
|
||||||
|
|
||||||
|
sub knows_location ( $self, $location ) {
|
||||||
|
require LasTres::Schema;
|
||||||
|
my $array = $location->to_array;
|
||||||
|
my ( $planet, $super_area, $area ) = @$array[ 0 .. 2 ];
|
||||||
|
$location = $array->[3];
|
||||||
|
my $schema = LasTres::Schema->Schema;
|
||||||
|
my @places = $schema->resultset('PJKnownPlaces')->search(
|
||||||
|
{
|
||||||
|
owner => $self->uuid,
|
||||||
|
planet => $planet,
|
||||||
|
super_area => $super_area,
|
||||||
|
area => $area,
|
||||||
|
location => $location
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (@places) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_known_location ( $self, $location ) {
|
||||||
|
require LasTres::Schema;
|
||||||
|
my $array = $location->to_array;
|
||||||
|
my ( $planet, $super_area, $area ) = @$array[ 0 .. 2 ];
|
||||||
|
$location = $array->[3];
|
||||||
|
my $schema = LasTres::Schema->Schema;
|
||||||
|
$schema->resultset('PJKnownPlaces')
|
||||||
|
->new( {
|
||||||
|
owner => $self->uuid,
|
||||||
|
planet => $planet,
|
||||||
|
super_area => $super_area,
|
||||||
|
area => $area,
|
||||||
|
location => $location
|
||||||
|
}
|
||||||
|
)->insert;
|
||||||
|
}
|
||||||
|
|
||||||
sub hash ($self) {
|
sub hash ($self) {
|
||||||
my $image;
|
my $image;
|
||||||
my $race = $self->race;
|
my $race = $self->race;
|
||||||
|
74
lib/LasTres/Schema/Result/PJKnownPlaces.pm
Normal file
74
lib/LasTres/Schema/Result/PJKnownPlaces.pm
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package LasTres::Schema::Result::PJKnownPlaces;
|
||||||
|
|
||||||
|
use v5.36.0;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use feature 'signatures';
|
||||||
|
|
||||||
|
use parent 'DBIx::Class::Core';
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
use JSON qw/from_json/;
|
||||||
|
use DateTime::Format::ISO8601::Format;
|
||||||
|
|
||||||
|
use Moo;
|
||||||
|
|
||||||
|
__PACKAGE__->table('player_pjs_known_places');
|
||||||
|
|
||||||
|
__PACKAGE__->add_columns(
|
||||||
|
owner => {
|
||||||
|
data_type => 'uuid',
|
||||||
|
is_nullable => 0,
|
||||||
|
is_foreign_key => 1,
|
||||||
|
},
|
||||||
|
planet => {
|
||||||
|
data_type => 'text',
|
||||||
|
is_nullable => 0,
|
||||||
|
accessor => '_planet',
|
||||||
|
},
|
||||||
|
super_area => {
|
||||||
|
data_type => 'text',
|
||||||
|
is_nullable => 0,
|
||||||
|
accessor => '_super_area',
|
||||||
|
},
|
||||||
|
area => {
|
||||||
|
data_type => 'text',
|
||||||
|
is_nullable => 0,
|
||||||
|
accessor => '_area',
|
||||||
|
},
|
||||||
|
location => {
|
||||||
|
data_type => 'text',
|
||||||
|
is_nullable => 0,
|
||||||
|
accessor => '_location',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
sub location {
|
||||||
|
my $self = shift;
|
||||||
|
my $location = shift;
|
||||||
|
my $planet;
|
||||||
|
my $super_area;
|
||||||
|
my $area;
|
||||||
|
if ( defined $location ) {
|
||||||
|
$self->_location( $location->identifier );
|
||||||
|
$area = $location->parent;
|
||||||
|
$self->_area( $area->identifier );
|
||||||
|
$super_area = $area->parent;
|
||||||
|
$self->_super_area( $super_area->identifier );
|
||||||
|
$planet = $super_area->parent;
|
||||||
|
$self->_planet( $planet->identifier );
|
||||||
|
}
|
||||||
|
$location = $self->_location;
|
||||||
|
$area = $self->_area;
|
||||||
|
$super_area = $self->_super_area;
|
||||||
|
$planet = $self->_planet;
|
||||||
|
$location =
|
||||||
|
LasTres::Location::get( $planet, $super_area, $area, $location );
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
|
__PACKAGE__->set_primary_key(qw/owner planet super_area area location/);
|
||||||
|
__PACKAGE__->belongs_to( 'owner', 'LasTres::Schema::Result::PJ' );
|
||||||
|
1;
|
Loading…
Reference in New Issue
Block a user