Add basic functionality of raising mining rate
This commit is contained in:
parent
14f399659e
commit
8b5eef482f
|
@ -65,7 +65,7 @@ export default class SystemResourceManager extends ResourceManager {
|
||||||
id: resource.id,
|
id: resource.id,
|
||||||
amount: resource.amount,
|
amount: resource.amount,
|
||||||
lastUpdated: null,
|
lastUpdated: null,
|
||||||
perHourMiningRate: null,
|
perHourMiningRate: 0,
|
||||||
data: resFromDB
|
data: resFromDB
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ export type Resource = {
|
||||||
id: string,
|
id: string,
|
||||||
amount: number,
|
amount: number,
|
||||||
lastUpdated: Date | null,
|
lastUpdated: Date | null,
|
||||||
perHourMiningRate: number | null,
|
perHourMiningRate: number,
|
||||||
data: DBResource
|
data: DBResource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,22 @@ export const POST: APIRoute = async({ request }) => {
|
||||||
|
|
||||||
userPlanet.resources.setAmount(resourcesAfter.map(res => { return { id: res.id, amount: res.amount } }));
|
userPlanet.resources.setAmount(resourcesAfter.map(res => { return { id: res.id, amount: res.amount } }));
|
||||||
userPlanet.buildings.addBuilding(building);
|
userPlanet.buildings.addBuilding(building);
|
||||||
|
if(building.data.category === "mines") {
|
||||||
|
switch(building.data.id) {
|
||||||
|
case 'coal-mine':
|
||||||
|
const coalResource = userPlanet.resources.resources.find(r => r.id === "coal");
|
||||||
|
if(coalResource) coalResource.perHourMiningRate += 10;
|
||||||
|
break;
|
||||||
|
case 'iron-mine':
|
||||||
|
const ironResource = userPlanet.resources.resources.find(r => r.id === "iron");
|
||||||
|
if(ironResource) ironResource.perHourMiningRate += 10;
|
||||||
|
break;
|
||||||
|
case 'gold-mine':
|
||||||
|
const goldResource = userPlanet.resources.resources.find(r => r.id === "gold");
|
||||||
|
if(goldResource) goldResource.perHourMiningRate += 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await userPlanet.buildings.sync();
|
await userPlanet.buildings.sync();
|
||||||
await userPlanet.resources.sync();
|
await userPlanet.resources.sync();
|
||||||
|
|
Loading…
Reference in New Issue