From 6183c512c63ac94c479193fa50204ca1a5cbc62b Mon Sep 17 00:00:00 2001 From: jbion Date: Mon, 25 Feb 2019 21:39:47 +0100 Subject: Add production bar --- frontend/src/components/game/ProductionBar.jsx | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 frontend/src/components/game/ProductionBar.jsx (limited to 'frontend/src/components/game/ProductionBar.jsx') diff --git a/frontend/src/components/game/ProductionBar.jsx b/frontend/src/components/game/ProductionBar.jsx new file mode 100644 index 00000000..623389aa --- /dev/null +++ b/frontend/src/components/game/ProductionBar.jsx @@ -0,0 +1,74 @@ +import React from 'react'; +import type { ApiCountedResource, ApiProduction, ApiResourceType } from '../../api/model'; +import './ProductionBar.css' + +type ProductionBarProps = { + production: ApiProduction, +} + +export const ProductionBar = ({production}: ProductionBarProps) => { + return
+ + +
; +}; + +type FixedResourcesProps = { + resources: ApiCountedResource[], +} + +const FixedResources = ({resources}: FixedResourcesProps) => { + return
+ {resources.map(r => )} +
+}; + +type ResourceCountProps = { + resource: ApiCountedResource, +} + +const ResourceCount = ({resource}: ResourceCountProps) => { + return
+ + × {resource.count} +
+}; + +type AlternativeResourcesProps = { + resources: ApiResourceType[][], +} + +const AlternativeResources = ({resources}: AlternativeResourcesProps) => { + return
+ {resources.map((types, i) => )} +
+}; + +type ResourceChoiceProps = { + types: ApiResourceType[], +} + +const ResourceChoice = ({types}: ResourceChoiceProps) => { + let typeImages = types.map(type => ); + let separator = ; + return
+ {intersperce(typeImages, separator)} +
+}; + +function intersperce(array: T[], separator: T): T[] { + let result = array.reduce((acc, elt) => acc.concat(elt, separator), []); + return result.slice(0, -1); +} + +type ResourceImageProps = { + type: ApiResourceType, +} + +const ResourceImage = ({type}: ResourceImageProps) => { + return {type} +}; + +function getImagePath(resourceType: ApiResourceType): string { + return `/images/resources/${resourceType.toLowerCase()}.png`; +} -- cgit