<?php
    /**
     * Home view.
     *
     * Contains the view layout and some code to present the data.
     *
     * @category View
     * @property_read Home_Page $page The page model.
     */

    namespace swdb;
?>
<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
        <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
        <title><?=$page->title?></title>
        <link rel='shortcut icon' href='<?=$page->favicon?>'/>
        <!-- CSS files -->
        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
        <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>home.css'/>
        <!-- Meta tags -->
        <link rel='canonical' href='<?=$page->canonical?>'/>
        <link rel='author' href='<?=$page->author?>'/>
        <link rel='publisher' href='<?=$page->author?>'/>
        <meta name='description' content='<?=$page->description?>'/>
        <meta property='og:title' content='<?=$page->title?>'/>
        <meta property='og:url' content='<?=$page->canonical?>'/>
        <meta property='og:description' content='<?=$page->description?>'/>
        <meta property='og:image' content='<?=$page->icon?>'/>
        <meta property='og:site_name' content='<?=$page->name?>'/>
        <meta property='og:type' content='website'/>
        <meta property='og:locale' content='en'/>
        <meta name='twitter:card' content='summary'/>
        <meta name='twitter:title' content='<?=$page->title?>'/>
        <meta name='twitter:description' content='<?=$page->description?>'/>
        <meta name='twitter:image' content='<?=$page->icon?>'/>
        <meta name='twitter:url' content='<?=$page->canonical?>'/>
        <meta name='robots' content='index follow'/>
    </head>
    <body>
<?php
        include __DIR__ . "/inc/header.php";
?>
        <section class='content'>
            <h2>
                <span>
                    Summoners War DataBase
                </span>
            </h2>
            <article id='profile'>
                <h3>
                    <span id='user_name'>
                        <?=$page->name?>
                    </span>
                    <span id='user_level'>
                        Lv. <?=$page->level?>
                        <span id='user_exp'>
                            (exp: <?=$page->experience?>)
                        </span>
                    </span>
                </h3>
<?php
                if (isset($page->rep)){
?>
                    <div id='rep' class='profile_section'>
                        <h4>
                            Rep. Monster
                        </h4>
                        <div class='monster_panel'>
                            <?=HTML::unit_panel($page->rep)?>
                        </div> <!-- .monster_panel -->
                    </div>
<?php
                } // if (isset($page->rep))
?>
                <div id='defense' class='profile_section'>
                    <h4>
                        Arena defense
                    </h4>
<?php
                    $first = true;
                    foreach ($page->defense as $defense){
?>
                        <div class='monster_panel'>
                            <?=HTML::unit_panel($defense)?>
                        </div>
<?php
                        if ($first && isset($defense->unit->leader_skill) && ($defense->unit->leader_skill->area == $EFFECT_AREA["GENERAL"] || $defense->unit->leader_skill->area == $EFFECT_AREA["ARENA"])){
?>
                            <div class='skill'>
                                <img class='skill_img' title='<?=$defense->unit->leader_skill->create_description()?>' src='<?=$defense->unit->leader_skill->get_image()?>'/>
                            </div>
<?php
                        }
                        $first = false;
                    }
?>
                </div>
                <div id='building' class='profile_section'>
                    <h4>
                        Buildings
                    </h4>
