예제 #1
0
def make_rolls(caller):
    menu = caller.ndb._menutree
    roll_count = menu.roll_count
    roll_count -= 1
    plural = "s" if roll_count != 1 else ""
    rolls = []
    for _ in range(6):
        rolls.append(rulebook.d_roll('4d6-1L'))
    rolls.sort(reverse=True)
    show = []
    choice = menu.choice
    for each in range(6):  # Combine sorted rolls with stat priorities.
        show.append(choice[each] + ": " + str(rolls[each]))
    text = ", ".join(show) + "\n"  # Add newline; more text to come!
    if roll_count:  # Rolls remain to be made.
        text += "You have {count} roll{plural} remaining.".format(
            count=roll_count, plural=plural)
        options = ({
            "desc": "Accept this roll.",
            "key": "A",
            "goto": "show_stats"
        }, )
        options += ({
            "desc": "Press [|w|lc|ltEnter|le|n] to roll again.",
            "key": "E",
            "goto": "make_rolls"
        }, )
        options += ({"key": "_default", "goto": "make_rolls"}, )
    else:  # All rolls have been used.
        text += "Last roll completed. Press enter to continue."
        options = ({"key": "_default", "goto": "show_stats"}, )
    menu.rolls = rolls
    menu.roll_count = roll_count
    return text, options
