541 lines
14 KiB
PHP
541 lines
14 KiB
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
This script is used to create the database and the tables for said database.
|
||
|
php create.php <database>
|
||
|
*/
|
||
|
|
||
|
require_once __DIR__ . '/../../color.php';
|
||
|
|
||
|
const AUTH = 'auth.db';
|
||
|
const LIVE = 'live.db';
|
||
|
const FIGHTS = 'fights.db';
|
||
|
const BPS = 'blueprints.db';
|
||
|
|
||
|
/**
|
||
|
* Echo a string with a newline.
|
||
|
*/
|
||
|
function eln(string $string): void
|
||
|
{
|
||
|
echo $string . PHP_EOL;
|
||
|
}
|
||
|
|
||
|
// pick the database to create
|
||
|
if (!isset($argv[1])) {
|
||
|
eln(red('Missing database name.'));
|
||
|
eln(blue('Usage: ') . 'php create.php auth.db|live.db|fight.db|blueprints.db [-d]');
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
// make sure it's a valid database
|
||
|
if (!in_array($argv[1], [AUTH, LIVE, FIGHTS, BPS])) {
|
||
|
eln(red('Invalid database: ') . $argv[1]);
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
$database = $argv[1];
|
||
|
// whether the -d flag is set
|
||
|
$drop = isset($argv[2]) && $argv[2] === '-d';
|
||
|
|
||
|
/*
|
||
|
================================================================================
|
||
|
Databases
|
||
|
================================================================================
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
The Auth database is used to store user information - not player info, but user info.
|
||
|
Usernames, passwords, email, session tokens, etc.
|
||
|
*/
|
||
|
if ($database === AUTH) {
|
||
|
if ($drop) {
|
||
|
unlink(__DIR__ . '/../' . AUTH);
|
||
|
eln(red('Dropped database: ') . 'auth.db');
|
||
|
}
|
||
|
$db = new SQLite3(__DIR__ . '/../' . AUTH);
|
||
|
|
||
|
// Users table
|
||
|
$db->exec('DROP TABLE IF EXISTS users');
|
||
|
$db->exec('CREATE TABLE users (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
email TEXT NOT NULL UNIQUE,
|
||
|
password TEXT NOT NULL,
|
||
|
auth INT NOT NULL DEFAULT 0,
|
||
|
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||
|
last_login DATETIME DEFAULT CURRENT_TIMESTAMP
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'users');
|
||
|
|
||
|
// Sessions table
|
||
|
$db->exec('DROP TABLE IF EXISTS sessions');
|
||
|
$db->exec('CREATE TABLE sessions (
|
||
|
user_id INTEGER NOT NULL,
|
||
|
token TEXT NOT NULL UNIQUE,
|
||
|
expires INTEGER NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'sessions');
|
||
|
|
||
|
// Verification tokens
|
||
|
$db->exec('DROP TABLE IF EXISTS tokens');
|
||
|
$db->exec('CREATE TABLE tokens (
|
||
|
user_id INTEGER NOT NULL,
|
||
|
token TEXT NOT NULL UNIQUE,
|
||
|
created INTEGER NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'tokens');
|
||
|
|
||
|
eln(green('Created database: ') . 'auth.db');
|
||
|
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
The Fights database is used to store information about fights.
|
||
|
A fight is a battle between two characters; players or NPCs.
|
||
|
*/
|
||
|
if ($database === FIGHTS) {
|
||
|
if ($drop) {
|
||
|
unlink(__DIR__ . '/../' . FIGHTS);
|
||
|
eln(red('Dropped database: ') . 'fights.db');
|
||
|
}
|
||
|
$db = new SQLite3(__DIR__ . '/../' . FIGHTS);
|
||
|
|
||
|
// PvE fights
|
||
|
$db->exec('DROP TABLE IF EXISTS pve');
|
||
|
$db->exec('CREATE TABLE pve (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
player_id INTEGER NOT NULL,
|
||
|
player_hp INTEGER NOT NULL,
|
||
|
player_max_hp INTEGER NOT NULL,
|
||
|
player_mp INTEGER NOT NULL,
|
||
|
player_max_mp INTEGER NOT NULL,
|
||
|
player_power INTEGER NOT NULL,
|
||
|
player_toughness INTEGER NOT NULL,
|
||
|
player_armor INTEGER NOT NULL,
|
||
|
player_precision INTEGER NOT NULL,
|
||
|
player_crit INTEGER NOT NULL,
|
||
|
player_ferocity INTEGER NOT NULL,
|
||
|
player_vitality INTEGER NOT NULL,
|
||
|
mob_id INTEGER NOT NULL,
|
||
|
mob_level INTEGER NOT NULL,
|
||
|
mob_rank INTEGER NOT NULL,
|
||
|
mob_hp INTEGER NOT NULL,
|
||
|
mob_max_hp INTEGER NOT NULL,
|
||
|
mob_mp INTEGER NOT NULL,
|
||
|
mob_max_mp INTEGER NOT NULL,
|
||
|
mob_power INTEGER NOT NULL,
|
||
|
mob_toughness INTEGER NOT NULL,
|
||
|
mob_armor INTEGER NOT NULL,
|
||
|
mob_precision INTEGER NOT NULL,
|
||
|
mob_crit INTEGER NOT NULL,
|
||
|
mob_ferocity INTEGER NOT NULL,
|
||
|
mob_vitality INTEGER NOT NULL,
|
||
|
first_turn INTEGER NOT NULL,
|
||
|
turn INTEGER NOT NULL default 1,
|
||
|
winner INTEGER NOT NULL default 0,
|
||
|
flee INTEGER NOT NULL default 1,
|
||
|
escaped INTEGER NOT NULL default 0,
|
||
|
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||
|
updated DATETIME DEFAULT CURRENT_TIMESTAMP
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'pve');
|
||
|
|
||
|
// PvP fights
|
||
|
$db->exec('DROP TABLE IF EXISTS pvp');
|
||
|
$db->exec('CREATE TABLE pvp (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
player1_id INTEGER NOT NULL,
|
||
|
player1_hp INTEGER NOT NULL,
|
||
|
player1_max_hp INTEGER NOT NULL,
|
||
|
player1_mp INTEGER NOT NULL,
|
||
|
player1_max_mp INTEGER NOT NULL,
|
||
|
player1_power INTEGER NOT NULL,
|
||
|
player1_toughness INTEGER NOT NULL,
|
||
|
player1_armor INTEGER NOT NULL,
|
||
|
player1_precision INTEGER NOT NULL,
|
||
|
player1_crit INTEGER NOT NULL,
|
||
|
player1_ferocity INTEGER NOT NULL,
|
||
|
player1_vitality INTEGER NOT NULL,
|
||
|
player2_id INTEGER NOT NULL,
|
||
|
player2_hp INTEGER NOT NULL,
|
||
|
player2_max_hp INTEGER NOT NULL,
|
||
|
player2_mp INTEGER NOT NULL,
|
||
|
player2_max_mp INTEGER NOT NULL,
|
||
|
player2_power INTEGER NOT NULL,
|
||
|
player2_toughness INTEGER NOT NULL,
|
||
|
player2_armor INTEGER NOT NULL,
|
||
|
player2_precision INTEGER NOT NULL,
|
||
|
player2_crit INTEGER NOT NULL,
|
||
|
player2_ferocity INTEGER NOT NULL,
|
||
|
player2_vitality 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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'pvp');
|
||
|
|
||
|
// PvE fight logs
|
||
|
$db->exec('DROP TABLE IF EXISTS pve_logs');
|
||
|
$db->exec('CREATE TABLE pve_logs (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
fight_id INTEGER NOT NULL,
|
||
|
info TEXT NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'pve_logs');
|
||
|
|
||
|
// PvP fight logs
|
||
|
$db->exec('DROP TABLE IF EXISTS pvp_logs');
|
||
|
$db->exec('CREATE TABLE pvp_logs (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
fight_id INTEGER NOT NULL,
|
||
|
info TEXT NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'pvp_logs');
|
||
|
|
||
|
eln(green('Created database: ') . 'fights.db');
|
||
|
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
The Blueprints database is used to store information about items, weapons, armor, etc.
|
||
|
*/
|
||
|
if ($database === BPS) {
|
||
|
if ($drop) {
|
||
|
unlink(__DIR__ . '/../' . BPS);
|
||
|
eln(red('Dropped database: ') . 'blueprints.db');
|
||
|
}
|
||
|
|
||
|
$db = new SQLite3(__DIR__ . '/../' . BPS);
|
||
|
|
||
|
// Items
|
||
|
$db->exec('DROP TABLE IF EXISTS items');
|
||
|
$db->exec('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,
|
||
|
power INTEGER NOT NULL DEFAULT 0,
|
||
|
toughness INTEGER NOT NULL DEFAULT 0,
|
||
|
armor INTEGER NOT NULL DEFAULT 0,
|
||
|
precision INTEGER NOT NULL DEFAULT 0,
|
||
|
crit INTEGER NOT NULL DEFAULT 0,
|
||
|
ferocity INTEGER NOT NULL DEFAULT 0,
|
||
|
vitality 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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'items');
|
||
|
|
||
|
// Mobs
|
||
|
$db->exec('DROP TABLE IF EXISTS mobs');
|
||
|
$db->exec('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,
|
||
|
max_hp INTEGER NOT NULL,
|
||
|
mp INTEGER NOT NULL,
|
||
|
max_mp INTEGER NOT NULL,
|
||
|
power INTEGER NOT NULL,
|
||
|
toughness INTEGER NOT NULL,
|
||
|
armor INTEGER NOT NULL,
|
||
|
precision INTEGER NOT NULL,
|
||
|
crit INTEGER NOT NULL,
|
||
|
ferocity INTEGER NOT NULL,
|
||
|
vitality 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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'mobs');
|
||
|
|
||
|
eln(green('Created database: ') . 'blueprints.db');
|
||
|
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
The Live database is used to store information about players, NPCs, guilds, etc.
|
||
|
*/
|
||
|
if ($database === LIVE) {
|
||
|
if ($drop) {
|
||
|
unlink(__DIR__ . '/../' . LIVE);
|
||
|
eln(red('Dropped database: ') . 'live.db');
|
||
|
}
|
||
|
|
||
|
$db = new SQLite3(__DIR__ . '/../' . LIVE);
|
||
|
|
||
|
// Players
|
||
|
$db->exec('DROP TABLE IF EXISTS players');
|
||
|
$db->exec('CREATE TABLE players (
|
||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||
|
user_id INTEGER NOT NULL,
|
||
|
name TEXT NOT NULL UNIQUE,
|
||
|
title_id INTEGER NOT NULL DEFAULT,
|
||
|
level INTEGER NOT NULL DEFAULT 1,
|
||
|
xp INTEGER NOT NULL DEFAULT 0,
|
||
|
xp_to_level INTEGER NOT NULL DEFAULT 100,
|
||
|
current_hp INTEGER NOT NULL DEFAULT 20,
|
||
|
max_hp INTEGER NOT NULL DEFAULT 20,
|
||
|
current_mp INTEGER NOT NULL DEFAULT 10,
|
||
|
max_mp INTEGER NOT NULL DEFAULT 10,
|
||
|
current_tp INTEGER NOT NULL DEFAULT 0,
|
||
|
max_tp INTEGER NOT NULL DEFAULT 0,
|
||
|
power INTEGER NOT NULL DEFAULT 0,
|
||
|
toughness INTEGER NOT NULL DEFAULT 0,
|
||
|
armor INTEGER NOT NULL DEFAULT 0,
|
||
|
precision INTEGER NOT NULL DEFAULT 0,
|
||
|
crit INTEGER NOT NULL DEFAULT 0,
|
||
|
ferocity INTEGER NOT NULL DEFAULT 0,
|
||
|
vitality INTEGER NOT NULL DEFAULT 0,
|
||
|
inv_slots INTEGER NOT NULL DEFAULT 10
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'players');
|
||
|
|
||
|
// Player gear
|
||
|
$db->exec('DROP TABLE IF EXISTS player_gear');
|
||
|
$db->exec('CREATE TABLE player_gear (
|
||
|
player_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,
|
||
|
main_hand INTEGER NOT NULL DEFAULT 0,
|
||
|
off_hand INTEGER NOT NULL DEFAULT 0,
|
||
|
rune INTEGER NOT NULL DEFAULT 0,
|
||
|
ring INTEGER NOT NULL DEFAULT 0,
|
||
|
amulet INTEGER NOT NULL DEFAULT 0,
|
||
|
power INTEGER NOT NULL DEFAULT 0,
|
||
|
toughness INTEGER NOT NULL DEFAULT 0,
|
||
|
armor INTEGER NOT NULL DEFAULT 0,
|
||
|
precision INTEGER NOT NULL DEFAULT 0,
|
||
|
crit INTEGER NOT NULL DEFAULT 0,
|
||
|
ferocity INTEGER NOT NULL DEFAULT 0,
|
||
|
vitality INTEGER NOT NULL DEFAULT 0,
|
||
|
max_hp INTEGER NOT NULL DEFAULT 0,
|
||
|
max_mp INTEGER NOT NULL DEFAULT 0,
|
||
|
traits TEXT NOT NULL DEFAULT ""
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'player_gear');
|
||
|
|
||
|
// Player inventory
|
||
|
$db->exec('DROP TABLE IF EXISTS player_inventory');
|
||
|
$db->exec('CREATE TABLE inventory (
|
||
|
player_id INTEGER NOT NULL,
|
||
|
item_id INTEGER NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'inventory');
|
||
|
|
||
|
// Player wallet
|
||
|
$db->exec('DROP TABLE IF EXISTS player_wallet');
|
||
|
$db->exec('CREATE TABLE wallet (
|
||
|
player_id INTEGER NOT NULL,
|
||
|
silver INTEGER NOT NULL DEFAULT 10,
|
||
|
stargem INTEGER NOT NULL DEFAULT 0
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'wallet');
|
||
|
|
||
|
// Player bank
|
||
|
$db->exec('DROP TABLE IF EXISTS player_bank');
|
||
|
$db->exec('CREATE TABLE bank (
|
||
|
player_id INTEGER NOT NULL,
|
||
|
slots INTEGER NOT NULL DEFAULT 5,
|
||
|
silver INTEGER NOT NULL DEFAULT 0,
|
||
|
tier INTEGER NOT NULL DEFAULT 1,
|
||
|
interest INTEGER NOT NULL DEFAULT 0
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'bank');
|
||
|
|
||
|
// Banked items
|
||
|
$db->exec('DROP TABLE IF EXISTS player_banked_items');
|
||
|
$db->exec('CREATE TABLE banked_items (
|
||
|
player_id INTEGER NOT NULL,
|
||
|
item_id INTEGER NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'banked_items');
|
||
|
|
||
|
// Towns
|
||
|
$db->exec('DROP TABLE IF EXISTS towns');
|
||
|
$db->exec('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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'towns');
|
||
|
|
||
|
// Shops
|
||
|
$db->exec('DROP TABLE IF EXISTS shops');
|
||
|
$db->exec('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,
|
||
|
buy_modifier INTEGER NOT NULL DEFAULT 100,
|
||
|
sell_modifier INTEGER NOT NULL DEFAULT 100,
|
||
|
created DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||
|
updated DATETIME DEFAULT CURRENT_TIMESTAMP
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'shops');
|
||
|
|
||
|
// Inns
|
||
|
$db->exec('DROP TABLE IF EXISTS inns');
|
||
|
$db->exec('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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'inns');
|
||
|
|
||
|
// Guilds
|
||
|
$db->exec('DROP TABLE IF EXISTS guilds');
|
||
|
$db->exec('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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'guilds');
|
||
|
|
||
|
// Guild ranks
|
||
|
$db->exec('DROP TABLE IF EXISTS guild_ranks');
|
||
|
$db->exec('CREATE TABLE guild_ranks (
|
||
|
guild_id INTEGER NOT NULL,
|
||
|
rank INTEGER NOT NULL,
|
||
|
name TEXT NOT NULL,
|
||
|
permissions TEXT NOT NULL
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'guild_ranks');
|
||
|
|
||
|
// Guild members
|
||
|
$db->exec('DROP TABLE IF EXISTS guild_members');
|
||
|
$db->exec('CREATE TABLE guild_members (
|
||
|
guild_id INTEGER NOT NULL,
|
||
|
player_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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'guild_members');
|
||
|
|
||
|
// NPCs
|
||
|
$db->exec('DROP TABLE IF EXISTS npcs');
|
||
|
$db->exec('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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'npcs');
|
||
|
|
||
|
// Town reputation
|
||
|
$db->exec('DROP TABLE IF EXISTS player_town_rep');
|
||
|
$db->exec('CREATE TABLE town_rep (
|
||
|
player_id INTEGER NOT NULL,
|
||
|
town_id INTEGER NOT NULL,
|
||
|
rep INTEGER NOT NULL DEFAULT 0
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'town_rep');
|
||
|
|
||
|
// Items
|
||
|
// Items
|
||
|
$db->exec('DROP TABLE IF EXISTS items');
|
||
|
$db->exec('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,
|
||
|
max_durability INTEGER NOT NULL DEFAULT 0,
|
||
|
power INTEGER NOT NULL DEFAULT 0,
|
||
|
toughness INTEGER NOT NULL DEFAULT 0,
|
||
|
armor INTEGER NOT NULL DEFAULT 0,
|
||
|
precision INTEGER NOT NULL DEFAULT 0,
|
||
|
crit INTEGER NOT NULL DEFAULT 0,
|
||
|
ferocity INTEGER NOT NULL DEFAULT 0,
|
||
|
vitality 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
|
||
|
)');
|
||
|
|
||
|
eln(yellow('Created table: ') . 'items');
|
||
|
|
||
|
eln(green('Created database: ') . 'live.db');
|
||
|
|
||
|
exit(0);
|
||
|
}
|
||
|
|