diff options
-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) { |