Skip to content

Commit

Permalink
Merge branch 'master' into 105.manipulator-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
mithrandi committed Nov 15, 2020
2 parents 9ecabe2 + 53fe250 commit 07357e2
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 48 deletions.
80 changes: 46 additions & 34 deletions .requirements-readthedocs.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
Axiom==0.7.5
Babel==2.2.0
Epsilon==0.7.1
Jinja2==2.8
Mantissa==0.8.3
MarkupSafe==0.23
Nevow==0.12.0
Pillow==3.1.1
Pygments==2.1
Sphinx==1.3.5
Twisted==15.5.0
alabaster==0.7.12
appdirs==1.4.4
argon2-cffi==20.1.0
attrs==20.3.0
Automat==20.2.0
axiom==0.9.0
Babel==2.8.0
bcrypt==3.1.7
certifi==2020.6.20
cffi==1.14.3
chardet==3.0.4
constantly==15.1.0
cryptography==3.2.1
cssutils==1.0.2
docutils==0.16
enum34==1.1.10
epsilon==0.8.0
hyperlink==20.0.1
idna==2.10
imagesize==1.2.0
incremental==17.5.0
ipaddress==1.0.23
Jinja2==2.11.2
Mantissa==0.9.0
MarkupSafe==1.1.1
Nevow==0.14.5
packaging==20.4
passlib==1.7.4
Pillow==6.2.2
pyasn1==0.4.8
pycparser==2.20
Pygments==2.5.2
PyHamcrest==1.10.1
pyOpenSSL==19.1.0
pyparsing==2.4.7
pytz==2020.4
requests==2.24.0
six==1.15.0
snowballstemmer==2.0.0
Sphinx==1.8.5
sphinxcontrib-websupport==1.1.2
Twisted==20.3.0
txpasslib==0.1.0
typing==3.7.4.3
urllib3==1.25.11
Vertex==0.3.1
alabaster==0.7.7
cffi==1.5.0
chardet==2.3.0
cryptography==1.2.2
cssutils==1.0.1
doc8==0.6.0
docutils==0.12
enum34==1.1.2
idna==2.0
ipaddress==1.0.16
pbr==1.8.1
pyOpenSSL==0.15.1
pyasn1==0.1.9
pycparser==2.14
pycrypto==2.6.1
pytz==2015.7
restructuredtext-lint==0.14.0
six==1.10.0
snowballstemmer==1.2.1
sphinx-rtd-theme==0.1.9
stevedore==1.10.0
wheel==0.26.0
zope.interface==4.1.3
zope.interface==5.2.0
31 changes: 17 additions & 14 deletions src/imaginary/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def parseImpl(self, instring, loc, doActions=True):



orLiterals = lambda xs: pyparsing.Or(map(pyparsing.Literal, xs))



class _ActionType(type):
actions = []
def __new__(cls, name, bases, attrs):
Expand Down Expand Up @@ -571,8 +575,7 @@ def targetTaken(player, target, container=None):


class Remove(TargetAction):
expr = ((pyparsing.Literal("remove") |
pyparsing.Literal("take off")) +
expr = (orLiterals(["remove", "take off"]) +
pyparsing.White() +
targetString("target"))

Expand Down Expand Up @@ -641,7 +644,7 @@ def do(self, player, line):
class TakeFrom(ToolAction):
actionName = "take"

expr = ((pyparsing.Literal("get") ^ pyparsing.Literal("take")) +
expr = (orLiterals(["get", "take"]) +
pyparsing.White() +
targetString("target") +
pyparsing.Optional(pyparsing.White() +
Expand Down Expand Up @@ -899,14 +902,9 @@ def do(self, player, line, direction):


class Go(Action):
expr = (
(pyparsing.Literal("go") + pyparsing.White() +
targetString("direction")) |
(pyparsing.Literal("enter") + pyparsing.White() +
targetString("direction")) |
(pyparsing.Literal("exit") + pyparsing.White() +
targetString("direction")) |
DIRECTION_LITERAL)
_goVerbs = orLiterals(["go", "enter", "exit"])
_goForm = _goVerbs + pyparsing.White() + targetString("direction")
expr = _goForm | DIRECTION_LITERAL

actorInterface = iimaginary.IThing

Expand Down Expand Up @@ -948,6 +946,13 @@ def do(self, player, line, direction):
actor=player,
actorMessage=language.ExpressString(
u"There's no room for you there.")))
except eimaginary.Closed:
raise eimaginary.ActionFailure(events.ThatDoesntWork(
actor=player,
actorMessage=language.ExpressString(
u"The way is shut.",
),
))

# This is subtly incorrect: see http://divmod.org/trac/ticket/2917
lookAroundActor = iimaginary.IActor(player)
Expand Down Expand Up @@ -999,9 +1004,7 @@ def do(self, player, line, target):


class Hit(TargetAction):
expr = ((pyparsing.Literal("hit") ^
pyparsing.Literal("attack") ^
pyparsing.Literal("kill")) +
expr = (orLiterals(["hit", "attack", "kill"]) +
pyparsing.White() +
pyparsing.restOfLine.setResultsName("target"))

Expand Down
51 changes: 51 additions & 0 deletions src/imaginary/test/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,21 @@ def test_directionalMovement(self):
""])


def test_goClosed(self):
"""
You cannot move through an exit to a "closed" location.
"""
unreachable = objects.Thing(store=self.store, name=u"unreachable")
objects.Container.createFor(unreachable, capacity=1000, closed=True)
objects.Exit.link(self.location, unreachable, u"west")

self._test(
"west",
["The way is shut."],
[],
)


def test_scrutinize(self):
"""
The scrutinize action takes a thing as a target and displays a lot of
Expand Down Expand Up @@ -768,3 +783,39 @@ def test_helpMultiword(self):
self._test("help foo bar", ["baz"], [])
finally:
Help.helpContentPath = original


def test_hit(self):
"""
The hit action removes some hitpoints from the target.
"""
self._violenceTest("hit")


def test_kill(self):
"""
The hit action has I{kill} as an alias.
"""
self._violenceTest("hit")


def test_attack(self):
"""
The hit action has I{attack} as an alias.
"""
self._violenceTest("hit")


def _violenceTest(self, verb):
fuzzy = self.world.create(u"fuzzy", proper=True)
# Flush the buffer to simplify the real assertion.
self.assertCommandOutput(
None,
["Fuzzy arrives."],
["Fuzzy arrives."],
)
self.assertCommandOutput(
verb + " fuzzy",
["You hit fuzzy for [12345] hitpoints."],
["Test Player hits fuzzy."],
)

0 comments on commit 07357e2

Please sign in to comment.