Skip to content

Commit

Permalink
feature: add new error messages (#2304)
Browse files Browse the repository at this point in the history
Co-authored-by: Gtravisani <[email protected]>
  • Loading branch information
elsongabriel and myallith authored Feb 22, 2024
1 parent c798b3c commit 6705f59
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ void Game::playerMoveItem(std::shared_ptr<Player> player, const Position &fromPo
auto toHouseTile = map.getTile(mapToPos)->dynamic_self_cast<HouseTile>();
auto fromHouseTile = map.getTile(mapFromPos)->dynamic_self_cast<HouseTile>();
if (fromHouseTile && (!toHouseTile || toHouseTile->getHouse()->getId() != fromHouseTile->getHouse()->getId())) {
player->sendCancelMessage("You can't move this item outside a house.");
player->sendCancelMessage("You cannot move this item out of this house.");
return;
}
}
Expand Down Expand Up @@ -1666,12 +1666,12 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr<Player> player, std::s
bool allowAnything = g_configManager().getBoolean(TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, __FUNCTION__);

if (!allowAnything && item->getID() != ITEM_GOLD_COIN && item->getID() != ITEM_PLATINUM_COIN && item->getID() != ITEM_CRYSTAL_COIN) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
return RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH;
}

// prevent move up
// prevent move up from ponch to store inbox.
if (!item->canBeMovedToStore() && fromCylinder->getContainer() && fromCylinder->getContainer()->getID() == ITEM_GOLD_POUCH) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
return RETURNVALUE_NOTBOUGHTINSTORE;
}

return RETURNVALUE_NOERROR;
Expand All @@ -1681,7 +1681,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr<Player> player, std::s
const auto parentContainer = topParentContainer->getParent() ? topParentContainer->getParent()->getContainer() : nullptr;
auto isStoreInbox = parentContainer && parentContainer->isStoreInbox();
if (!item->canBeMovedToStore() && (containerID == ITEM_STORE_INBOX || isStoreInbox)) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
return RETURNVALUE_NOTBOUGHTINSTORE;
}

if (item->isStoreItem()) {
Expand All @@ -1705,7 +1705,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr<Player> player, std::s
}

if (!isValidMoveItem) {
return RETURNVALUE_NOTPOSSIBLE;
return RETURNVALUE_ITEMCANNOTBEMOVEDTHERE;
}

if (item->hasOwner() && !item->isOwner(player)) {
Expand Down Expand Up @@ -1738,7 +1738,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr<Player> player, std::s
}

if (item->isStoreItem() && !house) {
return RETURNVALUE_NOTPOSSIBLE;
return RETURNVALUE_ITEMCANNOTBEMOVEDTHERE;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/items/items_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ enum Attr_ReadValue {

enum ReturnValue {
RETURNVALUE_NOERROR,
RETURNVALUE_NOTBOUGHTINSTORE,
RETURNVALUE_ITEMCANNOTBEMOVEDTHERE,
RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH,
RETURNVALUE_NOTPOSSIBLE,
RETURNVALUE_NOTENOUGHROOM,
RETURNVALUE_PLAYERISPZLOCKED,
Expand Down
3 changes: 3 additions & 0 deletions src/lua/functions/core/game/lua_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,9 @@ void LuaEnums::initMapMarkEnums(lua_State* L) {
// Use with Game.getReturnMessage
void LuaEnums::initReturnValueEnums(lua_State* L) {
registerEnum(L, RETURNVALUE_NOERROR);
registerEnum(L, RETURNVALUE_NOTBOUGHTINSTORE);
registerEnum(L, RETURNVALUE_ITEMCANNOTBEMOVEDTHERE);
registerEnum(L, RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH);
registerEnum(L, RETURNVALUE_NOTPOSSIBLE);
registerEnum(L, RETURNVALUE_NOTENOUGHROOM);
registerEnum(L, RETURNVALUE_PLAYERISPZLOCKED);
Expand Down
9 changes: 9 additions & 0 deletions src/utils/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,15 @@ const char* getReturnMessage(ReturnValue value) {
case RETURNVALUE_NOERROR:
return "No error.";

case RETURNVALUE_NOTBOUGHTINSTORE:
return "You cannot move this item into your store inbox as it was not bought in the store.";

case RETURNVALUE_ITEMCANNOTBEMOVEDPOUCH:
return "This item cannot be moved there. You can only place gold, platinum and crystal coins in your gold pouch.";

case RETURNVALUE_ITEMCANNOTBEMOVEDTHERE:
return "This item cannot be moved there.";

case RETURNVALUE_REWARDCHESTISEMPTY:
return "The chest is currently empty. You did not take part in any battles in the last seven days or already claimed your reward.";

Expand Down

0 comments on commit 6705f59

Please sign in to comment.