import { UIObtainedResourcesPipe } from "../UIPipes/UIPipes";

const period = 1;
let currentPeriod = 0;
const goldForBuilding = 0.35;
export let buildingsCount = 0;
export function incBuildingCount(x) {
    buildingsCount += x;
    UIObtainedResourcesPipe.update((s)=>{
        s.score += 100 + (Math.floor(buildingsCount / 10) * (buildingsCount * goldForBuilding * 10));
    });
};
export function handleBuildingsIncome(tick) {
    currentPeriod += tick.deltaMS / 1000;
    if(currentPeriod > period)
    {
        currentPeriod = 0;
        let r = buildingsCount * goldForBuilding + (Math.floor(buildingsCount / 10) * (buildingsCount * goldForBuilding));
        UIObtainedResourcesPipe.update((s)=>{
            s.gold += r;
            s.goldPerSec = r;
        });
    }
};