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">
|
||||
import moves from "../moves";
|
||||
import type { BuildingType } from "../types";
|
||||
import { canPayBuildingCost } from "../utils";
|
||||
import { canPayBuildingCost, getPrettyTime } from "../utils";
|
||||
import village from "../village";
|
||||
|
||||
export let building: BuildingType;
|
||||
@ -23,7 +23,6 @@
|
||||
<img src="/img/buildings/{ building.type }.png" alt="">
|
||||
</div>
|
||||
<div class="content">
|
||||
<!-- <p>{ building.name }</p> -->
|
||||
<div class="level">
|
||||
<button
|
||||
class:can-upgrade={ canUpgrade }
|
||||
@ -34,7 +33,7 @@
|
||||
{ building.level }
|
||||
{ #if building.state.upgrade.isUpgrading }
|
||||
<span>
|
||||
({ Math.ceil(building.state.upgrade.remainingTime / 1000) }’)
|
||||
({ getPrettyTime(building.state.upgrade.remainingTime) })
|
||||
</span>
|
||||
{ /if }
|
||||
</button>
|
||||
|
@ -296,7 +296,7 @@ export default [
|
||||
},
|
||||
units: {
|
||||
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: {
|
||||
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">
|
||||
import moves from "../moves";
|
||||
import showBuildingPanel from "../stores/showBuildingPanel";
|
||||
import { getBuilding, getBuildingUpgradeCost } from "../utils";
|
||||
import { getBuilding, getBuildingUpgradeCost, getPrettyTime } from "../utils";
|
||||
import village from "../village";
|
||||
import BuildingRecruitment from "./BuildingRecruitment.svelte";
|
||||
import Cost from "./Cost.svelte";
|
||||
@ -44,7 +44,7 @@
|
||||
{ #if building.state.upgrade.isUpgrading }
|
||||
<p>
|
||||
Upgrading to level { building.level + 1 }
|
||||
({ Math.ceil(building.state.upgrade.remainingTime / 1000) }’)
|
||||
({ getPrettyTime(building.state.upgrade.remainingTime) })
|
||||
</p>
|
||||
{ :else if building.level === building.maxLevel }
|
||||
<p>Max level reached!</p>
|
||||
|
@ -5,6 +5,7 @@
|
||||
import village from "../village";
|
||||
import Reward from "./Reward.svelte";
|
||||
import { flip } from "svelte/animate";
|
||||
import { getPrettyTime } from "../utils";
|
||||
|
||||
|
||||
$: availableHeroes = $village.heroes.filter(h => !$village.quests.some(q => q.hero === h.id));
|
||||
@ -28,7 +29,7 @@
|
||||
<p>
|
||||
<img src="/img/icons/time.png" alt="Duration">
|
||||
{ #if quest.started }
|
||||
{ Math.ceil((quest.remainingTime || 0) / 1000) }
|
||||
{ getPrettyTime(quest.remainingTime || 0) }
|
||||
{ :else }
|
||||
{ quest.duration }
|
||||
{ #each availableHeroes as hero }
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { BuildingType } from "../types";
|
||||
import { getPrettyTime } from "../utils";
|
||||
import village from "../village";
|
||||
|
||||
export let building: BuildingType;
|
||||
@ -9,12 +10,11 @@
|
||||
$: recruitmentTime = building.behavior.units?.recruitmentTime($village, building) || 0;
|
||||
$: currentRecruitTime = building.state.recruitment?.elapsedTime || 0;
|
||||
$: timeToNextRecruit = recruitmentTime * 1000 - currentRecruitTime;
|
||||
$: prettyDuration = Math.ceil(timeToNextRecruit / 1000);
|
||||
</script>
|
||||
|
||||
{ #if unitsCount > 0 }
|
||||
<div>
|
||||
{ unitsCount }
|
||||
({ prettyDuration }’)
|
||||
({ getPrettyTime(timeToNextRecruit) })
|
||||
</div>
|
||||
{ /if }
|
||||
|
@ -216,3 +216,9 @@ export function indexToPoint(index: number): Point {
|
||||
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.
|
||||
const townhall = createBuilding('townhall');
|
||||
// townhall.level = 20;
|
||||
townhall.level = 20;
|
||||
state.villageTiles[0][0] = townhall.id;
|
||||
state.buildings.push(townhall);
|
||||
|
||||
@ -160,7 +160,7 @@ function getInitialState() {
|
||||
}
|
||||
const newBuilding = createBuilding(type);
|
||||
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.buildings.push(newBuilding);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user