<?php
$rankingResets = amwdeveloper()->table("Character")->columns("Imagem as avatar,Name as name,ResetCount as score,cLevel as level,Class as class,Strength as strength, Dexterity as dexterity,Energy as energy,Vitality as vitality,Leadership as command")->limit(5)->orderby("ResetCount")->all();
?>
<div class="rankings blockHome">
    <div class="h2-title h2-title-table flex-s-c">
        <span>Resets Total</span>
    </div><!--h2-title-->
    <div class="table tabTable-block active" id="players">
        <div class="tableBlock">
            <div class="tableBlock-title">
                <div class="tableBlock-title_player">Player</div>
                <div class="tableBlock-title_level">Level <sup>ML</sup></div>
                <div class="tableBlock-title_score">Score</div>
            </div>
            <?php $cont = 0;
            foreach ($rankingResets as $rank) : $cont++;
                $masterLevel = amwdeveloper()->table("MasterSkillTree")->columns("MasterLevel as ml")->where("Name = :n", "n={$rank->name}")->get();
                $classColor = "";
                if ($cont <= 3) $classColor = "color-purple";
                elseif ($cont <= 6) $classColor = "color-blue";
                elseif ($cont <= 9) $classColor = "color-green";
                else $classColor = "color-yellow";
            ?>
                <div class="tableBlock-content">
                    <div class="tableBlock-conten_number"><?= $cont ?></div>
                    <div class="tableBlock-conten_name">
                        <img src="<?= __files('images/classes/' . characters['classes'][$rank->class]['short_name'] . '.png') ?>" alt="">
                        <a href="<?= __redirect("preview/char/{$rank->name}") ?>"><?= $rank->name ?>
                            <div class="tablePopup">
                                <span class="tablePopup-title"><?= $rank->name ?></span>
                                <div class="tablePopup-ava"><img src="<?= __files('images/classes/' . characters['classes'][$rank->class]['short_name'] . '.png') ?>" alt=""></div>
                                <div class="tablePopup-block">
                                    <span>Class:</span> <span><?= characters['classes'][$rank->class]['name'] ?></span>
                                </div>
                                <div class="tablePopup-block">
                                    <span>Master Level:</span> <span><?= $masterLevel->ml ?? 0 ?></span>
                                </div>
                                <div class="tablePopup-block">
                                    <span>Strength:</span> <span><?= $rank->strength ?></span>
                                </div>
                                <div class="tablePopup-block">
                                    <span>Dexterity:</span> <span><?= $rank->dexterity ?></span>
                                </div>
                                <div class="tablePopup-block">
                                    <span>Vitality:</span> <span><?= $rank->vitality ?></span>
                                </div>
                                <div class="tablePopup-block">
                                    <span>Energy:</span> <span><?= $rank->energy ?></span>
                                </div>
                                <?php if (characters['classes'][$rank->class]['short_name'] == "DL" or characters['classes'][$rank->class]['short_name'] == "LE") : ?>
                                    <div class="tablePopup-block">
                                        <span>Command:</span> <span><?= $rank->command ?></span>
                                    </div>
                                <?php endif; ?>
                            </div>

                        </a>
                    </div>
                    <div class="tableBlock-conten_lvl"><span class="<?= $classColor ?>"><?= $rank->level ?> <sup><?= $masterLevel->ml ?? 0 ?></sup></span></div>
                    <div class="tableBlock-conten_scr"><?= $rank->score ?></div>
                </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>