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">
|
<script lang="ts">
|
||||||
|
import { createBuilding } from "../create";
|
||||||
import buildings from "../data/buildings";
|
import buildings from "../data/buildings";
|
||||||
import moves from "../moves";
|
import moves from "../moves";
|
||||||
import showBuildingCreator from "../stores/showBuildingCreator";
|
import showBuildingCreator from "../stores/showBuildingCreator";
|
||||||
|
import { canPayBuildingCost } from "../utils";
|
||||||
|
import village from "../village";
|
||||||
import Cost from "./Cost.svelte";
|
import Cost from "./Cost.svelte";
|
||||||
|
|
||||||
function close() {
|
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>
|
</script>
|
||||||
|
|
||||||
{ #if $showBuildingCreator !== null }
|
{ #if $showBuildingCreator !== null }
|
||||||
@ -36,7 +43,12 @@
|
|||||||
<div>
|
<div>
|
||||||
<p>{ building.name }</p>
|
<p>{ building.name }</p>
|
||||||
<Cost cost={ building.cost(1) } />
|
<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>
|
</div>
|
||||||
{ /each }
|
{ /each }
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user