Run black reformatter on code

This commit is contained in:
Griatch 2022-02-08 13:03:52 +01:00
parent 4582eb4085
commit bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions

View file

@ -42,6 +42,7 @@ from evennia.utils.utils import delay, repeat, interactive
# Commands for the state when the lid covering the button is closed.
class CmdPushLidClosed(Command):
"""
Push the red button (lid closed)
@ -121,23 +122,27 @@ class CmdSmashGlass(Command):
"""
rand = random.random()
self.caller.location.msg_contents(
f"{self.caller.name} tries to smash the glass of the button.",
exclude=self.caller)
f"{self.caller.name} tries to smash the glass of the button.", exclude=self.caller
)
if rand < 0.2:
string = ("You smash your hand against the glass"
" with all your might. The lid won't budge"
" but you cause quite the tremor through the button's mount."
"\nIt looks like the button's lamp stopped working for the time being, "
"but the lid is still as closed as ever.")
string = (
"You smash your hand against the glass"
" with all your might. The lid won't budge"
" but you cause quite the tremor through the button's mount."
"\nIt looks like the button's lamp stopped working for the time being, "
"but the lid is still as closed as ever."
)
# self.obj is the button itself
self.obj.break_lamp()
elif rand < 0.6:
string = "You hit the lid hard. It doesn't move an inch."
else:
string = ("You place a well-aimed fist against the glass of the lid."
" Unfortunately all you get is a pain in your hand. Maybe"
" you should just try to just ... open the lid instead?")
string = (
"You place a well-aimed fist against the glass of the lid."
" Unfortunately all you get is a pain in your hand. Maybe"
" you should just try to just ... open the lid instead?"
)
self.caller.msg(string)
@ -165,8 +170,8 @@ class CmdOpenLid(Command):
string += "the lid will soon close again."
self.caller.msg(string)
self.caller.location.msg_contents(
f"{self.caller.name} opens the lid of the button.",
exclude=self.caller)
f"{self.caller.name} opens the lid of the button.", exclude=self.caller
)
self.obj.to_open_state()
@ -200,6 +205,7 @@ class LidClosedCmdSet(CmdSet):
# Commands for the state when the button's protective cover is open - now the
# push command will work. You can also close the lid again.
class CmdPushLidOpen(Command):
"""
Push the red button
@ -225,15 +231,15 @@ class CmdPushLidOpen(Command):
"""
# pause a little between each message.
self.caller.msg("You reach out to press the big red button ...")
yield(2) # pause 2s before next message
yield (2) # pause 2s before next message
self.caller.msg("\n\n|wBOOOOM! A bright light blinds you!|n")
yield(1) # pause 1s before next message
yield (1) # pause 1s before next message
self.caller.msg("\n\n|xThe world goes dark ...|n")
name = self.caller.name
self.caller.location.msg_contents(
f"{name} presses the button. BOOM! {name} is blinded by a flash!",
exclude=self.caller)
f"{name} presses the button. BOOM! {name} is blinded by a flash!", exclude=self.caller
)
self.obj.blind_target(self.caller)
@ -259,8 +265,8 @@ class CmdCloseLid(Command):
# this will clean out scripts dependent on lid being open.
self.caller.msg("You close the button's lid. It clicks back into place.")
self.caller.location.msg_contents(
f"{self.caller.name} closes the button's lid.",
exclude=self.caller)
f"{self.caller.name} closes the button's lid.", exclude=self.caller
)
class LidOpenCmdSet(CmdSet):
@ -286,6 +292,7 @@ class LidOpenCmdSet(CmdSet):
# Commands for when the button has been pushed and the player is blinded. This
# replaces commands on the player making them 'blind' for a while.
class CmdBlindLook(Command):
"""
Looking around in darkness
@ -317,12 +324,14 @@ class CmdBlindLook(Command):
string = "You fumble around, hands outstretched. You bump your knee."
else:
# trying to look
string = ("You are temporarily blinded by the flash. "
"Until it wears off, all you can do is feel around blindly.")
string = (
"You are temporarily blinded by the flash. "
"Until it wears off, all you can do is feel around blindly."
)
self.caller.msg(string)
self.caller.location.msg_contents(
f"{self.caller.name} stumbles around, blinded.",
exclude=self.caller)
f"{self.caller.name} stumbles around, blinded.", exclude=self.caller
)
class CmdBlindHelp(Command):
@ -420,20 +429,26 @@ class RedButton(DefaultObject):
`button = create_object(RedButton, ..., attributes=[('desc', 'my desc')])`.
"""
# these are the pre-set descriptions. Setting attributes will override
# these on the fly.
desc_closed_lid = ("This is a large red button, inviting yet evil-looking. "
"A closed glass lid protects it.")
desc_open_lid = ("This is a large red button, inviting yet evil-looking. "
"Its glass cover is open and the button exposed.")
desc_closed_lid = (
"This is a large red button, inviting yet evil-looking. " "A closed glass lid protects it."
)
desc_open_lid = (
"This is a large red button, inviting yet evil-looking. "
"Its glass cover is open and the button exposed."
)
auto_close_msg = "The button's glass lid silently slides back in place."
lamp_breaks_msg = "The lamp flickers, the button going dark."
desc_add_lamp_broken = "\nThe big red button has stopped blinking for the time being."
# note that this is a list. A random message will display each time
blink_msgs = ["The red button flashes briefly.",
"The red button blinks invitingly.",
"The red button flashes. You know you wanna push it!"]
blink_msgs = [
"The red button flashes briefly.",
"The red button blinks invitingly.",
"The red button flashes. You know you wanna push it!",
]
def at_object_creation(self):
"""
@ -523,9 +538,9 @@ class RedButton(DefaultObject):
self.cmdset.add(LidOpenCmdSet)
# wait 20s then call self.to_closed_state with a message as argument
delay(35, self.to_closed_state,
self.db.auto_close_msg or self.auto_close_msg,
persistent=True)
delay(
35, self.to_closed_state, self.db.auto_close_msg or self.auto_close_msg, persistent=True
)
def _unblind_target(self, caller):
"""
@ -536,7 +551,8 @@ class RedButton(DefaultObject):
caller.msg("You blink feverishly as your eyesight slowly returns.")
self.location.msg_contents(
f"{caller.name} seems to be recovering their eyesight, blinking feverishly.",
exclude=caller)
exclude=caller,
)
def blind_target(self, caller):
"""
@ -554,8 +570,7 @@ class RedButton(DefaultObject):
# wait 20s then call self._unblind to remove blindness effect. The
# persistent=True means the delay should survive a server reload.
delay(20, self._unblind_target, caller,
persistent=True)
delay(20, self._unblind_target, caller, persistent=True)
def _unbreak_lamp(self):
"""

