Skip to content
Permalink
Browse files

Merged PR 509: Merge 607_get_drop_wizard_enhancements to master

Related work items: #607
  • Loading branch information...
realms-mud committed May 30, 2019
1 parent 36398c9 commit 3a26d49a92845654331eeff3292be810849de5e5
Showing with 106 additions and 6 deletions.
  1. +12 −1 commands/player/drop.c
  2. +13 −3 commands/player/get.c
  3. +3 −2 items/item.c
  4. +43 −0 tests/commands/player/dropTest.c
  5. +35 −0 tests/commands/player/getTest.c
@@ -59,6 +59,11 @@ public nomask int execute(string command, object initiator)
!$1->query("undroppable") &&
$1->id($2) :), targetString);
}
else if ((member(inherit_list(initiator), "lib/realizations/wizard.c") > -1) &&
present_clone(targetString, initiator))
{
targets += ({ present_clone(targetString, initiator) });
}
else
{
targets += ({ getTarget(initiator, command, TargetInventory) });
@@ -73,10 +78,16 @@ public nomask int execute(string command, object initiator)
if (!initiator->isEquipped(target) ||
sizeof(regexp(({ command }), "-f")))
{
if (!function_exists("drop", target) &&
(member(inherit_list(initiator),
"lib/realizations/wizard.c") > -1))
{
move_object(target, environment(initiator));
}
if (!target->drop())
{
displayMessage("##InitiatorName## ##Infinitive::drop## " +
target->query("name") + ".\n", initiator);
(target->query("name") || target->Name()) + ".\n", initiator);
}
}
}
@@ -44,15 +44,25 @@ private nomask object *getAllOfSpecificId(object initiator, object source)
}

/////////////////////////////////////////////////////////////////////////////
private nomask object *getSpecificItem(object initiator, object source, string targetString)
private nomask object *getSpecificItem(object initiator, object source,
string targetString)
{
object *targets = ({});
object target = present(targetString, source) ||
present(targetString, environment(initiator));

int isWizard =
member(inherit_list(initiator), "lib/realizations/wizard.c") > -1;

if (!target && isWizard)
{
target = present_clone(targetString, source) ||
present_clone(targetString, environment(initiator));
}

if (target)
{
if (target->get())
if (target->get() || isWizard)
{
targets += ({ target });
}
@@ -94,7 +104,7 @@ private nomask int getObjects(object initiator, object source, object *targets)
{
move_object(target, initiator);
displayMessage("##InitiatorName## ##Infinitive::pick## up " +
target->query("name") + ".\n", initiator);
(target->query("name") || target->Name()) + ".\n", initiator);
}
else
{
@@ -12,10 +12,11 @@
virtual inherit "/lib/core/thing.c";

private nosave string AttacksBlueprint = "/lib/dictionaries/attacksDictionary.c";
protected nosave string MaterialsBlueprint = "/lib/dictionaries/materialsDictionary.c";
private nosave string BonusesBlueprint = "/lib/dictionaries/bonusesDictionary.c";
private nosave string CraftingDictionary = "/lib/dictionaries/craftingDictionary.c";
protected nosave string MaterialsBlueprint = "/lib/dictionaries/materialsDictionary.c";

protected nosave string MessageParser = "/lib/core/messageParser.c";
private nosave string BonusesBlueprint = "/lib/dictionaries/bonusesDictionary.c";
private object MaterialsObject = load_object(MaterialsBlueprint);

protected mapping itemData = ([
@@ -221,3 +221,46 @@ void CanDropSomeMoney()
ExpectEq(100, present_clone("lib/items/money.c", Room)->query("value"));
ExpectEq("You drop money.\n", Player->caughtMessage());
}

/////////////////////////////////////////////////////////////////////////////
void PlayersCannotDropItemsWithoutDropMethod()
{
object player2 = clone_object("/lib/tests/support/services/mockPlayer.c");
Player->Name("fred");

move_object(player2, Player);
ExpectFalse(Player->executeCommand("drop fred"));
ExpectFalse(present(player2, Room));

destruct(player2);
}

/////////////////////////////////////////////////////////////////////////////
void WizardsCanDropItemsWithoutDropMethod()
{
object player2 = clone_object("/lib/tests/support/services/mockWizard.c");
Player->Name("fred");

move_object(player2, Room);
move_object(Player, player2);

ExpectTrue(player2->executeCommand("drop fred"));
ExpectTrue(present(Player, Room));

destruct(player2);
}

/////////////////////////////////////////////////////////////////////////////
void WizardsCanDropItemsById()
{
object player2 = clone_object("/lib/tests/support/services/mockWizard.c");
Player->Name("fred");

move_object(player2, Room);
move_object(Player, player2);

ExpectTrue(player2->executeCommand("drop " + object_name(Player)));
ExpectTrue(present(Player, Room));

destruct(player2);
}
@@ -331,3 +331,38 @@ void AFlagForGetAllMoneyGetsAllMoney()
ExpectEq(250, Player->Money());
ExpectEq(4, sizeof(all_inventory(Room)));
}

/////////////////////////////////////////////////////////////////////////////
void PlayersCannotGetUngettableItems()
{
object player2 = clone_object("/lib/tests/support/services/mockPlayer.c");
player2->Name("fred");

move_object(player2, Room);
ExpectFalse(Player->executeCommand("get fred"));
ExpectTrue(present(player2, Room), "Fred is here.");
}

/////////////////////////////////////////////////////////////////////////////
void WizardsCanGetUngettableItems()
{
object player2 = clone_object("/lib/tests/support/services/mockWizard.c");
player2->Name("fred");

move_object(player2, Room);

ExpectTrue(player2->executeCommand("get bob"));
ExpectFalse(present(Player, Room));
}

/////////////////////////////////////////////////////////////////////////////
void WizardsCanGetByObjectId()
{
object player2 = clone_object("/lib/tests/support/services/mockWizard.c");
player2->Name("fred");

move_object(player2, Room);

ExpectTrue(player2->executeCommand("get " + object_name(Player)));
ExpectFalse(present(Player, Room));
}

0 comments on commit 3a26d49

Please sign in to comment.
You can’t perform that action at this time.