assignments = array(); $this->cvar = false; $this->cval = false; } } class Action { var $actionblocks; function Action() { $this->actionblocks = array(); } function perform() { global $location, $vars; $this->display_text = ''; $countblocks = 0; foreach($this->actionblocks as $this->block) { //global $vars; if($this->block->cvar == 'else') { continue; } if($this->block->cvar != false) { if(!array_key_exists($this->block->cvar, $vars)) { exit("Game Error: Undefined variable '{$this->block->cvar}' used in 'if' statement."); } } //echo intval($vars[$this->block->cvar]) . " == " . intval($this->block->cval) . "
"; if(intval($vars[$this->block->cvar]) == intval($this->block->cval) || !$this->block->cvar) { //echo "yup
"; // go ahead and process the if } elseif($this->actionblocks[$countblocks+1]->cvar == 'else') // if this if has an else { // process the else instead of the if $this->block = $this->actionblocks[$countblocks+1]; } else { // this isn't true, then...so skip to the next block continue; } foreach($this->block->assignments as $this->assvar => $this->assval) { switch($this->assvar) { case false: break; case 'location': $location = $this->assval; break; case 'display': $this->display_text .= $this->assval; break; default: if(!array_key_exists($this->assvar, $vars)) { exit("Game Error: Assignment to undefined variable '{$this->assvar}' detected."); } $vars[$this->assvar] = $this->assval; } } $countblocks++; } return $this->display_text; } } class GameObj { var $actions; var $object_description; function GameObj() { $this->actions = array(); } } ?>