diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-09-21 21:19:35 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-09-21 21:20:07 +0200 |
commit | 68d8d67fc3b0b0338fab398a0b3dc3237a6870e6 (patch) | |
tree | 9b1f494aa5cf637e354ee2df0425c734c9d6c6f1 /src/game-server | |
parent | 0f525c92dece8b302356c63864c6209309293184 (diff) | |
download | manaserv-68d8d67fc3b0b0338fab398a0b3dc3237a6870e6.tar.gz manaserv-68d8d67fc3b0b0338fab398a0b3dc3237a6870e6.tar.bz2 manaserv-68d8d67fc3b0b0338fab398a0b3dc3237a6870e6.tar.xz manaserv-68d8d67fc3b0b0338fab398a0b3dc3237a6870e6.zip |
Added @commands for setting attribute and correction points
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/commandhandler.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index cfdee8b5..0bf3adeb 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -85,6 +85,8 @@ static void handleGiveAbility(Entity*, std::string&); static void handleTakeAbility(Entity*, std::string&); static void handleRechargeAbility(Entity*, std::string&); static void handleListAbility(Entity*, std::string&); +static void handleSetAttributePoints(Entity*, std::string&); +static void handleSetCorrectionPoints(Entity*, std::string&); static CmdRef const cmdRef[] = { @@ -164,6 +166,10 @@ static CmdRef const cmdRef[] = "<setname>_<abilityname>", &handleRechargeAbility}, {"listabilities", "<character>", "Lists the abilitys of the character.", &handleListAbility}, + {"setattributepoints", "<character> <amount>", + "Sets the attribute points of a character.", &handleSetAttributePoints}, + {"setcorrectionpoints", "<character> <amount>", + "Sets the correction points of a character.", &handleSetCorrectionPoints}, {nullptr, nullptr, nullptr, nullptr} }; @@ -1724,6 +1730,74 @@ static void handleListAbility(Entity *player, std::string &args) } } +static void handleSetAttributePoints(Entity *player, std::string &args) +{ + std::string character = getArgument(args); + std::string attributePoints = getArgument(args); + if (character.empty()) + { + say("Invalid amount of arguments given.", player); + say("Usage: @setattributepoints <character> <point>", player); + return; + } + + Entity *other; + if (character == "#") + other = player; + else + other = gameHandler->getCharacterByNameSlow(character); + + if (!other) + { + say("Invalid character, or player is offline.", player); + return; + } + + if (!utils::isNumeric(attributePoints)) + { + say("Invalid character, or player is offline.", player); + return; + } + + auto *characterComponent = other->getComponent<CharacterComponent>(); + + characterComponent->setAttributePoints(utils::stringToInt(attributePoints)); +} + +static void handleSetCorrectionPoints(Entity *player, std::string &args) +{ + std::string character = getArgument(args); + std::string correctionPoints = getArgument(args); + if (character.empty()) + { + say("Invalid amount of arguments given.", player); + say("Usage: @setcorrectionpoints <character> <point>", player); + return; + } + + Entity *other; + if (character == "#") + other = player; + else + other = gameHandler->getCharacterByNameSlow(character); + + if (!other) + { + say("Invalid character, or player is offline.", player); + return; + } + + if (!utils::isNumeric(correctionPoints)) + { + say("Invalid character, or player is offline.", player); + return; + } + + auto *characterComponent = other->getComponent<CharacterComponent>(); + + characterComponent->setCorrectionPoints(utils::stringToInt(correctionPoints)); +} + void CommandHandler::handleCommand(Entity *player, const std::string &command) { |