Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.