예제 #2
0
    def death_spike(self):
        caller = self.caller
        target = self.target
        ttr = target.traits
        sk = self.caller.skills
        resist = ttr.MDEF.actual - sk.SPC.actual
        damage = d_roll("{}d6".format((sk.NEC.actual // 3) + 1))

        self.item.delete()
        caller.msg(
            '|MWith a wave of your hand, you send the spike of bone into {target}.|n '
        )
        caller.location.msg_contents(
            "|MWith a wave of <> hand,{actor} spends a spike of bone into {target}.|n",
            mapping=dict(actor=caller, target=self.target),
            exclude=caller)
        if resist >= 0:
            ttr.HP.current -= damage - resist
        else:
            ttr.HP.current -= damage
        # if the spell was successfully cast, store the casting time
        caller.db.ds_lc = time.time()
        # set up combat
        if target.ndb.combat_handler:
            # target is already in combat - join it
            target.ndb.combat_handler.add_character(self.caller)
            target.ndb.combat_handler.msg_all("%s joins combat!" % self.caller)
        else:
            # create a new combat handler
            chandler = create_script("combat_handler.CombatHandler")
            chandler.add_character(self.caller)
            chandler.add_character(target)
            self.caller.msg("Battle with %s begins." % target)
            target.msg("Battle with %s begins" % self.caller)
예제 #3
0
 def storage(self):
     # remove the body
     self.obj.location.msg_contents("The body of {npc} rots away to dust.",
                                    mapping={'npc': self.obj},
                                    exclude=self.obj)
     limbo = self.obj.search('Limbo', global_search=True)
     self.obj.move_to(limbo, quiet=True, move_hooks=False)
     self.db.death_step += 1
     delay(10 * d_roll('1d12') + 30,
           getattr(self, self.db.death_sequence[self.db.death_step]))
예제 #4
0
    def at_start(self):
        """Handles the 'phases' of death"""
        super(NPCDeathHandler, self).at_start()
        self.obj.location.msg_contents("{character} falls dead.",
                                       mapping={'character': self.obj},
                                       exclude=self.obj)

        self.obj.db.pose = self.obj.db.pose_death
        delay(10 * d_roll('1d6'),
              getattr(self, self.db.death_sequence[self.db.death_step]))
예제 #5
0
파일: chargen.py 프로젝트: evennia/ainneve
def menunode_allocate_skills(caller, raw_string):
    """Skill -1 counter allocation menu node."""
    char = caller.new_char
    sk = char.skills
    total = 3
    counts = {1: 'one', 2: 'two', 3: 'three'}

    plusses = (ceil(char.traits.INT.actual / 3.0) -
               sum(sk[s].plus for s in skills.ALL_SKILLS))
    minuses = total - sum(sk[s].minus for s in skills.ALL_SKILLS)

    text = ""
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(skills.ALL_SKILLS):
        skill = sk[skills.ALL_SKILLS[int(raw_string) - 1]]
        if minuses:
            if skill.actual - skill.minus - 1 > 0:
                skill.minus += 1
                minuses -= 1
            else:
                text += "|rSkills cannot be reduced below one.|n\n"
        elif plusses:
            if skill.actual + skill.plus + 1 <= 10:
                skill.plus += 1
                plusses -= 1
            else:
                text += "|rSkills cannot be increased above ten.|n\n"

    if plusses or minuses:
        text += "{}\n\n".format(raw_string) if raw_string and raw_string[0] == 'F' else ""
        text += "Your ability to perform actions in Ainneve is\n"
        text += "tied to your character's skills.\n"

        if minuses:
            text += "Please allocate |w{}|n |m'-1'|n counter{}.".format(
                        counts[minuses],
                        's' if minuses != 1 else '')
        elif plusses:
            text += "Please allocate |w{}|n |m'+1'|n counter{}.".format(
                        counts[plusses],
                        's' if plusses != 1 else '')

        help = "Skill allocation is a two step process. First, you\n"
        help += "distribute three '-1' counters across your skills,\n"
        help += "then a number of '+1' counters equal to your Intelligence\n"
        help += "divided by 3."

        options = [{"desc": _format_skill_opts(sk[s]),
                    "goto": "menunode_allocate_skills"}
                   for s in skills.ALL_SKILLS]

        def clear_skills(s):
            """Reset plus and minus counters on all skills."""
            for skill in skills.ALL_SKILLS:
                sk[skill].plus = 0
                sk[skill].minus = 0

        options.append({"desc": "Start Over",
                        "exec": clear_skills,
                        "goto": "menunode_allocate_skills"})
        return (text, help), options
    else:
        skills.finalize_skills(char.skills)
        data = []
        for i in xrange(3):
            data.append([_format_trait_opts(sk[s], color='|M')
                         for s in skills.ALL_SKILLS[i::3]])
        table = EvTable(header=False, table=data)
        output = "Final Skills:\n"
        output += "{skills}\n"

        char.db.wallet['SC'] = d_roll('2d6+3')
        output += "You begin with |w{sc} SC|n (Silver Coins)."

        return menunode_equipment_cats(
            caller,
            output.format(skills=table, sc=char.db.wallet['SC'])
        )
예제 #6
0
def menunode_allocate_skills(caller, raw_string):
    """Skill -1 counter allocation menu node."""
    char = caller.new_char
    sk = char.skills
    total = 3
    counts = {1: 'one', 2: 'two', 3: 'three'}

    plusses = (ceil(char.traits.INT.actual / 3.0) -
               sum(sk[s].plus for s in skills.ALL_SKILLS))
    minuses = total - sum(sk[s].minus for s in skills.ALL_SKILLS)

    text = ""
    raw_string = raw_string.strip()
    if raw_string.isdigit() and int(raw_string) <= len(skills.ALL_SKILLS):
        skill = sk[skills.ALL_SKILLS[int(raw_string) - 1]]
        if minuses:
            if skill.actual - skill.minus - 1 > 0:
                skill.minus += 1
                minuses -= 1
            else:
                text += "|rSkills cannot be reduced below one.|n\n"
        elif plusses:
            if skill.actual + skill.plus + 1 <= 10:
                skill.plus += 1
                plusses -= 1
            else:
                text += "|rSkills cannot be increased above ten.|n\n"

    if plusses or minuses:
        text += "{}\n\n".format(
            raw_string) if raw_string and raw_string[0] == 'F' else ""
        text += "Your ability to perform actions in Ainneve is\n"
        text += "tied to your character's skills.\n"

        if minuses:
            text += "Please allocate |w{}|n |m'-1'|n counter{}.".format(
                counts[minuses], 's' if minuses != 1 else '')
        elif plusses:
            text += "Please allocate |w{}|n |m'+1'|n counter{}.".format(
                counts[plusses], 's' if plusses != 1 else '')

        help = "Skill allocation is a two step process. First, you\n"
        help += "distribute three '-1' counters across your skills,\n"
        help += "then a number of '+1' counters equal to your Intelligence\n"
        help += "divided by 3."

        options = [{
            "desc": _format_skill_opts(sk[s]),
            "goto": "menunode_allocate_skills"
        } for s in skills.ALL_SKILLS]

        def clear_skills(s):
            """Reset plus and minus counters on all skills."""
            for skill in skills.ALL_SKILLS:
                sk[skill].plus = 0
                sk[skill].minus = 0

        options.append({
            "desc": "Start Over",
            "exec": clear_skills,
            "goto": "menunode_allocate_skills"
        })
        return (text, help), options
    else:
        skills.finalize_skills(char.skills)
        data = []
        for i in xrange(3):
            data.append([
                _format_trait_opts(sk[s], color='|M')
                for s in skills.ALL_SKILLS[i::3]
            ])
        table = EvTable(header=False, table=data)
        output = "Final Skills:\n"
        output += "{skills}\n"

        char.db.wallet['SC'] = d_roll('2d6+3')
        output += "You begin with |w{sc} SC|n (Silver Coins)."

        return menunode_equipment_cats(
            caller, output.format(skills=table, sc=char.db.wallet['SC']))
예제 #7
0
        'lockpick': 1,
        'listen': 1,
        'sense': 1,
        'appraise': 1,
        'medicine': 1,
        'survival': 1,
        'balance': 1,
        'sneak': 1,
        'throwing': 1,
        'animal': 1,
        'barter': 1,
        'leadership': 1
    },
}

GOBLIN = {
    "key": "a tiny little goblin",
    "aliases": ["goblin", "tiny"],
    "tag": ["NPC"],
    "typeclass": "typeclasses.characters.NPC",
    "desc": "It's a little green goblin. It wants your love and affection",
    "traits": {
        'STR': lambda: d_roll('1d8'),
        'DEX': lambda: d_roll('1d8')
    },
    "skills": {
        'escape': 10,
        'barter': 3
    },
}
예제 #8
0
    "key": "an orc npc",
    "sdesc": lambda: "{}, {} orc".format(random.choice(orc_adj_1),random.choice(orc_adj_2)),
    "tags": ["NPC", "AGGRESSIVE"],
    "exec": "obj.execute_cmd('say My tags include {}'.format(obj.db.tag))",
    "typeclass": "typeclasses.characters.NPC",
    "desc": "An intellectual creature at heart, the orc is a misunderstood beast who simply desires to be understood and loved. It expresses this love through extreme violence.",
    "traits": {'STR': 5, 'DEX': 5, 'PER': 5, 'CHA': 5, 'INT': 5, 'VIT': 5,
               'BM': 5, 'WM': 5, 'MAG': 10,
               'REFL': 5, 'FORT': 5, 'WILL': 5, 'ENC': 50,
               'HP': 5, 'MV': 5, 'SP': 5, 'LV': 1, 'ACT': 5,
               'ATKM': 5, 'DEF': 5, 'ATKR': 5, 'PP': 5, 'ATKU': 5},
    "skills": {'escape': 1, 'climb': 1, 'jump': 1,
               'lockpick': 1, 'listen': 1, 'sense': 1,
               'appraise': 1, 'medicine': 1, 'survival': 1,
               'balance': 1, 'sneak': 1, 'throwing': 1,
               'animal': 1, 'barter': 1, 'leadership': 1},
}


GOBLIN = {
    "key": "a tiny little goblin",
    "aliases": ["goblin", "tiny"],
    "tags": ["NPC"],
    "typeclass": "typeclasses.characters.NPC",
    "desc": "It's a little green goblin. It wants your love and affection",
    "traits": {'STR': lambda: d_roll('1d8'), 'DEX': lambda: d_roll('1d8')},
    "skills": {'escape': 10, 'barter': 3},
}