View file

@ -65,8 +65,10 @@ def info2(caller):
def info3(caller):
text = ("'Well ... I'm sort of busy so, have to go. NPC business. "
"Important stuff. You wouldn't understand.'")
text = (
"'Well ... I'm sort of busy so, have to go. NPC business. "
"Important stuff. You wouldn't understand.'"
)
options = (
{"desc": "Oookay ... I won't keep you. Bye.", "goto": "END"},
@ -91,15 +93,15 @@ def END(caller):
class CmdTalk(default_cmds.MuxCommand):
"""
Talks to an npc
Talks to an npc
Usage:
talk
Usage:
talk
This command is only available if a talkative non-player-character
(NPC) is actually present. It will strike up a conversation with
that NPC and give you options on what to talk about.
"""
This command is only available if a talkative non-player-character
(NPC) is actually present. It will strike up a conversation with
that NPC and give you options on what to talk about.
"""
key = "talk"
locks = "cmd:all()"
@ -113,8 +115,11 @@ class CmdTalk(default_cmds.MuxCommand):
# Initiate the menu. Change this if you are putting this on
# some other custom NPC class.
EvMenu(self.caller, "evennia.contrib.tutorials.talking_npc.talking_npc",
startnode="menu_start_node")
EvMenu(
self.caller,
"evennia.contrib.tutorials.talking_npc.talking_npc",
startnode="menu_start_node",
)
class TalkingCmdSet(CmdSet):

View file

@ -1158,7 +1158,8 @@ class TutorialWeaponRack(TutorialObject):
|wstab/thrust/pierce <target>|n - poke at the enemy. More damage but harder to hit.
|wslash/chop/bash <target>|n - swipe at the enemy. Less damage but easier to hit.
|wdefend/parry|n - protect yourself and make yourself harder to hit.)
""").strip()
"""
).strip()
self.db.no_more_weapons_msg = "you find nothing else of use."
self.db.available_weapons = ["knife", "dagger", "sword", "club"]

View file

@ -78,6 +78,7 @@ class CmdTutorial(Command):
helptext += "\n\n (Write 'give up' if you want to abandon your quest.)"
caller.msg(helptext)
# for the @detail command we inherit from MuxCommand, since
# we want to make use of MuxCommand's pre-parsing of '=' in the
# argument.
@ -202,22 +203,26 @@ class CmdTutorialLook(default_cmds.CmdLook):
looking_at_obj.at_desc(looker=caller)
return
class CmdTutorialGiveUp(default_cmds.MuxCommand):
"""
Give up the tutorial-world quest and return to Limbo, the start room of the
server.
"""
key = "give up"
aliases = ['abort']
aliases = ["abort"]
def func(self):
outro_room = OutroRoom.objects.all()
if outro_room:
outro_room = outro_room[0]
else:
self.caller.msg("That didn't work (seems like a bug). "
"Try to use the |wteleport|n command instead.")
self.caller.msg(
"That didn't work (seems like a bug). "
"Try to use the |wteleport|n command instead."
)
return
self.caller.move_to(outro_room)
@ -312,6 +317,7 @@ class TutorialStartExit(DefaultExit):
will also clean up the intro command.
"""
def at_object_creation(self):
self.cmdset.add(CmdSetEvenniaIntro, persistent=True)
@ -397,6 +403,7 @@ SUPERUSER_WARNING = (
#
# -------------------------------------------------------------
class CmdEvenniaIntro(Command):
"""
Start the Evennia intro wizard.
@ -405,10 +412,12 @@ class CmdEvenniaIntro(Command):
intro
"""
key = "intro"
def func(self):
from .intro_menu import init_menu
# quell also superusers
if self.caller.account:
self.caller.msg("Auto-quelling permissions while in intro ...")
@ -463,6 +472,7 @@ class IntroRoom(TutorialRoom):
character.account.execute_cmd("quell")
character.msg("(Auto-quelling while in tutorial-world)")
# -------------------------------------------------------------
#
# Bridge - unique room
@ -1176,4 +1186,3 @@ class OutroRoom(TutorialRoom):
def at_object_leave(self, character, destination):
if character.account:
character.account.execute_cmd("unquell")