Jump to content

textCommands


RichardRotterdam

Recommended Posts

Currently I'm trying to build a texadventure with php. I'm having trouble with the text commands and I don't think I have the right approach.

 

Every Scenery has its own set of textcommands that can be executed. There for I am placing a textCommandListeren object inside the Scenery object.

<?php
class Scenery{

var $description;		  //description of area in text
        var $textCommandListeren;   //object used to accept text commands 

public function Scenery($description){
                $this->textCommandListeren = new textCommandListeren;
	$this->description=$description;
	$this->pathDescription=$pathDescription;
}
}
?>

 

I want to fetch these text commands from an mysql database. Getting text from a database and storing it in an array is not the problem. What the problem is is that I want something to be done with an item when a text was entered.

example

get sword should perform the sword being removed from the Scenery object and placed into the Inventory object

 

I'm thinking of using some kind event listeners I don't have much experience with events besides flash and javascripting. Is there anyone that can send me in the right direction? And am I doing the right thing to build the textCommandListener object?

Link to comment
https://forums.phpfreaks.com/topic/72386-textcommands/
Share on other sites

  • 1 month later...

Ajax may well be the only route available, as you have to remember that PHP is a STATELESS environment. Once the page is run everything is dumped from memory, so while implementing an Observer/Observable pattern may have benefited you, you are looking to do something during the client side phase (typing into the browser).

Link to comment
https://forums.phpfreaks.com/topic/72386-textcommands/#findComment-391353
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.