"); } function cmpIni($a, $b) { return ($a["initiative"] > $b["initiative"]); } session_start(); // Use $HTTP_SESSION_VARS with PHP 4.0.6 or less if (!isset($_SESSION['initialised']) || $_GET['reset'] == 1) { $_SESSION['initialised'] = 1; $aCombatants = array(); $oAttackOption = array ( name=>"Attack", requires => "front-row", area => "single", effect => "roll-to-hit, SUCCESS damage, FAIL miss"); $oDefendOption = array ( name=>"Defend", requires => "front-row", area => "self", effect => "AC+"); $oDoNothingOption = array ( name=>"Defend", requires => "", area => "self", effect => ""); $oFighterOptions = array ( $oAttackOption, oDefendOption, oDoNothingOption ); $aOrders = array(); //create party $nPartyMembers = 4; $oCombatant = array( name => "Pete", hp=>10, currentHP=>10, thac0=>18, ac=>3, combatAC=>3, options => $oFighterOptions, row=>"front-row" ); array_push($aCombatants, $oCombatant); $oCombatant = array( name => "Anne", hp=>10, currentHP=>10, thac0=>18, ac=>3, combatAC=>3, options => $oFighterOptions, row=>"front-row" ); array_push($aCombatants, $oCombatant); $oCombatant = array( name => "Hissspit", hp=>5, currentHP=>5, thac0=>19, ac=>8, combatAC=>8, options => $oFighterOptions, row=>"back-row" ); array_push($aCombatants, $oCombatant); $oCombatant = array( name => "Shengui", hp=>5, currentHP=>5, thac0=>19, ac=>8, combatAC=>8, options => $oFighterOptions, row=>"back-row" ); array_push($aCombatants, $oCombatant); //create some enemies $oCombatant = array( name => "Goblin", hp=>5, currentHP=>5, thac0=>20, ac=>7, combatAC=>7, options => $oFighterOptions, row=>"front-row" ); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); array_push($aCombatants, $oCombatant); $nPhase = "order"; $nSubPhase = -1; tracer("initialising"); } else { tracer("initialised"); $aCombatants = $_SESSION['aCombatants']; $nPartyMembers = $_SESSION['nPartyMembers']; $nPhase = $_SESSION['nPhase']; $nSubPhase = $_SESSION['nSubPhase']; $aOrders = $_SESSION['aOrders']; //unset($_SESSION['initialised']); } ?> BT Combat test Restart

Phase...
$nSubPhase, order => "attack", target=>-1, initiative=> rand(0,20) )); } if ($_GET['opt'] == "c") { //ignore, do nothing option } if ($_GET['opt'] == "b") { array_push($aOrders, array(who => $nSubPhase, order => "defend", initiative=> rand(0,20) )); } if ($_GET['t'] != null) { $nPhase="order"; $aOrders[count($aOrders)-1]["target"] = ($_GET['t']); tracer("target set"); } if ($_GET['c'] == "n") { $aOrders = array(); $nPhase = "order"; $nSubPhase = -1; } if ($_GET['c'] == "y") { $nPhase = "action!"; } if ($nPhase == "order") { if ($nSubPhase >= $nPartyMembers -1) { $nSubPhase++; while ($nSubPhase < count($aCombatants)) { array_push($aOrders, array(who => $nSubPhase, order => "attack", target=>-1, initiative=> rand(0,20) )); while (true) { $target = rand(0, $nPartyMembers-1); if ($aCombatants[$target]["row"][0]=="f" && $aCombatants[$target]["currentHP"]>0) { break; } } $aOrders[count($aOrders)-1]["target"] = $target; $nSubPhase++; } $nPhase="confirm"; } } switch($nPhase) { case "order": $nSubPhase++; ?> Order phase

Attack Defend Do nothing 0) { echo ("" . $aCombatants[$i]["name"] . "
"); } } break; case "confirm": ?> Use these orders?
Yes or No

attacks =$aCombatants[$nWho]["thac0"]-$aCombatants[$nTarget]["ac"]) { $aCombatants[$nTarget]["currentHP"]--; if ($aCombatants[$nTarget]["currentHP"]>0) { ?> and hits! and is slain! but misses!

moves into a defensive stance...

Continue...
Party...
Pos
" . $aCombatants[$i]["row"][0] . ""); } ?>
Name
" . $aCombatants[$i]["name"] . ""); } ?>
AC
" . $aCombatants[$i]["ac"] . ""); } ?>
HP / Current
" . $aCombatants[$i]["hp"] ." / " . $aCombatants[$i]["currentHP"] . ""); } ?>

Enemies...
Pos
" . $aCombatants[$i]["row"][0] . ""); } ?>
Name
" . $aCombatants[$i]["name"] . ""); } ?>
AC
" . $aCombatants[$i]["ac"] . ""); } ?>
HP / Current
" . $aCombatants[$i]["hp"] ." / " . $aCombatants[$i]["currentHP"] . ""); } ?>