<?php if (!defined('FLUX_ROOT')) exit; ?>

<div class="adjust">
<h2>Viewing Monster</h2>
<?php if ($monster): ?>

<?php foreach ($attribIDs as $attribID){?><?php } ?>


<table class="horizontal-table">
 <tr>
  <td colspan=6><h3><?php echo htmlspecialchars($monster->iro_name) ?>(<?php echo htmlspecialchars($monster->kro_name) ?>) Mob-ID#<?php echo htmlspecialchars($monster->monster_id)?></h3></td>
  <td colspan=2><h3>Location</h3></td>
  <td colspan=2><h3>Elements</h3></td>
 </tr>
 <tr>
  <td>HP</td>
  <td ><?php echo number_format($monster->hp) ?></td>
  <td colspan=4 rowspan=6 style="text-align:center";>
	<div style="width=200px;">
		<?php if ($image=$this->monsterImage($monster->monster_id)): ?>
			<img src="<?php echo $image ?>" />
		<?php endif ?>
	</div>		
  </td>
  <td colspan=2 rowspan=7 >


	<!-- MOB SPAWN -->
	<div style ="height: 160px; max-height: 160px; overflow: scroll";> 
	<?php if($mobSpawn !== false) { ?>
		
		<?php
		if (sizeof($mobSpawn)) {
			
			foreach ($mobSpawn as $spawn) { ?>
					<?php if($auth->actionAllowed('map', 'view')){ ?>
						<a href="<?= $this->url('map', 'view', array('map' => $spawn->map)) ?>"><?= $spawn->map ?>&nbsp;(<?= $spawn->count ?>)
					<?php } else { ?>
						<?= $spawn->map ?></td>(<?= $spawn->count ?>)

					<?php } ?>
					
					<br> <span style="color:green">
							<i>+&nbsp;<?= ceil($spawn->time_to / 60000) ?></i>min<?=
							($spawn->time_from ?
							' - <i>' . (ceil($spawn->time_to / 60000) + ceil($spawn->time_from / 60000)) . '</i>min' :
							'')
							?>
					</span>	
					<br>
			<?php }
		} else {
			echo 'Not found on any map. This monster might be:<br>
<ol>
 <li>not implemented yet</li>
 <li>used in quests, or</li>
 <li>summoned as slave by other monsters</li>
</ol>';
		}
	}
	?>
	</div>
	<!-- MOB SPAWN -->

