php - How to implement an inventory system for a game? -


How do I go about implementing an inventory system for a game in PHP? I am trying to find a way in which the item can be used dynamically instead of just in your inventory, eg Enabling weapons that use drugs, teleporting etc.

The only solution I can store PHP code in the database, and when the item is used it is to get it, but it does not really seem reasonable. Is this a better way to implement it?

To clarify: This is an mmo browser game, and the inventory of each player must continue through the game. It is difficult to maintain a square for every item (there can be hundreds of items) if any changes are made. In addition to applying a 'base item' class as suggested, you may also want to consider developing an interface.

In order to highlight all the approaches, all the objects must be in the class. Then, each type of item can apply these methods differently. For example, all items may need the 'las ()' method, but on what kind of commodities it can be applied differently? You may not need to create a class for each individual item, but you should probably create classes that are able to create unique examples of items based on some kind of data structure you provide (which are stored in the database can be done).

A really common example can be:

  class extends Leather_Armor Armor_Base implies equippable {// It is preserved in base class instead of preserved $ _itemName Will be done; Secure $ _item Description; Safe $ _ defencerating; Public Function __ Construct (properties) with data from {// DB} compulsory making // the same information needs to define this function, public function equip () {// Call a call from the base class - it-> Recalculate Defender $ $-> Protecting you}}}  

You should read on the interface and intangible sections to get the full idea.

Along with this, keep in mind that it can actually be contacted in thousands of different ways by a comprehensive, open-ended question. You may want to ask something more specific or provide concrete examples.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -