From 2382a452456e4bdef4584e1046925e372624cb79 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Thu, 16 May 2019 23:48:38 +0200 Subject: Rationalize module names --- sw-ui/src/components/game/ProductionBar.tsx | 87 +++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sw-ui/src/components/game/ProductionBar.tsx (limited to 'sw-ui/src/components/game/ProductionBar.tsx') diff --git a/sw-ui/src/components/game/ProductionBar.tsx b/sw-ui/src/components/game/ProductionBar.tsx new file mode 100644 index 00000000..3e5c6d34 --- /dev/null +++ b/sw-ui/src/components/game/ProductionBar.tsx @@ -0,0 +1,87 @@ +import React from 'react'; +import { ApiCountedResource, ApiProduction, ApiResourceType } from '../../api/model'; +import './ProductionBar.css' + +type ProductionBarProps = { + gold: number, + production: ApiProduction, +} + +export const ProductionBar = ({gold, production}: ProductionBarProps) => { + return
+ + + +
; +}; + +type GoldIndicatorProps = { + amount: number, +} +const GoldIndicator = ({amount}: GoldIndicatorProps) => { + return +}; + +type FixedResourcesProps = { + resources: ApiCountedResource[], +} +const FixedResources = ({resources}: FixedResourcesProps) => { + return
+ {resources.map(r => )} +
+}; + +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: T[], elt: T) => acc.concat(elt, separator), []); + return result.slice(0, -1); // remove extra separator at the end +} + +type TokenWithCountProps = { + tokenName: string, + count: number, + otherClasses?: string, +} +const TokenWithCount = ({tokenName, count, otherClasses = ""}: TokenWithCountProps) => { + return
+ + × {count} +
+}; + +type TokenImageProps = { + tokenName: string, +} +const TokenImage = ({tokenName}: TokenImageProps) => { + return {tokenName} +}; + +function getTokenImagePath(tokenName: string): string { + return `/images/tokens/${tokenName}.png`; +} + +function getTokenName(resourceType: ApiResourceType): string { + return `resources/${resourceType.toLowerCase()}`; +} -- cgit