Condense blueprints and fights to live, rename auth
This commit is contained in:
parent
8b03b209dc
commit
b9ab398792
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
.env
|
||||
database/*.db
|
||||
db/*.db
|
||||
|
|
15
color.php
15
color.php
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* A collection of functions to colorize the output of the terminal.
|
||||
*/
|
||||
|
||||
function c($c, $s) { return $c . $s . "\033[0m"; }
|
||||
function black($s) { return c("\033[30m", $s); }
|
||||
function red($s) { return c("\033[31m", $s); }
|
||||
function green($s) { return c("\033[32m", $s); }
|
||||
function yellow($s) { return c("\033[33m", $s); }
|
||||
function blue($s) { return c("\033[34m", $s); }
|
||||
function magenta($s) { return c("\033[35m", $s); }
|
||||
function cyan($s) { return c("\033[36m", $s); }
|
||||
function white($s) { return c("\033[37m", $s); }
|
|
@ -1,56 +0,0 @@
|
|||
DROP TABLE IF EXISTS items;
|
||||
CREATE TABLE items (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL DEFAULT 0,
|
||||
`subtype` INTEGER NOT NULL DEFAULT 0,
|
||||
`slot` INTEGER NOT NULL DEFAULT 0,
|
||||
`rarity` INTEGER NOT NULL DEFAULT 0,
|
||||
`value` INTEGER NOT NULL DEFAULT 0,
|
||||
`consumable` INTEGER NOT NULL DEFAULT 0,
|
||||
`duration` INTEGER NOT NULL DEFAULT 0,
|
||||
`durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`pow` INTEGER NOT NULL DEFAULT 0, -- Power
|
||||
`acc` INTEGER NOT NULL DEFAULT 0, -- Accuracy
|
||||
`pen` INTEGER NOT NULL DEFAULT 0, -- Penetration
|
||||
`foc` INTEGER NOT NULL DEFAULT 0, -- Focus
|
||||
`tou` INTEGER NOT NULL DEFAULT 0, -- Toughness
|
||||
`arm` INTEGER NOT NULL DEFAULT 0, -- Armor
|
||||
`res` INTEGER NOT NULL DEFAULT 0, -- Resist
|
||||
`pre` INTEGER NOT NULL DEFAULT 0, -- Precision
|
||||
`fer` INTEGER NOT NULL DEFAULT 0, -- Ferocity
|
||||
`luck` INTEGER NOT NULL DEFAULT 0,
|
||||
`reqs` TEXT NOT NULL DEFAULT "",
|
||||
`traits` TEXT NOT NULL DEFAULT "",
|
||||
`lore` TEXT NOT NULL DEFAULT "",
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS mobs;
|
||||
CREATE TABLE mobs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`rank` INTEGER NOT NULL,
|
||||
`level` INTEGER NOT NULL,
|
||||
`hp` INTEGER NOT NULL,
|
||||
`m_hp` INTEGER NOT NULL,
|
||||
`mp` INTEGER NOT NULL,
|
||||
`m_mp` INTEGER NOT NULL,
|
||||
`pow` INTEGER NOT NULL, -- Power
|
||||
`acc` INTEGER NOT NULL, -- Accuracy
|
||||
`pen` INTEGER NOT NULL, -- Penetration
|
||||
`foc` INTEGER NOT NULL, -- Focus
|
||||
`tou` INTEGER NOT NULL, -- Toughness
|
||||
`arm` INTEGER NOT NULL, -- Armor
|
||||
`res` INTEGER NOT NULL, -- Resist
|
||||
`pre` INTEGER NOT NULL, -- Precision
|
||||
`fer` INTEGER NOT NULL, -- Ferocity
|
||||
`xp` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL,
|
||||
`loot` TEXT NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
@PvE
|
||||
*/
|
||||
DROP TABLE IF EXISTS pve;
|
||||
CREATE TABLE pve (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`char_hp` INTEGER NOT NULL,
|
||||
`char_m_hp` INTEGER NOT NULL,
|
||||
`char_mp` INTEGER NOT NULL,
|
||||
`char_m_mp` INTEGER NOT NULL,
|
||||
`char_pow` INTEGER NOT NULL, -- Power
|
||||
`char_acc` INTEGER NOT NULL, -- Accuracy
|
||||
`char_pen` INTEGER NOT NULL, -- Penetration
|
||||
`char_foc` INTEGER NOT NULL, -- Focus
|
||||
`char_tou` INTEGER NOT NULL, -- Toughness
|
||||
`char_arm` INTEGER NOT NULL, -- Armor
|
||||
`char_res` INTEGER NOT NULL, -- Resist
|
||||
`char_pre` INTEGER NOT NULL, -- Precision
|
||||
`char_fer` INTEGER NOT NULL, -- Ferocity
|
||||
`mob_id` INTEGER NOT NULL,
|
||||
`mob_level` INTEGER NOT NULL,
|
||||
`mob_rank` INTEGER NOT NULL,
|
||||
`mob_hp` INTEGER NOT NULL,
|
||||
`mob_m_hp` INTEGER NOT NULL,
|
||||
`mob_mp` INTEGER NOT NULL,
|
||||
`mob_m_mp` INTEGER NOT NULL,
|
||||
`mob_pow` INTEGER NOT NULL, -- Power
|
||||
`mob_acc` INTEGER NOT NULL, -- Accuracy
|
||||
`mob_pen` INTEGER NOT NULL, -- Penetration
|
||||
`mob_foc` INTEGER NOT NULL, -- Focus
|
||||
`mob_tou` INTEGER NOT NULL, -- Toughness
|
||||
`mob_arm` INTEGER NOT NULL, -- Armor
|
||||
`mob_res` INTEGER NOT NULL, -- Resist
|
||||
`mob_pre` INTEGER NOT NULL, -- Precision
|
||||
`mob_fer` INTEGER NOT NULL, -- Ferocity
|
||||
`first_turn` INTEGER NOT NULL,
|
||||
`turn` INTEGER NOT NULL default 1,
|
||||
`winner` INTEGER NOT NULL default 0,
|
||||
`can_flee` INTEGER NOT NULL default 1,
|
||||
`escaped` INTEGER NOT NULL default 0,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_pve_char_id ON pve (`char_id`);
|
||||
|
||||
DROP TABLE IF EXISTS pve_logs;
|
||||
CREATE TABLE pve_logs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`fight_id` INTEGER NOT NULL,
|
||||
`info` TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_pve_logs_fight_id ON pve_logs (`fight_id`);
|
||||
|
||||
/*
|
||||
@PvP
|
||||
*/
|
||||
DROP TABLE IF EXISTS pvp;
|
||||
CREATE TABLE pvp (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`char1_id` INTEGER NOT NULL,
|
||||
`char1_hp` INTEGER NOT NULL,
|
||||
`char1_max_hp` INTEGER NOT NULL,
|
||||
`char1_mp` INTEGER NOT NULL,
|
||||
`char1_max_mp` INTEGER NOT NULL,
|
||||
`char1_pow` INTEGER NOT NULL, -- Power
|
||||
`char1_acc` INTEGER NOT NULL, -- Accuracy
|
||||
`char1_pen` INTEGER NOT NULL, -- Penetration
|
||||
`char1_foc` INTEGER NOT NULL, -- Focus
|
||||
`char1_tou` INTEGER NOT NULL, -- Toughness
|
||||
`char1_arm` INTEGER NOT NULL, -- Armor
|
||||
`char1_res` INTEGER NOT NULL, -- Resist
|
||||
`char1_pre` INTEGER NOT NULL, -- Precision
|
||||
`char1_fer` INTEGER NOT NULL, -- Ferocity
|
||||
`char2_id` INTEGER NOT NULL,
|
||||
`char2_hp` INTEGER NOT NULL,
|
||||
`char2_m_hp` INTEGER NOT NULL,
|
||||
`char2_mp` INTEGER NOT NULL,
|
||||
`char2_m_mp` INTEGER NOT NULL,
|
||||
`char2_pow` INTEGER NOT NULL, -- Power
|
||||
`char2_acc` INTEGER NOT NULL, -- Accuracy
|
||||
`char2_pen` INTEGER NOT NULL, -- Penetration
|
||||
`char2_foc` INTEGER NOT NULL, -- Focus
|
||||
`char2_tou` INTEGER NOT NULL, -- Toughness
|
||||
`char2_arm` INTEGER NOT NULL, -- Armor
|
||||
`char2_res` INTEGER NOT NULL, -- Resist
|
||||
`char2_pre` INTEGER NOT NULL, -- Precision
|
||||
`char2_fer` INTEGER NOT NULL, -- Ferocity
|
||||
`first_turn` INTEGER NOT NULL,
|
||||
`turn` INTEGER NOT NULL default 1,
|
||||
`winner` INTEGER NOT NULL default 0,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_pvp_char1_id ON pvp (`char1_id`);
|
||||
CREATE INDEX idx_pvp_char2_id ON pvp (`char2_id`);
|
||||
|
||||
CREATE TABLE pvp_logs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`fight_id` INTEGER NOT NULL,
|
||||
`info` TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_pvp_logs_fight_id ON pvp_logs (`fight_id`);
|
|
@ -1,333 +0,0 @@
|
|||
/*
|
||||
============================================================
|
||||
Stats
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE stats (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`luck` INTEGER NOT NULL DEFAULT 0,
|
||||
`armor` INTEGER NOT NULL DEFAULT 0,
|
||||
`focus` INTEGER NOT NULL DEFAULT 0,
|
||||
`power` INTEGER NOT NULL DEFAULT 0,
|
||||
`resist` INTEGER NOT NULL DEFAULT 0,
|
||||
`accuracy` INTEGER NOT NULL DEFAULT 0,
|
||||
`ferocity` INTEGER NOT NULL DEFAULT 0,
|
||||
`precision` INTEGER NOT NULL DEFAULT 0,
|
||||
`toughness` INTEGER NOT NULL DEFAULT 0,
|
||||
`penetration` INTEGER NOT NULL DEFAULT 0,
|
||||
) STRICT;
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Characters
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE characters (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`name` TEXT NOT NULL UNIQUE,
|
||||
`title_id` INTEGER NOT NULL DEFAULT 1,
|
||||
`level` INTEGER NOT NULL DEFAULT 1,
|
||||
`xp` INTEGER NOT NULL DEFAULT 0,
|
||||
`xp_to_level` INTEGER NOT NULL DEFAULT 100,
|
||||
`hp` INTEGER NOT NULL DEFAULT 20,
|
||||
`m_hp` INTEGER NOT NULL DEFAULT 20,
|
||||
`mp` INTEGER NOT NULL DEFAULT 10,
|
||||
`m_mp` INTEGER NOT NULL DEFAULT 10,
|
||||
`tp` INTEGER NOT NULL DEFAULT 1,
|
||||
`m_tp` INTEGER NOT NULL DEFAULT 1,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`inv_slots` INTEGER NOT NULL DEFAULT 10,
|
||||
`att_points` INTEGER NOT NULL DEFAULT 0,
|
||||
`bio` TEXT DEFAULT ''
|
||||
);
|
||||
CREATE INDEX idx_characters_user_id ON characters (`user_id`);
|
||||
|
||||
CREATE TABLE equipped_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`head` INTEGER NOT NULL DEFAULT 0,
|
||||
`chest` INTEGER NOT NULL DEFAULT 0,
|
||||
`boots` INTEGER NOT NULL DEFAULT 0,
|
||||
`hands` INTEGER NOT NULL DEFAULT 0,
|
||||
`m_hand` INTEGER NOT NULL DEFAULT 0,
|
||||
`o_hand` INTEGER NOT NULL DEFAULT 0,
|
||||
`rune` INTEGER NOT NULL DEFAULT 0,
|
||||
`ring` INTEGER NOT NULL DEFAULT 0,
|
||||
`amulet` INTEGER NOT NULL DEFAULT 0,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`max_hp` INTEGER NOT NULL DEFAULT 0,
|
||||
`max_mp` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_char_gear_char_id ON char_gear (`char_id`);
|
||||
|
||||
CREATE TABLE inventory_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`item_id` INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_inventory_char_id ON char_inventory (`char_id`);
|
||||
|
||||
-- Wallets are account-bound rather than character-bound. Should I move this to auth?
|
||||
CREATE TABLE wallets (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL DEFAULT 10,
|
||||
`stargem` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_wallets_user_id ON wallets (`user_id`);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Blog
|
||||
============================================================
|
||||
*/
|
||||
create table blog (
|
||||
`id` integer primary KEY AUTOINCREMENT,
|
||||
`author_id` integer not null,
|
||||
`title` TEXT not null,
|
||||
`slug` TEXT not null unique,
|
||||
`content` TEXT not null,
|
||||
`created` DATETIME default current_timestamp,
|
||||
`updated` DATETIME default current_timestamp
|
||||
);
|
||||
CREATE INDEX idx_blog_author_id ON blog (`author_id`);
|
||||
CREATE INDEX idx_blog_slug ON blog (`slug`);
|
||||
|
||||
/*
|
||||
@WALLETS
|
||||
*/
|
||||
DROP TABLE IF EXISTS wallets;
|
||||
CREATE TABLE wallets (
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL DEFAULT 10,
|
||||
`stargem` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_wallets_user_id ON wallets (`user_id`);
|
||||
|
||||
/*
|
||||
@CHARBANK
|
||||
*/
|
||||
DROP TABLE IF EXISTS char_bank;
|
||||
CREATE TABLE char_bank (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`slots` INTEGER NOT NULL DEFAULT 5,
|
||||
`silver` INTEGER NOT NULL DEFAULT 0,
|
||||
`tier` INTEGER NOT NULL DEFAULT 0,
|
||||
`can_collect` INTEGER NOT NULL DEFAULT 1,
|
||||
`last_collect` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_bank_char_id ON char_bank (`char_id`);
|
||||
|
||||
/*
|
||||
@CHARBANKITEMS
|
||||
*/
|
||||
DROP TABLE IF EXISTS char_banked_items;
|
||||
CREATE TABLE char_banked_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`item_id` INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_banked_items_char_id ON char_banked_items (`char_id`);
|
||||
CREATE INDEX idx_banked_items_item_id ON char_banked_items (`item_id`);
|
||||
|
||||
/*
|
||||
@TOWNS
|
||||
*/
|
||||
DROP TABLE IF EXISTS towns;
|
||||
CREATE TABLE towns (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_towns_location ON towns (`x`, `y`);
|
||||
|
||||
/*
|
||||
@SHOPS
|
||||
*/
|
||||
DROP TABLE IF EXISTS shops;
|
||||
CREATE TABLE shops (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`items` TEXT NOT NULL,
|
||||
`gear` TEXT NOT NULL,
|
||||
`materials` TEXT NOT NULL,
|
||||
`b_mod` INTEGER NOT NULL DEFAULT 100,
|
||||
`s_mod` INTEGER NOT NULL DEFAULT 100,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_shops_location ON shops (`x`, `y`);
|
||||
|
||||
/*
|
||||
@INNS
|
||||
*/
|
||||
DROP TABLE IF EXISTS inns;
|
||||
CREATE TABLE inns (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`cost` INTEGER NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_inns_location ON inns (`x`, `y`);
|
||||
|
||||
/*
|
||||
@GUILDS
|
||||
*/
|
||||
DROP TABLE IF EXISTS guilds;
|
||||
CREATE TABLE guilds (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`lore` TEXT NOT NULL DEFAULT "",
|
||||
`leader_id` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL DEFAULT 0,
|
||||
`rep` INTEGER NOT NULL DEFAULT 0,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_guilds_leader_id ON guilds (`leader_id`);
|
||||
|
||||
/*
|
||||
@GUILDRANKS
|
||||
*/
|
||||
DROP TABLE IF EXISTS guild_ranks;
|
||||
CREATE TABLE guild_ranks (
|
||||
`guild_id` INTEGER NOT NULL,
|
||||
`order` INTEGER NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`permissions` TEXT NOT NULL,
|
||||
`leader` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_guild_ranks_guild_id ON guild_ranks (`guild_id`);
|
||||
|
||||
/*
|
||||
@GUILDMEMBERS
|
||||
*/
|
||||
DROP TABLE IF EXISTS guild_members;
|
||||
CREATE TABLE guild_members (
|
||||
`guild_id` INTEGER NOT NULL,
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`rank` INTEGER NOT NULL,
|
||||
`rep` INTEGER NOT NULL DEFAULT 0,
|
||||
`donated` INTEGER NOT NULL DEFAULT 0,
|
||||
`joined` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_guild_members_guild_id ON guild_members (`guild_id`);
|
||||
CREATE INDEX idx_guild_members_char_id ON guild_members (`char_id`);
|
||||
|
||||
/*
|
||||
@NPCS
|
||||
*/
|
||||
DROP TABLE IF EXISTS npcs;
|
||||
CREATE TABLE npcs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`conversation` TEXT NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_npcs_location ON npcs (`x`, `y`);
|
||||
|
||||
/*
|
||||
@TOWNREP
|
||||
*/
|
||||
DROP TABLE IF EXISTS char_town_rep;
|
||||
CREATE TABLE char_town_rep (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`town_id` INTEGER NOT NULL,
|
||||
`rep` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_char_town_rep_char_id ON char_town_rep (`char_id`);
|
||||
|
||||
/*
|
||||
@ITEMS
|
||||
*/
|
||||
DROP TABLE IF EXISTS items;
|
||||
CREATE TABLE items (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` TEXT NOT NULL DEFAULT 0,
|
||||
`rarity` INTEGER NOT NULL DEFAULT 0,
|
||||
`forged` INTEGER NOT NULL DEFAULT 0,
|
||||
`quality` INTEGER NOT NULL DEFAULT 0,
|
||||
`value` INTEGER NOT NULL DEFAULT 0,
|
||||
`consumable` INTEGER NOT NULL DEFAULT 0,
|
||||
`duration` INTEGER NOT NULL DEFAULT 0,
|
||||
`durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`m_durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`pow` INTEGER NOT NULL DEFAULT 0, -- Power
|
||||
`acc` INTEGER NOT NULL DEFAULT 0, -- Accuracy
|
||||
`pen` INTEGER NOT NULL DEFAULT 0, -- Penetration
|
||||
`foc` INTEGER NOT NULL DEFAULT 0, -- Focus
|
||||
`tou` INTEGER NOT NULL DEFAULT 0, -- Toughness
|
||||
`arm` INTEGER NOT NULL DEFAULT 0, -- Armor
|
||||
`res` INTEGER NOT NULL DEFAULT 0, -- Resist
|
||||
`pre` INTEGER NOT NULL DEFAULT 0, -- Precision
|
||||
`fer` INTEGER NOT NULL DEFAULT 0, -- Ferocity
|
||||
`luck` INTEGER NOT NULL DEFAULT 0, -- Luck
|
||||
`reqs` TEXT NOT NULL DEFAULT "",
|
||||
`traits` TEXT NOT NULL DEFAULT "",
|
||||
`lore` TEXT NOT NULL DEFAULT "",
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
/*
|
||||
@CHARTRAITS
|
||||
*/
|
||||
DROP TABLE IF EXISTS char_traits;
|
||||
CREATE TABLE char_traits (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`trait_id` INTEGER NOT NULL,
|
||||
`value` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_char_traits_char_id ON char_traits (`char_id`);
|
||||
|
||||
/*
|
||||
@CHARLOCATIONS
|
||||
*/
|
||||
DROP TABLE IF EXISTS char_locations;
|
||||
CREATE TABLE char_locations (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`currently` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_char_locations_char_id ON char_locations (`char_id`);
|
||||
CREATE INDEX idx_char_locations_location ON char_locations (`x`, `y`);
|
||||
|
||||
/*
|
||||
@TITLES
|
||||
*/
|
||||
DROP TABLE IF EXISTS titles;
|
||||
CREATE TABLE titles (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL DEFAULT 'Title',
|
||||
`lore` TEXT
|
||||
);
|
||||
|
||||
/*
|
||||
@OWNEDTITLES
|
||||
*/
|
||||
DROP TABLE IF EXISTS owned_titles;
|
||||
CREATE TABLE owned_titles (
|
||||
`title_id` INTEGER NOT NULL,
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`awarded` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_owned_titles_char_id ON owned_titles (`char_id`);
|
||||
CREATE INDEX idx_owned_titles_owned ON owned_titles (`char_id`, `title_id`);
|
|
@ -1,77 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Directories for schema and population scripts
|
||||
CREATE_DIR="create"
|
||||
POPULATE_DIR="populate"
|
||||
|
||||
# List of databases
|
||||
DATABASES=("auth" "blueprints" "fights" "live")
|
||||
|
||||
# Function to create a database and apply the schema
|
||||
create_db() {
|
||||
for db in "${DATABASES[@]}"; do
|
||||
db_file="${db}.db"
|
||||
schema_file="${CREATE_DIR}/${db}.sql"
|
||||
|
||||
if [[ -f "$schema_file" ]]; then
|
||||
echo "Creating $db_file and applying schema from $schema_file..."
|
||||
sqlite3 "$db_file" < "$schema_file"
|
||||
else
|
||||
echo "Schema file for $db not found. Skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to populate the database with data
|
||||
populate_db() {
|
||||
for db in "${DATABASES[@]}"; do
|
||||
db_file="${db}.db"
|
||||
populate_file="${POPULATE_DIR}/${db}.sql"
|
||||
|
||||
if [[ -f "$populate_file" ]]; then
|
||||
echo "Populating $db_file using data from $populate_file..."
|
||||
sqlite3 "$db_file" < "$populate_file"
|
||||
else
|
||||
echo "Population file for $db not found. Skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to drop (delete) the databases
|
||||
drop_db() {
|
||||
for db in "${DATABASES[@]}"; do
|
||||
db_file="${db}.db"
|
||||
|
||||
if [[ -f "$db_file" ]]; then
|
||||
echo "Dropping $db_file..."
|
||||
rm "$db_file"
|
||||
else
|
||||
echo "$db_file does not exist. Skipping."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function for a full reset (create and populate)
|
||||
full_reset() {
|
||||
create_db
|
||||
populate_db
|
||||
}
|
||||
|
||||
# Main script
|
||||
case $1 in
|
||||
create)
|
||||
create_db
|
||||
;;
|
||||
populate)
|
||||
populate_db
|
||||
;;
|
||||
reset)
|
||||
full_reset
|
||||
;;
|
||||
drop)
|
||||
drop_db
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {create|populate|reset|drop}"
|
||||
;;
|
||||
esac
|
290
db/sql/create/live.sql
Normal file
290
db/sql/create/live.sql
Normal file
|
@ -0,0 +1,290 @@
|
|||
/*
|
||||
============================================================
|
||||
Stats
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE stats (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`luck` INTEGER NOT NULL DEFAULT 0,
|
||||
`armor` INTEGER NOT NULL DEFAULT 0,
|
||||
`focus` INTEGER NOT NULL DEFAULT 0,
|
||||
`power` INTEGER NOT NULL DEFAULT 0,
|
||||
`resist` INTEGER NOT NULL DEFAULT 0,
|
||||
`accuracy` INTEGER NOT NULL DEFAULT 0,
|
||||
`ferocity` INTEGER NOT NULL DEFAULT 0,
|
||||
`precision` INTEGER NOT NULL DEFAULT 0,
|
||||
`toughness` INTEGER NOT NULL DEFAULT 0,
|
||||
`penetration` INTEGER NOT NULL DEFAULT 0
|
||||
) STRICT;
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Characters
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE characters (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`user_id` INTEGER NOT NULL,
|
||||
`name` TEXT NOT NULL UNIQUE,
|
||||
`title_id` INTEGER NOT NULL DEFAULT 1,
|
||||
`level` INTEGER NOT NULL DEFAULT 1,
|
||||
`xp` INTEGER NOT NULL DEFAULT 0,
|
||||
`xp_to_level` INTEGER NOT NULL DEFAULT 100,
|
||||
`hp` INTEGER NOT NULL DEFAULT 20,
|
||||
`m_hp` INTEGER NOT NULL DEFAULT 20,
|
||||
`mp` INTEGER NOT NULL DEFAULT 10,
|
||||
`m_mp` INTEGER NOT NULL DEFAULT 10,
|
||||
`tp` INTEGER NOT NULL DEFAULT 1,
|
||||
`m_tp` INTEGER NOT NULL DEFAULT 1,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`inv_slots` INTEGER NOT NULL DEFAULT 10,
|
||||
`att_points` INTEGER NOT NULL DEFAULT 0,
|
||||
`bio` TEXT DEFAULT ''
|
||||
);
|
||||
CREATE INDEX idx_characters_user_id ON characters (`user_id`);
|
||||
|
||||
CREATE TABLE equipped_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`head` INTEGER NOT NULL DEFAULT 0,
|
||||
`chest` INTEGER NOT NULL DEFAULT 0,
|
||||
`boots` INTEGER NOT NULL DEFAULT 0,
|
||||
`hands` INTEGER NOT NULL DEFAULT 0,
|
||||
`m_hand` INTEGER NOT NULL DEFAULT 0,
|
||||
`o_hand` INTEGER NOT NULL DEFAULT 0,
|
||||
`rune` INTEGER NOT NULL DEFAULT 0,
|
||||
`ring` INTEGER NOT NULL DEFAULT 0,
|
||||
`amulet` INTEGER NOT NULL DEFAULT 0,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`max_hp` INTEGER NOT NULL DEFAULT 0,
|
||||
`max_mp` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_equipped_items_char_id ON equipped_items (`char_id`);
|
||||
|
||||
CREATE TABLE inventory_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`item_id` INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_inventory_items_char_id ON inventory_items (`char_id`);
|
||||
|
||||
CREATE TABLE banked_items (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`item_id` INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_banked_items_char_id ON banked_items (`char_id`);
|
||||
CREATE INDEX idx_banked_items_item_id ON banked_items (`item_id`);
|
||||
|
||||
CREATE TABLE wallets (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL DEFAULT 10
|
||||
);
|
||||
CREATE INDEX idx_wallets_char_id ON wallets (`char_id`);
|
||||
|
||||
CREATE TABLE bank_accounts (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`slots` INTEGER NOT NULL DEFAULT 5,
|
||||
`silver` INTEGER NOT NULL DEFAULT 0,
|
||||
`tier` INTEGER NOT NULL DEFAULT 0,
|
||||
`can_collect` INTEGER NOT NULL DEFAULT 1,
|
||||
`last_collect` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_bank_char_id ON bank_accounts (`char_id`);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Blog
|
||||
============================================================
|
||||
*/
|
||||
create table blog (
|
||||
`id` integer primary KEY AUTOINCREMENT,
|
||||
`author_id` integer not null,
|
||||
`title` TEXT not null,
|
||||
`slug` TEXT not null unique,
|
||||
`content` TEXT not null,
|
||||
`created` DATETIME default current_timestamp,
|
||||
`updated` DATETIME default current_timestamp
|
||||
);
|
||||
CREATE INDEX idx_blog_author_id ON blog (`author_id`);
|
||||
CREATE INDEX idx_blog_slug ON blog (`slug`);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
World
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE towns (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_towns_location ON towns (`x`, `y`);
|
||||
|
||||
CREATE TABLE character_locations (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`x` INTEGER NOT NULL,
|
||||
`y` INTEGER NOT NULL,
|
||||
`currently` INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE INDEX idx_character_locations_char_id ON character_locations (`char_id`);
|
||||
CREATE INDEX idx_character_locations_location ON character_locations (`x`, `y`);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Items
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE items (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` TEXT NOT NULL DEFAULT 0,
|
||||
`subtype` INTEGER NOT NULL DEFAULT 0,
|
||||
`rarity` INTEGER NOT NULL DEFAULT 0,
|
||||
`forged` INTEGER NOT NULL DEFAULT 0,
|
||||
`quality` INTEGER NOT NULL DEFAULT 0,
|
||||
`value` INTEGER NOT NULL DEFAULT 0,
|
||||
`consumable` INTEGER NOT NULL DEFAULT 0,
|
||||
`duration` INTEGER NOT NULL DEFAULT 0,
|
||||
`durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`m_durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`reqs` TEXT NOT NULL DEFAULT "",
|
||||
`traits` TEXT NOT NULL DEFAULT "",
|
||||
`lore` TEXT NOT NULL DEFAULT "",
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Titles
|
||||
============================================================
|
||||
*/
|
||||
DROP TABLE IF EXISTS titles;
|
||||
CREATE TABLE titles (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL DEFAULT 'Title',
|
||||
`lore` TEXT
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS owned_titles;
|
||||
CREATE TABLE owned_titles (
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`title_id` INTEGER NOT NULL,
|
||||
`awarded` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_owned_titles_char_id ON owned_titles (`char_id`);
|
||||
CREATE INDEX idx_owned_titles_owned ON owned_titles (`char_id`, `title_id`);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Blueprints
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE item_blueprints (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` TEXT NOT NULL DEFAULT 0,
|
||||
`subtype` INTEGER NOT NULL DEFAULT 0,
|
||||
`rarity` INTEGER NOT NULL DEFAULT 0,
|
||||
`value` INTEGER NOT NULL DEFAULT 0,
|
||||
`consumable` INTEGER NOT NULL DEFAULT 0,
|
||||
`duration` INTEGER NOT NULL DEFAULT 0,
|
||||
`durability` INTEGER NOT NULL DEFAULT 0,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`reqs` TEXT NOT NULL DEFAULT "",
|
||||
`traits` TEXT NOT NULL DEFAULT "",
|
||||
`lore` TEXT NOT NULL DEFAULT "",
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE mob_blueprints (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`type` INTEGER NOT NULL,
|
||||
`rank` INTEGER NOT NULL,
|
||||
`level` INTEGER NOT NULL,
|
||||
`hp` INTEGER NOT NULL,
|
||||
`m_hp` INTEGER NOT NULL,
|
||||
`mp` INTEGER NOT NULL,
|
||||
`m_mp` INTEGER NOT NULL,
|
||||
`stats_id` INTEGER NOT NULL,
|
||||
`xp` INTEGER NOT NULL,
|
||||
`silver` INTEGER NOT NULL,
|
||||
`loot` TEXT NOT NULL,
|
||||
`lore` TEXT NOT NULL,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
/*
|
||||
============================================================
|
||||
Battles
|
||||
============================================================
|
||||
*/
|
||||
CREATE TABLE pve (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`char_id` INTEGER NOT NULL,
|
||||
`char_hp` INTEGER NOT NULL,
|
||||
`char_m_hp` INTEGER NOT NULL,
|
||||
`char_mp` INTEGER NOT NULL,
|
||||
`char_m_mp` INTEGER NOT NULL,
|
||||
`char_stats_id` INTEGER NOT NULL,
|
||||
`mob_id` INTEGER NOT NULL,
|
||||
`mob_level` INTEGER NOT NULL,
|
||||
`mob_rank` INTEGER NOT NULL,
|
||||
`mob_hp` INTEGER NOT NULL,
|
||||
`mob_m_hp` INTEGER NOT NULL,
|
||||
`mob_mp` INTEGER NOT NULL,
|
||||
`mob_m_mp` INTEGER NOT NULL,
|
||||
`mob_stats_id` INTEGER NOT NULL,
|
||||
`first_turn` INTEGER NOT NULL,
|
||||
`turn` INTEGER NOT NULL default 1,
|
||||
`winner` INTEGER NOT NULL default 0,
|
||||
`can_flee` INTEGER NOT NULL default 1,
|
||||
`escaped` INTEGER NOT NULL default 0,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_pve_char_id ON pve (`char_id`);
|
||||
|
||||
CREATE TABLE pve_logs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`fight_id` INTEGER NOT NULL,
|
||||
`info` TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_pve_logs_fight_id ON pve_logs (`fight_id`);
|
||||
|
||||
CREATE TABLE pvp (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`char1_id` INTEGER NOT NULL,
|
||||
`char1_hp` INTEGER NOT NULL,
|
||||
`char1_max_hp` INTEGER NOT NULL,
|
||||
`char1_mp` INTEGER NOT NULL,
|
||||
`char1_max_mp` INTEGER NOT NULL,
|
||||
`char1_stats_id` INTEGER NOT NULL,
|
||||
`char2_id` INTEGER NOT NULL,
|
||||
`char2_hp` INTEGER NOT NULL,
|
||||
`char2_m_hp` INTEGER NOT NULL,
|
||||
`char2_mp` INTEGER NOT NULL,
|
||||
`char2_m_mp` INTEGER NOT NULL,
|
||||
`char2_stats_id` INTEGER NOT NULL,
|
||||
`first_turn` INTEGER NOT NULL,
|
||||
`turn` INTEGER NOT NULL default 1,
|
||||
`winner` INTEGER NOT NULL default 0,
|
||||
`created` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated` DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE INDEX idx_pvp_char1_id ON pvp (`char1_id`);
|
||||
CREATE INDEX idx_pvp_char2_id ON pvp (`char2_id`);
|
||||
|
||||
CREATE TABLE pvp_logs (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`fight_id` INTEGER NOT NULL,
|
||||
`info` TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_pvp_logs_fight_id ON pvp_logs (`fight_id`);
|
Loading…
Reference in New Issue
Block a user