Scripts

RuneScape II Combat Calculator

UPDATE: v2 Een PHP Script dat het combat lvl aan de hand van je RuneScape levels uitrekend... inclusief form. De combat formule is gemaakt door Covey van Sythe.org. Changelog: v2: *Herscript in een class (ruimte open voor uitbreiding)... *Selecteerd automatisch type account... *Kan afronden naar beneden, afronden op 2 decimalen of niet afronden... *Valid XHTML Transitional... *Valid CSS... *Geen errors op error_reporting(E_ALL); ...

runescape-ii-combat-calculator
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RuneScape II Combat Calculator</title>
<!--
Valid XHTML 1.0 Transitional/CSS
Script by YPM Design - http://ypm-design.com
Combat Formula by Covey (Sythe.org) - http://sythe.org
License: GNU: General Public License (GPL)
-->
<style type="text/css">
body {
	background-image: url();
	background-repeat: no-repeat;
	background-color: #000000;
}
.style2 {color: #FF0000}
.buttons2
{
	vertical-align: middle;
	margin: 5px;
	border: 1px solid #ffffff;
	background: url(http://teampk.ypm-design.com/images/form.jpg) #333333;
	font-size: 10pt; color:#FFFFFF;
	height: 20px;
	width: 125px;
	text-align: inherit;
}
.lvl { border: 1px solid #ffffff;
		background: url(http://teampk.ypm-design.com/images/form.jpg);
		font-size: 9pt; color:#FFFFFF;
}
body,td,th {
	color: #FFFFFF;
	font-family: Verdana;
	font-size: 10px;
}
a:link {
	color: #CCCCCC;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #CCCCCC;
}
a:hover {
	text-decoration: none;
	color: #999999;
}
a:active {
	text-decoration: none;
	color: #999999;
}
</style>
</head>
<body>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
  <div align="center">
    <table width="125" border="0">
      <tr>
        <td><div align="left"><label>Attack lvl:</label></div></td>
        <td><input name="att" type="text" class="lvl" id="att" value="<?php if(isset($_POST['att'])) echo $_POST['att'];?>" size="5" maxlength="2" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>Strenght lvl:</label></div></td>
        <td><input name="str" type="text" id="str" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['str'])) echo $_POST['str'];?>" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>Defence lvl:</label></div></td>
        <td><input name="def" type="text" id="def" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['def'])) echo $_POST['def'];?>" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>HP lvl: </label></div></td>
        <td><input name="hp" type="text" id="hp" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['hp'])) echo $_POST['hp'];?>" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>Magic lvl:</label></div></td>
        <td><input name="mag" type="text" id="mag" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['mag'])) echo $_POST['mag'];?>" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>Prayer lvl:</label></div></td>
        <td><input name="pray" type="text" id="pray" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['pray'])) echo $_POST['pray'];?>" /></td>
      </tr>
      <tr>
        <td><div align="left"><label>Ranged lvl:</label></div></td>
        <td><input name="ran" type="text" id="ran" size="5" maxlength="2" class="lvl" value="<?php if(isset($_POST['ran'])) echo $_POST['ran'];?>" /></td>
      </tr>
    </table>
    <br/>
  </div>
  <div align="center">
  <label>
    <input type="submit" name="Submit" value="Calculate" class="buttons2" />
  </label>
  </div>
</form>
<div align="center">

<?php
/*==============================================================*/
/*                           HTML/CSS                           */
/*==============================================================*/
/*Info:             Valid XHTML 1.0 Transitional                */
/*Made by:       YPM Design - http://ypm-design.com             */
/*==============================================================*/
/*                       Combat Formula                         */
/*==============================================================*/
/*Made by:                    Covey                             */
/*URL:                  http://sythe.org                        */
/*==============================================================*/
/*                           License                            */
/*==============================================================*/
/*License:       GNU: General Public License (GPL)              */
/*==============================================================*/
/*=================Copyright © YPM Design 2007==================*/
/*==============================================================*/

//error_reporting
error_reporting(E_ALL);

//defineer $action
$action = "floor"; //actie, kan zijn: floor (naar beneden afronden (RuneScape gebruikt deze)) of round_2 (afronden op 2 decimalen)

class cb{
	function cblvl($att, $def, $str, $hp, $pray, $ran, $mag, $action){
		//bereken melee-based combat level
    	$ranged_cb = (0.483 * $ran + 0.249 * $def + 0.25 * $hp + 0.124 * $pray);
		
		//bereken magic-based combat level
	    $magic_cb = (0.483 * $mag + 0.249 * $def + 0.25 * $hp + 0.124 * $pray);
		
		//bereken ranged-based combat level
   	 $warrior_cb = (0.32707 * $att + 0.249 * $def + 0.324 * $str + 0.25 * $hp + 0.124 * $pray);
		
		//defineer account type
    	if($warrior_cb>=$magic_cb && $warrior_cb>=$ranged_cb){
		    //warrior
    	    $cb = $warrior_cb;
	    }
    	elseif($magic_cb>$warrior_cb && $magic_cb>=$ranged_cb){
	    	//mage
   	        $cb = $magic_cb;
	    }
 	    elseif($ranged_cb>$warrior_cb && $ranged_cb>$magic_cb){
	 	    //ranger
   	        $cb = $ranged_cb;
   	    }
	    if(!empty($cb)){//controleer of het een geldige uitkomst is
			//verwerk $cb met $action
			if($action == "floor"){
				//naar beneden afronden (net als RuneScape doet)
				echo "Combat lvl: ";
			    echo floor($cb);
			}
			elseif ($action == "round_2"){
			    //afronden op 2 decimalen
				echo "Combat lvl: ";
			    echo round($cb, 2);
			}
			else{
			    //verander niks
				echo "Combat lvl: ";
			    echo $cb;
			}
		}
	}
}
if(
    //controleer of alle gegevens zijn ingevuld
    !empty($_POST['att']) &&
	!empty($_POST['def']) &&
	!empty($_POST['str']) &&
	!empty($_POST['hp']) &&
	!empty($_POST['pray']) &&
	!empty($_POST['mag']) &&
	!empty($_POST['ran'])
){
    //zo ja, echo het combat lvl
    $calc = new cb();
    $calc->cblvl($_POST['att'], $_POST['def'], $_POST['str'], $_POST['hp'], $_POST['pray'], $_POST['mag'], $_POST['ran'], $action);
}
?>

<!--Valid HTML/CSS Logo-->
<!--You can remove this if you want to-->
  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" border="0" /></a>
	<a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fypm-design.com/cb.php">
  <img style="border:0;width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
    </a>

  </p>
</div>
</body>
</html>
[/code]

Reacties

0
Nog geen reacties.