<?php
$events_in_war = array();
function attack($attacker, $target){
echo $attacker->name. " attacked " . $target->name;
$events_in_war[] = array(
'attacker' => $attacker,
'target' => $target
);
}
function who_hit_me($target_id){
$attacker = null;
for($x = sizeof($events_in_war) - 1; $x >= 0; $x--){
if($events_in_war[$x]['target']->id == $target_id){$attacker = $events_in_war[$x]['attacker'];
break;}}
return $attacker;
}
function fourth_shinobi_war($good_guys, $bad_guys, $hostages){
$war = true;
$SA_shinobis = $good_guys;
while($war){
$participants = array_merge($good_guys, $bad_guys);
foreach($participants as $attacker){
$target_id = random(0, sizeof($participants));
attack($attacker->name, $participants[$target_id]->name);
}
foreach($SA_shinobis as $instance => $SA_member){
switch($SA_member->name){
case "Uzumaki Naruto":
if($SA_member->hp == 0){
$war = false;
$killer = who_hit_me($SA_member->id);
if($killer->name == "Uchiha Obito" || $killer->name == "Uchiha Madara"){
$result['who_won'] = "Bad guys";
$result['last_phrase'] = "I won't surrend...aughghauhuahg";
$result['death_cause'] = "Impaled";
}
elseif($killer->name == "Uchiha Sasuke"){
$result['who_won'] = $killer->name;
$result['last_phrase'] = "SASUKEEEEEEE...E...E... ******";
$result['death_cause'] = "Genjutsu";
}
else {
$result['who_won'] = "Bad guys";
$result['death_cause'] = "Chakra exhaustion";
}
}
break;
case "Uchiha Sasuke":
if($SA_member->hp == 0){
$war = false;
$killer = who_hit_me($SA_member->id);
if($killer->name == "Uzumaki Naruto"){
$result['who_won'] = "Good guys";
$result['last_phrase'] = "NARUTOOOO.....O..OO... ******";
$result['death_cause'] = "TnJ for sure";
}
}
break;
default:
if($SA_member->hp == 0){
$result['event'] = "Aww, a fodder died :(";
}
}
}
foreach($bad_guys as $instance => $bad_guy){
if($bad_guy->hp == 0){
$war = false;
$killer = who_hit_me($bad_guy->id);
if($killer->name == "Uchiha Sasuke"){
$result['who_won'] = "Good guys";
$result['last_phrase'] = "You traitor... you killed your own kin! D:<";
$result['death_cause'] = "Impaled";
}
elseif($killer->name == "Uzumaki Naruto"){
$result['who_won'] = "Good guys";
$result['last_phrase'] = "You're so boooriiiiiiiiiiinggg...";
$result['death_cause'] = "TnJ for sure";} else {
$result['system_message'] = "Error. Memory overload.";
}
}
}
}
return $result;
}
fourth_shinobi_war(SA_members, bad_guys, BIJUUS);
?>