示例#1
0
    def skill_check(self, skill, die=dice.d20(), adv=False, dis=False):
        # takes the skill, checks skill mod for it, rolls with or without advantage
        if self.ab_mods is None:
            print(
                "Ability modifiers haven't been set, trying to calculate those"
            )
            if self.calc_ab_mods() is False:
                return None
        if self.proficiency is None:
            print(
                f"Proficiency isn't set, set character level which will automatically set proficiency"
            )
            return None
        if self.prof_skills is None:
            print(
                "Can't skill check because proficient skills have not been set"
            )
            return None
        if self.skill_mods is None:
            # if we get this far everything should be good and this can run silently
            if self.calc_skills() is False:
                print(
                    "Error: skill mods are not set and could not be automatically set"
                )
                return None
        if skill not in self.skill_mods:
            print(f"{skill} not found in the skill modifiers")
            return None

        if adv:
            return die.roll(adv=True) + self.skill_mods[skill]
        if dis:
            return die.roll(dis=False) + self.skill_mods[skill]
        return die.roll() + self.skill_mods[skill]
示例#2
0
def test_20roll(fv, roll):
    if fv <= 20:
        return "critical failure"
    else:
        roll = D.d20()
        if roll == 20:
            return test_20roll(fv - 20, roll)
        elif roll <= fv - 20:
            return "success"
        else:
            return "failure"
示例#3
0
def roll_skill(fv):
    roll = D.d20()

    if roll == 1:
        return "perfect"
    elif roll == 20:
        return test_20roll(fv, roll)
    elif roll <= fv:
        return "success"
    else:
        return "failure"
示例#4
0
def combat_start(player, *enemy):
    units = []

    player_d20 = dice.d20()
    player_mod = (player.dex - 10) // 2
    player_roll = player_d20 + player_mod
    player.init_roll = player_roll  # change to initiative_roll
    print(f"Player: {player_d20}, modified to {player_roll}")
    units.append(player)

    for unit in enemy:

        enemy_d20 = dice.d20()
        enemy_mod = (unit.dex - 10) // 2
        enemy_roll = enemy_d20 + enemy_mod
        unit.init_roll = enemy_roll
        print(f"Enemy: {enemy_roll}")
        units.append(unit)
    print(f"Player roll: {player_d20}\nEnemy roll: {enemy_roll}")

    return (units)
示例#5
0
def test_20roll(stat, roll):
    if stat <= 20:

        return 0
    else:
        roll = D.d20()

        if roll == 20:
            return test_20roll(stat - 20, roll)
        elif roll <= stat - 20:

            return 1
        else:

            return 0
示例#6
0
def roll_for_xp(rolls, stat, teacherbonus=0):
    count = 0
    for i in range(rolls):
        roll = D.d20()

        if roll == 20:
            count += test_20roll(stat, roll)
        elif roll == 1:
            xproll = D.d3(1)

            count += xproll
        elif roll < 20:
            roll = roll - teacherbonus
            if roll <= stat:

                count += 1
    return count
示例#7
0
文件: gui.py 项目: juntaizheng/summer
if (E1.get() == ""):
	E1.insert(END, "0")
	E2.insert(END, "0")
	E3.insert(END, "0")
	E4.insert(END, "0")
v=StringVar()
L6 = Label(textvariable=v)
B1 = Button(text="Roll!", command=lambda: v.set(E2.get() + "d(" + E1.get() + '{:+}'.format(int(E3.get())) + ") " + '{:+}'.format(int(E4.get())) + " = "
	'{:+}'.format(dice.roller(int(E1.get()), int(E2.get()), int(E3.get())) + int(E4.get()))))
B2 = Button(text='d2', command=lambda: v.set("d2: " + str(dice.d2())))
B3 = Button(text="d3", command=lambda: v.set("d3: " + str(dice.d3())))
B4 = Button(text="d4", command=lambda: v.set("d4: " + str(dice.d4())))
B6 = Button(text="d6", command=lambda: v.set("d6: " + str(dice.d6())))
B8 = Button(text="d8", command=lambda: v.set("d8: " + str(dice.d8())))
B10 = Button(text="d10", command=lambda: v.set("d10: " + str(dice.d10())))
B20 = Button(text="d20", command=lambda: v.set("d20: " + str(dice.d20())))
B100 = Button(text="d100", command=lambda: v.set("d100: " + str(dice.d100())))
L1.grid(row=0, column=0, columnspan=1)
E1.grid(row=1, column=0, columnspan=1)
L2.grid(row=2, column=0, columnspan=1)
E2.grid(row=3, column=0, columnspan=1)
L3.grid(row=4, column=0, columnspan=1)
E3.grid(row=5, column=0, columnspan=1)
L4.grid(row=6, column=0, columnspan=1)
E4.grid(row=7, column=0, columnspan=1)
L5.grid(row=8, column=0, columnspan=1, sticky=W)
L6.grid(row=9, column=0, columnspan=1, sticky=W)
B1.grid(row=0, column=1, columnspan=1, sticky=W, padx = 10)
B2.grid(row=0, column=2, columnspan=1, sticky=W, padx = 10)
B3.grid(row=0, column=3, columnspan=1, sticky=W, padx = 10)
B4.grid(row=2, column=1, columnspan=1, sticky=W, padx = 10)
示例#8
0
# using dnd character classes to practice python classes and (more importantly) class inheritance

# not sure what main will be used for, lol

import dice
import class_types
import armor

# testing Dice
d4 = dice.d4()
d6 = dice.d6()
d8 = dice.d8()
d10 = dice.d10()
d12 = dice.d12()
d20 = dice.d20()
"""
print(f"Rolling d4: {d4.roll()}")
print(f"Rolling d4: {d4.roll()}")
print(f"Rolling d4: {d4.roll()}")

print(f"Rolling d6: {d6.roll()}")
print(f"Rolling d8: {d8.roll()}")
print(f"Rolling d20: {d20.roll()}")

print(f"Rolling 4d6, indiv: {d6.roll_indiv(4)}")
print(f"Rolling 6d8, summed: {d8.roll_sum(4)}")
"""

Drat = class_types.Bard("Drat of Hithendale")

Drat.say_name()