Display the time to recruit units in the University panel.
This commit is contained in:
parent
abdc207b12
commit
ba812bbc03
17
package-lock.json
generated
17
package-lock.json
generated
@ -10,7 +10,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||||
"@tsconfig/svelte": "^5.0.4",
|
"@tsconfig/svelte": "^5.0.4",
|
||||||
|
"@types/luxon": "^3.4.2",
|
||||||
"immer": "^10.1.1",
|
"immer": "^10.1.1",
|
||||||
|
"luxon": "^3.5.0",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^4.2.19",
|
||||||
"svelte-check": "^4.0.4",
|
"svelte-check": "^4.0.4",
|
||||||
"tslib": "^2.7.0",
|
"tslib": "^2.7.0",
|
||||||
@ -706,6 +708,12 @@
|
|||||||
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
|
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/luxon": {
|
||||||
|
"version": "3.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz",
|
||||||
|
"integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.13.0",
|
"version": "8.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.13.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.13.0.tgz",
|
||||||
@ -912,6 +920,15 @@
|
|||||||
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/luxon": {
|
||||||
|
"version": "3.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz",
|
||||||
|
"integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/magic-string": {
|
"node_modules/magic-string": {
|
||||||
"version": "0.30.12",
|
"version": "0.30.12",
|
||||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz",
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz",
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||||
"@tsconfig/svelte": "^5.0.4",
|
"@tsconfig/svelte": "^5.0.4",
|
||||||
|
"@types/luxon": "^3.4.2",
|
||||||
"immer": "^10.1.1",
|
"immer": "^10.1.1",
|
||||||
|
"luxon": "^3.5.0",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^4.2.19",
|
||||||
"svelte-check": "^4.0.4",
|
"svelte-check": "^4.0.4",
|
||||||
"tslib": "^2.7.0",
|
"tslib": "^2.7.0",
|
||||||
|
BIN
public/img/icons/time.png
Normal file
BIN
public/img/icons/time.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -1,7 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Duration } from 'luxon';
|
||||||
|
|
||||||
import type { CostType } from "../types";
|
import type { CostType } from "../types";
|
||||||
|
|
||||||
export let cost: CostType;
|
export let cost: CostType;
|
||||||
|
export let duration: number | null = null;
|
||||||
|
|
||||||
|
|
||||||
|
$: prettyDuration = (duration !== null) ? Duration.fromMillis(duration * 1000).toFormat(`mm:ss:SS`) : '';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="cost">
|
<div class="cost">
|
||||||
@ -21,6 +27,12 @@
|
|||||||
<img src="/img/icons/food.png" alt="Food" />
|
<img src="/img/icons/food.png" alt="Food" />
|
||||||
{ cost.food }
|
{ cost.food }
|
||||||
</div>
|
</div>
|
||||||
|
{ #if duration !== null }
|
||||||
|
<div>
|
||||||
|
<img src="/img/icons/time.png" alt="Duration">
|
||||||
|
{ prettyDuration }
|
||||||
|
</div>
|
||||||
|
{ /if }
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
iron: unit.cost.iron * numberOfUnits,
|
iron: unit.cost.iron * numberOfUnits,
|
||||||
food: unit.cost.food * numberOfUnits,
|
food: unit.cost.food * numberOfUnits,
|
||||||
};
|
};
|
||||||
|
$: timeToRecruit = building.behavior.units?.recruitmentTime($village, building) * numberOfUnits;
|
||||||
|
|
||||||
function recruit() {
|
function recruit() {
|
||||||
moves.recruitUnits(building.id, unitType, numberOfUnits);
|
moves.recruitUnits(building.id, unitType, numberOfUnits);
|
||||||
@ -46,23 +46,27 @@
|
|||||||
|
|
||||||
<div class="university">
|
<div class="university">
|
||||||
<p>Create Philosophers</p>
|
<p>Create Philosophers</p>
|
||||||
<div class="cost"><Cost { cost } /></div>
|
<div class="cost">
|
||||||
|
<Cost { cost } duration={ timeToRecruit } />
|
||||||
|
</div>
|
||||||
|
|
||||||
<input
|
<div>
|
||||||
type="range"
|
<input
|
||||||
name="units"
|
type="range"
|
||||||
min="1"
|
name="units"
|
||||||
max={ maximumUnits }
|
min="1"
|
||||||
bind:value={ numberOfUnits }
|
max={ maximumUnits }
|
||||||
/>
|
bind:value={ numberOfUnits }
|
||||||
<input
|
/>
|
||||||
type="number"
|
<input
|
||||||
name="units"
|
type="number"
|
||||||
min="1"
|
name="units"
|
||||||
max={ maximumUnits }
|
min="1"
|
||||||
bind:value={ numberOfUnits }
|
max={ maximumUnits }
|
||||||
/>
|
bind:value={ numberOfUnits }
|
||||||
<button on:click={ recruit } disabled={ numberOfUnits > maximumUnits }>Recruit</button>
|
/>
|
||||||
|
<button on:click={ recruit } disabled={ numberOfUnits > maximumUnits }>Recruit</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user