<?php

require_once __DIR__ . '/../../src/Events/MonthEndEvent.php';
require_once __DIR__ . '/../../src/Classes/Kobold.php';

class IncreaseConsumptionEvent extends MonthEndEvent
{
    public function getMinAge()
    {
        return 10;
    }

    public function getMinParticipants()
    {
        return 1;
    }

    public function getMaxParticipants()
    {
        return 1;
    }

    public function getCost()
    {
        return 85;
    }

    public function isAvailable()
    {
        return true;
    }

    public function execute()
    {
        $this->story = '';

        $eligible = array_filter($this->tribe->getAliveKobolds(), fn($k) => $k->getAge() >= $this->getMinAge());
        $eligible = array_values($eligible);

        if (empty($eligible)) {
            return;
        }

        $kobold = $eligible[array_rand($eligible)];

        $foodCost = rand(2, 5);
        $this->tribe->removeFood($foodCost);

        $nameA = $kobold->getName();

        $reasons = [
            'grew a significant appetite',
            'was always hungry',
            'had an insatiable appetite this month',
            'seemed particularly famished',
            'ate with vigor',
        ];

        $reason = $reasons[array_rand($reasons)];

        $variations = [
            "{$nameA} {$reason}, consuming more food than usual.",
            "This month, {$nameA} {$reason} and the food stores are diminished.",
            "{$nameA} {$reason}, putting extra strain on the tribe's resources.",
            "The tribe noticed {$nameA} {$reason}, draining more of their supplies.",
            "{$nameA} {$reason}, and the food situation became slightly more dire.",
        ];

        $this->story = $variations[array_rand($variations)];
    }
}