</td>


	<td>Neutral</td>
	<?php if(($attribID->Neutral) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Neutral ?>%</td>
	<?php elseif(($attribID->Neutral) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Neutral ?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Neutral ?>%</td>
	<?php endif ?>



 </tr>
 <tr>
  <td>Level</td>
  <td><?php echo number_format($monster->level) ?></td>


	<td>Water</td>
	<?php if(($attribID->Water) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Water?>%</td>
	<?php elseif(($attribID->Water) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Water?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Water?>%</td>
	<?php endif ?>


 </tr>
 <tr'>
  <td>Race</td>
  <td>
			<?php if ($race=Flux::monsterRaceName($monster->race)): ?>
				<?php echo htmlspecialchars($race) ?>
			<?php else: ?>
				<span class="not-applicable">Unknown</span>
			<?php endif ?>
</td>

	<td>Earth</td>
	<?php if(($attribID->Earth) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Earth?>%</td>
	<?php elseif(($attribID->Earth) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Earth?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Earth?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Property</td>
  <td><?php echo Flux::elementName($monster->element_type) ?> (Lv <?php echo floor($monster->element_level) ?>)</td>

	<td>Fire</td>
	<?php if(($attribID->Fire) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Fire?>%</td>
	<?php elseif(($attribID->Fire) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Fire?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Fire?>%</td>
	<?php endif ?>

 </tr>
 <tr>
  <td >Size</td>
  <td>
			<?php if ($size=Flux::monsterSizeName($monster->size)): ?>
				<?php echo htmlspecialchars($size) ?>
			<?php else: ?>
				<span class="not-applicable">Unknown</span>
			<?php endif ?>

</td>

	<td>Wind</td>
	<?php if(($attribID->Wind) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Wind?>%</td>
	<?php elseif(($attribID->Wind) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Wind?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Wind?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Hit(100%)</td>
  <td>xx</td>

	<td>Poison</td>
	<?php if(($attribID->Poison) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Poison?>%</td>
	<?php elseif(($attribID->Poison) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Poison?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Poison?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Flee(95%)</td>
  <td>xx</td>
  <td colspan=2>Base Experience</td>
  <td colspan=2><?php echo number_format($monster->base_exp) ?></td>

	<td>Holy</td>
	<?php if(($attribID->Holy) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Holy?>%</td>
	<?php elseif(($attribID->Holy) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Holy?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Holy?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Walk Speed</td>
  <td><?php echo number_format($monster->speed) ?></td>
  <td colspan=2>Job Experience</td>
  <td colspan=2><?php echo number_format($monster->job_exp) ?></td>
  <td colspan=2>Mode</td>

	<td>Shadow</td>
	<?php if(($attribID->Shadow) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Shadow?>%</td>
	<?php elseif(($attribID->Shadow) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Shadow?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Shadow?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td >Atk Delay</td>
  <td><?php echo number_format($monster->attack_delay) ?> ms</td>
  <td colspan=2>MVP Experience</td>
  <td colspan=2><?php echo number_format($monster->mvp_exp) ?></td>
  <td colspan=2 rowspan=7>
	<?php foreach ($this->monsterMode($monster->mode) as $mode): ?>
	<li style="margin-left:15px;" ><?php echo htmlspecialchars($mode) ?></li>
	<?php endforeach ?>

</td>

	<td>Ghost</td>
	<?php if(($attribID->Ghost) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Ghost?>%</td>
	<?php elseif(($attribID->Ghost) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Ghost?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Ghost?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Attack</td>
  <td><?php echo number_format($monster->attack1) ?>~<?php echo number_format($monster->attack2) ?></td>
  <td colspan=2>Base Exp Per HP</td>
  <td colspan=2>xx</td>

	<td>Undead</td>
	<?php if(($attribID->Undead) < 100): ?>
		<td style="text-align:right;color:red;"><?php echo $attribID->Undead?>%</td>
	<?php elseif(($attribID->Undead) > 100): ?>
		<td style="text-align:right;color:green;"><?php echo $attribID->Undead?>%</td>
	<?php else: ?>
		<td style="text-align:right;"><?php echo $attribID->Undead?>%</td>
	<?php endif ?>


 </tr>
 <tr>
  <td>Def</td>
  <td><?php echo number_format($monster->defense) ?></td>
  <td colspan=2>Job Exp Per HP</td>
  <td colspan=2>xx</td>
<td></td><td></td>
 </tr>
 <tr>
  <td>Magic Def</td>
  <td><?php echo number_format($monster->magic_defense) ?></td>
  <td colspan=2>Delay After Hit</td>
  <td colspan=2><?php echo number_format($monster->attack_motion) ?> ms</td>
<td></td><td></td>
  </tr>
 <tr>
  <td>Atk Range</td>
  <td><?php echo number_format($monster->range1) ?> cell</td>
  <td>Str</td>
  <td><?php echo number_format((int)$monster->strength) ?></td>
  <td>Int</td>
  <td><?php echo number_format((int)$monster->intelligence) ?></td>
<td></td><td></td>
 </tr>
 <tr>
  <td>Spell Range</td>
  <td><?php echo number_format($monster->range2) ?> cell</td>
  <td>Agi</td>
  <td><?php echo number_format((int)$monster->agility) ?></td>
  <td>Dex</td>
  <td><?php echo number_format((int)$monster->dexterity) ?></td>
<td></td><td></td>
 </tr>
 <tr>
  <td>Sight Range</td>
  <td><?php echo number_format($monster->range3) ?> cell</td>
  <td>Vit</td>
  <td><?php echo number_format((int)$monster->vitality) ?></td>
  <td>Luk</td>
  <td><?php echo number_format((int)$monster->luck) ?></td>
<td></td><td></td>
 </tr>
<tr>
<td colspan=10 ><h3><?php echo htmlspecialchars($monster->iro_name) ?> Item Drops</h3></td>
</tr>
<?php if ($itemDrops): ?>
<tr>
	<td colspan=10>
	<?php foreach ($itemDrops as $itemDrop): ?>
	
			<?php if ($image=$this->iconImage($itemDrop['id'])): ?>
			<img src="<?php echo $image ?>" />
			<?php echo $this->linkToItem($itemDrop['id'], $itemDrop['name']) ?>
			<?php if ($itemDrop['type'] == 'mvp'): ?>
				<span class="mvp">MVP!</span>
			<?php endif ?>
				( <?php echo (float)$itemDrop['chance'] ?>% )
			<?php endif ?>
	

	

	<?php endforeach ?>
	</td>
</tr>
<?php else: ?>
<p>No item drops found for <?php echo htmlspecialchars($monster->iro_name) ?>.</p>
<?php endif ?>
</table>

<?php else: ?>
<p>No such monster was found. <a href="javascript:history.go(-1)">Go back</a>.</p>
<?php endif ?>
</div>

