Better introduction with a letter
This commit is contained in:
parent
a224b0e493
commit
d1b3f98820
2 changed files with 71 additions and 9 deletions
|
|
@ -9,6 +9,7 @@ creation commands.
|
|||
"""
|
||||
|
||||
from evennia.objects.objects import DefaultCharacter
|
||||
from evennia.prototypes.spawner import spawn
|
||||
|
||||
from utils.word_list import Token, routput
|
||||
from .objects import Object
|
||||
|
|
@ -23,6 +24,35 @@ class Character(Object, DefaultCharacter):
|
|||
properties and methods available on all Object child classes like this.
|
||||
|
||||
"""
|
||||
def at_object_creation(self):
|
||||
"called when a character is first created."
|
||||
letter = spawn({
|
||||
"typeclass": "typeclasses.readables.Letter",
|
||||
"key": "letter",
|
||||
"desc": "A letter of familiar penmanship stuffed in an envelope.",
|
||||
})[0]
|
||||
letter.db.inside = f"""You read a letter with an oddly familiar penmanship:
|
||||
|
||||
My dearest {self.name},
|
||||
|
||||
If you are reading this, you've found the world I was overly excited in relaying to you over drinks in Marsivan. Most excellent. Enjoy this halcyon world, unspoiled and idyllic.
|
||||
|
||||
I'm here, so join me in a cup of tea and we can reconnect and reminisce of glorious days gone by, and the utter curiosity that surrounds us.
|
||||
|
||||
Your friend,
|
||||
Dabbler
|
||||
|
||||
(Type 'help me start' for details on playing this game)
|
||||
"""
|
||||
letter.location = self
|
||||
|
||||
self.msg("""
|
||||
As the surrounding mists dissipate, you find yourself in an ancient, halcyon forest dripping with moss.
|
||||
|
||||
You see an envelope of parchment wedged under a scaly protrusion of bark...inside, a letter in familiar penmanship, personally addressed to you, which you pick up.
|
||||
|
||||
(Type 'inventory' or 'inv' or just 'i' to see what you carry).""")
|
||||
|
||||
def do_take(self, args):
|
||||
"""
|
||||
A character has a _steal_command. What are the limitations?
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from evennia import Command, CmdSet
|
||||
from evennia.utils import logger
|
||||
from evennia.prototypes.spawner import spawn
|
||||
|
||||
from typeclasses.objects import Object
|
||||
from typeclasses.rooms import DabblersRoom
|
||||
from evennia import Command, CmdSet
|
||||
from evennia.prototypes.spawner import spawn
|
||||
from utils.word_list import routput, Token
|
||||
|
||||
import random
|
||||
|
|
@ -99,8 +101,8 @@ class CmdBurnBook(Command):
|
|||
"""
|
||||
Destroy the instance of the book
|
||||
"""
|
||||
key = "burn book"
|
||||
aliases = "burn book"
|
||||
key = "burn"
|
||||
aliases = "throw"
|
||||
|
||||
def func(self):
|
||||
self.obj.do_burn(self.caller)
|
||||
|
|
@ -109,8 +111,8 @@ class CmdDropBook(Command):
|
|||
"""
|
||||
Drop the instance of the book
|
||||
"""
|
||||
key = "drop book"
|
||||
aliases = "throw book"
|
||||
priority = 3
|
||||
key = "drop"
|
||||
|
||||
def func(self):
|
||||
self.obj.do_burn(self.caller, drop=True)
|
||||
|
|
@ -133,16 +135,46 @@ class CmdSetShelf(CmdSet):
|
|||
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
class Book(Object):
|
||||
class Readable(Object):
|
||||
"""
|
||||
Create with a command:
|
||||
|
||||
@create/drop sign : typeclasses.readables.Readable
|
||||
@desc sign = A tall wooden post.
|
||||
@set sign/inside = "What happens when you read it."
|
||||
"""
|
||||
def at_object_creation(self):
|
||||
"""
|
||||
called at creation
|
||||
"""
|
||||
self.cmdset.add_default(CmdSetBook, persistent=True)
|
||||
self.cmdset.add_default(CmdSetBook)
|
||||
|
||||
def do_read(self, reader):
|
||||
"called when 'read'."
|
||||
reader.msg(self.db.inside)
|
||||
self.location.msg_contents(routput(f"{reader.name} reads a book. You notice the title, |b{0}|n.".format(self.db.title)), exclude=reader)
|
||||
|
||||
|
||||
class Letter(Readable):
|
||||
"""
|
||||
Something that can be read, but is _personal_, so if it is
|
||||
dropped, it is destroyed.
|
||||
"""
|
||||
def at_pre_drop(self, dropper):
|
||||
dropper.msg("Hrm ... you don't want to litter in such an idyllic location. But you can |bthrow|n it away.")
|
||||
return False
|
||||
|
||||
def do_burn(self, thrower, drop=False):
|
||||
if isinstance(thrower.location, DabblersRoom):
|
||||
thrower.msg(f"You throw {self.name} into the fire to burn it.")
|
||||
else:
|
||||
thrower.msg(f"You throw {self.name} away.")
|
||||
self.delete()
|
||||
|
||||
|
||||
class Book(Readable):
|
||||
def do_read(self, reader):
|
||||
super().do_read(reader)
|
||||
reader.location.msg_contents(routput(f"{reader.name} reads a book. You notice the title, |b{0}|n.".format(self.db.title)), exclude=reader)
|
||||
|
||||
def do_burn(self, reader, drop=False):
|
||||
if isinstance(reader.location, DabblersRoom):
|
||||
|
|
|
|||
Loading…
Reference in a new issue