|
CreatingNewUserCommands
This page describes how to create a new user command in Snookiepoof
Phase-Implementation IntroductionUserCommands represent a central concept in Snookiepoof. You can extend the game engine by adding new commands, which represent everything a user can do in the game. This page describes the normal steps you go through to create a new UserCommand. Remember to start by creating tests first. Tests for UserCommands are created in project Test.Snookiepoof.Core. Creating a new concrete UserCommandIn the UserCommands foler in the Snookiepoof.Core project you'll find all the existing commands. Add a new class which inherits from the UserCommand interface.
Using the new command in a text based gameIn order for the user to run the UserCommand you just created from a text based game, you need to create a UserCommandTextParser for that command. You'll do this in Snookiepoof.Text, under the TextParsing/SpecificTextParsers folder. Remember to write tests for the parser.
Here is a sample text parser: [UserCommandKeyword("look")]
[UserCommandKeyword("l")]
[UserCommandKeyword("see")]
public class LookCommandTextParser : IUserCommandTextParser
{
public UserCommand GetCommand(FirstPerson person, string[] commandArguments)
{
return new LookCommand(person, ParserHelper.GetDirectionFromArguments(commandArguments));
}
}Your new command should now be ready to be used in the Console game. |