12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "ChatCommand.h"
- ChatCommand::ChatCommand(
- Framework::Text name, Framework::Text description, int securityLevel)
- : Framework::ReferenceCounter(),
- name(name),
- description(description),
- securityLevel(securityLevel)
- {}
- void ChatCommand::addParam(ChatCommandParameter* param)
- {
- params.add(param);
- }
- const Framework::RCArray<ChatCommandParameter>& ChatCommand::getParams() const
- {
- return params;
- }
- Framework::Text ChatCommand::getName() const
- {
- return name;
- }
- Framework::Text ChatCommand::getHelp() const
- {
- Framework::Text result = "/";
- result += name;
- for (ChatCommandParameter* param : params)
- {
- result += " ";
- if (param->isOptional()) result += "[";
- result += param->getName();
- if (param->isOptional()) result += "]";
- }
- if (description.getLength() > 0)
- {
- result += "\n ";
- result += description;
- }
- for (ChatCommandParameter* param : params)
- {
- if (param->getDescription().getLength() > 0)
- {
- result += "\n ";
- if (param->isOptional()) result += "[";
- result += param->getName();
- if (param->isOptional()) result += "]";
- result += " - ";
- result += param->getDescription();
- }
- }
- return result;
- }
- int ChatCommand::getSecurityLevel() const
- {
- return securityLevel;
- }
- ChatCommandParameter::ChatCommandParameter(
- Framework::Text name, Framework::Text description, bool optional)
- : ReferenceCounter(),
- name(name),
- description(description),
- optional(optional)
- {}
- bool ChatCommandParameter::isLegalValue(Framework::Text value) const
- {
- return 1;
- }
- Framework::Text ChatCommandParameter::getDefaultValue(Entity* zActor) const
- {
- return "";
- }
- Framework::Text ChatCommandParameter::getName() const
- {
- return name;
- }
- Framework::Text ChatCommandParameter::getDescription() const
- {
- return description;
- }
- bool ChatCommandParameter::isOptional() const
- {
- return optional;
- }
|