Saturday, January 2, 2010

Battle output...



Battle Output.

The entire system is modular and the fight between two complete set of stats will always produce a valid result that reflects both general luck and skill. A randomizer is used to try and liven up some of the textual results as well. It can eventually be more fine-tuned to react to specific contexts.

The values, like monsters, players, and responses should be pulled from a database and adjusted accordingly.

//This is the randomized response engine
function response($response){
if ($response == "ATTACK"){
$attack[0] = "attack";
$attack[2] = "slash";
$attack[3] = "jab";
$attack[4] = "chop";
$attack[5] = "slash";
$attack[6] = "kick";
$attack[7] = "hurt";
$attack[8] = "pulverize";
$attack[9] = "cut";
$attack[1] = "upper-cut";
$responseBack = array_rand(array_flip($attack), 1);
echo $responseBack;
}

if ($response == "BLOCKED"){
$blocked[0] = "blocked";
$blocked[2] = "stopped";
$blocked[3] = "deflected";
$blocked[4] = "useless";
$blocked[5] = "too late";
$blocked[6] = "too early";
$blocked[7] = "absorbed";
$blocked[8] = "rejected";
$blocked[9] = "nullified";
$blocked[1] = "laughable";
$responseBack = array_rand(array_flip($blocked), 1);
echo $responseBack;
}
}

No comments:

Post a Comment