create table user_accounts (
  id serial primary key not null,
  name varchar(128) not null unique,
  password varchar(128) not null,
  banned timestamptz,
  muted timestamptz,
  created_at timestamptz default current_timestamp not null,
  flags integer default 0
);

create table user_settings (
  id serial primary key not null,
  user_account integer references user_accounts (id) not null,
  blocked_users bytea not null,
  key_config bytea not null,
  joystick_config bytea not null,
  option_flags integer not null,
  shortcuts bytea not null,
  symbol_chats bytea not null,
  team_name bytea not null
);

/* TODO: guild card data */

create table player_character (
  id serial primary key not null,
  user_account integer references user_accounts (id) not null,
  slot smallint not null,
  name varchar(12) not null,
  exp integer not null,
  class varchar(12) null,
  section_id varchar(12) not null,

  costume smallint not null,
  skin smallint not null,
  face smallint not null,
  head smallint not null,
  hair smallint not null,
  hair_r smallint not null,
  hair_g smallint not null,
  hair_b smallint not null,
  prop_x real not null,
  prop_y real not null,
  
  techs bytea not null,
 
  config bytea not null,
  infoboard varchar(172) not null,
  guildcard varchar(172) not null,
  option_flags integer not null,
  
  power smallint not null,
  mind smallint not null,
  def smallint not null,
  evade smallint not null,
  luck smallint not null,
  hp smallint not null,
  tp smallint not null,

  tech_menu bytea not null,
  meseta integer not null,
  bank_meseta integer not null

);


create table item (
  id serial primary key not null,
  item jsonb not null
);

create table item_location (
  item integer references item (id) not null,
  location jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table inventory_slots (
  pchar integer references player_character not null,
  items integer[30] /* references item (id) */
);

create table weapon_modifier (
  weapon integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table armor_modifier (
  armor integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table shield_modifier (
  shield integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table unit_modifier (
  unit integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table esweapon_modifier (
  esweapon integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);

create table mag_modifier (
  mag integer references item (id) not null,
  modifier jsonb not null,
  created_at timestamptz default current_timestamp not null
);
