<commit_before><?php

namespace OpenDominion\Services\Dominion\Actions;

use OpenDominion\Exceptions\GameException;
use OpenDominion\Models\Dominion;
use OpenDominion\Services\Dominion\HistoryService;
use OpenDominion\Traits\DominionGuardsTrait;

class DailyBonusesActionService
{
    use DominionGuardsTrait;

    /**
     * Claims the daily platinum bonus for a Dominion.
     *
     * @param Dominion $dominion
     * @return array
     * @throws GameException
     */
    public function claimPlatinum(Dominion $dominion): array
    {
        $this->guardLockedDominion($dominion);

        if ($dominion->daily_platinum) {
            throw new GameException('You already claimed your platinum bonus for today.');
        }

        $platinumGained = $dominion->peasants * 4;
        $dominion->resource_platinum += $platinumGained;
        $dominion->daily_platinum = true;
        $dominion->save(['event' => HistoryService::EVENT_ACTION_DAILY_BONUS]);

        return [
            'message' => sprintf(
                'You gain %s platinum.',
                number_format($platinumGained)
            ),
            'data' => [
                'platinumGained' => $platinumGained,
            ],
        ];
    }

    /**
     * Claims the daily land bonus for a Dominion.
     *
     * @param Dominion $dominion
     * @return array
     * @throws GameException
     */
    public function claimLand(Dominion $dominion): array
    {
        $this->guardLockedDominion($dominion);

        if ($dominion->daily_land) {
            throw new GameException('You already claimed your land bonus for today.');
        }

        $landGained = 20;
        $researchPointsGained = 128;
        $attribute = ('land_' . $dominion->race->home_land_type);
        $dominion->{$attribute} += $landGained;
        $dominion->stat_total_land_explored += $landGained;
        $dominion->resource_tech += $researchPointsGained;<commit_msg>fix for daily land bonus not increasing tech cost<commit_after><?php

namespace OpenDominion\Services\Dominion\Actions;

use OpenDominion\Calculators\Dominion\LandCalculator;
use OpenDominion\Exceptions\GameException;
use OpenDominion\Models\Dominion;
use OpenDominion\Services\Dominion\HistoryService;
use OpenDominion\Traits\DominionGuardsTrait;

class DailyBonusesActionService
{
    use DominionGuardsTrait;

    /**
     * Claims the daily platinum bonus for a Dominion.
     *
     * @param Dominion $dominion
     * @return array
     * @throws GameException
     */
    public function claimPlatinum(Dominion $dominion): array
    {
        $this->guardLockedDominion($dominion);

        if ($dominion->daily_platinum) {
            throw new GameException('You already claimed your platinum bonus for today.');
        }

        $platinumGained = $dominion->peasants * 4;
        $dominion->resource_platinum += $platinumGained;
        $dominion->daily_platinum = true;
        $dominion->save(['event' => HistoryService::EVENT_ACTION_DAILY_BONUS]);

        return [
            'message' => sprintf(
                'You gain %s platinum.',
                number_format($platinumGained)
            ),
            'data' => [
                'platinumGained' => $platinumGained,
            ],
        ];
    }

    /**
     * Claims the daily land bonus for a Dominion.
     *
     * @param Dominion $dominion
     * @return array
     * @throws GameException
     */
    public function claimLand(Dominion $dominion): array
    {
        $this->guardLockedDominion($dominion);

        if ($dominion->daily_land) {
            throw new GameException('You already claimed your land bonus for today.');
        }

        $landGained = 20;
        $researchPointsGained = 128;

        $landCalculator = app(LandCalculator::class);
        $landTotal = $landCalculator->getTotalLand($dominion);
        $dominion->highest_land_achieved = max($dominion->highest_land_achieved, $landTotal + $landGained);

        $attribute = ('land_' . $dominion->race->home_land_type);
        $dominion->{$attribute} += $landGained;

        $dominion->stat_total_land_explored += $landGained;
        $dominion->resource_tech += $researchPointsGained;
{'fraction_non_alphanumeric': 0.109360076408787, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 2.5864726027397262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3225424', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1217, 'n_words': 245}