summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/public/images/tokens/coin.pngbin0 -> 4515 bytes
-rw-r--r--frontend/public/images/tokens/resources/clay.png (renamed from frontend/public/images/resources/clay.png)bin19566 -> 19566 bytes
-rw-r--r--frontend/public/images/tokens/resources/glass.png (renamed from frontend/public/images/resources/glass.png)bin20961 -> 20961 bytes
-rw-r--r--frontend/public/images/tokens/resources/loom.png (renamed from frontend/public/images/resources/loom.png)bin21053 -> 21053 bytes
-rw-r--r--frontend/public/images/tokens/resources/ore.png (renamed from frontend/public/images/resources/ore.png)bin21524 -> 21524 bytes
-rw-r--r--frontend/public/images/tokens/resources/papyrus.png (renamed from frontend/public/images/resources/papyrus.png)bin22695 -> 22695 bytes
-rw-r--r--frontend/public/images/tokens/resources/stone.png (renamed from frontend/public/images/resources/stone.png)bin21516 -> 21516 bytes
-rw-r--r--frontend/public/images/tokens/resources/wood.png (renamed from frontend/public/images/resources/wood.png)bin21642 -> 21642 bytes
-rw-r--r--frontend/src/components/game/GameScene.jsx2
-rw-r--r--frontend/src/components/game/ProductionBar.css20
-rw-r--r--frontend/src/components/game/ProductionBar.jsx61
11 files changed, 48 insertions, 35 deletions
diff --git a/frontend/public/images/tokens/coin.png b/frontend/public/images/tokens/coin.png
new file mode 100644
index 00000000..f4813042
--- /dev/null
+++ b/frontend/public/images/tokens/coin.png
Binary files differ
diff --git a/frontend/public/images/resources/clay.png b/frontend/public/images/tokens/resources/clay.png
index 72fc0b0e..72fc0b0e 100644
--- a/frontend/public/images/resources/clay.png
+++ b/frontend/public/images/tokens/resources/clay.png
Binary files differ
diff --git a/frontend/public/images/resources/glass.png b/frontend/public/images/tokens/resources/glass.png
index 61fd2be5..61fd2be5 100644
--- a/frontend/public/images/resources/glass.png
+++ b/frontend/public/images/tokens/resources/glass.png
Binary files differ
diff --git a/frontend/public/images/resources/loom.png b/frontend/public/images/tokens/resources/loom.png
index 294adcb2..294adcb2 100644
--- a/frontend/public/images/resources/loom.png
+++ b/frontend/public/images/tokens/resources/loom.png
Binary files differ
diff --git a/frontend/public/images/resources/ore.png b/frontend/public/images/tokens/resources/ore.png
index c2149daa..c2149daa 100644
--- a/frontend/public/images/resources/ore.png
+++ b/frontend/public/images/tokens/resources/ore.png
Binary files differ
diff --git a/frontend/public/images/resources/papyrus.png b/frontend/public/images/tokens/resources/papyrus.png
index 91a59221..91a59221 100644
--- a/frontend/public/images/resources/papyrus.png
+++ b/frontend/public/images/tokens/resources/papyrus.png
Binary files differ
diff --git a/frontend/public/images/resources/stone.png b/frontend/public/images/tokens/resources/stone.png
index 674c40db..674c40db 100644
--- a/frontend/public/images/resources/stone.png
+++ b/frontend/public/images/tokens/resources/stone.png
Binary files differ
diff --git a/frontend/public/images/resources/wood.png b/frontend/public/images/tokens/resources/wood.png
index 09a4ede8..09a4ede8 100644
--- a/frontend/public/images/resources/wood.png
+++ b/frontend/public/images/tokens/resources/wood.png
Binary files differ
diff --git a/frontend/src/components/game/GameScene.jsx b/frontend/src/components/game/GameScene.jsx
index 18d7ca26..23be5ef1 100644
--- a/frontend/src/components/game/GameScene.jsx
+++ b/frontend/src/components/game/GameScene.jsx
@@ -46,7 +46,7 @@ class GameScenePresenter extends Component<GameSceneProps> {
<Hand cards={turnInfo.hand}
wonderUpgradable={turnInfo.wonderBuildability.buildable}
prepareMove={this.props.prepareMove}/>
- <ProductionBar production={board.production}/>
+ <ProductionBar gold={board.gold} production={board.production}/>
</div>
}
}
diff --git a/frontend/src/components/game/ProductionBar.css b/frontend/src/components/game/ProductionBar.css
index 35b25137..15893b59 100644
--- a/frontend/src/components/game/ProductionBar.css
+++ b/frontend/src/components/game/ProductionBar.css
@@ -27,23 +27,23 @@
margin-left: 1.5rem;
}
-.resource-img {
+.choice-separator {
+ font-size: 2rem;
+ vertical-align: middle;
+ margin: 5px;
+ color: #c29929;
+ text-shadow: 0 0 1px black;
+}
+
+.token-img {
height: 3rem;
vertical-align: middle;
width: 3rem;
}
-.resource-count {
+.token-count {
font-family: fantasy;
font-size: 1.5rem;
margin-left: 0.2rem;
vertical-align: middle;
}
-
-.choice-separator {
- font-size: 2rem;
- vertical-align: middle;
- margin: 5px;
- color: #c29929;
- text-shadow: 0 0 1px black;
-}
diff --git a/frontend/src/components/game/ProductionBar.jsx b/frontend/src/components/game/ProductionBar.jsx
index 623389aa..ec924b31 100644
--- a/frontend/src/components/game/ProductionBar.jsx
+++ b/frontend/src/components/game/ProductionBar.jsx
@@ -3,41 +3,40 @@ import type { ApiCountedResource, ApiProduction, ApiResourceType } from '../../a
import './ProductionBar.css'
type ProductionBarProps = {
+ gold: number,
production: ApiProduction,
}
-export const ProductionBar = ({production}: ProductionBarProps) => {
+export const ProductionBar = ({gold, production}: ProductionBarProps) => {
return <div className='production-bar'>
+ <GoldIndicator amount={gold}/>
<FixedResources resources={production.fixedResources}/>
<AlternativeResources resources={production.alternativeResources}/>
</div>;
};
+type GoldIndicatorProps = {
+ amount: number,
+}
+const GoldIndicator = ({amount}: GoldIndicatorProps) => {
+ return <TokenWithCount tokenName="coin" count={amount} otherClasses="gold-indicator"/>
+};
+
type FixedResourcesProps = {
resources: ApiCountedResource[],
}
-
const FixedResources = ({resources}: FixedResourcesProps) => {
return <div className="fixed-resources">
- {resources.map(r => <ResourceCount key={r.type} resource={r}/>)}
- </div>
-};
-
-type ResourceCountProps = {
- resource: ApiCountedResource,
-}
-
-const ResourceCount = ({resource}: ResourceCountProps) => {
- return <div className="resource-with-count">
- <ResourceImage type={resource.type}/>
- <span className="resource-count">× {resource.count}</span>
+ {resources.map(r => <TokenWithCount key={r.type}
+ tokenName={getTokenName(r.type)}
+ count={r.count}
+ otherClasses="resource-with-count"/>)}
</div>
};
type AlternativeResourcesProps = {
resources: ApiResourceType[][],
}
-
const AlternativeResources = ({resources}: AlternativeResourcesProps) => {
return <div className="alternative-resources">
{resources.map((types, i) => <ResourceChoice key={i} types={types}/>)}
@@ -47,28 +46,42 @@ const AlternativeResources = ({resources}: AlternativeResourcesProps) => {
type ResourceChoiceProps = {
types: ApiResourceType[],
}
-
const ResourceChoice = ({types}: ResourceChoiceProps) => {
- let typeImages = types.map(type => <ResourceImage key={type} type={type}/>);
+ let typeImages = types.map(type => <TokenImage key={type} tokenName={getTokenName(type)}/>);
let separator = <span className="choice-separator">∕</span>;
return <div className="resource-choice">
{intersperce(typeImages, separator)}
</div>
};
-function intersperce(array: T[], separator: T): T[] {
+function intersperce(array, separator) {
let result = array.reduce((acc, elt) => acc.concat(elt, separator), []);
return result.slice(0, -1);
}
-type ResourceImageProps = {
- type: ApiResourceType,
+type TokenWithCountProps = {
+ tokenName: string,
+ count: number,
+ otherClasses?: string,
}
+const TokenWithCount = ({tokenName, count, otherClasses = ""}: TokenWithCountProps) => {
+ return <div className={`token-with-count ${otherClasses}`}>
+ <TokenImage tokenName={tokenName}/>
+ <span className="token-count">× {count}</span>
+ </div>
+};
-const ResourceImage = ({type}: ResourceImageProps) => {
- return <img src={getImagePath(type)} title={type} alt={type} className="resource-img"/>
+type TokenImageProps = {
+ tokenName: string,
+}
+const TokenImage = ({tokenName}: TokenImageProps) => {
+ return <img src={getTokenImagePath(tokenName)} title={tokenName} alt={tokenName} className="token-img"/>
};
-function getImagePath(resourceType: ApiResourceType): string {
- return `/images/resources/${resourceType.toLowerCase()}.png`;
+function getTokenImagePath(tokenName: number): string {
+ return `/images/tokens/${tokenName}.png`;
+}
+
+function getTokenName(resourceType: ApiResourceType): string {
+ return `resources/${resourceType.toLowerCase()}`;
}
bgstack15