Show a pretty time for durations. Increase recruitment time for soldiers and philosophers.
This commit is contained in:
parent
fc02fefa80
commit
0ee34e6831
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import moves from "../moves";
|
import moves from "../moves";
|
||||||
import type { BuildingType } from "../types";
|
import type { BuildingType } from "../types";
|
||||||
import { canPayBuildingCost } from "../utils";
|
import { canPayBuildingCost, getPrettyTime } from "../utils";
|
||||||
import village from "../village";
|
import village from "../village";
|
||||||
|
|
||||||
export let building: BuildingType;
|
export let building: BuildingType;
|
||||||
@ -23,7 +23,6 @@
|
|||||||
<img src="/img/buildings/{ building.type }.png" alt="">
|
<img src="/img/buildings/{ building.type }.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<!-- <p>{ building.name }</p> -->
|
|
||||||
<div class="level">
|
<div class="level">
|
||||||
<button
|
<button
|
||||||
class:can-upgrade={ canUpgrade }
|
class:can-upgrade={ canUpgrade }
|
||||||
@ -34,7 +33,7 @@
|
|||||||
{ building.level }
|
{ building.level }
|
||||||
{ #if building.state.upgrade.isUpgrading }
|
{ #if building.state.upgrade.isUpgrading }
|
||||||
<span>
|
<span>
|
||||||
({ Math.ceil(building.state.upgrade.remainingTime / 1000) }’)
|
({ getPrettyTime(building.state.upgrade.remainingTime) })
|
||||||
</span>
|
</span>
|
||||||
{ /if }
|
{ /if }
|
||||||
</button>
|
</button>
|
||||||
|
@ -296,7 +296,7 @@ export default [
|
|||||||
},
|
},
|
||||||
units: {
|
units: {
|
||||||
type: 'philosopher',
|
type: 'philosopher',
|
||||||
recruitmentTime: (V: VillageState, self: BuildingType) => 2 - 0.06 * self.level,
|
recruitmentTime: (V: VillageState, self: BuildingType) => 3 - 0.06 * self.level,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -323,7 +323,7 @@ export default [
|
|||||||
},
|
},
|
||||||
units: {
|
units: {
|
||||||
type: 'soldier',
|
type: 'soldier',
|
||||||
recruitmentTime: (V: VillageState, self: BuildingType) => 1 - 0.03 * self.level,
|
recruitmentTime: (V: VillageState, self: BuildingType) => 2 - 0.03 * self.level,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import moves from "../moves";
|
import moves from "../moves";
|
||||||
import showBuildingPanel from "../stores/showBuildingPanel";
|
import showBuildingPanel from "../stores/showBuildingPanel";
|
||||||
import { getBuilding, getBuildingUpgradeCost } from "../utils";
|
import { getBuilding, getBuildingUpgradeCost, getPrettyTime } from "../utils";
|
||||||
import village from "../village";
|
import village from "../village";
|
||||||
import BuildingRecruitment from "./BuildingRecruitment.svelte";
|
import BuildingRecruitment from "./BuildingRecruitment.svelte";
|
||||||
import Cost from "./Cost.svelte";
|
import Cost from "./Cost.svelte";
|
||||||
@ -44,7 +44,7 @@
|
|||||||
{ #if building.state.upgrade.isUpgrading }
|
{ #if building.state.upgrade.isUpgrading }
|
||||||
<p>
|
<p>
|
||||||
Upgrading to level { building.level + 1 }
|
Upgrading to level { building.level + 1 }
|
||||||
({ Math.ceil(building.state.upgrade.remainingTime / 1000) }’)
|
({ getPrettyTime(building.state.upgrade.remainingTime) })
|
||||||
</p>
|
</p>
|
||||||
{ :else if building.level === building.maxLevel }
|
{ :else if building.level === building.maxLevel }
|
||||||
<p>Max level reached!</p>
|
<p>Max level reached!</p>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import village from "../village";
|
import village from "../village";
|
||||||
import Reward from "./Reward.svelte";
|
import Reward from "./Reward.svelte";
|
||||||
import { flip } from "svelte/animate";
|
import { flip } from "svelte/animate";
|
||||||
|
import { getPrettyTime } from "../utils";
|
||||||
|
|
||||||
|
|
||||||
$: availableHeroes = $village.heroes.filter(h => !$village.quests.some(q => q.hero === h.id));
|
$: availableHeroes = $village.heroes.filter(h => !$village.quests.some(q => q.hero === h.id));
|
||||||
@ -28,7 +29,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<img src="/img/icons/time.png" alt="Duration">
|
<img src="/img/icons/time.png" alt="Duration">
|
||||||
{ #if quest.started }
|
{ #if quest.started }
|
||||||
{ Math.ceil((quest.remainingTime || 0) / 1000) }
|
{ getPrettyTime(quest.remainingTime || 0) }
|
||||||
{ :else }
|
{ :else }
|
||||||
{ quest.duration }
|
{ quest.duration }
|
||||||
{ #each availableHeroes as hero }
|
{ #each availableHeroes as hero }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { BuildingType } from "../types";
|
import type { BuildingType } from "../types";
|
||||||
|
import { getPrettyTime } from "../utils";
|
||||||
import village from "../village";
|
import village from "../village";
|
||||||
|
|
||||||
export let building: BuildingType;
|
export let building: BuildingType;
|
||||||
@ -9,12 +10,11 @@
|
|||||||
$: recruitmentTime = building.behavior.units?.recruitmentTime($village, building) || 0;
|
$: recruitmentTime = building.behavior.units?.recruitmentTime($village, building) || 0;
|
||||||
$: currentRecruitTime = building.state.recruitment?.elapsedTime || 0;
|
$: currentRecruitTime = building.state.recruitment?.elapsedTime || 0;
|
||||||
$: timeToNextRecruit = recruitmentTime * 1000 - currentRecruitTime;
|
$: timeToNextRecruit = recruitmentTime * 1000 - currentRecruitTime;
|
||||||
$: prettyDuration = Math.ceil(timeToNextRecruit / 1000);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{ #if unitsCount > 0 }
|
{ #if unitsCount > 0 }
|
||||||
<div>
|
<div>
|
||||||
{ unitsCount }
|
{ unitsCount }
|
||||||
({ prettyDuration }’)
|
({ getPrettyTime(timeToNextRecruit) })
|
||||||
</div>
|
</div>
|
||||||
{ /if }
|
{ /if }
|
||||||
|
@ -216,3 +216,9 @@ export function indexToPoint(index: number): Point {
|
|||||||
y: Math.floor(index / WORLD_MAP_WIDTH),
|
y: Math.floor(index / WORLD_MAP_WIDTH),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getPrettyTime(milliseconds: number) {
|
||||||
|
const timeInSeconds = Math.ceil(milliseconds / 1000.0);
|
||||||
|
return `${timeInSeconds}s`;
|
||||||
|
}
|
||||||
|
@ -137,7 +137,7 @@ function getInitialState() {
|
|||||||
|
|
||||||
// Create the Town hall.
|
// Create the Town hall.
|
||||||
const townhall = createBuilding('townhall');
|
const townhall = createBuilding('townhall');
|
||||||
// townhall.level = 20;
|
townhall.level = 20;
|
||||||
state.villageTiles[0][0] = townhall.id;
|
state.villageTiles[0][0] = townhall.id;
|
||||||
state.buildings.push(townhall);
|
state.buildings.push(townhall);
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ function getInitialState() {
|
|||||||
}
|
}
|
||||||
const newBuilding = createBuilding(type);
|
const newBuilding = createBuilding(type);
|
||||||
newBuilding.tile = new Hex(x, y);
|
newBuilding.tile = new Hex(x, y);
|
||||||
newBuilding.level = 1; //20; //newBuilding.type === 'field' ? 1 : 10;
|
newBuilding.level = 20; //newBuilding.type === 'field' ? 1 : 10;
|
||||||
state.outsideTiles[y][x] = newBuilding.id;
|
state.outsideTiles[y][x] = newBuilding.id;
|
||||||
state.buildings.push(newBuilding);
|
state.buildings.push(newBuilding);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user