Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <!doctype html>
  2. <?php
  3.     $classColors = array (
  4.                 'Wizard' => 'blue',
  5.                 'Warrior' => 'brown'
  6.                       );
  7.                      
  8.     function getClass($qClass)
  9.     {
  10.         global $classColors;
  11.         foreach($classColors as $class => $color)
  12.         {
  13.             if($qClass == $class)
  14.             {
  15.                 return($color);
  16.             }
  17.         }
  18.     }
  19.    
  20.     function getRoll()
  21.     {
  22.      global $turn;
  23.      $pRoll = rand(1 , 10);
  24.      $npcRoll = rand(1 , 10);
  25.      if($npcRoll > $pRoll)
  26.      {
  27.       $turn = 0;
  28.      }
  29.      elseif($pRoll > $npcRoll)
  30.      {
  31.       $turn = 1;
  32.      }
  33.      else{
  34.       $turn = rand(0 , 1);
  35.      }
  36.     }
  37.    
  38.     function checkHealth()
  39.     {
  40.      global $npcHealth, $pHealth;
  41.      if($pHealth < 1)
  42.      {
  43.       print("$pName has been DEFEATED!");
  44.      }
  45.      elseif($npcHealth < 1)
  46.      {
  47.       return(true);
  48.      }
  49.      else
  50.      {
  51.       return("You Dumb Kid!");
  52.      }
  53.     }
  54.    
  55.     $turn = NULL;
  56.    
  57.     $pName = 'Ecko';
  58.     $pClass = 'Wizard';
  59.     $pHealth = 30;
  60.    
  61.     $npcName = 'Orcish Brute';
  62.     $npcClass = 'Warrior';
  63.     $npcHealth = 30;
  64.    
  65.     $getColor = getClass($pClass);
  66.  $roll = getRoll();
  67.    
  68. ?>
  69. <html>
  70.     <head>
  71.         <title></title>
  72.        
  73.     </head>
  74.     <body>
  75.         <font color="<?php print($getColor) ?>"><?php print($pName) ?></font>
  76.     </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement