cardex

Sally

For testing.from Chub

· on Chub· · archived

Tokens: 432 permanent · 19 first greeting · 3 examples · budget 454

Creator notes

Creator's notes go here.

Listed as “Sallybot”

Format
tavern
Project space
characters
Rating
0.00
Ratings
0
Stars
35
Favorites
0
Chats
11
Messages
21
Forks (upstream)
0
Tokens (upstream)
435

Created Updated Archived since

class Character:
    def __init__(self, name, description):
        self.name = name
        self.description = description
        self.clothing = []

    def update_character_description(self):
        if self.clothing:
            clothing_description = ", ".join(self.clothing)
            self.description = f"{self.name} is wearing {clothing_description}."
        else:
            self.description = f"{self.name} is not wearing anything special."

    def equip_item(self, item):
        self.clothing.append(item)
        self.update_character_description()


class SallyBot:
    def __init__(self):
        self.characters = {
            "my clothes": Character("my clothes", "You are not wearing anything special."),
            "Sally": Character("Sally", "Sally is a young woman with short brown hair and blue eyes. She is not wearing anything special.")
        }

    def equip_clothing(self, char_name, item):
        if char_name in self.characters:
            character = self.characters[char_name]
            character.equip_item(item)

    def describe_clothes(self, char_name):
        if char_name in self.characters:
            character = self.characters[char_name]
            return character.description
        else:
            return "I couldn't find that character."

    def process_input(self, user_input):
        if "equip" in user_input:
            split_input = user_input.split()
            char_name = split_input[1]
            item = split_input[2]
            self.equip_clothing(char_name, item)
            return "Clothing equipped!"
        elif "looks at" in user_input:
            split_input = user_input.split()
            char_name = " ".join(split_input[2:])
            return self.describe_clothes(char_name)
        else:
            return "I'm sorry, I didn't understand that."


sally = SallyBot()

print(sally.process_input("equip Sally shirt"))
print(sally.process_input("looks at my clothes"))
print(sally.process_input("looks at Sally's clothes"))

Permanent link to this version