<?php
                    $half = sizeof($page->building) / 2;
                    $i = 0;
                    foreach ($page->building as $building){
                        if ($i == $half){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::building_panel($building)?>
<?php
                        $i ++;
                    }$i ++;
?>
                </div>
                <div id='decoration' class='profile_section'>
                    <h4>
                        Decorations
                    </h4>
<?php
                    $half = sizeof($page->decoration) / 2;
                    $i = 0;
                    foreach ($page->decoration as $decoration){
                        if ($i == $half){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::building_panel($decoration)?>
<?php
                        $i ++;
                    }
?>
                </div>
                <div class='inventory profile_section' id='inventory_scroll'>
                    <h4>
                        Scrolls
                    </h4>
<?php
                    $half = sizeof($page->building) / 2;
                    $i = 0;
                    foreach ($page->inventory_scroll as $item){
                        if ($half > 6 && $i == $half){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::item_panel($item)?>
<?php
                        $i ++;
                    }
?>
                </div>
                <div class='inventory profile_section' id='inventory_craft_rune'>
                    <h4>
                        Rune crafting items
                    </h4>
<?php
                    $prev = 0;
                    foreach ($page->inventory_craft_rune as $item){
                        if ($prev != 0 && $prev + 2000 < $item->id){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::item_panel($item)?>
<?php
                        $prev = $item->id;
                    }
?>
                </div>
                <div class='inventory profile_section' id='inventory_craft'>
                    <h4>
                        Other crafting items
                    </h4>
<?php
                    $prev = 0;
                    foreach ($page->inventory_craft as $item){
                        if ($prev != 0 && $prev < 5000 && $item->id > 5000){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::item_panel($item)?>
<?php
                        $prev = $item->id;
                    }
?>
                </div>
                <div class='inventory profile_section' id='inventory_essence'>
                    <h4>
                        Essences
                    </h4>
<?php
                    $prev = "";
                    foreach ($page->inventory_essence as $item){
                        if ($prev != "" && $prev != preg_split('/\s+/', $item->name)[2]){
?>
                            <br class='desktop'/>
<?php
                        }
?>
                        <?=HTML::item_panel($item)?>
<?php
                        $prev = preg_split('/\s+/', $item->name)[2];
                    }
?>
                </div>
                <div id='currency' class='profile_section'>
                    <h4>
                        Currency
                    </h4>
                    <ul>
                        <li>
                            <img title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
                            <?=$page->currency["energy"]?> / <?=$page->currency["energy_max"]?>
                        </li>
                        <li>
                            <img title='Arena Invitations' src='<?=URL::IMG["CURRENCY"]?>arenaenergy.png'/>
                            <?=$page->currency["arena_energy"]?> / <?=$page->currency["arena_energy_max"]?>
                        </li>
                        <li>
                            <img title='Dimensional Energy' src='<?=URL::IMG["CURRENCY"]?>dimensionenergy.png'/>
                            <?=$page->currency["dimension_energy"]?> / <?=$page->currency["dimension_energy_max"]?>
                        </li>
                        <li>
                            <img title='Dimensional Crystal' src='<?=URL::IMG["CURRENCY"]?>darkportalenergy.png'/>
                            <?=$page->currency["darkportal_energy"]?> / <?=$page->currency["darkportal_energy_max"]?>
                        </li>
                        <li>
                            <img title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
                            <?=$page->currency["mana"]?>
                        </li>
                        <li>
                            <img title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
                            <?=$page->currency["crystal"]?>
                        </li>
                        <li>
                            <img title='Social Points' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
                            <?=$page->currency["social_point"]?>
                        </li>
                        <li>
                            <img title='Honor Points' src='<?=URL::IMG["CURRENCY"]?>honor.png'/>
                            <?=$page->currency["honor_point"]?>
                        </li>
                        <li>
                            <img title='Guild Points' src='<?=URL::IMG["CURRENCY"]?>guildpoint.png'/>
                            <?=$page->currency["guild_point"]?>
                        </li>
                        <li>
                            <img title='Honor Medals' src='<?=URL::IMG["CURRENCY"]?>badge.png'/>
                            <?=$page->currency["honor_medal"]?>
                        </li>
                        <li>
                            <img src='<?=URL::IMG["CURRENCY"]?>mark.png'/>
                            <?=$page->currency["honor_mark"]?>
                        </li>
                        <li>
                            <img title='Ancient Coins' src='<?=URL::IMG["CURRENCY"]?>ancientcoin.png'/>
                            <?=$page->currency["event_coin"]?>
                        </li>
                        <li>
                            <img title='Ancient Crystal' src='<?=URL::IMG["CURRENCY"]?>ancientstone.png'/>
                            <?=$page->currency["ancient_stone"]?>
                        </li>
                        <li>
                            <img title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
                            <?=$page->currency["costume_point"]?>
                        </li>
                    </ul>
                </div>
            </article>
        </section>
<?php
        include __DIR__ . "/inc/footer.php";
?>
    </body>
</html>

