Skip to content

Instantly share code, notes, and snippets.

@aquilax
Created August 27, 2011 17:11
Show Gist options
  • Save aquilax/1175621 to your computer and use it in GitHub Desktop.
Save aquilax/1175621 to your computer and use it in GitHub Desktop.
NoviGeroi2 Fight
public function fight() {
$cmd = $this->getCommandHero();
if ($cmd) {
// Da real deal
switch ($cmd) {
case 'hit' : $this->heroHit(); break;
case 'spell' : $this->heroSpell(); break;
case 'run' : if ($this->heroRun()) return $this->messages; break;
default: // Cheating hurts
}
if ($this->hero_dead) {
$this->redirect = "dead";
return $this->messages;
}
$this->monsterHit(); //Monster will try to hit even if you run
if ($this->monster_dead) {
$this->redirect = "vitory";
return $this->messages;
}
$this->monster_model->save();
} else {
// User's turn no command given show status
$this->messages[] = sprintf(lang('You are fighting %s'), $this->monster_model->get('name'));
}
return $this->messages;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment