Compare commits
No commits in common. "387e980f5dd058f524705ef8fb26cdf5525050c0" and "a21585280adf67fc3fa5f08ceb6c001643d4cb4d" have entirely different histories.
387e980f5d
...
a21585280a
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 232 KiB |
Before Width: | Height: | Size: 204 KiB |
Before Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 289 KiB |
@ -30,7 +30,6 @@ export default [
|
|||||||
name: 'Town Hall',
|
name: 'Town Hall',
|
||||||
autoBuilt: true,
|
autoBuilt: true,
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getResourceBuildingCost(level, 10),
|
wood: getResourceBuildingCost(level, 10),
|
||||||
@ -57,7 +56,6 @@ export default [
|
|||||||
name: 'Woodcutter',
|
name: 'Woodcutter',
|
||||||
autoBuilt: true,
|
autoBuilt: true,
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getResourceBuildingCost(level, 6),
|
wood: getResourceBuildingCost(level, 6),
|
||||||
@ -85,7 +83,6 @@ export default [
|
|||||||
name: 'Mine',
|
name: 'Mine',
|
||||||
autoBuilt: true,
|
autoBuilt: true,
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getResourceBuildingCost(level, 10),
|
wood: getResourceBuildingCost(level, 10),
|
||||||
@ -113,7 +110,6 @@ export default [
|
|||||||
name: 'Pit',
|
name: 'Pit',
|
||||||
autoBuilt: true,
|
autoBuilt: true,
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getResourceBuildingCost(level, 14),
|
wood: getResourceBuildingCost(level, 14),
|
||||||
@ -141,7 +137,6 @@ export default [
|
|||||||
name: 'Field',
|
name: 'Field',
|
||||||
autoBuilt: true,
|
autoBuilt: true,
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getResourceBuildingCost(level, 14),
|
wood: getResourceBuildingCost(level, 14),
|
||||||
@ -164,7 +159,6 @@ export default [
|
|||||||
type: 'warehouse',
|
type: 'warehouse',
|
||||||
name: 'Warehouse',
|
name: 'Warehouse',
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getStorageBuildingCost(level, 15),
|
wood: getStorageBuildingCost(level, 15),
|
||||||
@ -191,7 +185,6 @@ export default [
|
|||||||
type: 'granary',
|
type: 'granary',
|
||||||
name: 'Granary',
|
name: 'Granary',
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 0,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getStorageBuildingCost(level, 12),
|
wood: getStorageBuildingCost(level, 12),
|
||||||
@ -214,65 +207,10 @@ export default [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: 'great-warehouse',
|
|
||||||
name: 'Great Warehouse',
|
|
||||||
maxLevel: 20,
|
|
||||||
requiredTownhallLevel: 15,
|
|
||||||
cost: (level: number) => {
|
|
||||||
return {
|
|
||||||
wood: getStorageBuildingCost(level, 150),
|
|
||||||
stone: getStorageBuildingCost(level, 200),
|
|
||||||
iron: getStorageBuildingCost(level, 100),
|
|
||||||
food: getStorageBuildingCost(level, 150),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 2,
|
|
||||||
behavior: {
|
|
||||||
storage: (V: VillageState, self: BuildingType) => {
|
|
||||||
const x = self.level;
|
|
||||||
const capacity = ( ( ( x + ( x * x ) ) / 2 ) + 3 ) * 250;
|
|
||||||
return {
|
|
||||||
'wood': capacity,
|
|
||||||
'stone': capacity,
|
|
||||||
'iron': capacity,
|
|
||||||
'food': 0,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'great-granary',
|
|
||||||
name: 'Great Granary',
|
|
||||||
maxLevel: 20,
|
|
||||||
requiredTownhallLevel: 15,
|
|
||||||
cost: (level: number) => {
|
|
||||||
return {
|
|
||||||
wood: getStorageBuildingCost(level, 120),
|
|
||||||
stone: getStorageBuildingCost(level, 220),
|
|
||||||
iron: getStorageBuildingCost(level, 100),
|
|
||||||
food:getStorageBuildingCost(level, 60),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 2,
|
|
||||||
behavior: {
|
|
||||||
storage: (V: VillageState, self: BuildingType) => {
|
|
||||||
const x = self.level;
|
|
||||||
const capacity = ( ( ( x + ( x * x ) ) / 2 ) + 3 ) * 250;
|
|
||||||
return {
|
|
||||||
'wood': 0,
|
|
||||||
'stone': 0,
|
|
||||||
'iron': 0,
|
|
||||||
'food': capacity,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: 'university',
|
type: 'university',
|
||||||
name: 'University',
|
name: 'University',
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 5,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getUnitBuildingCost(level, 75),
|
wood: getUnitBuildingCost(level, 75),
|
||||||
@ -299,7 +237,6 @@ export default [
|
|||||||
type: 'barracks',
|
type: 'barracks',
|
||||||
name: 'Barracks',
|
name: 'Barracks',
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
requiredTownhallLevel: 3,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getUnitBuildingCost(level, 60),
|
wood: getUnitBuildingCost(level, 60),
|
||||||
@ -327,7 +264,6 @@ export default [
|
|||||||
name: 'Palace',
|
name: 'Palace',
|
||||||
maxLevel: 20,
|
maxLevel: 20,
|
||||||
unique: true,
|
unique: true,
|
||||||
requiredTownhallLevel: 10,
|
|
||||||
cost: (level: number) => {
|
cost: (level: number) => {
|
||||||
return {
|
return {
|
||||||
wood: getStorageBuildingCost(level, 200),
|
wood: getStorageBuildingCost(level, 200),
|
||||||
@ -353,35 +289,4 @@ export default [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
type: 'wonder',
|
|
||||||
name: 'World Wonder',
|
|
||||||
maxLevel: 1,
|
|
||||||
unique: true,
|
|
||||||
requiredTownhallLevel: 20,
|
|
||||||
cost: () => {
|
|
||||||
return {
|
|
||||||
wood: 42000,
|
|
||||||
stone: 42000,
|
|
||||||
iron: 42000,
|
|
||||||
food: 38000,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
timeToBuild: () => 120,
|
|
||||||
behavior: {
|
|
||||||
production: (V: VillageState, self: BuildingType) => {
|
|
||||||
const prod = getEmptyResources();
|
|
||||||
prod.food = self.level * -300;
|
|
||||||
return prod;
|
|
||||||
},
|
|
||||||
triggers: {
|
|
||||||
onLevelUp: (V: VillageState, self: BuildingType) => {
|
|
||||||
if (self.level === 1) {
|
|
||||||
// Gain a lot of culture.
|
|
||||||
V.resources.culture += 18000;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
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, getTownhall } from "../utils";
|
import { canPayBuildingCost } from "../utils";
|
||||||
import village from "../village";
|
import village, { type VillageState } from "../village";
|
||||||
import Cost from "./Cost.svelte";
|
import Cost from "./Cost.svelte";
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
@ -25,13 +25,11 @@
|
|||||||
$: constructible = buildings
|
$: constructible = buildings
|
||||||
.filter(b => !b.autoBuilt)
|
.filter(b => !b.autoBuilt)
|
||||||
.filter(b => !(b.unique && $village.buildings.some(b2 => b2.type === b.type)))
|
.filter(b => !(b.unique && $village.buildings.some(b2 => b2.type === b.type)))
|
||||||
.filter(b => !b.requiredTownhallLevel || getTownhall($village).level >= b.requiredTownhallLevel)
|
|
||||||
.map(b =>{
|
.map(b =>{
|
||||||
const building = createBuilding(b.type);
|
const building = createBuilding(b.type);
|
||||||
building.level = 0;
|
building.level = 0;
|
||||||
return building;
|
return building;
|
||||||
})
|
});
|
||||||
.sort((a, b) => a.requiredTownhallLevel - b.requiredTownhallLevel);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{ #if $showBuildingCreator !== null }
|
{ #if $showBuildingCreator !== null }
|
||||||
|
31
src/quests.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import type { QuestType, ResourcesType } from "./types";
|
||||||
|
import { getEmptyResources, random } from "./utils";
|
||||||
|
|
||||||
|
|
||||||
|
let uid = 0;
|
||||||
|
|
||||||
|
|
||||||
|
export function createQuest(level: number): QuestType {
|
||||||
|
const reward = getEmptyResources();
|
||||||
|
const adjustedLevel = level * level + 3;
|
||||||
|
const duration = random(adjustedLevel - 2, adjustedLevel + 2);
|
||||||
|
Object.keys(reward).forEach(r => {
|
||||||
|
const resource = r as keyof ResourcesType;
|
||||||
|
reward[resource] = random(
|
||||||
|
Math.round((duration * 5 - level * 10) * (1 + level / 3)),
|
||||||
|
Math.round((duration * 5 + level * 10) * (1 + level / 3)),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (resource === 'culture') {
|
||||||
|
reward[resource] = Math.round(reward[resource] / 20);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: uid++,
|
||||||
|
duration,
|
||||||
|
reward,
|
||||||
|
level,
|
||||||
|
started: false,
|
||||||
|
};
|
||||||
|
}
|
@ -26,7 +26,6 @@ export interface BuildingSource {
|
|||||||
autoBuilt?: boolean;
|
autoBuilt?: boolean;
|
||||||
unique?: boolean;
|
unique?: boolean;
|
||||||
maxLevel: number;
|
maxLevel: number;
|
||||||
requiredTownhallLevel: number;
|
|
||||||
cost: (level: number) => CostType;
|
cost: (level: number) => CostType;
|
||||||
timeToBuild: (level: number) => number;
|
timeToBuild: (level: number) => number;
|
||||||
behavior: {
|
behavior: {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { produce } from 'immer';
|
import { produce } from 'immer';
|
||||||
|
|
||||||
import { CULTURE_TO_WIN } from './constants';
|
import { CULTURE_TO_WIN } from './constants';
|
||||||
import { createQuest } from './create';
|
|
||||||
import { resolveMission } from './missions';
|
import { resolveMission } from './missions';
|
||||||
import type { ProductionType } from './types';
|
import type { ProductionType } from './types';
|
||||||
import { getProduction, getStorage, shuffle } from './utils';
|
import { getProduction, getStorage, shuffle } from './utils';
|
||||||
import village, { type VillageState } from "./village";
|
import village, { type VillageState } from "./village";
|
||||||
|
import { createQuest } from './quests';
|
||||||
|
|
||||||
|
|
||||||
let lastFrame: number;
|
let lastFrame: number;
|
||||||
|
@ -161,12 +161,3 @@ export function canPayBuildingCost(V: VillageState, building: BuildingType): boo
|
|||||||
|| cost.food > V.resources.food
|
|| cost.food > V.resources.food
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getTownhall(V: VillageState): BuildingType {
|
|
||||||
const townhall = V.buildings.find(b => b.type === 'townhall');
|
|
||||||
if (!townhall) {
|
|
||||||
throw new Error("Unable to find the Town hall");
|
|
||||||
}
|
|
||||||
return townhall;
|
|
||||||
}
|
|
||||||
|
@ -112,7 +112,6 @@ function getInitialState() {
|
|||||||
|
|
||||||
// Create the Town hall.
|
// Create the Town hall.
|
||||||
const townhall = createBuilding('townhall');
|
const townhall = createBuilding('townhall');
|
||||||
// townhall.level = 20;
|
|
||||||
state.villageTiles[0][0] = townhall.id;
|
state.villageTiles[0][0] = townhall.id;
|
||||||
state.buildings.push(townhall);
|
state.buildings.push(townhall);
|
||||||
|
|
||||||
@ -135,7 +134,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);
|
||||||
});
|
});
|
||||||
|