예제 #1
0
    def outfit(self):

        a = genarmor(self.clas, self.level)
        self.armor = a[0]
        self.armorvalue = a[1]
        self.movement = a[2]

        m = genmeleeweapon(self.clas, self.level)
        self.meleeweapon = m[0]
        self.damage = m[2]

        if m[1] < 2:
            s = genshield(self.clas, self.level)
            self.shield = s[1]
            self.shieldvalue = s[2]

        if self.clas == 2:
            if Dice.D(1, 100) < min(95, self.level * 4):
                self.ringpro = Dice.tableroller(ringprobonus)[1]

        self.potion = genpotion(self.clas, self.level)
        self.scroll = genscroll(self.clas, self.level)

        if self.clas == 0 or self.clas == 2:  # generate spells
            self.spells = Spells.genspells(self.clas, self.level)

        self.calc()
예제 #2
0
 def __init__(self):
     _Treasure.Item.__init__(self)
     self.cat = "Art"
     self.fullcat = self.fullcat + "." + self.cat
     row = Dice.Roll(_art_types_table)
     self.name = self.shortname = row[1]
     self.value = float(Dice.D(2, 8, 0) * 100)
예제 #3
0
def makename():
    if Dice.D(1, 100) <= 25:
        # 2 names
        return "%s %s" % (random.choice(names), random.choice(names))
    else:
        # 1 name
        return random.choice(names)
예제 #4
0
def magicarmor(c, chance):
    if Dice.D(1, 100) > min(95, c.level * chance):
        return
    if c.armor == "":
        return
    bonus = Dice.tableroller(armorbonus)[1]
    c.armor = "%s +%d" % (c.armor, bonus)
    c.armorvalue = c.armorvalue + bonus
예제 #5
0
def genscroll(cclass, level):
    if Dice.D(1, 100) < (level * 3):
        scroll = Dice.tableroller(scrolltable[cclass])[1]
        if type(scroll) is tuple:
            scrollspells = Spells.genscroll(scroll[0], scroll[1])
            scroll = "Scroll of %s Spells: %s" \
                   % (classnames[cclass], string.join(scrollspells, ", "))
        return scroll
    return ""
예제 #6
0
 def rollhp(self):
     hp = 0
     for i in range(min(self.level, 9)):
         roll = Dice.D(1,
                       hitdice[self.clas][0]) + statbonuses[self.stats[4]]
         hp = hp + max(roll, 1)
     if self.level > 9:
         hp = hp + (hitdice[self.clas][1] * (self.level - 9))
     return hp
예제 #7
0
def Treasure(typ):
    tr = []
    try:
        tbl = _treasure_table[string.upper(typ)]
        for i in tbl:
            if Dice.D(1, 100, 0) <= i[0]:
                tr = tr + i[1](i[2])
    except:
        tr = [ Unknown.Unknown(typ) ]
    return tr
예제 #8
0
def genpotion(cclass, level):
    rc = [0, "", 0]
    if Dice.D(1, 100) < (level * 2):
        rc = Dice.tableroller(potiontable)
        while rc[2] != -1 and rc[2] != cclass:
            rc = Dice.tableroller(potiontable)
        if rc[1] == "Delusion":
            rc2 = Dice.tableroller(potiontable)
            rc = [rc[0], "Delusion (%s)" % rc2[1], rc[2]]
    return rc[1]
예제 #9
0
def makedungeon(level, rooms, first=1):

    body = []

    body.append("<p class='Text Body'>\n<b>%d Rooms on Level %d</b>" %
                (rooms, level))

    for i in range(rooms):
        row = Dice.tableroller(dungeon_table)
        contents = row[1](row, level)
        items = []
        if Dice.D(1, 2) == 1 or row[2] == "Empty":
            for j in range(Dice.D(1, 3)) or row[2] == "Empty":
                items.append(Dice.tableroller(Items.itemtable)[1])
        body.append(
            "<p class='Text Body'>\n<b>Room %d:</b> %s\n<p class='Text Body'>\n%s"
            % (i + first, string.join(items, ", "), contents))

    return string.join(body, "\n")
예제 #10
0
def genshield(cclass, level):

    if cclass > 1:
        return [0, "", 0]

    arm = [0, "Shield", 1]

    # is it magical?
    if Dice.D(1, 100) < min(95, level * 5):
        row = Dice.tableroller(armorbonus)
        arm[1] = "%s +%d" % (arm[1], row[1])
        arm[2] = arm[2] + row[1]

    return arm
예제 #11
0
def pirates():

    party = []

    # how many flunkies?

    mooks = Dice.D(3, 8)
    mates = Dice.D(1, 3)

    # captain
    character = Pirate(Dice.D(1, 4) + 2, 1)
    character.outfit(1)
    character.name = "Captain " + character.name
    party.append(character)

    # mates
    for i in range(mates):
        character = Pirate(Dice.D(1, 4) + 1, 1)
        character.outfit(1)
        party.append(character)

    # mooks

    nmooks = mooks

    while nmooks:
        character = Pirate(1, 1)
        character.outfit(0)
        character.name = ""
        character.noapp = min(nmooks, Dice.D(1, mooks))
        nmooks -= character.noapp
        character.hp = []
        for i in range(character.noapp):
            character.hp.append(character.rollhp())
        party.append(character)

    return party
예제 #12
0
def genmeleeweapon(cclass, level):

    # choose a weapon type
    wpn = Dice.tableroller(meleeweapons[cclass])

    # is it magical?
    chance = 5
    if cclass == 2:
        chance = 3
    bonus = ""
    damage = wpn[3]
    if Dice.D(1, 100) < min(95, level * chance):
        row = Dice.tableroller(meleeweaponbonus)
        bonus = " " + row[1]
        damage = damage + bonus

    return [wpn[1] + bonus, wpn[2], damage]
예제 #13
0
def genarmor(cclass, level):

    if cclass == 2:
        return defaultarmor[cclass]

    # is it magical?  (overrides armor type choice)
    chance = 5
    if cclass == 2:
        chance = 4
    if Dice.D(1, 100) < min(95, level * chance):
        typ = Dice.tableroller(armortypes[cclass])
        row = Dice.tableroller(armorbonus)
        return [
            "%s +%d" % (typ[1], row[1]), typ[2] + row[1],
            min(typ[3] + 10, 40)
        ]

    return defaultarmor[cclass]
예제 #14
0
def magicItem(table):
    if table not in list(string.ascii_uppercase)[:8]:
        print("Invalid Table!")
        return
    table = "Tables/" + table + ".csv"
    itemTableFile = open(table, newline="")
    reader = csv.reader(itemTableFile, delimiter=";")
    itemTable = {rows[0]: rows[1] for rows in reader}
    previous = 0
    roll = Dice.D(100)
    for key in itemTable:
        if roll in range(previous, int(key)):
            print(itemTable.get(key))
            if "Spell scroll" in itemTable.get(key):
                scroll = itemTable.get(key).split(" ")
                scroll = scroll[2].strip("()")
                spellScroll(scroll)
            break
        else:
            previous = int(key)
예제 #15
0
 def __init__(self):
     _Treasure.Item.__init__(self)
     row = Dice.NRoll(_gem_table)
     self.name = self.shortname = Dice.Select(_gem_table[row][2])
     self.cat = "Gem"
     self.fullcat = self.fullcat + "." + self.cat
     va = Dice.D(2, 6)
     mult = 1.0
     if va == 2:
         row -= 1
     elif va == 3:
         mult = 0.5
     elif va == 4:
         mult = 0.75
     elif va == 10:
         mult = 1.5
     elif va == 11:
         mult = 2.0
     elif va == 12:
         row += 1
     self.value = _gem_table[row][3] * mult
     if self.value >= 1:
         self.value = int(self.value) * 1.0
예제 #16
0
def _gen_coins(argtup):
    kind, n, s, b, mul = argtup
    return [ Coins.Coin(kind, (Dice.D(n, s, b) * mul)) ]
예제 #17
0
def money(tier):
    pRoll = Dice.D(100)
    if tier not in ["t1", "t2", "t3", "t4"]:
        return "Tier not recognised! Please try again."
    elif tier == "t1":
        if 1 <= pRoll <= 30:
            return str(Dice.D(6, 5)) + "CP"
        elif 31 <= pRoll <= 60:
            return str(Dice.D(6, 4)) + "SP"
        elif 61 <= pRoll <= 70:
            return str(Dice.D(6, 3)) * 10 + "SP"
        elif 71 <= pRoll <= 95:
            return str(Dice.D(6, 3)) + "GP"
        else:
            return str(Dice.D(6)) + "PP"
    elif tier == "t2":
        if 1 <= pRoll <= 30:
            return str(Dice.D(6, 7)) + "GP"
        elif 31 <= pRoll <= 60:
            return str(Dice.D(6, 6) + Dice.D(6, 2) * 10) + "GP"
        elif 61 <= pRoll <= 70:
            return str(Dice.D(6, 3) + Dice.D(6, 2) * 10) + "GP"
        elif 71 <= pRoll <= 95:
            return str(Dice.D(6, 4) * 10) + "GP"
        else:
            return str(Dice.D(6, 5)) + "GP"
    elif tier == "t3":
        if 1 <= pRoll <= 20:
            return f"{Dice.D(6, 4)*100}SP + {Dice.D(6)*100}GP"
        elif 21 <= pRoll <= 35:
            return f"{Dice.D(6)*100}EP + {Dice.D(6)*100}GP"
        elif 36 <= pRoll <= 75:
            return f"{Dice.D(6, 2)*100}GP + {Dice.D(6)*10}PP"
        else:
            return f"{Dice.D(6, 2)*100}GP + {Dice.D(6, 2)*10}PP"
    elif tier == "t4":
        if 1 <= pRoll <= 15:
            return f"{Dice.D(6, 2) * 1000}EP + {Dice.D(6, 8) * 100}GP"
        elif 16 <= pRoll <= 55:
            return f"{Dice.D(6) * 1000}GP + {Dice.D(6) * 100}PP"
        else:
            return f"{Dice.D(6) * 1000}GP + {Dice.D(6, 2) * 100}PP"
예제 #18
0
    def __init__(self, level, clas, actuallevel=0):

        self.name = makename()
        self.noapp = 1

        self.clas = clas
        self.classname = classnames[self.clas]

        self.spells = None

        self.level = level
        if not actuallevel:
            if Dice.D(1, 100) <= 30:
                self.level = max(Dice.D(1, self.level), Dice.D(1, self.level))
            self.level = levels[self.level][clas]

        self.stats = [
            Dice.D(3, 6),
            Dice.D(3, 6),
            Dice.D(3, 6),
            Dice.D(3, 6),
            Dice.D(3, 6),
            Dice.D(3, 6)
        ]

        # boost prime if it's not good.
        self.stats[primes[clas]] = max(self.stats[primes[clas]], Dice.D(3, 6),
                                       9)
        # boost constitution if it's not good.
        self.stats[4] = max(self.stats[4], Dice.D(3, 6))

        self.race = "Human"

        if Dice.D(1, 100) <= 25:
            # this character will be a demi-human if the stats allow
            eligible = []
            if self.stats[4] >= 9:
                if self.clas != 2:
                    eligible.append("Dwarf")
            if self.stats[1] >= 9:
                eligible.append("Elf")
            if self.stats[3] >= 9:
                if self.clas != 2:
                    eligible.append("Halfling")
            if eligible:
                race = random.choice(eligible)
                if race == "Dwarf":
                    if self.stats[5] > 17:
                        self.stats[5] = 17
                if race == "Elf":
                    if self.stats[4] > 17:
                        self.stats[4] = 17
                if race == "Halfling":
                    if self.stats[0] > 17:
                        self.stats[0] = 17
                self.race = race

        self.hp = self.rollhp()

        self.movement = 40
        self.morale = 9

        self.armor = ""
        self.armorvalue = 0
        self.meleeweapon = "Pointy Stick"
        self.damage = "1d6"

        self.shield = ""
        self.shieldvalue = 0
        self.ringpro = 0
        self.potion = ""
        self.scroll = ""

        self.calc()
예제 #19
0
def bandits():

    # how many flunkies?

    ftrs = Dice.D(2, 12)
    thfs = Dice.D(1, 6)

    # if there are 11 or more mooks, a fighter
    # and a thief will lead them; otherwise,
    # 50% chance of either.

    lftr = 0
    lthf = 0

    if (ftrs + thfs) >= 11:
        lftr = Dice.D(1, 4) + 1
        lthf = Dice.D(1, 4) + 1
    else:
        if Dice.D(1, 100) <= 50:
            lftr = Dice.D(1, 4) + 1
        else:
            lthf = Dice.D(1, 4) + 1

    party = []

    if lftr > 0:
        character = Bandit(lftr, 1)
        character.outfit(1)
        party.append(character)

    if lthf > 0:
        character = Bandit(lthf, 3)
        character.outfit(1)
        party.append(character)

    nftrs = ftrs

    while nftrs:
        character = Bandit(1, 1)
        character.outfit(0)
        character.name = ""
        character.noapp = min(nftrs, Dice.D(1, ftrs))
        nftrs -= character.noapp
        party.append(character)

    nthfs = thfs

    while nthfs:
        character = Bandit(1, 3)
        character.outfit(0)
        character.name = ""
        character.noapp = min(nthfs, Dice.D(1, thfs))
        nthfs -= character.noapp
        party.append(character)

    for character in party:
        if character.noapp > 1:
            character.hp = []
            for i in range(character.noapp):
                character.hp.append(character.rollhp())

    return party
예제 #20
0
def magicweapon(c, chance):
    if Dice.D(1, 100) > min(95, c.level * chance):
        return
    bonus = Dice.tableroller(meleeweaponbonus)[1]
    c.meleeweapon = "%s %s" % (c.meleeweapon, bonus)
    c.damage = "%s %s" % (c.damage, bonus)
예제 #21
0
def _quantify(row):
    num = Dice.D(*row[2])
    return (0, row[1] % num)