mutate($user, $villageId, function (Simulation $sim, Village $village, CarbonImmutable $now) use ($buildingId) { $building = $this->building($village, $buildingId); $offer = $sim->upgradeOffer($building) ?? throw new GameRuleViolation('max_level', 'Already at max level.'); $sim->pay($offer['cost']); $sim->enqueue([ 'building_id' => $building->id, 'type' => $building->type, 'action' => BuildOrder::UPGRADE, 'target_level' => $offer['target_level'], 'x' => $building->x, 'y' => $building->y, 'cost' => $offer['cost'], ], $now); }); } }