Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runProduction($t) //$time/ticks
- {
- //run the cycles that are output only
- $this->runOutputCycles($t);
- //go over all the province buildings
- foreach ($this->buildings->getBuildings() as $building)
- {
- //if we have a cycle
- if(isset($this->cycles->ageCycles[$building->name]))
- {
- $building_cycles = $this->cycles->ageCycles[$building->name];
- foreach($building_cycles as $single_cycle)
- {
- $in = (isset($single_cycle['in']) AND !empty($single_cycle['in'])) ? $single_cycle['in'] : array();
- $out = isset($single_cycle['out']) ? $single_cycle['out'] : array() ;
- if(count($in) == 0)
- continue; //skip if there's no input, we've already done the pure output ones
- $stop_cycle = false;
- foreach($in as $cycle_resource)
- {
- $resourceAmount = $this->run_cycle($building,$cycle_resource,$t);
- if($this->resources->hasEnough($cycle_resource->resourceID,$resourceAmount))
- {
- $this->resources->spend($cycle_resource->resourceID,$resourceAmount);
- }
- else
- {
- $stop_cycle = true;
- break;
- }
- }
- if(!$stop_cycle)
- foreach($out as $cycle_resource)
- {
- $resourceAmount = $this->run_cycle($building,$cycle_resource,$t);
- $this->resources->gather($cycle_resource->resourceID,$resourceAmount);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement