diff --git a/src/App.js b/src/App.js
index a8271c1..46614aa 100644
--- a/src/App.js
+++ b/src/App.js
@@ -22,7 +22,6 @@ const App = ({
const homePlanet = planets.find(planet => planet.isHomePlanet === true)
- console.log({ homePlanet, shipLocation })
const value = homePlanet.location
const name = homePlanet.name
diff --git a/src/util.js b/src/util.js
index 9e894fd..46fc763 100644
--- a/src/util.js
+++ b/src/util.js
@@ -6,14 +6,27 @@ const getPlanetName = () => {
return planet
}
-export const generateItems = () => {
+export const generateItems = possibleDestinations => {
const items = []
+ console.log({ possibleDestinations })
+
for (let i = 0; i < 5; i++) {
+ const destinationPlanet =
+ possibleDestinations[
+ Math.floor(Math.random() * possibleDestinations.length)
+ ]
+
const item = Object.assign(
{},
itemList[Math.floor(Math.random() * itemList.length)],
- { id: uuidv4() }
+ {
+ id: uuidv4(),
+ destination: {
+ name: destinationPlanet.name,
+ value: destinationPlanet.location
+ }
+ }
)
items.push(item)
}
@@ -25,13 +38,19 @@ export const generatePlanets = () => {
for (let i = 0; i < 3; i++) {
const isHomePlanet = i === 0
- const items = generateItems()
const location = Math.floor(Math.random() * 100 + 1)
const name = getPlanetName()
- planets.push({ isHomePlanet, items, location, name })
+ planets.push({ isHomePlanet, location, name })
}
+ planets.forEach((planet, i) => {
+ const otherPlanets = [...planets]
+ otherPlanets.splice(i, 1)
+
+ planet.items = generateItems(otherPlanets)
+ })
+
return planets
}
diff --git a/src/views/planets.js b/src/views/planets.js
index ff70372..7ddf78d 100644
--- a/src/views/planets.js
+++ b/src/views/planets.js
@@ -39,7 +39,7 @@ const PlanetsView = ({
Items:
{items.map(item => {
- const { id, name, space, value } = item
+ const { destination, id, name, space, value } = item
return (
Value: {value}
+
+ Destination: {destination.name}
+
{shipLocationValue === location && (