コード例 #1
0
ファイル: house.py プロジェクト: zaghaghi/Tale
            self.tell_others("{Actor} stares at {target} incomprehensibly.",
                             target=actor)
        else:
            message = (parsed.message or parsed.unparsed).lower().split()
            if self.name in message or "cat" in message:
                self.tell_others(
                    "{Actor} looks up at {target} and wiggles %s tail." %
                    self.possessive,
                    target=actor)


cat = Cat(
    "garfield",
    "m",
    race="cat",
    descr=
    "A very obese cat, orange and black. It looks tired, but glances at you happily."
)
livingroom.insert(cat, None)
key = Key(
    "key",
    "small rusty key",
    descr=
    "This key is small and rusty. It has a label attached, reading \"garden door\"."
)
key.key_for(door)
closet.insert(key, None)

closet.insert(woodenYstick.clone(), None)
livingroom.insert(elastic_band.clone(), None)
コード例 #2
0
ファイル: shoppe.py プロジェクト: zaghaghi/Tale
)  # the shopkeeper wants to act on certain things happening in her shop.
shop.add_exits([
    Exit(["door", "out"], "town.lane",
         "A fancy door provides access back to the lane outside.")
])

# provide some items in the shop
clock = gameclock.clone()
clock.value = 500
paper = newspaper.clone()
gem2 = diamond.clone()
gem2.value = 80000
gem3 = gem.clone()
gem3.value = 9055
stick = woodenYstick.clone()
elastic = elastic_band.clone()
shopkeeper.init_inventory([gem2, gem3, toothpick, stick, elastic])
shopkeeper.set_shop(shopinfo)

# some stuff and people that are present in the shoppe
shop.insert(clock, None)
shop.insert(paper, None)
lamp = Item("lamp", "rather small lamp")
lamp.value = 600
customer = CustomerJames(
    "James",
    "m",
    title="Sir James",
    descr="Sir James is trying to sell something, it looks like a lamp.")
lamp.add_extradesc(
    {"lamp"}, "The lamp looks quite old, but otherwise is rather unremarkable."
コード例 #3
0
ファイル: house_tpl.py プロジェクト: irmen/Tale
        if random.random() > 0.7:
            self.location.tell("%s purrs happily." % capital(self.title))
        else:
            self.location.tell("%s yawns sleepily." % capital(self.title))
        # it's possible to stop the periodical calling by setting:  call_periodically(0)(Cat.do_purr)

    def notify_action(self, parsed: ParseResult, actor: Living) -> None:
        if actor is self or parsed.verb in self.verbs:
            return  # avoid reacting to ourselves, or reacting to verbs we already have a handler for
        if parsed.verb in ("pet", "stroke", "tickle", "cuddle", "hug", "caress", "rub"):
            self.tell_others("{Actor} curls up in a ball and purrs contently.")
        elif parsed.verb in AGGRESSIVE_VERBS:
            if self in parsed.who_info:   # only give aggressive response when directed at the cat.
                self.tell_others("{Actor} hisses! I wouldn't make %s angry if I were you!" % self.objective)
        elif parsed.verb in ("hello", "hi", "greet", "meow", "purr"):
            self.tell_others("{Actor} stares at {target} incomprehensibly.", target=actor)
        else:
            message = (parsed.message or parsed.unparsed).lower().split()
            if self.name in message or "cat" in message:
                self.tell_others("{Actor} looks up at {target} and wiggles %s tail." % self.possessive, target=actor)


cat = Cat("garfield", "m", race="cat", descr="A very obese cat, orange and black. It looks tired, but glances at you happily.")
livingroom.insert(cat, None)
key = Key("key", "small rusty key", descr="This key is small and rusty. It has a label attached, reading \"garden door\".")
key.key_for(door)
closet.insert(key, None)

closet.insert(woodenYstick.clone(), None)
livingroom.insert(elastic_band.clone(), None)
コード例 #4
0
ファイル: shoppe.py プロジェクト: irmen/Tale
shop = Shoppe("Curiosity Shoppe", "A weird little shop. It sells odd stuff.")
shop.insert(shopkeeper, None)
shop.get_wiretap().subscribe(shopkeeper)    # the shopkeeper wants to act on certain things happening in her shop.
shop.add_exits([Exit(["door", "out"], "town.lane", "A fancy door provides access back to the lane outside.")])


# provide some items in the shop
clock = gameclock.clone()
clock.value = 500
paper = newspaper.clone()
gem2 = diamond.clone()
gem2.value = 80000
gem3 = gem.clone()
gem3.value = 9055
stick = woodenYstick.clone()
elastic = elastic_band.clone()
shopkeeper.init_inventory([gem2, gem3, toothpick, stick, elastic])
shopkeeper.set_shop(shopinfo)


# some stuff and people that are present in the shoppe
shop.insert(clock, None)
shop.insert(paper, None)
lamp = Item("lamp", "rather small lamp")
lamp.value = 600
customer = CustomerJames("James", "m", title="Sir James", descr="Sir James is trying to sell something, it looks like a lamp.")
lamp.add_extradesc({"lamp"}, "The lamp looks quite old, but otherwise is rather unremarkable."
                             " There is something weird going on with the cord though!")
lamp.add_extradesc({"cord"}, "Even when the lamp doesn't move, the power cord keeps snaking around as if it were alive. How odd.")
customer.insert(lamp, customer)
shop.insert(customer, None)