Nếu bạn tạo ra các lệnh riêng của bạn và quên thêm require_once () tham chiếu đến tập tin thì trò chơi sẽ cho bạn biết rằng nó là Làm cho lệnh trò chơi chính bằng cách mặc định trở lại mới Nó không xác định, vì vậy đi với mặc định khác | 250 Chapter 11 Kiddy Cartel Creating Your Own MMO class CCommandFactory This exists in order to allow the parent reference in the commands to be set to null. var m_NullVariable null function CreateCommand sCmdName if it s a known class create it if class_exists sCmdName return new sCmdName m_NullVariable are we trying to create a class that doesn t exist else if sCmdName class_exists sCmdName this should never happen so warn the programmer they probably forgot to require_once the command echo UNKNOWN COMMAND BR hard exit since there is nothing else we can really do exit 1 it s undefined so go with the default else render the main game command by default return new CGameMenuCmd this- m_NullVariable If you create your own commands and forget to add the require_once reference to the file then the game will let you know that it is trying to execute an unknown command. So remember to add your command to the command factory. As you can see all that the command factory does is check to see if the command that you are trying to create exists. If the command does exist then it creates it if the command does not exist then it lets you know. If there is no command to execute then it assumes that you are on the game menu and that it should render the menu to the browser. Look at All the Commands. Now What 251 So how in the world do you put all of this together Well that is where the CGame class comes into play. Everything that happens in the game occurs through the page. The page calls the CGame class. Take a look at the page. require_once require_once require_once require_once function main seed the random number generator once for all commands srand time get the session up and running session_start if there isn t a game objection in the session make one if isset _SESSION game _SESSION game new CGame execute the current game command _SESSION game - ExecuteCommand _REQUEST main The first event .