Disable build button if cost of a building cannot be paid.
This commit is contained in:
parent
42b8dae615
commit
92dd8716a4
@ -1,7 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { createBuilding } from "../create";
|
||||
import buildings from "../data/buildings";
|
||||
import moves from "../moves";
|
||||
import showBuildingCreator from "../stores/showBuildingCreator";
|
||||
import { canPayBuildingCost } from "../utils";
|
||||
import village from "../village";
|
||||
import Cost from "./Cost.svelte";
|
||||
|
||||
function close() {
|
||||
@ -19,7 +22,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
const constructible = buildings.filter(b => !b.autoBuilt);
|
||||
const constructible = buildings.filter(b => !b.autoBuilt).map(b =>{
|
||||
const building = createBuilding(b.type);
|
||||
building.level = 0;
|
||||
return building;
|
||||
});
|
||||
</script>
|
||||
|
||||
{ #if $showBuildingCreator !== null }
|
||||
@ -36,7 +43,12 @@
|
||||
<div>
|
||||
<p>{ building.name }</p>
|
||||
<Cost cost={ building.cost(1) } />
|
||||
<button on:click={ () => build(building.type) }>Build</button>
|
||||
<button
|
||||
on:click={ () => build(building.type) }
|
||||
disabled={ !canPayBuildingCost($village, building) }
|
||||
>
|
||||
Build
|
||||
</button>
|
||||
</div>
|
||||
{ /each }
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user