diff --git a/ngsplanner_patch.sql b/ngsplanner_patch.sql index 70fcfd8..1a468f8 100644 --- a/ngsplanner_patch.sql +++ b/ngsplanner_patch.sql @@ -1,9 +1,12 @@ -/*9 Aug Database Patch*/ -alter table potential add column description text; -alter table weapon_existence_data add column icon text; -alter table weapon_type add column shorthand text; -alter table weapon_existence_data add column special_name text; -alter table potential drop column description; -alter table potential_data add column description text; -alter table photon_art add column icon text; -alter table users add column recovery_hash text; \ No newline at end of file +/*9 Aug Database Patch*/ +alter table potential add column description text; +alter table weapon_existence_data add column icon text; +alter table weapon_type add column shorthand text; +alter table weapon_existence_data add column special_name text; +alter table potential drop column description; +alter table potential_data add column description text; +alter table photon_art add column icon text; +alter table users add column recovery_hash text; +alter table armor rename column pb_gauge_build to slot; +CREATE TABLE "skill_tree_data"("id" SERIAL UNIQUE PRIMARY KEY,"class_id" int,"data" text,"skill_data" text,"line_color" text,"line_width" int,"gridsizex" int,"gridsizey" int,"gridpaddingx" int,"gridpaddingy" int); +ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); \ No newline at end of file diff --git a/ngsplanner_schema.sql b/ngsplanner_schema.sql index 059e5d9..55e9a0d 100644 --- a/ngsplanner_schema.sql +++ b/ngsplanner_schema.sql @@ -1,15 +1,3 @@ -CREATE TABLE "database_audit" ( - "id" SERIAL UNIQUE PRIMARY KEY, - "action" text, - "table_name" text, - "row_name" text, - "row_id" int, - "old_value" text, - "new_value" text, - "date" timestamptz, - "users_id" int -); - CREATE TABLE "food_mult" ( "id" SERIAL UNIQUE PRIMARY KEY, "amount" int, @@ -138,7 +126,7 @@ CREATE TABLE "armor" ( "shock_res" float, "panic_res" float, "poison_res" float, - "battle_power_value" int, + "slot" int, "pb_gauge_build" float, "icon" text, "popularity" int, @@ -206,37 +194,6 @@ CREATE TABLE "skill_type" ( "name" text ); -CREATE TABLE "users" ( - "id" SERIAL PRIMARY KEY, - "username" text UNIQUE, - "email" text UNIQUE, - "password_hash" text, - "created_on" timestamptz, - "roles_id" int, - "avatar" text, - "editors_choice" int, - "recovery_hash" text -); - -CREATE TABLE "roles" ( - "id" SERIAL UNIQUE PRIMARY KEY, - "name" text -); - -CREATE TABLE "builds" ( - "id" SERIAL UNIQUE PRIMARY KEY, - "users_id" int, - "creator" text, - "build_name" text, - "class1" int, - "class2" int, - "created_on" timestamptz, - "last_modified" timestamptz, - "likes" int, - "data" text, - "editors_choice" int -); - CREATE TABLE "weapon_existence_data" ( "id" SERIAL UNIQUE PRIMARY KEY, "weapon_type_id" int, @@ -306,6 +263,68 @@ CREATE TABLE "class_skill_data" ( "pb_gauge_fortification" float ); +CREATE TABLE "database_audit" ( + "id" SERIAL UNIQUE PRIMARY KEY, + "action" text, + "table_name" text, + "row_name" text, + "row_id" int, + "old_value" text, + "new_value" text, + "date" timestamptz, + "users_id" int +); + +CREATE TABLE "users" ( + "id" SERIAL PRIMARY KEY, + "username" text UNIQUE, + "email" text UNIQUE, + "password_hash" text, + "created_on" timestamptz, + "roles_id" int, + "avatar" text, + "editors_choice" int, + "recovery_hash" text +); + +CREATE TABLE "roles" ( + "id" SERIAL UNIQUE PRIMARY KEY, + "name" text +); + +CREATE TABLE "builds" ( + "id" SERIAL UNIQUE PRIMARY KEY, + "users_id" int, + "creator" text, + "build_name" text, + "class1" int, + "class2" int, + "created_on" timestamptz, + "last_modified" timestamptz, + "likes" int, + "data" text, + "editors_choice" int +); + +CREATE TABLE "skill_tree_data" ( + "id" SERIAL UNIQUE PRIMARY KEY, + "class_id" int, + "data" text, + "skill_data" text, + "line_color" text, + "line_width" int, + "gridsizex" int, + "gridsizey" int, + "gridpaddingx" int, + "gridpaddingy" int +); + +ALTER TABLE "builds" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id"); + +ALTER TABLE "users" ADD FOREIGN KEY ("roles_id") REFERENCES "roles" ("id"); + +ALTER TABLE "database_audit" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id"); + ALTER TABLE "class_weapon_type_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); ALTER TABLE "class_level_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); @@ -320,24 +339,20 @@ ALTER TABLE "skill_data" ADD FOREIGN KEY ("skill_id") REFERENCES "skill" ("id"); ALTER TABLE "skill" ADD FOREIGN KEY ("skill_type_id") REFERENCES "skill_type" ("id"); -ALTER TABLE "builds" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id"); - -ALTER TABLE "builds" ADD FOREIGN KEY ("class1") REFERENCES "class" ("id"); - -ALTER TABLE "builds" ADD FOREIGN KEY ("class2") REFERENCES "class" ("id"); - -ALTER TABLE "users" ADD FOREIGN KEY ("roles_id") REFERENCES "roles" ("id"); - ALTER TABLE "weapon_existence_data" ADD FOREIGN KEY ("weapon_id") REFERENCES "weapon" ("id"); ALTER TABLE "weapon_existence_data" ADD FOREIGN KEY ("weapon_type_id") REFERENCES "weapon_type" ("id"); ALTER TABLE "augment" ADD FOREIGN KEY ("augment_type_id") REFERENCES "augment_type" ("id"); -ALTER TABLE "database_audit" ADD FOREIGN KEY ("users_id") REFERENCES "users" ("id"); - ALTER TABLE "photon_art" ADD FOREIGN KEY ("weapon_type_id") REFERENCES "weapon_type" ("id"); ALTER TABLE "class_skill_data" ADD FOREIGN KEY ("class_skill_id") REFERENCES "class_skill" ("id"); ALTER TABLE "class_skill" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); + +ALTER TABLE "builds" ADD FOREIGN KEY ("class1") REFERENCES "class" ("id"); + +ALTER TABLE "builds" ADD FOREIGN KEY ("class2") REFERENCES "class" ("id"); + +ALTER TABLE "skill_tree_data" ADD FOREIGN KEY ("class_id") REFERENCES "class" ("id"); diff --git a/ngsplanner_seed.sql b/ngsplanner_seed.sql index 6b37ab4..b470bba 100644 --- a/ngsplanner_seed.sql +++ b/ngsplanner_seed.sql @@ -1,3 +1,4 @@ +delete from skill_tree_data; delete from class_skill_data; delete from class_skill; delete from photon_art; @@ -233,12 +234,12 @@ insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg, insert into augment(augment_type_id,name,variance,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,affix_success_rate,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,popularity,editors_choice) values((select id from augment_type where name='Precision' limit 1),3,0,0,0,0,1.02,0,0,0,0,0,0,0,0.09,0,0,0,0,0,0,0,6,0,0,0); -insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,icon,popularity,editors_choice) - values('Primm Armor',1,1,8,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,'/icons/20M6Z7t.png',0,0); -insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,icon,popularity,editors_choice) - values('Tzvia Armor',2,1,9,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2,0,'/icons/F0t58xP.png',0,0); -insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,pb_gauge_build,icon,popularity,editors_choice) - values('Theseus Armor',3,5,10,10,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.1,0,'/icons/uldt9lR.png',0,0); +insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,slot,icon,popularity,editors_choice) + values('Primm Armor',1,1,8,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,'/icons/20M6Z7t.png',0,0); +insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,slot,icon,popularity,editors_choice) + values('Tzvia Armor',2,1,9,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.2,2,'/icons/F0t58xP.png',0,0); +insert into armor(name,rarity,level_req,def,hp,pp,mel_dmg,rng_dmg,tec_dmg,crit_rate,crit_dmg,pp_cost_reduction,active_pp_recovery,natural_pp_recovery,dmg_res,all_down_res,burn_res,freeze_res,blind_res,shock_res,panic_res,poison_res,battle_power_value,slot,icon,popularity,editors_choice) + values('Theseus Armor',3,5,10,10,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.1,3,'/icons/uldt9lR.png',0,0); insert into database_audit(action,table_name,row_name,row_id,old_value,new_value,date,users_id) values('INSERT','augment','crit_rate',4,'','0.15','2018-07-16 03:30+00',(select id from users where username='sigonasr2' limit 1)); @@ -274,3 +275,6 @@ insert into class_skill_data(name,class_skill_id,dependency,level,effect,duratio values('War Cry Lv.2',(SELECT id from class_skill WHERE name='War Cry' limit 1),'',2,'Effect Name',11,11,0.8,1.0,false,0.7,'',0,0,0,0.9,0,0,0,0,0); insert into class_skill_data(name,class_skill_id,dependency,level,effect,duration,cooldown,damage_taken,pa_potency,conditional_buff,pp_recovery,property,all_damage_buff,active_pp_recovery,status_ailment_accum,status_ailment_duration,pp_consumption,max_hp_decrease,natural_pp_recovery,added_pp,pb_gauge_fortification) values('Assault Charge Advent',(SELECT id from class_skill WHERE name='Assault Charge Advent' limit 1),'',1,'Effect Name',30,24,1.0,1.1,false,0.8,'',0,0,0,0,0,0,0.6,0,0); + +insert into skill_tree_data(class_id,data,skill_data,line_color,line_width,gridsizex,gridsizey,gridpaddingx,gridpaddingy) + values((select id from class where name='Hunter'),'□ □ ,└□─┘□□, │ ││, │ □│, □─□┼□, □ ','','#000000',3,80,60,10,10); \ No newline at end of file diff --git a/server.js b/server.js index 58767ff..0844157 100644 --- a/server.js +++ b/server.js @@ -122,7 +122,7 @@ const ENDPOINTDATA=[ { endpoint:"armor", requiredfields:["name","rarity","level_req","def"], - optionalfields:["hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","pb_gauge_build","icon","popularity","editors_choice"], + optionalfields:["hp","pp","mel_dmg","rng_dmg","tec_dmg","crit_rate","crit_dmg","pp_cost_reduction","active_pp_recovery","natural_pp_recovery","dmg_res","all_down_res","burn_res","freeze_res","blind_res","shock_res","panic_res","poison_res","battle_power_value","slot","icon","popularity","editors_choice"], excludedfields:[] //Fields to not output in GET. }, { @@ -220,6 +220,12 @@ const ENDPOINTDATA=[ requiredfields:["action","table_name","row_name","row_id","new_value","date","users_id"], optionalfields:["old_value"], excludedfields:[] //Fields to not output in GET. + }, + { + endpoint:"skill_tree_data", + requiredfields:["class_id","data","skill_data","line_color","line_width","gridsizex","gridsizey","gridpaddingx","gridpaddingy"], + optionalfields:[], + excludedfields:[] //Fields to not output in GET. } ] @@ -382,15 +388,15 @@ for (var test of ["","/test"]) { }) app.post(PREFIX+test+"/databases/backup",(req,res)=>{ + var date = new Date() db4.query('select * from password where password=$1',[req.body.pass]) .then((data)=>{ if (data.rows.length>0) { db.end(()=>{}) - var date = new Date() return db3.query('select pg_terminate_backend (pid) from pg_stat_activity where pg_stat_activity.datname=\'ngsplanner\'') } else { var msg="Could not authenticate!";res.status(500).send(msg);throw msg - } + } }) .then(()=>{ return db3.query('create database ngsplanner'+String(date.getFullYear()).padStart(4,'0')+String(date.getMonth()).padStart(2,'0')+String(date.getDate()).padStart(2,'0')+String(date.getHours()).padStart(2,'0')+String(date.getMinutes()).padStart(2,'0')+String(date.getSeconds()).padStart(2,'0')+' with template ngsplanner') @@ -791,8 +797,8 @@ app.get(PREFIX+'/test/dataid',async(req,res)=>{ }) app.post(PREFIX+"/validUser",(req,res)=>{ - console.log(sh.SecretHash("test")) - db.query('select * from users where username=$1 and password_hash=$2 limit 1',[req.body.username,req.body.password]) + //console.log(sh.SecretHash("098f6bcd4621d373cade4e832627b4f6")) + db.query('select * from users where username=$1 and password_hash=$2 limit 1',[req.body.username,sh.SecretHash(req.body.password)]) .then((data)=>{ if (data.rows.length>0) { res.status(200).json({verified:true}) @@ -808,6 +814,6 @@ app.post(PREFIX+"/validUser",(req,res)=>{ //Generates our table schema: ENDPOINTDATA.forEach((endpoint)=>{ console.log(endpoint.endpoint+":\n\t"+endpoint.requiredfields.join('\t')+(endpoint.optionalfields.length>0?"\t":"")+endpoint.optionalfields.join("\t")) -}) +}) CreateDynamicEndpoints() \ No newline at end of file