<?php
    /**
     * Monster Info Page view.
     *
     * Contains the view layout and ome code to present the data.
     *
     * @category View
     * @property_read Monster_Info_Page The page model.
     */
?>
<!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?>monster_info.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";
        for ($i = 0; $i < 3; $i ++){
            if ($page->monster[$i] != null){
?>
                <section class='content'>
                    <h2>
                        <?=$page->monster[$i]->title?>
                    </h2>
                    <article class='stage'>
                        <div class='profile'>
                            <div class='monster_panel'>
                                <?=HTML::unit_panel($page->monster[$i])?>
                            </div>
                            <?=HTML::unit_transformation_panel($page->monster[$i])?>
                        </div>
                        <table class='stats'>
                            <tr>
                                <th>
                                    Type
                                </th>
                                <th>
                                    <?=$page->monster[$i]->archetype_name?>
                                </th>
                            </tr>
                            <tr>
                                <th>
                                    ATK
                                </th>
                                <td>
                                    <?=$page->monster[$i]->attack?>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    DEF
                                </th>
                                <td>
                                    <?=$page->monster[$i]->defense?>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    HP
                                </th>
                                <td>
                                    <?=$page->monster[$i]->hp?>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    SPD
                                </th>
                                <td>
                                    <?=$page->monster[$i]->speed?>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    CRR
                                </th>
                                <td>
                                    <?=$page->monster[$i]->crit_rate?>%
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    CRD
                                </th>
                                <td>
                                    <?=$page->monster[$i]->crit_damage?>%
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    ACC
                                </th>
                                <td>
                                    <?=$page->monster[$i]->accuracy?>%
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    RES
                                </th>
                                <td>
                                    <?=$page->monster[$i]->resistance?>%
                                </td>
                            </tr>
                        </table>
                        <div class='extra'>
<?php
                            if (count($page->monster[$i]->sources) > 0){
?>
                                <!-- TODO NOT WORKING<div class='sources'>
                                    <span>
                                        Obtainable from:
                                    </span>
<?php
                                    foreach ($page->monster[$i]->sources as $source){
?>
                                        <img title='<?=$source->name?>' class='source' src='<?=$source->get_image()?>' />
<?php
                                    }
?>
                                </div>-->
<?php
                            }
                            if (count($page->monster[$i]->essences) > 0){
?>
                                <div class='essences'>
                                    <span>
                                        Awake with:
                                    </span>
<?php
                                    foreach ($page->monster[$i]->essences as $essence){
?>
                                       <div class='essence border_<?=$essence["element"]?>'>
                                            <img alt='<?=$essence["grade"]?> <?=$essence["element"]?> essence' title='<?=$essence["amount"]?>x <?=$essence["grade"]?> <?=$essence["element"]?> essence' class='essence' src='<?=URL::IMG["ESSENCE"]?><?=$essence["element"]?>_<?=$essence["grade"]?>.png'/>
                                            <span>
                                                <?=$essence["amount"]?>
                                            </span>
                                        </div>
<?php
                                    }
?>
                                </div>
<?php
                            }
?>
                        </div> <!-- .extra -->
                        <table class='skills'>
                            <tr>
<?php
                                $colspan = sizeof($page->monster[$i]->skill);
                                if ($page->monster[$i]->leader_skill){
                                    $colspan ++;
                                }
?>
                                <th colspan='<?=$colspan?>'>
                                    Skills
                                </th>
                            </tr>
                            <tr>
<?php
                                if ($page->monster[$i]->leader_skill){
?>
                                    <td class='skill'>
                                        <img class='skill_img' src='<?=$page->monster[$i]->leader_skill->get_image()?>'/>
                                        <span class='skill_level'>
                                            &nbsp;
                                        </span>
                                        <span class='skill_name'>
                                            Leader skill
                                        </span>
                                        <span class='skill_description'>
                                            <?=$page->monster[$i]->leader_skill->create_description()?>
                                        </span>
                                    </td>
<?php
                                }
                                foreach ($page->monster[$i]->skill as $skill){
?>
                                    <td class='skill'>
                                        <img class='skill_img' src='<?=$skill->get_image()?>'/>
                                        <span class='skill_name'>
                                            <?=$skill->name?>
                                        </span>
                                        <span class='skill_description'>
                                            <?=$skill->description?>
                                        </span>
<?php
                                        if (strlen($skill->multiplier_formula) > 0){
?>
                                            <span class='skill_formula'>
                                                <?=$skill->multiplier_formula?>
                                            </span>
<?php
                                        }
                                        if (count($skill->effect) > 0){
?>
                                            <span class='skill_effects'>
<?php
                                                foreach ($skill->effect as $effect){
?>
                                                    <img class='effect_img' title='<?=$effect->name?>' src='<?=$effect->get_image()?>'/>
<?php
                                                }
?>
                                            </span>
<?php
                                        }
                                        if ($skill->max_level > 1){
?>
                                            <table class='skill_up'>
<?php
                                                foreach ($skill->level as $level){
                                                    if ($level->level > 1){
?>
                                                        <tr>
                                                            <td class='level'>
                                                                Lv. <?=$level->level?>
                                                            </td>
                                                            <td class='description'>
                                                                <?=$level->description?>
                                                            </td>
                                                        </tr>
<?php
                                                    }
                                                }
?>
                                            </table>
<?php
                                        }
?>
                                    </td>
<?php
                                }
?>
                            </tr>
                        </table> <!-- #skills -->
<?php
                        if ($page->monster[$i]->transformation != null){
?>
                            <table class='skills'>
                                <tr>
<?php
                                    $colspan = sizeof($page->monster[$i]->skill);
                                    if ($page->monster[$i]->leader_skill){
                                        $colspan ++;
                                    }
?>
                                    <th colspan='<?=$colspan?>'>
                                        Skills (transformation)
                                    </th>
                                </tr>
                                <tr>
<?php
                                    if ($page->monster[$i]->leader_skill){
?>
                                        <td class='skill'>
                                            <img class='skill_img' src='<?=$page->monster[$i]->leader_skill->get_image()?>'/>
                                            <span class='skill_level'>
                                                &nbsp;
                                            </span>
                                            <span class='skill_name'>
                                                Leader skill
                                            </span>
                                            <span class='skill_description'>
                                                <?=$page->monster[$i]->leader_skill->create_description()?>
                                            </span>
                                        </td>
<?php
                                    }
                                    foreach ($page->monster[$i]->transformation->skill as $skill){
?>
                                        <td class='skill'>
                                            <img class='skill_img' src='<?=$skill->get_image()?>'/>
                                            <span class='skill_name'>
                                                <?=$skill->name?>
                                            </span>
                                            <span class='skill_description'>
                                                <?=$skill->description?>
                                            </span>
<?php
                                            if (strlen($skill->multiplier_formula) > 0){
?>
                                                <span class='skill_formula'>
                                                    <?=$skill->multiplier_formula?>
                                                </span>
<?php
                                            }
                                            if (count($skill->effect) > 0){
?>
                                                <span class='skill_effects'>
<?php
                                                    foreach ($skill->effect as $effect){
?>
                                                        <img class='effect_img' title='<?=$effect->name?>' src='<?=$effect->get_image()?>'/>
<?php
                                                    }
?>
                                                </span>
<?php
                                            }
                                            if ($skill->max_level > 1){
?>
                                                <table class='skill_up'>
<?php
                                                    foreach ($skill->level as $level){
                                                        if ($level->level > 1){
?>
                                                            <tr>
                                                                <td class='level'>
                                                                    Lv. <?=$level->level?>
                                                                </td>
                                                                <td class='description'>
                                                                    <?=$level->description?>
                                                                </td>
                                                            </tr>
<?php
                                                        }
                                                    }
?>
                                                </table>
<?php
                                            }
?>
                                        </td>
<?php
                                    }
?>
                                </tr>
                            </table> <!-- #transformation_skills -->
<?php
                        }
?>

                    </article>
                </section>
<?php
            } // if ($page->monster[$i] != null)
        } // for (int $i = 0; $i < 3; $i ++)
        include __DIR__ . "/inc/footer.php";
?>
    </body>
</html>

