<?php

use Kirby\Cms\Page;

require_once __DIR__ . '/helpers.php';

class CharacterPage extends Page
{

    public function update(array|null $input = null, string|null $languageCode = null, bool $validate = false): static
    {
        $textContent = '';

        if (!empty($input['description'])) {
            $textContent .= writerToPlainText($input['description']) . "\n\n";
        }

        if (!empty($input['traits'])) {
            $textContent .= 'Traits: ' . writerToPlainText($input['traits']) . "\n\n";
        }

        $input['text_content'] = trim($textContent);

        return parent::update($input, $languageCode, $validate);
    }
}
