9
edits
Changes
→added db schema
Main.cpp: http://pastebin.com/Z17xSVym <br />
==SQL Schema==
<pre>
CREATE TABLE unx511.avatars (
id int unsigned not null auto_increment,
username varchar(20) not null,
password varchar(40) not null,
level tinyint unsigned not null default 1,
lvl_points int unsigned default 0,
health int unsigned not null default 100,
HP int unsigned not null default 1,
cash decimal default 0,
banked double default 0,
primary key (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.avatar_attack (
id int unsigned not null auto_increment,
attacker_id int unsigned not null,
victim_id int unsigned not null,
winner int not null,
attack_date datetime not null,
primary key (id),
foreign key (attacker_id) references avatars (id),
foreign key (victim_id) references avatars (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.hitlist (
id int unsigned not null auto_increment,
placed_hit int unsigned not null,
person_to_beat int unsigned not null,
amount_paid decimal not null,
paid_date datetime not null,
active ENUM('Y', 'N') not null,
beat_by int unsigned not null,
primary key (id),
foreign key (placed_hit) references avatars (id),
foreign key (person_to_beat) references avatars (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.missions (
id int unsigned not null auto_increment,
name varchar(256) not null,
description varchar(1024),
pay_amount decimal not null,
score_to_beat int not null,
attack_points int not null,
defence_points int not null,
exp float not null,
loot decimal not null,
primary key (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.item (
id int unsigned not null auto_increment,
name varchar(256) not null,
attack_points int unsigned null,
defence_points int unsigned null,
cost decimal unsigned not null,
primary key (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.avatar_item (
id int unsigned not null auto_increment,
avatar_id int unsigned not null,
item_id int unsigned not null,
amount int not null default 0, # how many of items exist in user inventory
amount_paid decimal not null, # is this necessary? since each item has a cost associated with it
# date -- if there are multiple items how does date work?
primary key (id),
foreign key (avatar_id) references avatars (id),
foreign key (item_id) references item (id)
) ENGINE = InnoDB;
CREATE TABLE unx511.avatar_mission (
id int unsigned not null auto_increment,
avatar_id int unsigned not null,
mission_id int unsigned not null,
mission_date datetime not null,
primary key (id),
foreign key (avatar_id) references avatars (id),
foreign key (mission_id) references missions (id)
) ENGINE = InnoDB;
</pre>
==Common server functions==