From 833b2875474e0431d6a77244d3d9a86bad2b5aeb Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Mon, 18 May 2020 11:10:10 -0700 Subject: [PATCH 01/24] seperated data tables into locations and events --- data/animals.js | 14 ---- data/events.js | 160 ++++++++++++++++++++++++++++++++++++++++++++++ data/locations.js | 37 +++++++++++ 3 files changed, 197 insertions(+), 14 deletions(-) delete mode 100644 data/animals.js create mode 100644 data/events.js create mode 100644 data/locations.js diff --git a/data/animals.js b/data/animals.js deleted file mode 100644 index fce3e93..0000000 --- a/data/animals.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = [ - { - name: 'bessie', - cool_factor: 3, - }, - { - name: 'jumpy', - cool_factor: 4, - }, - { - name: 'spot', - cool_factor: 10, - } -]; diff --git a/data/events.js b/data/events.js new file mode 100644 index 0000000..5974077 --- /dev/null +++ b/data/events.js @@ -0,0 +1,160 @@ +module.exports = [ + { + event_name: 'Desert Crops', + event_id: 1, + event_image: 'image', + event_description: 'As you land your ship you see some of the of the Alien farmers from this planet screaming at you. You quickly realize youve landed in the center of there crops! They seem really upset at your actions', + event_choices: [{ + choice_description: 'Attempt to explain the situation to the indigenous people.', + roll_needed: 5, + roll_type: 'diplomacy', + result: [{ + sucess: 'They reluctantly forgive you and allow you to leave the planet peacefully.', + failure: 'They scream and start banging on your ship and kick you off planet!' + }], + rewards: [{ + success_fuel: 0, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + }, + { + choice_description: 'Notice things are getting out of hand and prepare to handle the situation with force.', + roll_needed: 6, + roll_type: 'combat', + result: [{ + sucess: 'You power on your ships weapons and defend yourself against the alien farmers. After dealing with the Alien farmers you gather the supplies they had on planet..... you had to defend yourself, right?', + failure: 'You power on your ships weapons and attempt to defend yourself. You are quickly overpowered by the alien farmers as they steal your supplies. Luckily you break away and are able to leave planet before they can damage your ship any further.' + }], + rewards: [{ + success_fuel: 1, + success_credit: 2, + success_health: 0, + success_type: 'You have succeeded your science test', + failure_fuel: 0, + failure_credit: -2, + failure_health: -2, + failure_type: 'you have failed your science test' + }, + { + choice_description: 'Realize your mistake and attempt to use your ships facilities to correct the problem.', + roll_needed: 5, + roll_type: 'science', + result: [{ + sucess: 'They seem wary at first, but you create some advanced farming tools from your ship. The Alien farmers are ecstatic and allow you to stay the night in there village!', + failure: 'The tools you provide quickly fall apart and the Alien farmers scream and kick you off planet!' + }], + rewards: [{ + success_fuel: 2, + success_credit: -1, + success_health: 2, + success_type: 'You have succeeded your science test', + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + failure_type: 'you have failed your science test' + } + ] + } + ] + } + ] + } + ] + }, + + { + event_name: 'Oxygen Depletion', + event_id: 2, + event_image: 'image', + event_description: 'As you are gliding down to the planet a winged creature of some sort slams into your ship and causes you to crash into the surface.', + event_choices: [{ + //add a second choice for combat + choice_description: 'As you look over your ship you see that your life support system has been damaged. You put your space suit on and head outside to attempt to fix the damage.', + roll_needed: 4, + roll_type: 'science', + result: [{ + sucess: 'You finish the repairs on your life support system in time and even learn some interesting information from the damage.', + failure: 'You take way to long to finish the repairs and have to rest on planet before continuing your journey.' + }], + rewards: [{ + success_fuel: 0, + success_credit: 1, + success_health: 0, + failure_fuel: 0, + failure_credit: -1, + failure_health: -1 + }] + } + ] + }, + + { + event_name: 'Risk and Reward', + event_id: 3, + event_image: 'image', + event_description: 'You land your ship on planet to gather any supplies available to help on your journey. Nothing is setting off the scanner around your ship. You lower the bay door and walk onto the cold hard surface of this planet with your weapons. You find some minerals that would be worth a good amount of credits. You start to gather these materials when you hear a low rumble approaching you.', + event_choices: [{ + // add science choices + choice_description: 'You spin around with your rifle and attempt to defend yourself from the large apex-predator!', + roll_needed: 6, + roll_type: 'combat', + result: [{ + sucess: 'You unload your rifles clip into the apex predator before it is able to close the distance. The rare minerals are yours!', + failure: 'The apex predator leaps into the air and lands next to you slashing and biting at your body. You get into a prolonged fight but come out on top. Sadly the apex predator did some damage in return.' + }], + rewards: [{ + success_fuel: 0, + success_credit: 8, + success_health: 0, + failure_fuel: 0, + failure_credit: 3, + failure_health: -2, + }] + } + ] + }, + + { + event_name: 'Ancient City', + event_id: 4, + event_image: 'image', + event_description: 'You land your ship on the outskirts of the ancient abandoned city to see what you can find.', + event_choices: [{ + choice_description: 'You spot a local native looking at you and your ship curiously. It seems the Aliens of this planet have lost whatever technological advancements they had. You decide to introduce yourself and attempt some diplomacy.', + roll_needed: 6, + roll_type: 'diplomacy', + result: [{ + sucess: 'The alien leads you to his tribe and shows you there treasures. They seem to value food, strong metals, and things that help them hunt and protect themselves. You offer some of your tools and an advanced heater that never runs out of power. They are extremely grateful and offer you some old technology.', + failure: 'You attempt to communicate with the Alien. They howl and run off into the dense city and lose you. You look around for any supplies but find nothing of value, such a waste of fuel. Time to move on.' + }], + rewards: [{ + success_fuel: 2, + success_credit: 2, + success_health: 0, + failure_fuel: -1, + failure_credit: 0, + failure_health: 0, + }], + { + choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', + roll_needed: 5, + roll_type: 'science', + result: [{ + sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', + failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' + }], + rewards: [{ + success_fuel: 1, + success_credit: 3, + success_health: 0, + failure_fuel: 0, + failure_credit: -1, + failure_health: 0, + }] + } + ] + } +]; diff --git a/data/locations.js b/data/locations.js new file mode 100644 index 0000000..5154549 --- /dev/null +++ b/data/locations.js @@ -0,0 +1,37 @@ +module.exports = [ + { + location_name: 'Gilles C11Y', + location_type: 'Planet', + location_image: 'image', + location_description: 'Gilles C11Y is a desert of smooth rocks. Spires of sharp stone interrupt the otherwise flat terrain. There are groups of tall, dark orange stalks everywhere. There seems to be large burrows throughout the seemingly deserted planet.', + been_visited: false, + location_id: 1 + }, + + { + location_name: 'Sulia V', + location_type: 'Planet', + location_image: 'image', + location_description: 'Dense forests of brown plants cover Sulia V. Large water-filled caves are present just beneath the surface. The geological record shows irregular periods where, for unknown reasons, all oxygen vanished from the atmosphere.', + been_visited: false, + location_id: 2, + }, + { + location_name: 'Ipelup VI', + location_type: 'Planet', + location_image: 'image', + location_description: 'A planet-wide, deep ocean. The planet is home to extremely dangerous apex predators. The stone of the planetary crust is unusually dense and hard.', + been_visited: false, + location_id: 3 + }, + + { + location_name: 'Selelup II', + location_type: 'Planet', + location_image: 'image', + location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', + been_visited: false, + location_id: 4 + } +]; + From a04b02ab0a4715ff1f0ab9abe92e07f3c45986a8 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Mon, 18 May 2020 11:53:32 -0700 Subject: [PATCH 02/24] completed some of the create tables section and corrected syntax --- data/create-tables.js | 29 ++++- data/events.js | 295 ++++++++++++++++++++---------------------- data/locations.js | 4 - data/ship-choices.js | 13 ++ 4 files changed, 179 insertions(+), 162 deletions(-) create mode 100644 data/ship-choices.js diff --git a/data/create-tables.js b/data/create-tables.js index 24c7acd..eead547 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -17,12 +17,33 @@ async function run() { email VARCHAR(256) NOT NULL, hash VARCHAR(512) NOT NULL ); - CREATE TABLE animals ( + CREATE TABLE locations ( id SERIAL PRIMARY KEY NOT NULL, - name VARCHAR(512) NOT NULL, - cool_factor INTEGER NOT NULL, - owner_id INTEGER NOT NULL REFERENCES users(id) + location_name VARCHAR(512) NOT NULL, + location_image VARCHAR(512) NOT NULL, + location_description VARCHAR(512) NOT NULL, + been_visited BOOLEAN NOT NULL, + ); + CREATE TABLE events ( + id SERIAL PRIMARY KEY NOT NULL, + planet_id INTEGER NOT NULL, + event_name VARCHAR(512) NOT NULL, + event_image VARCHAR(512) NOT NULL, + event_description VARCHAR(512) NOT NULL, + event_choices ); + CREATE TABLE ship-choices ( + id SERIAL PRIMARY KEY NOT NULL, + ship_name VARCHAR(512) NOT NULL, + ship_image VARCHAR(512) NOT NULL, + ship_fuel INTEGER NOT NULL, + ship_hull INTEGER NOT NULL, + base_combat INTEGER NOT NULL, + base_diplomacy INTEGER NOT NULL, + base_science INTEGER NOT NULL, + used_item_slots INTEGER NOT NULL, + max_item_slots INTEGER NOT NULL, + been_visited BOOLEAN NOT NULL, `); console.log('create tables complete', getEmoji(), getEmoji(), getEmoji()); diff --git a/data/events.js b/data/events.js index 5974077..9437804 100644 --- a/data/events.js +++ b/data/events.js @@ -1,160 +1,147 @@ module.exports = [ + { + event_name: 'Desert Crops', + planet_id: 1, + event_image: 'image', + event_description: 'As you land your ship you see some of the of the Alien farmers from this planet screaming at you. You quickly realize youve landed in the center of there crops! They seem really upset at your actions', + event_choices: [{ + choice_description: 'Attempt to explain the situation to the indigenous people.', + roll_needed: 5, + roll_type: 'diplomacy', + result: [{ + sucess: 'They reluctantly forgive you and allow you to leave the planet peacefully.', + failure: 'They scream and start banging on your ship and kick you off planet!' + }], + rewards: [{ + success_fuel: 0, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + }] }, { - event_name: 'Desert Crops', - event_id: 1, - event_image: 'image', - event_description: 'As you land your ship you see some of the of the Alien farmers from this planet screaming at you. You quickly realize youve landed in the center of there crops! They seem really upset at your actions', - event_choices: [{ - choice_description: 'Attempt to explain the situation to the indigenous people.', - roll_needed: 5, - roll_type: 'diplomacy', - result: [{ - sucess: 'They reluctantly forgive you and allow you to leave the planet peacefully.', - failure: 'They scream and start banging on your ship and kick you off planet!' - }], - rewards: [{ - success_fuel: 0, - success_credit: 0, - success_health: 0, - failure_fuel: 0, - failure_credit: 0, - failure_health: -2, - }, - { - choice_description: 'Notice things are getting out of hand and prepare to handle the situation with force.', - roll_needed: 6, - roll_type: 'combat', - result: [{ - sucess: 'You power on your ships weapons and defend yourself against the alien farmers. After dealing with the Alien farmers you gather the supplies they had on planet..... you had to defend yourself, right?', - failure: 'You power on your ships weapons and attempt to defend yourself. You are quickly overpowered by the alien farmers as they steal your supplies. Luckily you break away and are able to leave planet before they can damage your ship any further.' - }], - rewards: [{ - success_fuel: 1, - success_credit: 2, - success_health: 0, - success_type: 'You have succeeded your science test', - failure_fuel: 0, - failure_credit: -2, - failure_health: -2, - failure_type: 'you have failed your science test' - }, - { - choice_description: 'Realize your mistake and attempt to use your ships facilities to correct the problem.', - roll_needed: 5, - roll_type: 'science', - result: [{ - sucess: 'They seem wary at first, but you create some advanced farming tools from your ship. The Alien farmers are ecstatic and allow you to stay the night in there village!', - failure: 'The tools you provide quickly fall apart and the Alien farmers scream and kick you off planet!' - }], - rewards: [{ - success_fuel: 2, - success_credit: -1, - success_health: 2, - success_type: 'You have succeeded your science test', - failure_fuel: 0, - failure_credit: 0, - failure_health: -2, - failure_type: 'you have failed your science test' - } - ] - } - ] - } - ] - } - ] - }, - + choice_description: 'Notice things are getting out of hand and prepare to handle the situation with force.', + roll_needed: 6, + roll_type: 'combat', + result: [{ + sucess: 'You power on your ships weapons and defend yourself against the alien farmers. After dealing with the Alien farmers you gather the supplies they had on planet..... you had to defend yourself, right?', + failure: 'You power on your ships weapons and attempt to defend yourself. You are quickly overpowered by the alien farmers as they steal your supplies. Luckily you break away and are able to leave planet before they can damage your ship any further.' + }], + rewards: [{ + success_fuel: 1, + success_credit: 2, + success_health: 0, + failure_fuel: 0, + failure_credit: -2, + failure_health: -2, + }] }, { - event_name: 'Oxygen Depletion', - event_id: 2, - event_image: 'image', - event_description: 'As you are gliding down to the planet a winged creature of some sort slams into your ship and causes you to crash into the surface.', - event_choices: [{ - //add a second choice for combat - choice_description: 'As you look over your ship you see that your life support system has been damaged. You put your space suit on and head outside to attempt to fix the damage.', - roll_needed: 4, - roll_type: 'science', - result: [{ - sucess: 'You finish the repairs on your life support system in time and even learn some interesting information from the damage.', - failure: 'You take way to long to finish the repairs and have to rest on planet before continuing your journey.' - }], - rewards: [{ - success_fuel: 0, - success_credit: 1, - success_health: 0, - failure_fuel: 0, - failure_credit: -1, - failure_health: -1 - }] - } - ] - }, + choice_description: 'Realize your mistake and attempt to use your ships facilities to correct the problem.', + roll_needed: 5, + roll_type: 'science', + result: [{ + sucess: 'They seem wary at first, but you create some advanced farming tools from your ship. The Alien farmers are ecstatic and allow you to stay the night in there village!', + failure: 'The tools you provide quickly fall apart and the Alien farmers scream and kick you off planet!' + }], + rewards: [{ + success_fuel: 2, + success_credit: -1, + success_health: 2, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + }] } + ] + }, + { + event_name: 'Oxygen Depletion', + planet_id: 2, + event_image: 'image', + event_description: 'As you are gliding down to the planet a winged creature of some sort slams into your ship and causes you to crash into the surface.', + event_choices: [{ + //add a second choice for combat + choice_description: 'As you look over your ship you see that your life support system has been damaged. You put your space suit on and head outside to attempt to fix the damage.', + roll_needed: 4, + roll_type: 'science', + result: [{ + sucess: 'You finish the repairs on your life support system in time and even learn some interesting information from the damage.', + failure: 'You take way to long to finish the repairs and have to rest on planet before continuing your journey.' + }], + rewards: [{ + success_fuel: 0, + success_credit: 1, + success_health: 0, + failure_fuel: 0, + failure_credit: -1, + failure_health: -1 + }] } + ] + }, - { - event_name: 'Risk and Reward', - event_id: 3, - event_image: 'image', - event_description: 'You land your ship on planet to gather any supplies available to help on your journey. Nothing is setting off the scanner around your ship. You lower the bay door and walk onto the cold hard surface of this planet with your weapons. You find some minerals that would be worth a good amount of credits. You start to gather these materials when you hear a low rumble approaching you.', - event_choices: [{ - // add science choices - choice_description: 'You spin around with your rifle and attempt to defend yourself from the large apex-predator!', - roll_needed: 6, - roll_type: 'combat', - result: [{ - sucess: 'You unload your rifles clip into the apex predator before it is able to close the distance. The rare minerals are yours!', - failure: 'The apex predator leaps into the air and lands next to you slashing and biting at your body. You get into a prolonged fight but come out on top. Sadly the apex predator did some damage in return.' - }], - rewards: [{ - success_fuel: 0, - success_credit: 8, - success_health: 0, - failure_fuel: 0, - failure_credit: 3, - failure_health: -2, - }] - } - ] - }, + { + event_name: 'Risk and Reward', + planet_id: 3, + event_image: 'image', + event_description: 'You land your ship on planet to gather any supplies available to help on your journey. Nothing is setting off the scanner around your ship. You lower the bay door and walk onto the cold hard surface of this planet with your weapons. You find some minerals that would be worth a good amount of credits. You start to gather these materials when you hear a low rumble approaching you.', + event_choices: [{ + // add science choices + choice_description: 'You spin around with your rifle and attempt to defend yourself from the large apex-predator!', + roll_needed: 6, + roll_type: 'combat', + result: [{ + sucess: 'You unload your rifles clip into the apex predator before it is able to close the distance. The rare minerals are yours!', + failure: 'The apex predator leaps into the air and lands next to you slashing and biting at your body. You get into a prolonged fight but come out on top. Sadly the apex predator did some damage in return.' + }], + rewards: [{ + success_fuel: 0, + success_credit: 8, + success_health: 0, + failure_fuel: 0, + failure_credit: 3, + failure_health: -2, + }] } + ] + }, - { - event_name: 'Ancient City', - event_id: 4, - event_image: 'image', - event_description: 'You land your ship on the outskirts of the ancient abandoned city to see what you can find.', - event_choices: [{ - choice_description: 'You spot a local native looking at you and your ship curiously. It seems the Aliens of this planet have lost whatever technological advancements they had. You decide to introduce yourself and attempt some diplomacy.', - roll_needed: 6, - roll_type: 'diplomacy', - result: [{ - sucess: 'The alien leads you to his tribe and shows you there treasures. They seem to value food, strong metals, and things that help them hunt and protect themselves. You offer some of your tools and an advanced heater that never runs out of power. They are extremely grateful and offer you some old technology.', - failure: 'You attempt to communicate with the Alien. They howl and run off into the dense city and lose you. You look around for any supplies but find nothing of value, such a waste of fuel. Time to move on.' - }], - rewards: [{ - success_fuel: 2, - success_credit: 2, - success_health: 0, - failure_fuel: -1, - failure_credit: 0, - failure_health: 0, - }], - { - choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', - roll_needed: 5, - roll_type: 'science', - result: [{ - sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', - failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' - }], - rewards: [{ - success_fuel: 1, - success_credit: 3, - success_health: 0, - failure_fuel: 0, - failure_credit: -1, - failure_health: 0, - }] - } - ] - } + { + event_name: 'Ancient City', + planet_id: 4, + event_image: 'image', + event_description: 'You land your ship on the outskirts of the ancient abandoned city to see what you can find.', + event_choices: [{ + choice_description: 'You spot a local native looking at you and your ship curiously. It seems the Aliens of this planet have lost whatever technological advancements they had. You decide to introduce yourself and attempt some diplomacy.', + roll_needed: 6, + roll_type: 'diplomacy', + result: [{ + sucess: 'The alien leads you to his tribe and shows you there treasures. They seem to value food, strong metals, and things that help them hunt and protect themselves. You offer some of your tools and an advanced heater that never runs out of power. They are extremely grateful and offer you some old technology.', + failure: 'You attempt to communicate with the Alien. They howl and run off into the dense city and lose you. You look around for any supplies but find nothing of value, such a waste of fuel. Time to move on.' + }], + rewards: [{ + success_fuel: 2, + success_credit: 2, + success_health: 0, + failure_fuel: -1, + failure_credit: 0, + failure_health: 0, + }] } + ] + }, + { + choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', + roll_needed: 5, + roll_type: 'science', + result: [{ + sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', + failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' + }], + rewards: [{ + success_fuel: 1, + success_credit: 3, + success_health: 0, + failure_fuel: 0, + failure_credit: -1, + failure_health: 0, + }] } ]; + diff --git a/data/locations.js b/data/locations.js index 5154549..a2ec84c 100644 --- a/data/locations.js +++ b/data/locations.js @@ -5,7 +5,6 @@ module.exports = [ location_image: 'image', location_description: 'Gilles C11Y is a desert of smooth rocks. Spires of sharp stone interrupt the otherwise flat terrain. There are groups of tall, dark orange stalks everywhere. There seems to be large burrows throughout the seemingly deserted planet.', been_visited: false, - location_id: 1 }, { @@ -14,7 +13,6 @@ module.exports = [ location_image: 'image', location_description: 'Dense forests of brown plants cover Sulia V. Large water-filled caves are present just beneath the surface. The geological record shows irregular periods where, for unknown reasons, all oxygen vanished from the atmosphere.', been_visited: false, - location_id: 2, }, { location_name: 'Ipelup VI', @@ -22,7 +20,6 @@ module.exports = [ location_image: 'image', location_description: 'A planet-wide, deep ocean. The planet is home to extremely dangerous apex predators. The stone of the planetary crust is unusually dense and hard.', been_visited: false, - location_id: 3 }, { @@ -31,7 +28,6 @@ module.exports = [ location_image: 'image', location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', been_visited: false, - location_id: 4 } ]; diff --git a/data/ship-choices.js b/data/ship-choices.js new file mode 100644 index 0000000..a72889c --- /dev/null +++ b/data/ship-choices.js @@ -0,0 +1,13 @@ +module.exports = [ + { + ship_name: 'The Enterprise', + ship_image: 'im an image', + ship_fuel: 4, + ship_hull: 10, + base_combat: 2, + base_diplomacy: 4, + base_science: 2, + used_item_slots: 0, + max_item_slots: 3 + } +]; From e521dda0fc4845f57769d5bcf8bf95f6417f2758 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Mon, 18 May 2020 13:05:56 -0700 Subject: [PATCH 03/24] table created --- data/create-tables.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index eead547..6e88f50 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -30,7 +30,7 @@ async function run() { event_name VARCHAR(512) NOT NULL, event_image VARCHAR(512) NOT NULL, event_description VARCHAR(512) NOT NULL, - event_choices + event_choices VARCHAR(512) ARRAY NOT NULL ); CREATE TABLE ship-choices ( id SERIAL PRIMARY KEY NOT NULL, @@ -43,7 +43,6 @@ async function run() { base_science INTEGER NOT NULL, used_item_slots INTEGER NOT NULL, max_item_slots INTEGER NOT NULL, - been_visited BOOLEAN NOT NULL, `); console.log('create tables complete', getEmoji(), getEmoji(), getEmoji()); From fe904c4b25197b3cd9a2c17ed6abad61a02a3cfb Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Mon, 18 May 2020 13:43:48 -0700 Subject: [PATCH 04/24] completed load, drop, and create tables --- .env-example | 9 ------ data/create-tables.js | 11 ++++---- data/drop-tables.js | 4 ++- data/events.js | 35 ++++++++++++------------ data/load-seed-data.js | 34 ++++++++++++++++++----- data/{ship-choices.js => shipchoices.js} | 0 lib/app.js | 4 +-- 7 files changed, 56 insertions(+), 41 deletions(-) delete mode 100644 .env-example rename data/{ship-choices.js => shipchoices.js} (100%) diff --git a/.env-example b/.env-example deleted file mode 100644 index b8517ec..0000000 --- a/.env-example +++ /dev/null @@ -1,9 +0,0 @@ -# *** Server *** -PORT=3000 - -# *** Database *** -DATABASE_URL={copy from terminal: `heroku config:get DATABASE_URL`} -PGSSLMODE=require - -# *** API KEYS *** - diff --git a/data/create-tables.js b/data/create-tables.js index 6e88f50..2e74c05 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -22,17 +22,17 @@ async function run() { location_name VARCHAR(512) NOT NULL, location_image VARCHAR(512) NOT NULL, location_description VARCHAR(512) NOT NULL, - been_visited BOOLEAN NOT NULL, + been_visited BOOLEAN NOT NULL ); CREATE TABLE events ( id SERIAL PRIMARY KEY NOT NULL, - planet_id INTEGER NOT NULL, + planet_id INTEGER NOT NULL REFERENCES locations(id), event_name VARCHAR(512) NOT NULL, event_image VARCHAR(512) NOT NULL, event_description VARCHAR(512) NOT NULL, - event_choices VARCHAR(512) ARRAY NOT NULL + event_choices VARCHAR(5000) ARRAY NOT NULL ); - CREATE TABLE ship-choices ( + CREATE TABLE shipchoices ( id SERIAL PRIMARY KEY NOT NULL, ship_name VARCHAR(512) NOT NULL, ship_image VARCHAR(512) NOT NULL, @@ -42,7 +42,8 @@ async function run() { base_diplomacy INTEGER NOT NULL, base_science INTEGER NOT NULL, used_item_slots INTEGER NOT NULL, - max_item_slots INTEGER NOT NULL, + max_item_slots INTEGER NOT NULL + ); `); console.log('create tables complete', getEmoji(), getEmoji(), getEmoji()); diff --git a/data/drop-tables.js b/data/drop-tables.js index 712386b..ba2ece3 100644 --- a/data/drop-tables.js +++ b/data/drop-tables.js @@ -10,7 +10,9 @@ async function run() { await client.query(` DROP TABLE IF EXISTS users CASCADE; - DROP TABLE IF EXISTS animals; + DROP TABLE IF EXISTS locations CASCADE; + DROP TABLE IF EXISTS events; + DROP TABLE IF EXISTS shipchoices; `); console.log(' drop tables complete', getEmoji(), getEmoji(), getEmoji()); diff --git a/data/events.js b/data/events.js index 9437804..846540d 100644 --- a/data/events.js +++ b/data/events.js @@ -124,24 +124,25 @@ module.exports = [ failure_fuel: -1, failure_credit: 0, failure_health: 0, + }] + }, + { + choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', + roll_needed: 5, + roll_type: 'science', + result: [{ + sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', + failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' + }], + rewards: [{ + success_fuel: 1, + success_credit: 3, + success_health: 0, + failure_fuel: 0, + failure_credit: -1, + failure_health: 0, }] } ] - }, - { - choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', - roll_needed: 5, - roll_type: 'science', - result: [{ - sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', - failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' - }], - rewards: [{ - success_fuel: 1, - success_credit: 3, - success_health: 0, - failure_fuel: 0, - failure_credit: -1, - failure_health: 0, - }] } + } ]; diff --git a/data/load-seed-data.js b/data/load-seed-data.js index 55f62b6..52e55cf 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -1,7 +1,9 @@ const client = require('../lib/client'); // import our seed data: -const animals = require('./animals.js'); +const locations = require('./locations.js'); const usersData = require('./users.js'); +const events = require('./events.js'); +const shipChoices = require('./shipchoices.js'); const { getEmoji } = require('../lib/emoji.js'); run(); @@ -21,16 +23,34 @@ async function run() { [user.email, user.hash]); }) ); - - const user = users[0].rows[0]; await Promise.all( - animals.map(animal => { + locations.map(location => { return client.query(` - INSERT INTO animals (name, cool_factor, owner_id) - VALUES ($1, $2, $3); + INSERT INTO locations (location_name, location_image, location_description, been_visited) + VALUES ($1, $2, $3, $4); `, - [animal.name, animal.cool_factor, user.id]); + [location.location_name, location.location_image, location.location_description, location.been_visited]); + }) + ); + + await Promise.all( + events.map(event => { + return client.query(` + INSERT INTO events (planet_id, event_name, event_image, event_description, event_choices) + VALUES ($1, $2, $3, $4, $5); + `, + [event.planet_id, event.event_name, event.event_image, event.event_description, event.event_choices]); + }) + ); + + await Promise.all( + shipChoices.map(ship => { + return client.query(` + INSERT INTO shipchoices (ship_name, ship_image, ship_fuel, ship_hull, base_combat, base_diplomacy, base_science, used_item_slots, max_item_slots) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9); + `, + [ship.ship_name, ship.ship_image, ship.ship_fuel, ship.ship_hull, ship.base_combat, ship.base_diplomacy, ship.base_science, ship.used_item_slots, ship.max_item_slots]); }) ); diff --git a/data/ship-choices.js b/data/shipchoices.js similarity index 100% rename from data/ship-choices.js rename to data/shipchoices.js diff --git a/lib/app.js b/lib/app.js index 1687831..b94302e 100644 --- a/lib/app.js +++ b/lib/app.js @@ -7,8 +7,8 @@ app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: false })); -app.get('/animals', async(req, res) => { - const data = await client.query('SELECT * from animals'); +app.get('/locations', async(req, res) => { + const data = await client.query('SELECT * from locations'); res.json(data.rows); }); From 729a63cedd8cde9e0ce11dc71929bc52b9bbbe0c Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Mon, 18 May 2020 13:48:16 -0700 Subject: [PATCH 05/24] postman shows data --- lib/app.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/app.js b/lib/app.js index b94302e..eafaa6f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -13,6 +13,18 @@ app.get('/locations', async(req, res) => { res.json(data.rows); }); +app.get('/events', async(req, res) => { + const data = await client.query('SELECT * from events'); + + res.json(data.rows); +}); + +app.get('/shipchoices', async(req, res) => { + const data = await client.query('SELECT * from shipchoices'); + + res.json(data.rows); +}); + app.use(require('./middleware/error')); module.exports = app; From fca42a581cce3bbcd0a938034afa947996cb8f34 Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Mon, 18 May 2020 14:41:01 -0700 Subject: [PATCH 06/24] adding end points for getting random planet and spaceship choice --- data/create-tables.js | 6 ++++-- data/load-seed-data.js | 8 ++++---- data/locations.js | 4 ++++ data/shipchoices.js | 11 +++++++++++ lib/app.js | 23 +++++++++++++++++++++++ 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index 2e74c05..6814e3e 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -20,13 +20,15 @@ async function run() { CREATE TABLE locations ( id SERIAL PRIMARY KEY NOT NULL, location_name VARCHAR(512) NOT NULL, + location_type VARCHAR(512) NOT NULL, location_image VARCHAR(512) NOT NULL, location_description VARCHAR(512) NOT NULL, - been_visited BOOLEAN NOT NULL + been_visited BOOLEAN NOT NULL, + event_id INTEGER NOT NULL UNIQUE ); CREATE TABLE events ( id SERIAL PRIMARY KEY NOT NULL, - planet_id INTEGER NOT NULL REFERENCES locations(id), + planet_id INTEGER REFERENCES locations(event_id), event_name VARCHAR(512) NOT NULL, event_image VARCHAR(512) NOT NULL, event_description VARCHAR(512) NOT NULL, diff --git a/data/load-seed-data.js b/data/load-seed-data.js index 52e55cf..c5649cb 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -13,7 +13,7 @@ async function run() { try { await client.connect(); - const users = await Promise.all( + await Promise.all( usersData.map(user => { return client.query(` INSERT INTO users (email, hash) @@ -27,10 +27,10 @@ async function run() { await Promise.all( locations.map(location => { return client.query(` - INSERT INTO locations (location_name, location_image, location_description, been_visited) - VALUES ($1, $2, $3, $4); + INSERT INTO locations (location_name, location_type,location_image, location_description, been_visited, event_id) + VALUES ($1, $2, $3, $4, $5, $6); `, - [location.location_name, location.location_image, location.location_description, location.been_visited]); + [location.location_name, location.location_type, location.location_image, location.location_description, location.been_visited, location.event_id]); }) ); diff --git a/data/locations.js b/data/locations.js index a2ec84c..9a0b324 100644 --- a/data/locations.js +++ b/data/locations.js @@ -5,6 +5,7 @@ module.exports = [ location_image: 'image', location_description: 'Gilles C11Y is a desert of smooth rocks. Spires of sharp stone interrupt the otherwise flat terrain. There are groups of tall, dark orange stalks everywhere. There seems to be large burrows throughout the seemingly deserted planet.', been_visited: false, + event_id: 1 }, { @@ -13,6 +14,7 @@ module.exports = [ location_image: 'image', location_description: 'Dense forests of brown plants cover Sulia V. Large water-filled caves are present just beneath the surface. The geological record shows irregular periods where, for unknown reasons, all oxygen vanished from the atmosphere.', been_visited: false, + event_id: 2 }, { location_name: 'Ipelup VI', @@ -20,6 +22,7 @@ module.exports = [ location_image: 'image', location_description: 'A planet-wide, deep ocean. The planet is home to extremely dangerous apex predators. The stone of the planetary crust is unusually dense and hard.', been_visited: false, + event_id: 3 }, { @@ -28,6 +31,7 @@ module.exports = [ location_image: 'image', location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', been_visited: false, + event_id: 4 } ]; diff --git a/data/shipchoices.js b/data/shipchoices.js index a72889c..4243dda 100644 --- a/data/shipchoices.js +++ b/data/shipchoices.js @@ -9,5 +9,16 @@ module.exports = [ base_science: 2, used_item_slots: 0, max_item_slots: 3 + }, + { + ship_name: 'The Enterprise2', + ship_image: 'im an image', + ship_fuel: 4, + ship_hull: 10, + base_combat: 2, + base_diplomacy: 4, + base_science: 2, + used_item_slots: 0, + max_item_slots: 3 } ]; diff --git a/lib/app.js b/lib/app.js index eafaa6f..1be7a43 100644 --- a/lib/app.js +++ b/lib/app.js @@ -25,6 +25,29 @@ app.get('/shipchoices', async(req, res) => { res.json(data.rows); }); +app.get('/usership/:id', async(req, res) => { + const data = await client.query(` + SELECT shipchoices.id, shipchoices.ship_name, shipchoices.ship_image, shipchoices.ship_fuel, shipchoices.ship_hull, shipchoices.base_combat, shipchoices.base_diplomacy, shipchoices.base_science, shipchoices.used_item_slots, shipchoices.max_item_slots + FROM shipchoices + WHERE shipchoices.id = $1 +`, [req.params.id]); + + res.json(data.rows); +}); + +app.get('/randomPlanet', async(req, res) => { + const data = await client.query(` + SELECT locations.id, locations.location_name, locations.location_type, locations.location_image, locations.location_description, locations.been_visited, events + FROM locations + JOIN events + on locations.event_id = events.planet_id + WHERE locations.been_visited=false + +`,); + + res.json(data.rows); +}); + app.use(require('./middleware/error')); module.exports = app; From 52c1010de6aaf1ad65c93d45edc7539b2d7875a9 Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Tue, 19 May 2020 10:40:14 -0700 Subject: [PATCH 07/24] adding get event by planet_id --- data/users.js | 3 ++- lib/app.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/data/users.js b/data/users.js index a0914e4..9115572 100644 --- a/data/users.js +++ b/data/users.js @@ -1,6 +1,7 @@ module.exports = [ { email: 'john@arbuckle.com', - hash: 1234 + hash: 1234, + beenvisted: [] } ]; diff --git a/lib/app.js b/lib/app.js index 1be7a43..b6b5e58 100644 --- a/lib/app.js +++ b/lib/app.js @@ -13,8 +13,10 @@ app.get('/locations', async(req, res) => { res.json(data.rows); }); -app.get('/events', async(req, res) => { - const data = await client.query('SELECT * from events'); +app.get('/events/:eventId', async(req, res) => { + const data = await client.query(` + select * from events where events.planet_id = $1 + `, [req.params.eventId]); res.json(data.rows); }); @@ -42,9 +44,10 @@ app.get('/randomPlanet', async(req, res) => { JOIN events on locations.event_id = events.planet_id WHERE locations.been_visited=false - `,); + + res.json(data.rows); }); From f02df426fbdbb89d559b7d1d90a1af0adb8ab572 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Tue, 19 May 2020 11:57:57 -0700 Subject: [PATCH 08/24] changed database structure --- data/events.js | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/data/events.js b/data/events.js index 846540d..c321135 100644 --- a/data/events.js +++ b/data/events.js @@ -8,50 +8,51 @@ module.exports = [ choice_description: 'Attempt to explain the situation to the indigenous people.', roll_needed: 5, roll_type: 'diplomacy', - result: [{ + result: { sucess: 'They reluctantly forgive you and allow you to leave the planet peacefully.', failure: 'They scream and start banging on your ship and kick you off planet!' - }], - rewards: [{ + }, + rewards: { success_fuel: 0, success_credit: 0, success_health: 0, failure_fuel: 0, failure_credit: 0, failure_health: -2, - }] }, + } + }, { choice_description: 'Notice things are getting out of hand and prepare to handle the situation with force.', roll_needed: 6, roll_type: 'combat', - result: [{ + result: { sucess: 'You power on your ships weapons and defend yourself against the alien farmers. After dealing with the Alien farmers you gather the supplies they had on planet..... you had to defend yourself, right?', failure: 'You power on your ships weapons and attempt to defend yourself. You are quickly overpowered by the alien farmers as they steal your supplies. Luckily you break away and are able to leave planet before they can damage your ship any further.' - }], - rewards: [{ + }, + rewards: { success_fuel: 1, success_credit: 2, success_health: 0, failure_fuel: 0, failure_credit: -2, failure_health: -2, - }] }, + } }, { choice_description: 'Realize your mistake and attempt to use your ships facilities to correct the problem.', roll_needed: 5, roll_type: 'science', - result: [{ + result: { sucess: 'They seem wary at first, but you create some advanced farming tools from your ship. The Alien farmers are ecstatic and allow you to stay the night in there village!', failure: 'The tools you provide quickly fall apart and the Alien farmers scream and kick you off planet!' - }], - rewards: [{ + }, + rewards: { success_fuel: 2, success_credit: -1, success_health: 2, failure_fuel: 0, failure_credit: 0, failure_health: -2, - }] } + } } ] }, { @@ -64,18 +65,18 @@ module.exports = [ choice_description: 'As you look over your ship you see that your life support system has been damaged. You put your space suit on and head outside to attempt to fix the damage.', roll_needed: 4, roll_type: 'science', - result: [{ + result: { sucess: 'You finish the repairs on your life support system in time and even learn some interesting information from the damage.', failure: 'You take way to long to finish the repairs and have to rest on planet before continuing your journey.' - }], - rewards: [{ + }, + rewards: { success_fuel: 0, success_credit: 1, success_health: 0, failure_fuel: 0, failure_credit: -1, failure_health: -1 - }] } + } } ] }, @@ -89,18 +90,18 @@ module.exports = [ choice_description: 'You spin around with your rifle and attempt to defend yourself from the large apex-predator!', roll_needed: 6, roll_type: 'combat', - result: [{ + result: { sucess: 'You unload your rifles clip into the apex predator before it is able to close the distance. The rare minerals are yours!', failure: 'The apex predator leaps into the air and lands next to you slashing and biting at your body. You get into a prolonged fight but come out on top. Sadly the apex predator did some damage in return.' - }], - rewards: [{ + }, + rewards: { success_fuel: 0, success_credit: 8, success_health: 0, failure_fuel: 0, failure_credit: 3, failure_health: -2, - }] } + } } ] }, @@ -113,35 +114,35 @@ module.exports = [ choice_description: 'You spot a local native looking at you and your ship curiously. It seems the Aliens of this planet have lost whatever technological advancements they had. You decide to introduce yourself and attempt some diplomacy.', roll_needed: 6, roll_type: 'diplomacy', - result: [{ + result: { sucess: 'The alien leads you to his tribe and shows you there treasures. They seem to value food, strong metals, and things that help them hunt and protect themselves. You offer some of your tools and an advanced heater that never runs out of power. They are extremely grateful and offer you some old technology.', failure: 'You attempt to communicate with the Alien. They howl and run off into the dense city and lose you. You look around for any supplies but find nothing of value, such a waste of fuel. Time to move on.' - }], - rewards: [{ + }, + rewards: { success_fuel: 2, success_credit: 2, success_health: 0, failure_fuel: -1, failure_credit: 0, failure_health: 0, - }] + } }, { choice_description: 'You decide to search the ancient abandoned city for any useful supplies.', roll_needed: 5, roll_type: 'science', - result: [{ + result: { sucess: 'You use your science tools at your disposal to scan the surrounding buildings. Your scanner goes off and you find a old research laboratory with a cacheful of supplies!', failure: 'It seems the city has already been ravaged by scavengers. Time to move on.' - }], - rewards: [{ + }, + rewards: { success_fuel: 1, success_credit: 3, success_health: 0, failure_fuel: 0, failure_credit: -1, failure_health: 0, - }] } + } } ] } ]; From 3033185cd72accfdfa2df55c7bc6e590f4b65e95 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Tue, 19 May 2020 14:49:54 -0700 Subject: [PATCH 09/24] database changes --- data/create-tables.js | 5 ++++- data/users.js | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index 6814e3e..f4759a6 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -15,7 +15,10 @@ async function run() { CREATE TABLE users ( id SERIAL PRIMARY KEY, email VARCHAR(256) NOT NULL, - hash VARCHAR(512) NOT NULL + hash VARCHAR(512) NOT NULL, + game_id INTEGER, + user_ship VARCHAR(512) + ); CREATE TABLE locations ( id SERIAL PRIMARY KEY NOT NULL, diff --git a/data/users.js b/data/users.js index 9115572..7b13920 100644 --- a/data/users.js +++ b/data/users.js @@ -2,6 +2,16 @@ module.exports = [ { email: 'john@arbuckle.com', hash: 1234, - beenvisted: [] + user_ship: { + ship_name: 'The Enterprise', + ship_image: 'im an image', + ship_fuel: 4, + ship_hull: 10, + base_combat: 2, + base_diplomacy: 4, + base_science: 2, + used_item_slots: 0, + max_item_slots: 3 + }, } ]; From 3ba48811331c3662d2f4ab89c99029d2b74f167c Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Tue, 19 May 2020 14:50:24 -0700 Subject: [PATCH 10/24] repush --- data/create-tables.js | 1 - data/users.js | 14 +------------- lib/app.js | 4 ++-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index f4759a6..a95e788 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -16,7 +16,6 @@ async function run() { id SERIAL PRIMARY KEY, email VARCHAR(256) NOT NULL, hash VARCHAR(512) NOT NULL, - game_id INTEGER, user_ship VARCHAR(512) ); diff --git a/data/users.js b/data/users.js index 7b13920..6a53729 100644 --- a/data/users.js +++ b/data/users.js @@ -1,17 +1,5 @@ module.exports = [ { - email: 'john@arbuckle.com', - hash: 1234, - user_ship: { - ship_name: 'The Enterprise', - ship_image: 'im an image', - ship_fuel: 4, - ship_hull: 10, - base_combat: 2, - base_diplomacy: 4, - base_science: 2, - used_item_slots: 0, - max_item_slots: 3 - }, + } ]; diff --git a/lib/app.js b/lib/app.js index b6b5e58..2cc173e 100644 --- a/lib/app.js +++ b/lib/app.js @@ -7,6 +7,8 @@ app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: false })); + + app.get('/locations', async(req, res) => { const data = await client.query('SELECT * from locations'); @@ -46,8 +48,6 @@ app.get('/randomPlanet', async(req, res) => { WHERE locations.been_visited=false `,); - - res.json(data.rows); }); From 08421060d954f1751d20d26c44f615f47ed88a50 Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Tue, 19 May 2020 22:43:25 -0700 Subject: [PATCH 11/24] testing put and get methods for user/ship --- data/users.js | 4 +++- lib/app.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/data/users.js b/data/users.js index 6a53729..edad1df 100644 --- a/data/users.js +++ b/data/users.js @@ -1,5 +1,7 @@ module.exports = [ { - + email: 'testemail@gmail.com', + hash: 1234, + user_ship: '' } ]; diff --git a/lib/app.js b/lib/app.js index 2cc173e..7533a90 100644 --- a/lib/app.js +++ b/lib/app.js @@ -51,6 +51,20 @@ app.get('/randomPlanet', async(req, res) => { res.json(data.rows); }); +app.put('/user', async(req, res) => { + // const id = req.userId; + const id = req.body.userId; + const shipChoice = req.body.shipChoice; + const data = await client.query(` + UPDATE users + SET user_ship=$1 + WHERE users.id=$2 + returning *; +`, [shipChoice, id]); + + res.json(data.rows); +}); + app.use(require('./middleware/error')); module.exports = app; From f9556e20c5d2a9e6358be8bb1d963ebb5db4a4fc Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Wed, 20 May 2020 12:06:59 -0700 Subject: [PATCH 12/24] updated tables --- data/create-tables.js | 1 - data/load-seed-data.js | 6 +++--- data/locations.js | 4 ---- data/shipchoices.js | 6 ++++-- data/users.js | 1 + lib/app.js | 3 +-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index a95e788..5964069 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -25,7 +25,6 @@ async function run() { location_type VARCHAR(512) NOT NULL, location_image VARCHAR(512) NOT NULL, location_description VARCHAR(512) NOT NULL, - been_visited BOOLEAN NOT NULL, event_id INTEGER NOT NULL UNIQUE ); CREATE TABLE events ( diff --git a/data/load-seed-data.js b/data/load-seed-data.js index c5649cb..93194f5 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -27,10 +27,10 @@ async function run() { await Promise.all( locations.map(location => { return client.query(` - INSERT INTO locations (location_name, location_type,location_image, location_description, been_visited, event_id) - VALUES ($1, $2, $3, $4, $5, $6); + INSERT INTO locations (location_name, location_type,location_image, location_description, event_id) + VALUES ($1, $2, $3, $4, $5); `, - [location.location_name, location.location_type, location.location_image, location.location_description, location.been_visited, location.event_id]); + [location.location_name, location.location_type, location.location_image, location.location_description, location.event_id]); }) ); diff --git a/data/locations.js b/data/locations.js index 9a0b324..ebf0452 100644 --- a/data/locations.js +++ b/data/locations.js @@ -4,7 +4,6 @@ module.exports = [ location_type: 'Planet', location_image: 'image', location_description: 'Gilles C11Y is a desert of smooth rocks. Spires of sharp stone interrupt the otherwise flat terrain. There are groups of tall, dark orange stalks everywhere. There seems to be large burrows throughout the seemingly deserted planet.', - been_visited: false, event_id: 1 }, @@ -13,7 +12,6 @@ module.exports = [ location_type: 'Planet', location_image: 'image', location_description: 'Dense forests of brown plants cover Sulia V. Large water-filled caves are present just beneath the surface. The geological record shows irregular periods where, for unknown reasons, all oxygen vanished from the atmosphere.', - been_visited: false, event_id: 2 }, { @@ -21,7 +19,6 @@ module.exports = [ location_type: 'Planet', location_image: 'image', location_description: 'A planet-wide, deep ocean. The planet is home to extremely dangerous apex predators. The stone of the planetary crust is unusually dense and hard.', - been_visited: false, event_id: 3 }, @@ -30,7 +27,6 @@ module.exports = [ location_type: 'Planet', location_image: 'image', location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', - been_visited: false, event_id: 4 } ]; diff --git a/data/shipchoices.js b/data/shipchoices.js index 4243dda..fe024bb 100644 --- a/data/shipchoices.js +++ b/data/shipchoices.js @@ -8,7 +8,8 @@ module.exports = [ base_diplomacy: 4, base_science: 2, used_item_slots: 0, - max_item_slots: 3 + max_item_slots: 3, + planet_visited: [] }, { ship_name: 'The Enterprise2', @@ -19,6 +20,7 @@ module.exports = [ base_diplomacy: 4, base_science: 2, used_item_slots: 0, - max_item_slots: 3 + max_item_slots: 3, + planet_visited: [] } ]; diff --git a/data/users.js b/data/users.js index edad1df..37fd980 100644 --- a/data/users.js +++ b/data/users.js @@ -3,5 +3,6 @@ module.exports = [ email: 'testemail@gmail.com', hash: 1234, user_ship: '' + //planets_visited a=yayayay } ]; diff --git a/lib/app.js b/lib/app.js index 7533a90..508e39f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -41,11 +41,10 @@ app.get('/usership/:id', async(req, res) => { app.get('/randomPlanet', async(req, res) => { const data = await client.query(` - SELECT locations.id, locations.location_name, locations.location_type, locations.location_image, locations.location_description, locations.been_visited, events + SELECT locations.id, locations.location_name, locations.location_type, locations.location_image, locations.location_description, events FROM locations JOIN events on locations.event_id = events.planet_id - WHERE locations.been_visited=false `,); res.json(data.rows); From cd5824eb74aeb20fc6f991fc66a5c3ad530895c8 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Wed, 20 May 2020 18:15:30 -0700 Subject: [PATCH 13/24] completed base game --- data/create-tables.js | 9 ++++++- data/drop-tables.js | 1 + data/users.js | 2 -- lib/app.js | 44 +++++++++++++++++++++++++++++++++- lib/auth/create-auth-routes.js | 2 +- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index 5964069..9daf33a 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -18,7 +18,14 @@ async function run() { hash VARCHAR(512) NOT NULL, user_ship VARCHAR(512) - ); + ); + CREATE TABLE loggedinuser ( + id SERIAL PRIMARY KEY, + name VARCHAR(512) NOT NULL, + score INTEGER NOT NULL, + owner_id INTEGER NOT NULL REFERENCES users(id) + ); + CREATE TABLE locations ( id SERIAL PRIMARY KEY NOT NULL, location_name VARCHAR(512) NOT NULL, diff --git a/data/drop-tables.js b/data/drop-tables.js index ba2ece3..d5215bb 100644 --- a/data/drop-tables.js +++ b/data/drop-tables.js @@ -13,6 +13,7 @@ async function run() { DROP TABLE IF EXISTS locations CASCADE; DROP TABLE IF EXISTS events; DROP TABLE IF EXISTS shipchoices; + DROP TABLE IF EXISTS loggedinuser; `); console.log(' drop tables complete', getEmoji(), getEmoji(), getEmoji()); diff --git a/data/users.js b/data/users.js index 37fd980..93cdfb7 100644 --- a/data/users.js +++ b/data/users.js @@ -2,7 +2,5 @@ module.exports = [ { email: 'testemail@gmail.com', hash: 1234, - user_ship: '' - //planets_visited a=yayayay } ]; diff --git a/lib/app.js b/lib/app.js index 508e39f..fd7ec2e 100644 --- a/lib/app.js +++ b/lib/app.js @@ -6,8 +6,32 @@ const app = express(); app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: false })); +const ensureAuth = require('./auth/ensure-auth'); +const createAuthRoutes = require('./auth/create-auth-routes'); + +const authRoutes = createAuthRoutes({ + selectUser(email) { + return client.query(` + SELECT id, email, hash + FROM users + WHERE email = $1; + `, + [email] + ).then(result => result.rows[0]); + }, + insertUser(user, hash) { + return client.query(` + INSERT into users (email, hash) + VALUES ($1, $2) + RETURNING id, email; + `, + [user.email, hash] + ).then(result => result.rows[0]); + } +}); - +app.use('/auth', authRoutes); +app.use('/api', ensureAuth); app.get('/locations', async(req, res) => { const data = await client.query('SELECT * from locations'); @@ -64,6 +88,24 @@ app.put('/user', async(req, res) => { res.json(data.rows); }); +app.post('/api/loggedinuser', async(req, res) => { + const data = await client.query(` + INSERT INTO loggedinuser (name, score, owner_id) + values ($1, $2, $3) + returning * + `, [req.body.name, req.body.score, req.userId]); + res.json(data.rows); +}); + +app.get('/api/loggedinuser', async(req, res) => { + const data = await client.query(` + SELECT * FROM loggedinuser + WHERE owner_id = $1 + `, [req.userId]); + res.json(data.rows); +}); + + app.use(require('./middleware/error')); module.exports = app; diff --git a/lib/auth/create-auth-routes.js b/lib/auth/create-auth-routes.js index b41ac0c..c0747ea 100644 --- a/lib/auth/create-auth-routes.js +++ b/lib/auth/create-auth-routes.js @@ -1,7 +1,7 @@ const express = require('express'); const bcrypt = require('bcryptjs'); const jwt = require('./jwt'); -const client = require('../client').connect(); +const client = require('../client'); const ensureAuth = require('./ensure-auth'); function getProfileWithToken(user) { From a504701e08ac1e195b200885bb77e424559c494c Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Thu, 21 May 2020 09:23:03 -0700 Subject: [PATCH 14/24] comimt message --- lib/app.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/app.js b/lib/app.js index 7533a90..b6d9801 100644 --- a/lib/app.js +++ b/lib/app.js @@ -7,6 +7,35 @@ app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: false })); +const PORT = process.env.PORT || 7890; +const ensureAuth = require('./auth/ensure-auth'); +const createAuthRoutes = require('./auth/create-auth-routes'); + +const authRoutes = createAuthRoutes({ + selectUser(email) { + console.log(email); + return client.query(` + SELECT id, email, hash + FROM users + WHERE email = $1; + `, [email] + ).then(result => result.rows[0]); + }, + insertUser(user, hash) { + console.log(user); + return client.query(` + INSERT into users (email, hash) + VALUES ($1, $2) + RETURNING id, email; + `, + [user.email, hash] + ).then(result => result.rows[0]); + } +}); + +app.use('/auth', authRoutes); + +app.use('/api', ensureAuth); app.get('/locations', async(req, res) => { From 1425b8d040fb1bf4820da450a63994292969d8dd Mon Sep 17 00:00:00 2001 From: Hunter Danielson Date: Thu, 21 May 2020 11:41:03 -0700 Subject: [PATCH 15/24] loggedinuser endpoints --- lib/app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/app.js b/lib/app.js index fd7ec2e..432da1c 100644 --- a/lib/app.js +++ b/lib/app.js @@ -105,6 +105,15 @@ app.get('/api/loggedinuser', async(req, res) => { res.json(data.rows); }); +app.put('/api/loggedinuser', async(req, res) => { + const data = await client.query(` + UPDATE loggedinuser + SET score = score + 1 + WHERE owner_id=$1 + `, [req.userId]); + res.json(data.rows); +}); + app.use(require('./middleware/error')); From c4a36bb32924def038545ca240f627fbdfc7fe2a Mon Sep 17 00:00:00 2001 From: Hunter Danielson Date: Thu, 21 May 2020 14:45:33 -0700 Subject: [PATCH 16/24] pathing --- data/load-seed-data.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/load-seed-data.js b/data/load-seed-data.js index 93194f5..f31e1da 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -13,7 +13,9 @@ async function run() { try { await client.connect(); - await Promise.all( + + + const users = await Promise.all( usersData.map(user => { return client.query(` INSERT INTO users (email, hash) @@ -23,6 +25,7 @@ async function run() { [user.email, user.hash]); }) ); + const user = users[0].rows[0]; await Promise.all( locations.map(location => { From 7bc544cdef8dd35a920609c7fabe7a99827bc095 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Thu, 21 May 2020 15:14:39 -0700 Subject: [PATCH 17/24] pushing to dev --- data/locations.js | 9 ++++----- data/shipchoices.js | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/data/locations.js b/data/locations.js index ebf0452..838b00a 100644 --- a/data/locations.js +++ b/data/locations.js @@ -2,7 +2,7 @@ module.exports = [ { location_name: 'Gilles C11Y', location_type: 'Planet', - location_image: 'image', + location_image: 'https://cdn.pixabay.com/photo/2018/08/08/20/23/planet-3593060_960_720.jpg', location_description: 'Gilles C11Y is a desert of smooth rocks. Spires of sharp stone interrupt the otherwise flat terrain. There are groups of tall, dark orange stalks everywhere. There seems to be large burrows throughout the seemingly deserted planet.', event_id: 1 }, @@ -10,14 +10,14 @@ module.exports = [ { location_name: 'Sulia V', location_type: 'Planet', - location_image: 'image', + location_image: 'https://cdn.pixabay.com/photo/2017/07/11/21/21/planet-2495089_960_720.jpg', location_description: 'Dense forests of brown plants cover Sulia V. Large water-filled caves are present just beneath the surface. The geological record shows irregular periods where, for unknown reasons, all oxygen vanished from the atmosphere.', event_id: 2 }, { location_name: 'Ipelup VI', location_type: 'Planet', - location_image: 'image', + location_image: 'https://cdn.pixabay.com/photo/2020/05/04/14/55/sci-fi-5129504_960_720.jpg', location_description: 'A planet-wide, deep ocean. The planet is home to extremely dangerous apex predators. The stone of the planetary crust is unusually dense and hard.', event_id: 3 }, @@ -25,9 +25,8 @@ module.exports = [ { location_name: 'Selelup II', location_type: 'Planet', - location_image: 'image', + location_image: 'https://cdn.pixabay.com/photo/2018/08/12/00/48/planet-3599887_960_720.jpg', location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', event_id: 4 } ]; - diff --git a/data/shipchoices.js b/data/shipchoices.js index fe024bb..742bc24 100644 --- a/data/shipchoices.js +++ b/data/shipchoices.js @@ -1,6 +1,6 @@ module.exports = [ { - ship_name: 'The Enterprise', + ship_name: 'diplomacy', ship_image: 'im an image', ship_fuel: 4, ship_hull: 10, @@ -12,7 +12,19 @@ module.exports = [ planet_visited: [] }, { - ship_name: 'The Enterprise2', + ship_name: 'combat', + ship_image: 'im an image', + ship_fuel: 4, + ship_hull: 10, + base_combat: 2, + base_diplomacy: 4, + base_science: 2, + used_item_slots: 0, + max_item_slots: 3, + planet_visited: [] + }, + { + ship_name: 'science', ship_image: 'im an image', ship_fuel: 4, ship_hull: 10, From bd7e7f9020a523b12f0dae2ea311255e97e6f15f Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Thu, 21 May 2020 15:22:29 -0700 Subject: [PATCH 18/24] pushing up db --- data/load-seed-data.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/load-seed-data.js b/data/load-seed-data.js index f31e1da..21216a8 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -13,8 +13,8 @@ async function run() { try { await client.connect(); - + const users = await Promise.all( usersData.map(user => { return client.query(` @@ -26,7 +26,7 @@ async function run() { }) ); const user = users[0].rows[0]; - + await Promise.all( locations.map(location => { return client.query(` From 95eb5dffd3dcf5a4795226985c3e444064ee0cc7 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Thu, 21 May 2020 17:22:31 -0700 Subject: [PATCH 19/24] finished backend databases --- data/create-tables.js | 1 - data/events.js | 211 +++++++++++++++++++++++++++++++++++++++-- data/load-seed-data.js | 8 +- data/locations.js | 30 +++++- data/shipchoices.js | 38 ++++---- lib/app.js | 2 +- 6 files changed, 252 insertions(+), 38 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index 9daf33a..e7043ba 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -45,7 +45,6 @@ async function run() { CREATE TABLE shipchoices ( id SERIAL PRIMARY KEY NOT NULL, ship_name VARCHAR(512) NOT NULL, - ship_image VARCHAR(512) NOT NULL, ship_fuel INTEGER NOT NULL, ship_hull INTEGER NOT NULL, base_combat INTEGER NOT NULL, diff --git a/data/events.js b/data/events.js index c321135..a241e29 100644 --- a/data/events.js +++ b/data/events.js @@ -2,7 +2,7 @@ module.exports = [ { event_name: 'Desert Crops', planet_id: 1, - event_image: 'image', + event_image: 'https://kevishere.files.wordpress.com/2017/12/pr-crops.jpg?w=648', event_description: 'As you land your ship you see some of the of the Alien farmers from this planet screaming at you. You quickly realize youve landed in the center of there crops! They seem really upset at your actions', event_choices: [{ choice_description: 'Attempt to explain the situation to the indigenous people.', @@ -18,7 +18,7 @@ module.exports = [ success_health: 0, failure_fuel: 0, failure_credit: 0, - failure_health: -2, + failure_health: -1, } }, { @@ -34,8 +34,8 @@ module.exports = [ success_credit: 2, success_health: 0, failure_fuel: 0, - failure_credit: -2, - failure_health: -2, + failure_credit: 0, + failure_health: -1, } }, { choice_description: 'Realize your mistake and attempt to use your ships facilities to correct the problem.', @@ -51,14 +51,14 @@ module.exports = [ success_health: 2, failure_fuel: 0, failure_credit: 0, - failure_health: -2, + failure_health: -1, } } ] }, { event_name: 'Oxygen Depletion', planet_id: 2, - event_image: 'image', + event_image: 'https://66.media.tumblr.com/8c3d6ffed9be5b4ec120c6665b177084/tumblr_nnja23kKnc1s0eroxo1_640.jpg', event_description: 'As you are gliding down to the planet a winged creature of some sort slams into your ship and causes you to crash into the surface.', event_choices: [{ //add a second choice for combat @@ -83,10 +83,9 @@ module.exports = [ { event_name: 'Risk and Reward', planet_id: 3, - event_image: 'image', + event_image: 'https://images.theconversation.com/files/157841/original/image-20170222-1364-hr3hcv.jpg?ixlib=rb-1.1.0&q=45&auto=format&w=496&fit=clip', event_description: 'You land your ship on planet to gather any supplies available to help on your journey. Nothing is setting off the scanner around your ship. You lower the bay door and walk onto the cold hard surface of this planet with your weapons. You find some minerals that would be worth a good amount of credits. You start to gather these materials when you hear a low rumble approaching you.', event_choices: [{ - // add science choices choice_description: 'You spin around with your rifle and attempt to defend yourself from the large apex-predator!', roll_needed: 6, roll_type: 'combat', @@ -108,7 +107,7 @@ module.exports = [ { event_name: 'Ancient City', planet_id: 4, - event_image: 'image', + event_image: 'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/cb63c2f9-bbd6-498a-902d-7627d6d48a05/dakedq-3ee895c6-5c3a-4c12-bd16-0f2ee6ecdc11.jpg/v1/fill/w_798,h_515,q_75,strp/alien_city_by_arrowfire_dakedq-fullview.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3siaGVpZ2h0IjoiPD01MTUiLCJwYXRoIjoiXC9mXC9jYjYzYzJmOS1iYmQ2LTQ5OGEtOTAyZC03NjI3ZDZkNDhhMDVcL2Rha2VkcS0zZWU4OTVjNi01YzNhLTRjMTItYmQxNi0wZjJlZTZlY2RjMTEuanBnIiwid2lkdGgiOiI8PTc5OCJ9XV0sImF1ZCI6WyJ1cm46c2VydmljZTppbWFnZS5vcGVyYXRpb25zIl19.6muSyo7qL4gNrGRM_roLX8twtkab_tnCCNwuv4vY-R8', event_description: 'You land your ship on the outskirts of the ancient abandoned city to see what you can find.', event_choices: [{ choice_description: 'You spot a local native looking at you and your ship curiously. It seems the Aliens of this planet have lost whatever technological advancements they had. You decide to introduce yourself and attempt some diplomacy.', @@ -144,6 +143,200 @@ module.exports = [ failure_health: 0, } } ] + }, + { + event_name: 'FrostBite?', + planet_id: 5, + event_image: 'https://i.pinimg.com/originals/55/c4/89/55c4892d99b434106e05ee892e6b54de.jpg', + event_description: 'You land your ship on the Icy planet hoping to find something useful on your journeys.', + event_choices: [{ + choice_description: 'You notice a large shape encased in ice a few hundred yards from your position.', + roll_needed: 7, + roll_type: 'science', + result: { + sucess: 'With your equipment in hand you head over to the frozen shape. You see its a old satelite from a long time ago. You melt the ice and recover what you can from it.', + failure: 'With your equipment in hand you head over to the frozen shape. You see its a old satelite. Sadly you are unable to free it from its cold prison. When you return to your ship you see its damaged from the blizzard. Time to move on.' + }, + rewards: { + success_fuel: 1, + success_credit: 1, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -1, + } + }, + { + choice_description: 'You see behind you there is a rock formation with a cave entrance. Perhaps there are some minerals inside you could use.', + roll_needed: 5, + roll_type: 'combat', + result: { + sucess: 'As you enter the cave complex you quickly realize you are not alone! You pull your flare out and light it seeing a large multi eyed creature scurrying toward you. You turn on your blaster and scare it away with a warning shot. You quickly find some minerals that will help your journey and decide to leave.', + failure: 'As you enter the cave complex you do not notice the creature crawling behind you. It quickly overwhelms you and tears into your space suit. You run out of the cave hoping you can make it to your ship in time!' + }, + rewards: { + success_fuel: 1, + success_credit: 1, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + } } + ] + }, + { + event_name: 'Do not touch the tar!', + planet_id: 6, + event_image: 'https://i.pinimg.com/originals/92/ee/d8/92eed8171d698f4d2aa1bb94ee24e350.jpg', + event_description: 'You land your ship on Xivon III. It seems mostly deserted and has a foul smell about it. The large pools of what you are guessing is tar keep bubbling...wait is the tar moving toward you?', + event_choices: [{ + choice_description: 'You are shocked as the tar comes sliming over toward you! You power up your ships weapons and shields and attempt to fight the entity off.', + roll_needed: 5, + roll_type: 'combat', + result: { + sucess: 'You quickly turn your ships weapons on the entity and shoot it back into the tar pit. You quickly notice more and more of these entitys are coming out of the surrounding pits. Time to move on!', + failure: 'You quickly turn your ships weapons on the entity but miss your first few shots. Your ships alarms start to blare as its eating into your hull. You quickly power on the thrusters and take off into space. Time to check the damage.' + }, + rewards: { + success_fuel: 0, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + } + }, + { + choice_description: 'You scream and run as the tar comes sliming over toward you. You enter your computers systems to prepare for the creature.', + roll_needed: 5, + roll_type: 'science', + result: { + sucess: 'You enter your ships systems to change the frequency of your shields. If this is anything like Earth you know exactly what to do! You hear the entity scream as it attempts to attack your ship. It rolls its way back into the pit and you take the oppurtunity to leave this place.', + failure: 'The entity slams into your ships and your alarms start to blare as its eating into your hull. You quickly power on the thrusters and take off into space. Time to check the damage.' + }, + rewards: { + success_fuel: 0, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + } } + ] + }, + { + event_name: 'Harvesting Gas', + planet_id: 7, + event_image: 'https://vignette.wikia.nocookie.net/warframe/images/e/ee/Plains_of_Eidolon_at_Day_%282%29.jpg/revision/latest?cb=20180717001626', + event_description: 'You land your ship on Noxabas I and take in the sceneray. It seems these large fissures are realising some type of gas. It could probably help fuel your ship.', + event_choices: [{ + choice_description: 'You see in the distance a alien looking facility. Perhaps they are friendly?', + roll_needed: 5, + roll_type: 'diplomacy', + result: { + sucess: 'You approach the facility and a native of this planet steps out of the doors to meet you. You exchange words and they agree to let you take some of the gas from there facility.', + failure: 'You approach the facility and a native of this planet steps out of the doors to meet you. You must have said something very upsetting as they seems to be calling to there comrades in the building. Time to move on!' + }, + rewards: { + success_fuel: 1, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: 0, + } + }, + { + choice_description: 'You see a fissure that is perfectly positioned for your ships harvester. Perhaps you can work the system to your advantage.', + roll_needed: 7, + roll_type: 'science', + result: { + sucess: 'You hover your ship over the fissure and start working at your terminal. After some time and a large amount of luck you are able to extract the gas into your ships reserve tank.', + failure: 'You hover your ship over the fissure and start working at your terminal. It seems you are unable to properly break down the gasses composition and it leaks into your ships systems. Time to move on.' + }, + rewards: { + success_fuel: 1, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -1, + } + }, + { + choice_description: 'You see in the distance a alien looking facility harvesting gas. A facility that advanced must have things worth taking.', + roll_needed: 8, + roll_type: 'combat', + result: { + sucess: 'You grab your weapons and head over to the facility. As you enter the facility you see multiple workers harvesting gas and placing them into energy capsules. You yell a few commands and they all back away. You fill your bag full of these capsules and make it back to your ship. Time to move on.', + failure: 'You grab your weapons and head over to the facility. As you enter the facility you get into a fire fight with some of the guards of the building. You quickly escape back to your ship and start to take off. They take some shots which damage your hull in your lift off.' + }, + rewards: { + success_fuel: 2, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -1, + } } + ] + }, + { + event_name: 'I feel like this has happened in a movie before...', + planet_id: 8, + event_image: 'https://i.redd.it/erbux89v0lx11.jpg', + event_description: 'You land on Yoraporr I and start to gather supplies. Did something just shimmer in that tree?', + event_choices: [{ + choice_description: 'Its probably nothing, just in case though maybe I should introduce myself.', + roll_needed: 10, + roll_type: 'diplomacy', + result: { + sucess: 'You call out to the tree and declare your intentions. A very long uncomfortable moment passes then something jumps out of the tree. You watch as it appears before your eyes. It was invisible! It offers you a small bag and then dissapears into the deep jungle. You examine the bag and see its full of supplies. Time to move on!', + failure: 'You call out to the tree and declare your intentions. After a short amount of time 3 red dots start to appear on your body. You quickly run toward your ship as the being starts to unleash energy blasts. You attempt to leave planet as its shooting at your ship.' + }, + rewards: { + success_fuel: 1, + success_credit: 1, + success_health: 1, + failure_fuel: 0, + failure_credit: 0, + failure_health: -3, + } + }, + { + choice_description: 'You slowly pull out your weapon acting like you do not notice it inside the tree.', + roll_needed: 9, + roll_type: 'combat', + result: { + sucess: 'You spin around and take a shot at the being inside the tree. It lets out a guttural noise and you see 3 red dots appear on your chest as it unleashes a energy blast. You quickly dodge out of the way and keep shooting. It goes quite for sometime and you finally notice you landed one of your shots. You take what you can off of its invisble corpse and leave.', + failure: 'You spin around and take a shot at the being inside the tree. It lets out a guttural noise and you see 3 red dots appear on your chest as it unleashes energy blasts. You can no longer pinpoint its position and you attempt to flee from the planet.' + }, + rewards: { + success_fuel: 1, + success_credit: 2, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + } + }, + { + choice_description: 'You pull out your scanner and point it at the tree...what could it be?', + roll_needed: 6, + roll_type: 'science', + result: { + sucess: 'You read your scanner and see a invisible large humanoid shape looking at you from the tree. You scream and run into your ship and take off before it can hunt you.', + failure: 'You read your scanner but it seems to be malfunctioning. Theres no way theres an invisble large humanoid there. A huge explosion knocks you off your feet as the creature lets out a guttural roar. You run into your ship and attempt to take off before it can cause more damage!' + }, + rewards: { + success_fuel: 0, + success_credit: 0, + success_health: 0, + failure_fuel: 0, + failure_credit: 0, + failure_health: -2, + } } + ] } ]; diff --git a/data/load-seed-data.js b/data/load-seed-data.js index 21216a8..83a5137 100644 --- a/data/load-seed-data.js +++ b/data/load-seed-data.js @@ -14,7 +14,7 @@ async function run() { await client.connect(); - + const users = await Promise.all( usersData.map(user => { return client.query(` @@ -50,10 +50,10 @@ async function run() { await Promise.all( shipChoices.map(ship => { return client.query(` - INSERT INTO shipchoices (ship_name, ship_image, ship_fuel, ship_hull, base_combat, base_diplomacy, base_science, used_item_slots, max_item_slots) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9); + INSERT INTO shipchoices (ship_name, ship_fuel, ship_hull, base_combat, base_diplomacy, base_science, used_item_slots, max_item_slots) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8); `, - [ship.ship_name, ship.ship_image, ship.ship_fuel, ship.ship_hull, ship.base_combat, ship.base_diplomacy, ship.base_science, ship.used_item_slots, ship.max_item_slots]); + [ship.ship_name, ship.ship_fuel, ship.ship_hull, ship.base_combat, ship.base_diplomacy, ship.base_science, ship.used_item_slots, ship.max_item_slots]); }) ); diff --git a/data/locations.js b/data/locations.js index 838b00a..71c47db 100644 --- a/data/locations.js +++ b/data/locations.js @@ -28,5 +28,33 @@ module.exports = [ location_image: 'https://cdn.pixabay.com/photo/2018/08/12/00/48/planet-3599887_960_720.jpg', location_description: 'Selelup II is a rocky desert type planet that is lit by a gentle sun. Spires of sharp stone interrupt the otherwise flat eterrain. There are signs of a once foreign colony, but now it seems abandoned. There is no water on this now deserted planet.', event_id: 4 - } + }, + { + location_name: 'Laravim VI', + location_type: 'Planet', + location_image: 'https://cdn.pixabay.com/photo/2015/06/26/18/48/mercury-822825_960_720.png', + location_description: 'Laravim VI is an icy desert. Towering columns of hexagonal black stone. Some local plants hover in mid-air, held aloft by gas bags.', + event_id: 5 + }, + { + location_name: 'Xivon III', + location_type: 'Planet', + location_image: 'https://cdn.pixabay.com/photo/2016/04/13/06/40/mars-1326108_960_720.jpg', + location_description: 'Xivon III is covered in black mud and small rivulets. Deep canyons cut into the planets crust. The local plant life takes the shape of small blue bubbles.', + event_id: 6 + }, + { + location_name: 'Noxabas I', + location_type: 'Planet', + location_image: 'https://cdn.pixabay.com/photo/2017/11/16/09/32/planet-2953871_960_720.png', + location_description: 'Noxabas I is covered in grey mud and small rivulets. Noxious gases erupt from deep fissures. There are massive flowers in all kinds of colors, sitting atop thick dark green stems.', + event_id: 7 + }, + { + location_name: 'Yoraporr I', + location_type: 'Planet', + location_image: 'https://cdn.pixabay.com/photo/2018/02/12/21/03/planet-3149121_960_720.jpg', + location_description: 'Yoraporr I is covered in dense jungles of giant dark green geodesic domes cover Yoraporr I. The land is a maze of steep valleys.', + event_id: 8 + }, ]; diff --git a/data/shipchoices.js b/data/shipchoices.js index 742bc24..7ae6c2b 100644 --- a/data/shipchoices.js +++ b/data/shipchoices.js @@ -1,38 +1,32 @@ module.exports = [ { - ship_name: 'diplomacy', - ship_image: 'im an image', + ship_name: 'The Reach', ship_fuel: 4, - ship_hull: 10, - base_combat: 2, - base_diplomacy: 4, + ship_hull: 6, + base_combat: 1, + base_diplomacy: 3, base_science: 2, used_item_slots: 0, max_item_slots: 3, - planet_visited: [] }, { - ship_name: 'combat', - ship_image: 'im an image', + ship_name: 'The Avenger', ship_fuel: 4, - ship_hull: 10, - base_combat: 2, - base_diplomacy: 4, - base_science: 2, + ship_hull: 6, + base_combat: 3, + base_diplomacy: 2, + base_science: 1, used_item_slots: 0, - max_item_slots: 3, - planet_visited: [] + max_item_slots: 3 }, { - ship_name: 'science', - ship_image: 'im an image', + ship_name: 'The Icarus', ship_fuel: 4, - ship_hull: 10, - base_combat: 2, - base_diplomacy: 4, - base_science: 2, + ship_hull: 6, + base_combat: 1, + base_diplomacy: 2, + base_science: 3, used_item_slots: 0, - max_item_slots: 3, - planet_visited: [] + max_item_slots: 3 } ]; diff --git a/lib/app.js b/lib/app.js index aeee255..4f91347 100644 --- a/lib/app.js +++ b/lib/app.js @@ -56,7 +56,7 @@ app.get('/shipchoices', async(req, res) => { app.get('/usership/:id', async(req, res) => { const data = await client.query(` - SELECT shipchoices.id, shipchoices.ship_name, shipchoices.ship_image, shipchoices.ship_fuel, shipchoices.ship_hull, shipchoices.base_combat, shipchoices.base_diplomacy, shipchoices.base_science, shipchoices.used_item_slots, shipchoices.max_item_slots + SELECT shipchoices.id, shipchoices.ship_name, shipchoices.ship_fuel, shipchoices.ship_hull, shipchoices.base_combat, shipchoices.base_diplomacy, shipchoices.base_science, shipchoices.used_item_slots, shipchoices.max_item_slots FROM shipchoices WHERE shipchoices.id = $1 `, [req.params.id]); From b97a2537e29a62f43cab5b1a78119c0642b700e4 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Thu, 21 May 2020 17:24:08 -0700 Subject: [PATCH 20/24] fixed table varchar --- data/create-tables.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index e7043ba..a5b3543 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -38,8 +38,8 @@ async function run() { id SERIAL PRIMARY KEY NOT NULL, planet_id INTEGER REFERENCES locations(event_id), event_name VARCHAR(512) NOT NULL, - event_image VARCHAR(512) NOT NULL, - event_description VARCHAR(512) NOT NULL, + event_image VARCHAR(1000) NOT NULL, + event_description VARCHAR(2000) NOT NULL, event_choices VARCHAR(5000) ARRAY NOT NULL ); CREATE TABLE shipchoices ( From cfda440cdfaa5c8ea4b9104858f78e9c43b63e44 Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Thu, 21 May 2020 19:41:34 -0700 Subject: [PATCH 21/24] commiting changes --- data/create-tables.js | 1 - lib/app.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/data/create-tables.js b/data/create-tables.js index 9daf33a..e7043ba 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -45,7 +45,6 @@ async function run() { CREATE TABLE shipchoices ( id SERIAL PRIMARY KEY NOT NULL, ship_name VARCHAR(512) NOT NULL, - ship_image VARCHAR(512) NOT NULL, ship_fuel INTEGER NOT NULL, ship_hull INTEGER NOT NULL, base_combat INTEGER NOT NULL, diff --git a/lib/app.js b/lib/app.js index aeee255..4f91347 100644 --- a/lib/app.js +++ b/lib/app.js @@ -56,7 +56,7 @@ app.get('/shipchoices', async(req, res) => { app.get('/usership/:id', async(req, res) => { const data = await client.query(` - SELECT shipchoices.id, shipchoices.ship_name, shipchoices.ship_image, shipchoices.ship_fuel, shipchoices.ship_hull, shipchoices.base_combat, shipchoices.base_diplomacy, shipchoices.base_science, shipchoices.used_item_slots, shipchoices.max_item_slots + SELECT shipchoices.id, shipchoices.ship_name, shipchoices.ship_fuel, shipchoices.ship_hull, shipchoices.base_combat, shipchoices.base_diplomacy, shipchoices.base_science, shipchoices.used_item_slots, shipchoices.max_item_slots FROM shipchoices WHERE shipchoices.id = $1 `, [req.params.id]); From d31e81113e45a892ebac47efefeefd9dc62f6c04 Mon Sep 17 00:00:00 2001 From: Erik Ford Date: Fri, 22 May 2020 09:51:51 -0700 Subject: [PATCH 22/24] completed project --- data/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/events.js b/data/events.js index a241e29..b44c965 100644 --- a/data/events.js +++ b/data/events.js @@ -228,7 +228,7 @@ module.exports = [ event_name: 'Harvesting Gas', planet_id: 7, event_image: 'https://vignette.wikia.nocookie.net/warframe/images/e/ee/Plains_of_Eidolon_at_Day_%282%29.jpg/revision/latest?cb=20180717001626', - event_description: 'You land your ship on Noxabas I and take in the sceneray. It seems these large fissures are realising some type of gas. It could probably help fuel your ship.', + event_description: 'You land your ship on Noxabas I and take in the scenery. It seems these large fissures are realising some type of gas. It could probably help fuel your ship.', event_choices: [{ choice_description: 'You see in the distance a alien looking facility. Perhaps they are friendly?', roll_needed: 5, From 9c72a2de9a8d2429964cf5682f789468390c000b Mon Sep 17 00:00:00 2001 From: Lucia Brammer Date: Fri, 22 May 2020 11:57:27 -0700 Subject: [PATCH 23/24] testing color --- lib/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/app.js b/lib/app.js index 4f91347..3e3cae9 100644 --- a/lib/app.js +++ b/lib/app.js @@ -2,6 +2,7 @@ const express = require('express'); const cors = require('cors'); const client = require('./client.js'); const app = express(); +const request = require('superagent'); app.use(cors()); app.use(express.json()); @@ -33,7 +34,11 @@ const authRoutes = createAuthRoutes({ app.use('/auth', authRoutes); app.use('/api', ensureAuth); +app.get('/color', async(req, res) => { + const data = await request.get('http://thecolorapi.com/scheme?hex=0047AB&rgb=0,71,171&hsl=215,100%,34%&cmyk=100,58,0,33&format=json&mode=analogic&count=6'); + res.json(data.body); +}); app.get('/locations', async(req, res) => { const data = await client.query('SELECT * from locations'); From 2e9d5b1d3933cd6419fad080ae71f460a9652c3e Mon Sep 17 00:00:00 2001 From: harriet-the-spy Date: Fri, 29 May 2020 17:18:41 -0700 Subject: [PATCH 24/24] add feedback --- data/create-tables.js | 3 ++- lib/app.js | 3 +++ server.js | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/data/create-tables.js b/data/create-tables.js index a5b3543..fe7e736 100644 --- a/data/create-tables.js +++ b/data/create-tables.js @@ -11,6 +11,7 @@ async function run() { await client.connect(); // run a query to create tables + // Wow!! Look at this data model! So much complexity. My only concern: is it necessary to track the loggedinuser in its own table? await client.query(` CREATE TABLE users ( id SERIAL PRIMARY KEY, @@ -53,7 +54,7 @@ async function run() { used_item_slots INTEGER NOT NULL, max_item_slots INTEGER NOT NULL ); - `); + `); // Generally, the SQL standard would have put ship_choices in snake case console.log('create tables complete', getEmoji(), getEmoji(), getEmoji()); } diff --git a/lib/app.js b/lib/app.js index 3e3cae9..d947a8c 100644 --- a/lib/app.js +++ b/lib/app.js @@ -1,3 +1,4 @@ +// I'm grading off the dev branch here. Is that right? Is dev the most updated code? The master branch didn't seem like it const express = require('express'); const cors = require('cors'); const client = require('./client.js'); @@ -35,6 +36,7 @@ app.use('/auth', authRoutes); app.use('/api', ensureAuth); app.get('/color', async(req, res) => { + // nice work getting this endpoint together so quickly! const data = await request.get('http://thecolorapi.com/scheme?hex=0047AB&rgb=0,71,171&hsl=215,100%,34%&cmyk=100,58,0,33&format=json&mode=analogic&count=6'); res.json(data.body); @@ -98,6 +100,7 @@ app.get('/api/loggedinuser', async(req, res) => { res.json(data.rows); }); +// seems like you could have managed this stuff with req.userId app.put('/api/loggedinuser', async(req, res) => { const data = await client.query(` UPDATE loggedinuser diff --git a/server.js b/server.js index 564a9ca..7fb15fa 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,5 @@ +// Did you end up running postman tests and screenshots of your passing tests? + require('dotenv').config(); require('./lib/client').connect();