diff --git a/public/lang/en/buildings.json b/public/lang/en/buildings.json index 5eda387..740120b 100644 --- a/public/lang/en/buildings.json +++ b/public/lang/en/buildings.json @@ -1,11 +1,37 @@ { "Label": { "mines": "Mines", - "iron-mine": "Iron mine", - "gold-mine": "Gold mine", + "iron-mine": { + "name": "Iron mine", + "description": "Iron mines produce iron ore, which is used to build and upgrade buildings." + }, + "gold-mine": { + "name": "Gold mine", + "description": "Gold mines produce gold ore, useful for trading and building." + }, + "coal-mine": { + "name": "Coal mine", + "description": "Coal mines produce coal, which is used to power buildings." + }, "utilities": "Utilities", - "research-lab": "Research lab", - "research-facility": "Research facility" + "research-lab": { + "name": "Research lab", + "description": "Research labs are used to research new technologies and improve existing ones." + }, + "research-facility": { + "name": "Research facility", + "description": "Research facilities are used to research advanced technologies." + }, + + "power-plants": "Power plants", + "coal-power-plant": { + "name": "Coal power plant", + "description": "Coal power plants produce electricity using coal." + }, + "nuclear-power-plant": { + "name": "Nuclear power plant", + "description": "Nuclear power plants produce electricity using uranium." + } } } \ No newline at end of file diff --git a/public/lang/en/research.json b/public/lang/en/research.json index 7740864..52b3014 100644 --- a/public/lang/en/research.json +++ b/public/lang/en/research.json @@ -30,6 +30,10 @@ "advanced-technologies": { "name": "Advanced Technologies", "description": "Various advanced technologies" + }, + "nuclear-power": { + "name": "Nuclear Power", + "description": "Advanced power generation using nuclear energy" } } } \ No newline at end of file diff --git a/src/components/BuildingCard.astro b/src/components/BuildingCard.astro new file mode 100644 index 0000000..6db65b9 --- /dev/null +++ b/src/components/BuildingCard.astro @@ -0,0 +1,78 @@ +--- +import { getHighestWeightedLanguage, getLocales } from '../lib/utils/langDriver'; + +interface Props { + id: string; + name: string; + description: string; + image: string; +} + +const lang = await getLocales(await getHighestWeightedLanguage(Astro.request.headers.get('accept-language')), ['resources', 'game', 'buildings', 'research']); + +--- + +
+
+
+
{Astro.props.name}
+
{Astro.props.description}
+ {lang["game"]['Link_build']} +
i
+
+
+ \ No newline at end of file diff --git a/src/lib/data/buildings.json b/src/lib/data/buildings.json index b571033..2eed6da 100644 --- a/src/lib/data/buildings.json +++ b/src/lib/data/buildings.json @@ -47,6 +47,29 @@ }, "energy": 11, "multiplier": 2.5 + }, + { + "id": "coal-mine", + "requirements": { + "buildings": [], + "research": [], + "resources": [ + { + "name": "iron", + "amount": 1 + }, + { + "name": "gold", + "amount": 1 + }, + { + "name": "coal", + "amount": 1 + } + ] + }, + "energy": 11, + "multiplier": 3 } ] }, { @@ -109,5 +132,65 @@ "multiplier": 2 } ] + }, { + "category": "power-plants", + "buildings": [ + { + "id": "coal-power-plant", + "requirements": { + "buildings": [], + "research": [], + "resources": [ + { + "name": "iron", + "amount": 1 + }, + { + "name": "gold", + "amount": 1 + }, + { + "name": "coal", + "amount": 1 + } + ] + }, + "energy": 100, + "multiplier": 3 + }, + { + "id": "nuclear-power-plant", + "requirements": { + "buildings": [ + { + "id": "coal-power-plant", + "level": 3 + } + ], + "research": [ + { + "id": "nuclear-power", + "level": 2 + } + ], + "resources": [ + { + "name": "iron", + "amount": 1 + }, + { + "name": "gold", + "amount": 1 + }, + { + "name": "coal", + "amount": 1 + } + ] + }, + "energy": 100, + "multiplier": 2 + } + ] } ] \ No newline at end of file diff --git a/src/lib/data/research.json b/src/lib/data/research.json index 9cf4083..630f4b3 100644 --- a/src/lib/data/research.json +++ b/src/lib/data/research.json @@ -123,5 +123,20 @@ }, "time": 1500, "multiplier": 4 + }, { + "id": "nuclear-power", + "requirements": { + "buildings": [ + { + "id": "research-lab", + "level": 10 + } + ], + "research": [], + "resources": { + "iron": 1000, + "gold": 500 + } + } } ] \ No newline at end of file diff --git a/src/pages/game/buildings.astro b/src/pages/game/buildings.astro index d3e0bd2..7103f81 100644 --- a/src/pages/game/buildings.astro +++ b/src/pages/game/buildings.astro @@ -1,6 +1,7 @@ --- import Layout from '../../layouts/Layout.astro'; import NavBar from '../../components/NavBar.astro'; +import BuildingCard from '../../components/BuildingCard.astro'; import { getUserByAccessToken } from '../../lib/db/users'; import { getHighestWeightedLanguage, getLocales } from '../../lib/utils/langDriver'; import ResourceBar from '../../components/ResourceBar.astro'; @@ -17,28 +18,47 @@ if(checkUser === null || checkUser.username !== username) return Astro.redirect( const locale = await getHighestWeightedLanguage(Astro.request.headers.get('accept-language')); const lang = await getLocales(locale, ['resources', 'game', 'buildings', 'research']); + +const modalSet: { [key: string]: { resources: Array, research: Array, buildings: Array, energy: number } } = {}; + +buildingsList.forEach(cat => { + cat.buildings.forEach(building => { + modalSet[building.id] = { + "resources": building.requirements.resources, + "research": building.requirements.research, + "buildings": building.requirements.buildings, + "energy": building.energy + }; + }); +}); --- +
+
+

Required resources

+
None
+

Required buildings

+
None
+

Required research

+
None
+
+
+ {buildingsList.map(cat => (
+ {console.log(cat.category)}

{lang["buildings"][`Label_${cat.category}`]}

- {cat.buildings.map(building => ( <> -

{lang["buildings"][`Label_${building.id}`]}

- {building.requirements.resources.map(res => ( -
{lang["resources"][`Label_${res.name}`]}: {res.amount}
- ))} - {building.requirements.buildings.map(b => ( -
{lang["buildings"][`Label_${b.id}`]}: {b.level}
- ))} - {building.requirements.research.map(t => ( -
{lang["research"][`Label_${t.id}`].name}: {t.level}
- ))} - {lang["game"]['Link_build']} - ))} +
+ {cat.buildings.map(building => )} +
))}
@@ -58,6 +78,39 @@ const lang = await getLocales(locale, ['resources', 'game', 'buildings', 'resear line-height: 1.6; } + .building-cat { + display: flex; + flex-direction: row; + flex-wrap: wrap; + row-gap: 40px; + column-gap: 2%; + } + + #building-modal-background { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.5); + z-index: 100; + } + + #building-modal-details { + display: none; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 80%; + max-width: 800px; + background: rgba(0, 0, 0, 0.9); + border-radius: 8px; + padding: 1rem; + z-index: 101; + } + .astro-a { position: absolute; top: -32px; @@ -76,6 +129,10 @@ const lang = await getLocales(locale, ['resources', 'game', 'buildings', 'resear margin-bottom: 1em; } + .building-modal-text { + font-size: 1.5rem; + } + .text-gradient { background-image: var(--accent-gradient); -webkit-background-clip: text; @@ -121,7 +178,50 @@ const lang = await getLocales(locale, ['resources', 'game', 'buildings', 'resear color: lime; } -