RichardRotterdam Posted October 9, 2007 Share Posted October 9, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/72386-textcommands/ Share on other sites More sharing options...
koen Posted November 13, 2007 Share Posted November 13, 2007 There's no such thing as an event like there is in javascript. After the user types in "get sword", do they have to press a submit button or are you doing things another way? Quote Link to comment https://forums.phpfreaks.com/topic/72386-textcommands/#findComment-390843 Share on other sites More sharing options...
teng84 Posted November 14, 2007 Share Posted November 14, 2007 you can try ajax... Quote Link to comment https://forums.phpfreaks.com/topic/72386-textcommands/#findComment-391084 Share on other sites More sharing options...
aschk Posted November 14, 2007 Share Posted November 14, 2007 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). Quote Link to comment https://forums.phpfreaks.com/topic/72386-textcommands/#findComment-391353 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.