<?= $this->layout('_layout', ['title' => $title]); ?>

<main class="main">
    <?= $this->insert('includes/aside_info') ?>

    <div class="content">
        <div class="h2-title h2-title-content flex-s-c">
            <span>All Characters market</span>
        </div>


        <div>
            <ul class="flex-c-c gap-10">
                <?php foreach (characters['classes'] as $class) : ?>
                    <li>
                        <a href="<?= __redirect("market/view/characters/class/{$class['short_name']}") ?>" class="button"> <?= $class['name'] ?></a>
                    </li>
                <?php endforeach; ?>
            </ul>
            <?php if (plugin()->market) : ?>
                <?php if ($items) :  ?>
                    <br>
                    <br>
                    <div class="flex-c-c gap-10 my-characters-market">
                        <?php foreach ($items as $item) :
                        ?>
                            <div class="details-character">
                                <p class="name"><?= $item->name ?></p>
                                <div>
                                    <img src="<?= __avatar(json_decode($item->description)->avatar) ?>" alt="" class="w-24 h-24 object-contain">
                                </div>
                                <div class="flex-c-c gap-5">
                                    <div class="information">
                                        <p class="info">Strength: <span><?= json_decode($item->description)->strength ?></span></p>
                                        <p class="info">Dexterity: <span><?= json_decode($item->description)->dexterity ?></span></p>
                                        <p class="info">Vitality: <span><?= json_decode($item->description)->vitality ?></span></p>
                                        <p class="info">Energy: <span><?= json_decode($item->description)->energy ?></span></p>
                                    </div>
                                    <div class="information">
                                        <p class="info">Resets: <span><?= json_decode($item->description)->resets ?></span></p>
                                        <p class="info">MResets: <span><?= json_decode($item->description)->mresets ?></span></p>
                                        <p class="info">Kills: <span><?= json_decode($item->description)->killer ?></span></p>
                                        <p class="info">Hero: <span><?= json_decode($item->description)->hero ?></span></p>
                                    </div>
                                </div>
                                <p class="price"><?= $item->price ?> <?= market['coin_name'] ?></p>
                                <div>
                                    <a class="button" href="<?= __redirect("market/view/character/{$item->name}/details") ?>">+ Details</a>
                                </div>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php else : ?>
                    <div class="warning">There are no characters on the market at the moment</div>
                <?php endif; ?>
            <?php else : ?>
                <div class="warning">Function disabled by administration</div>
            <?php endif; ?>
        </div>

    </div>
</main>