Created
August 27, 2011 17:11
-
-
Save aquilax/1175621 to your computer and use it in GitHub Desktop.
NoviGeroi2 Fight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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