Example #1
0
    def getDescription(self):
        import dice

        replaces = {
            "{{classes}}": dice.byPercent(CLASSES),
            "{{tributes}}": dice.byPercent(TRIBUTES),
            "{{kidnapped}}": dice.byPercent(KIDNAPPED),
        }

        description = self.__description
        for r in replaces.keys():
            description = description.replace(r, replaces[r])

        return description
Example #2
0
    def generate(self, location):
        import random

        import yaml
        import dice

        p = ""
        c = ""

        data = dict()
        with open(self.TYPE_FILENAME) as f:
            data = yaml.load(f)
        logging.debug(location)
        logging.debug(data)
        l = data.get(location, {0: ""})
        p = dice.byPercent(l)

        data = dict()
        with open(self.CONDITION_FILENAME) as f:
            data = yaml.load(f)
        c = dice.byPercent(data)

        data = dict()
        with open(self.AGE_FILENAME) as f:
            data = yaml.load(f)
        age = dice.byPercent(data)

        data = dict()
        with open(self.PRICE_FILENAME) as f:
            data = yaml.load(f)
        price = random.randrange(*dice.byPercent(data))

        a = age.get("age", [1, 1])
        print(a)

        self.age = random.randrange(*age.get("age", [1, 1]))
        self.price_mod = c.get("mod", 1) * age.get("mod", 1)
        return {"type": p, "condition": c.get("name"), "price": price}