예제 #1
0
 def rollCB(self):
     keep = [q == 1 for q in support.get_keepvals()]
     Dice.roll_dice(self.values,keep)
     self.updateDice()
     self.roll_cnt = self.roll_cnt + 1
     if self.roll_cnt >= 2:
         self.Roll["state"] = "disabled"
예제 #2
0
 def fill_dice_bags():
     bloodlust_dicebag = Dice.Dice_Bag(tcakdice.bloodlust_die_1,
                                       tcakdice.bloodlust_die_2,
                                       tcakdice.bloodlust_die_3,
                                       tcakdice.bloodlust_die_4,
                                       tcakdice.bloodlust_die_5,
                                       tcakdice.bloodlust_die_6)
     victims_dicebag = Dice.Dice_Bag(tcakdice.victims_die_1,
                                     tcakdice.victims_die_2,
                                     tcakdice.victims_die_3,
                                     tcakdice.victims_die_4,
                                     tcakdice.victims_die_5,
                                     tcakdice.victims_die_6)
     methods_dicebag = Dice.Dice_Bag(tcakdice.methods_die_1,
                                     tcakdice.methods_die_2,
                                     tcakdice.methods_die_3,
                                     tcakdice.methods_die_4,
                                     tcakdice.methods_die_5,
                                     tcakdice.methods_die_6)
     negligence_dicebag = Dice.Dice_Bag(tcakdice.negligence_die_1,
                                        tcakdice.negligence_die_2,
                                        tcakdice.negligence_die_3,
                                        tcakdice.negligence_die_4,
                                        tcakdice.negligence_die_5,
                                        tcakdice.negligence_die_6)
     dice_bag_dict = {
         "bloodlust_dicebag": bloodlust_dicebag,
         "victims_dicebag": victims_dicebag,
         "methods_dicebag": methods_dicebag,
         "negligence_dicebag": negligence_dicebag
     }
     return dice_bag_dict
예제 #3
0
    def __init__(self,
                 canvas,
                 grid,
                 width=BOARD_WIDTH,
                 height=BOARD_HEIGHT,
                 tb_pad=TB_PAD,
                 lr_pad=LR_PAD,
                 *args,
                 **kwargs):
        """ctor

        :param canvas:
        :param Grid grid:
        :param width: num tiles wide
        :param height:  num tiles high
        :param tb_pad:
        :param lr_pad:
        """
        self.canvas = canvas
        self.grid = grid
        self.width = width
        self.height = height
        self.lr_pad = lr_pad
        self.tb_pad = tb_pad

        self.d6 = Dice(sides=6)

        self.highlighted_positions = []
        # canvas objects
        self._pathlings = []  # list of rects used to make the board path
        self.tile_map = {}  # {pos: Tile(), ...}
예제 #4
0
파일: Wizard.py 프로젝트: lowhrtz/PyGM
def prefill_chosen_spells(spell_type, spells_dict_list):
    prechosen_ids = []
    prechosen_spells = []
    avail_list = [
        spell_dict for spell_dict in spells_dict_list
        if spell_dict['Type'] == spell_type and spell_dict['Level'] == 1
    ]
    if spell_type == 'magic_user':
        prechosen_ids.append('read_magic')
        for spell in avail_list:
            if spell['spell_id'] == 'read_magic':
                avail_list.remove(spell)

    if spell_type == 'magic_user' or spell_type == 'illusionist':
        first_random = Dice.randomInt(0, len(avail_list) - 1)
        first_random_spell = avail_list.pop(first_random)
        prechosen_ids.append(first_random_spell['spell_id'])

        second_random = Dice.randomInt(0, len(avail_list) - 1)
        second_random_spell = avail_list.pop(second_random)
        prechosen_ids.append(first_random_spell['spell_id'])
        prechosen_ids.append(second_random_spell['spell_id'])

    for spell_dict in spells_dict_list:
        if spell_dict['spell_id'] in prechosen_ids:
            prechosen_spells.append((spell_dict['Name'], spell_dict, True))
    return prechosen_spells
예제 #5
0
def hoard_table(table):
    if table not in ["h1", "h2", "h3", "h4"]:
        print("Invalid hoard table!")
        return
    with open("Tables/" + table + ".csv") as tf:
        reader = csv.reader(tf)
        pRoll = Dice.D(100)
        for row in reader:
            if int(row[0]) <= pRoll <= int(row[1]):
                if len(row) < 3:
                    print("No items for you. Better luck next time!")
                    return
                elif len(row) >= 5:
                    if "d" in row[2]:
                        rd = row[2].split("d")
                        for _ in range(Dice.D(int(rd[1]), int(rd[0]))):
                            booty(row[4], row[3])
                    else:
                        for _ in range(int(row[2])):
                            booty(row[4], row[3])
                if len(row) == 7:
                    if "d" in row[5]:
                        rd = row[5].split("d")
                        for _ in range(Dice.D(int(rd[1]), int(rd[0]))):
                            magicItem(row[6])
                    else:
                        for _ in range(int(row[5])):
                            magicItem(row[6])
예제 #6
0
def generate(level):

    ftrs = Dice.D(1, 3)
    thfs = Dice.D(1, 2)
    clrs = Dice.D(1, 2)
    mus = Dice.D(1, 2) - 1

    party = []

    for i in range(clrs):
        party.append(Character(level, 0))

    for i in range(ftrs):
        party.append(Character(level, 1))

    for i in range(mus):
        party.append(Character(level, 2))

    for i in range(thfs):
        party.append(Character(level, 3))

    totlvl = 0

    for character in party:
        character.outfit()
        totlvl += character.level

    items = miscitems(totlvl)

    return "%s\n%s" % (showparty(party), showitems(items))
예제 #7
0
파일: Wizard.py 프로젝트: lowhrtz/gm
    def roll_hp( self, level, attr_dict, class_dict ):
        hp = 0
        con_score = attr_dict['CON']
        con_bonus = SystemSettings.get_attribute_bonuses( 'CON', con_score )[0]
        con_bonus_list = con_bonus.replace( ' for Warriors)', '' ).split(' (')
        if len(con_bonus_list) == 1:
            con_bonus_list.append( con_bonus_list[0] )
        if 'classes' in class_dict:
            for cl in class_dict['classes']:
                hp_temp = 0
                if cl['Category'].lower() == 'warrior':
                    con_bonus = con_bonus_list[1]
                else:
                    con_bonus = con_bonus_list[0]
                hit_dice_string = 'd{}'.format( cl['Hit_Die_Type'] )
                for i in range( 0, int(level) ):
                    hp_temp += Dice.rollString( hit_dice_string )
                    hp_temp += int( con_bonus )
                hp += hp_temp / len( class_dict['classes'] )
        else:
            if class_dict['Category'].lower() == 'warrior':
                con_bonus = con_bonus_list[1]
            else:
                con_bonus = con_bonus_list[0]
            hit_dice_string = 'd{}'.format(class_dict['Hit_Die_Type'])
            for i in range(0, int(level)):
                hp += Dice.rollString(hit_dice_string)
                hp += int(con_bonus)

        return hp
예제 #8
0
 def get_full_items(items):
     items_table = DbQuery.getTable('Items')
     items_indexed = {i['unique_id']: i for i in items_table}
     full_items = []
     for item in items:
         if type(item) is tuple:
             gem_type, actual_value = item
             gem_type_list = [
                 i for i in items_table if i['Subcategory'] == gem_type
             ]
             gem_item = gem_type_list[Dice.randomInt(
                 0,
                 len(gem_type_list) - 1)]
             gem_item = copy(gem_item)
             gem_item['Value'] = actual_value
             full_items.append(gem_item)
         elif type(item) is list:
             print('list:', item)
         else:
             item_dict = copy(items_indexed[item])
             if item_dict['Category'] == 'Jewellery':
                 item_dict['Value'] = Dice.rollString(
                     item_dict['Value'])
             full_items.append(item_dict)
     return full_items
예제 #9
0
    def initialize_page(self, fields, pages, external_data):
        pc_team_roll = Dice.rollString(self.initiative_roll)
        monster_team_roll = Dice.rollString(self.initiative_roll)

        def get_pc_spells():
            spell_ids = []
            spells = []
            for pc in fields['PC Team']:
                for meta_row in pc['Characters_meta']:
                    if (meta_row['Type'].startswith('DailySpells') or meta_row['Type'] == 'Spellbook')\
                            and meta_row['Entry_ID'] not in spell_ids:
                        spell_ids.append(meta_row['Entry_ID'])
                        spells.append(
                            self.spells_indexed[meta_row['Entry_ID']])
            return spells

        return {
            'PC Team Initiative': pc_team_roll,
            'Monster Team Initiative': monster_team_roll,
            'PC Team Text':
            f'PC team will act on segment {monster_team_roll}.',
            'Monster Team Text':
            f'Monster team will act on segment {pc_team_roll}.',
            'PC Spells': get_pc_spells(),
            'All Spells': self.spells_table,
        }
예제 #10
0
 def initialize_page(self, fields, pages, external_data):
     t = time.time()
     self.encounter_id = f'encounter-{t}'
     hd_plus_minus_pattern = re.compile(r'^\d+[+-]\d+$')
     monster_team = external_data['Monster Team']
     enemies = []
     for enemy in monster_team:
         if enemy['TableName'] == 'Characters':
             enemy['XP Value'] = SystemSettings.get_xp_value(enemy)
             enemies.append(enemy)
         else:
             hd = enemy['HD']
             if hd.isdigit():
                 roll_string = f'{hd}d8'
                 hp = Dice.rollString(roll_string)
             elif hd_plus_minus_pattern.match(hd):
                 hd_split = re.split(r'([+-])', hd)
                 roll_string = f'{hd_split[0]}d8{hd_split[1]}{hd_split[2]}'
                 hp = max(Dice.rollString(roll_string), 1)
             elif hd.endswith('hp'):
                 roll_string = f'''{hd.replace('hp', '').strip()}'''
                 hp = max(Dice.rollString(roll_string), 1)
             else:
                 # hp = hd
                 hd = Dice.rollString(hd)
                 hp = Dice.rollString(f'{hd}d8')
             enemy['HP'] = hp
             enemy['XP Value'] = SystemSettings.get_xp_value(enemy)
             enemies.append(enemy)
     serialized_enemies = json.dumps(enemies)
     DbQuery.insertRow(
         'Encounters',
         (self.encounter_id, '', serialized_enemies, self.campaign_id))
     DbQuery.commit()
예제 #11
0
파일: Wizard.py 프로젝트: lowhrtz/PyGM
    def roll_hp(self, level, attr_dict, class_dict):
        hp = 0
        con_score = attr_dict['CON']
        con_bonus = SystemSettings.get_attribute_bonuses('CON', con_score)[0]
        con_bonus_list = con_bonus.replace(' for Warriors)', '').split(' (')
        if len(con_bonus_list) == 1:
            con_bonus_list.append(con_bonus_list[0])
        if 'classes' in class_dict:
            for cl in class_dict['classes']:
                hp_temp = 0
                if cl['Category'].lower() == 'warrior':
                    con_bonus = con_bonus_list[1]
                else:
                    con_bonus = con_bonus_list[0]
                hit_dice_string = 'd{}'.format(cl['Hit_Die_Type'])
                for i in range(0, int(level)):
                    hp_temp += Dice.rollString(hit_dice_string)
                    hp_temp += int(con_bonus)
                hp += hp_temp / len(class_dict['classes'])
        else:
            if class_dict['Category'].lower() == 'warrior':
                con_bonus = con_bonus_list[1]
            else:
                con_bonus = con_bonus_list[0]
            hit_dice_string = 'd{}'.format(class_dict['Hit_Die_Type'])
            for i in range(0, int(level)):
                hp += Dice.rollString(hit_dice_string)
                hp += int(con_bonus)

        return hp
    def gameInit(self):
        # make game board 0~16
        self.boards.append(Board(0, 1, "정문", self.texArr))
        self.boards.append(Board(1, 0, "넉터", self.texArr))
        self.boards.append(Board(2, 0, "제6 공학관", self.texArr))
        self.boards.append(Board(3, 0, "인문관", self.texArr))
        self.boards.append(Board(4, 0, "대학본부", self.texArr))
        self.boards.append(Board(5, 0, "제2 공학관", self.texArr))
        self.boards.append(Board(6, 0, "문창회관", self.texArr))
        self.boards.append(Board(7, 0, "자연대 연구실험동", self.texArr))
        self.boards.append(Board(8, 0, "새벽벌도서관", self.texArr))
        self.boards.append(Board(9, 0, "사회관", self.texArr))
        self.boards.append(Board(10, 0, "금정회관", self.texArr))
        self.boards.append(Board(11, 0, "법학관", self.texArr))
        self.boards.append(Board(12, 0, "테니스장", self.texArr))
        self.boards.append(Board(13, 0, "제 1도서관", self.texArr))
        self.boards.append(Board(14, 0, "무지개문", self.texArr))
        self.boards.append(Board(15, 0, "건설관", self.texArr))

        self.dice = Dice(self.texArr)

        # player setting
        for player_no in range(4):
            self.player.append(Player(player_no))

        # character setting
        for player_no in range(4):
            self.characters.append(Character(self, player_no, player_no))

        for build_no in range(16):
            self.buildings.append((Building(build_no, self.texArr)))
예제 #13
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)
예제 #14
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()
예제 #15
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)
    return rc[1]
예제 #16
0
 def next_round(_fields, _pages, _external):
     self.round_number += 1
     return {
         'Round Text': f'Round {self.round_number}',
         'PC Team Initiative': Dice.rollString(self.initiative_roll),
         'Monster Team Initiative':
         Dice.rollString(self.initiative_roll),
     }
예제 #17
0
 def scoreCB(self, row):
     self.scoreSheet.score(self.values,row)
     self.ScoreVars[row].set(str(self.scoreSheet.scores[row]))
     self.roll_cnt = 0
     self.Roll["state"] = "normal"
     Dice.roll_dice(self.values,[False]*5)
     self.updateDice()
     return False
예제 #18
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
예제 #19
0
def monster_fn(row, level):
    level = min(level, 8)
    rand_tbl = randenc_select[level]
    contents = Dice.tableroller(rand_tbl)
    treasure = ""
    if type(contents[1]) is type(""):  # it's a monster
        monster = contents[2]
        hd = monster["hd"]
        if hd[1] == 8:
            monster["hitdice"] = "%d" % hd[0]
        else:
            monster["hitdice"] = "%dd%d" % hd[:-1]
        if hd[2] != 0:
            if hd[2] > 0:
                monster["hitdice"] = "%s+%d" % (monster["hitdice"], hd[2])
            else:
                monster["hitdice"] = "%s%d" % (monster["hitdice"], hd[2])
        tt = None
        if type(monster["tt"]) == tuple:
            tt = monster["tt"]
            ls = []
            for i in tt:
                ls.append(str(i))
            monster["tt"] = string.join(ls, ", ")
        else:
            tt = (monster["tt"], )
        num = monster["noapp"]
        num = Dice.D(*num)
        if row[3]:
            if monster["tt"] != "None":
                treasure = None
                try:
                    types, tr = Treasure.Factory(tt)
                except:
                    tr = []
                    treasure = " with Treasure Type %s" % monster[-1]
                trlst = treasureformat(tr)
                if not treasure:
                    treasure = " with Treasure: " + string.join(trlst, ", ")
        monster["num"] = num
        monster = (statblock_fmt % monster)

        hplist = []

        for i in range(num):
            hplist.append(Adventurer.hitpointblock(max(1, Dice.D(*hd))))

        monster = monster + string.join(hplist, "\n")

    elif type(contents[1]) != type(""):
        args = contents[3:]
        monster = contents[1](*args)
        treasure = ""
    else:
        monster = contents[1]
        if row[3]:
            treasure = "with Treasure"
    return "%s<p class='Text Body'>%s" % (monster, treasure)
예제 #20
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 ""
예제 #21
0
파일: Attacks.py 프로젝트: tprimer/Pepper
 def __init__(self,targetDefence=7,attackBonus=1,vantage=None,weaponName="Longsword"):
     weapon = yaml.safe_load(open("Weapons.yaml",'r'))[weaponName]
     self.critRange = weapon['critRange']
     self.baseRoll = Dice.diceRolls([Dice.die() for die in range(2)])
     self.bonusRoll = Dice.diceRolls([Dice.die() for die in range(attackBonus)])
     # self.hitResult = self.checkForHit(self.baseRoll,targetDefence)
     self.hitResult = self.checkForHit(self.baseRoll.joinRolls(self.bonusRoll), targetDefence)
     self.hitTotal  = self.getHitTotal(self.baseRoll.joinRolls(self.bonusRoll))
     self.critResult = self.checkForCrit(self.baseRoll,self.critRange)
     self.hitDamage = Dice.die().roll*weapon['hands']+strength*weapon['weight']+int(self.critResult)*weapon['hands'] if self.hitResult else 0.0
예제 #22
0
 def initialize_page(self, fields, pages, external_data):
     surprise_roll = '1d6'
     pc_team_roll = Dice.rollString(surprise_roll)
     monster_team_roll = Dice.rollString(surprise_roll)
     return {
         'PC Team Surprise': pc_team_roll,
         'PC Team': external_data['PC Team'],
         'Monster Team Surprise': monster_team_roll,
         'Monster Team': external_data['Monster Team']
     }
예제 #23
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]
예제 #24
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]
예제 #25
0
        def roll_percentile(_fields):
            tens = Dice.rollString('1d10-1')
            ones = Dice.rollString('1d10-1')
            if tens == 0 and ones == 0:
                percentile_result = '00'
            else:
                percentile_result = f'{tens or ""}{ones}%'

            return {
                'Result': percentile_result,
            }
예제 #26
0
파일: Wizard.py 프로젝트: lowhrtz/gm
    def roll_height_weight( self ):
        race_dict = self.fields['Race']
        gender = self.fields['Gender']

        height_table = [ row for row in race_dict['Races_meta'] if row['Type'] == 'height table' and row['Subtype'].lower() == gender.lower() ]
        weight_table = [ row for row in race_dict['Races_meta'] if row['Type'] == 'weight table' and row['Subtype'].lower() == gender.lower() ]

        height_roll = Dice.randomInt( 1, 100 )
        weight_roll = Dice.randomInt( 1, 100 )

        def lookup( roll, table ):
            for row in table:
                d = row['Modifier']
                result = row['Modified']
                bounds = [ int(b) for b in d.split('-') ]
                if roll >= bounds[0] and roll <= bounds[1]:
                    return result

        height_result = lookup( height_roll, height_table )
        weight_result = lookup( weight_roll, weight_table )

        height_result_list = height_result.split( '+' )
        weight_result_list = weight_result.split( '+' )

        height_base = height_result_list[0].split()
        height_base_in = int( height_base[0] ) * 12 + int( height_base[2] )
        height_mod = height_result_list[1].replace( ' in', '' )
        weight_base = weight_result_list[0].replace( ' lbs', '' )
        weight_mod = weight_result_list[1].replace( ' lbs', '' )

        height = height_base_in + Dice.rollString( height_mod )
        weight = int(weight_base) + Dice.rollString(weight_mod)

        last_height_roll = Dice.rollString( 'd6' )
        last_weight_roll = Dice.rollString( 'd6' )

        while last_height_roll == 1 or last_height_roll == 6:
            height_sign = 1
            if last_height_roll == 1:
                height_sign = -1
            height = height + height_sign * Dice.rollString( '1d4' )
            last_height_roll = Dice.rollString( 'd6' )

        while last_weight_roll == 1 or last_weight_roll == 6:
            weight_sign = 1
            if last_weight_roll == 1:
                weight_sign = -1
            weight = weight + weight_sign * Dice.rollString( '1d20' )
            last_weight_roll = Dice.rollString( 'd6' )

        height_tuple = ( height / 12, height % 12 )

        return ( height_tuple, weight )
예제 #27
0
def miscitems(totlvl):

    items = []

    if Dice.D(1, 100) <= totlvl: # misc. magic item
        items.append(Dice.tableroller(miscmagictable)[1])
        if Dice.D(1, 100) <= (totlvl / 2): # another misc. magic item
            items.append(Dice.tableroller(miscmagictable)[1])
            if Dice.D(1, 100) <= (totlvl / 4): # yet another misc. magic item
                items.append(Dice.tableroller(miscmagictable)[1])

    return items
예제 #28
0
    def fill_attribute_fields(self, fields, pages, external_data):
        self.attr_dict = fill = {}
        for attr in self.attributes:
            if fields['Methods'].endswith('Drop Lowest'):
                rolls = [Dice.rollString('d6') for _ in range(4)]
                # print(rolls)
                rolls.remove(min(rolls))
                # print(rolls)
                fill[attr] = sum(rolls)
            else:
                fill[attr] = Dice.rollString('3d6')

        return fill
예제 #29
0
 def __init__(self):
     self.__concept = {
         'imię': "",
         'pochodzenie': "",
         'klasa': "",
         'gracz': ""
     }
     self.__attributes = {
         'krzepa': 0,
         'wytrzymałość': 0,
         'zręczność': 0,
         'zmysły': 0,
         'intelekt': 0,
         'charakter': 0
     }
     self.__skills = {
         'blef': 0,
         'empatia': 0,
         'jeździectwo': 0,
         'leczenie': 0,
         'obycie': 0,
         'perswazja': 0,
         'przetrwanie': 0,
         'rzemiosło': 0,
         'siła woli': 0,
         'skradanie': 0,
         'skupienie': 0,
         'spostrzegawczość': 0,
         'strzelectwo': 0,
         'walka': 0,
         'wykształcenie': 0,
         'wysportowanie': 0,
         'zastraszanie': 0,
         'złodziejstwo': 0,
         'żegluga': 0
     }
     self.__point_stats = {
         'pancerz': 1,
         'tarcza': 0,
         'broń': 0,
         'zdrowie': 0,
         'energia': 0,
         'inicjatywa': 0,
         'szczęście': 3,
         'doświadczenie': 0,
         'atrybuty': 15,
         'umiejętności': 20
     }
     self.__is_mage = False
     self.__dice10 = Dice.Dice(10)
     self.__dice6 = Dice.Dice(6)
예제 #30
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
예제 #31
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]
예제 #32
0
 def __init__(self, Id, Level, Name, Perception, AC, MaxHP, ToHitBonus,
              MultAttackPenalty, DamageBonus, DieSize):
     self.Id = Id
     self.Name = Name
     self.HP = MaxHP
     self.MaxHP = MaxHP
     self.AC = AC
     self.Level = Level
     self.DieSize = DieSize
     self.DamageDice = Dice.Dice(DieSize)
     self.Perception = Perception
     self.ToHitBonus = ToHitBonus
     self.MultAttackPenalty = MultAttackPenalty
     self.DamageBonus = DamageBonus
     self.HitDice = Dice.Dice()
예제 #33
0
def __gen_magic(argtup):
    kind, n, s, b, mul = argtup
    lst = []
    qty = Dice.D(n, s, b) * mul
    for i in range(qty):
        lst = lst + [ Magic.Magic(kind) ]
    return lst
예제 #34
0
def trap_fn(row, level):
    trap = "<p class='Text Body'>Trap: %s" % Dice.tableroller(Traps.traptable)[1]
    treasure = ""
    if row[3]:
        trlst = treasureformat(Treasure.Treasure("U%d" % level))
        treasure = " with Treasure: %s" % string.join(trlst, ", ")
    return trap + treasure
예제 #35
0
def startTwoPlayerGame(color):
    board = Board.Board(color)
    dice = Dice.Dice()

    board.printBoard()

    print 'Determining Starter...'
    starter = dice.determineStarter()

    if starter == 1:
        turn = Turn.Turn(color, color)
    else:
        if color == 'b':
            turn = Turn.Turn('w', color)
        else:
            turn = Turn.Turn('b', color)

    while True:
        print turn.getTurnPrint() + "'s turn."
        print turn.getTurnPrint() + "'s roll:"

        turn.setRolls(dice.roll())
        print turn.printRoll()

        # Get and validate move from the player
        move = Move.getPlayerMove(turn, board)

        # Make the move
        if move == 'undo':
            board.undoMove(turn)
            turn.undoMove()
        else:
            pass

        break
예제 #36
0
def _gen_gems(argtup):
    n, s, b, mul = argtup
    lst = []
    qty = Dice.D(n, s, b) * mul
    for i in range(qty):
        lst = lst + [ Gems.Gem() ]
    return lst
예제 #37
0
def _gen_art(argtup):
    n, s, b, mul = argtup
    lst = []
    qty = Dice.D(n, s, b) * mul
    for i in range(qty):
        lst = lst + [ Art.Art() ]
    return lst
예제 #38
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()
예제 #39
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")
예제 #40
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 ]
예제 #41
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
예제 #42
0
def monster_fn(row, level):
    level = min(level, 8)
    rand_tbl = randenc_select[level]
    contents = Dice.tableroller(rand_tbl)
    treasure = ""
    if type(contents[1]) is type(""): # it's a monster
        monster = contents[2]
        hd = monster["hd"]
        if hd[1] == 8:
            monster["hitdice"] = "%d" % hd[0]
        else:
            monster["hitdice"] = "%dd%d" % hd[:-1]
        if hd[2] != 0:
            if hd[2] > 0:
                monster["hitdice"] = "%s+%d" % (monster["hitdice"], hd[2])
            else:
                monster["hitdice"] = "%s%d" % (monster["hitdice"], hd[2])
        tt = None
        if type(monster["tt"]) == tuple:
            tt = monster["tt"]
            ls = []
            for i in tt:
                ls.append(str(i))
            monster["tt"] = string.join(ls, ", ")
        else:
            tt = ( monster["tt"], )
        num = monster["noapp"]
        num = Dice.D(*num)
        if row[3]:
            if monster["tt"] != "None":
                treasure = None
                try:
                    types, tr = Treasure.Factory(tt)
                except:
                    tr = []
                    treasure = " with Treasure Type %s" % monster[-1]
                trlst = treasureformat(tr)
                if not treasure:
                    treasure = " with Treasure: " + string.join(trlst, ", ")
        monster["num"] = num
        monster = (statblock_fmt % monster)

        hplist = []

        for i in range(num):
            hplist.append(Adventurer.hitpointblock(max(1, Dice.D(*hd))))

        monster = monster + string.join(hplist, "\n")

    elif type(contents[1]) != type(""):
        args = contents[3:]
        monster = contents[1](*args)
        treasure = ""
    else:
        monster = contents[1]
        if row[3]:
            treasure = "with Treasure"
    return "%s<p class='Text Body'>%s" % (monster, treasure)
예제 #43
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 ""
예제 #44
0
    def outfit(c, ldr):

        a = Dice.tableroller(piratearmor)
        c.armor = a[1]
        c.armorvalue = a[2]

        if ldr:
            magicarmor(c, 5)

        c.calc()

        w = Dice.tableroller(banditweapons)
        c.meleeweapon = w[1]
        c.damage = w[3]

        if ldr:
            magicweapon(c, 5)
            c.potion = genpotion(c.clas, c.level)
            c.scroll = genscroll(c.clas, c.level)
예제 #45
0
파일: Wizard.py 프로젝트: lowhrtz/gm
 def get_starting_money( self ):
     class_dict = self.fields['Class']
     if 'classes' in class_dict:
         sm_list = []
         for cl in class_dict['classes']:
             sm_list.append( cl['Initial_Wealth_GP'] )
         starting_money_string = get_best_dice( sm_list )
     else:
         starting_money_string = class_dict['Initial_Wealth_GP']
     starting_money = Dice.rollString( starting_money_string )
     return ( 'Gold:', starting_money )
예제 #46
0
def genscroll(clas, number):
    if clas == 0:
        tbl = clericspells
    else:
        tbl = magicuserspells
    scrollspells = []
    for i in range(number):
        lvl = Dice.tableroller(scrolltable)[1]
        scrollspells.append(random.choice(tbl[lvl]))
    scrollspells.sort()
    return scrollspells
예제 #47
0
    def outfit(c, ldr):

        if ldr:
            a = Dice.tableroller(banditarmor)
            c.armor = a[1]
            c.armorvalue = a[2]
        else:
            c.armor = "Leather Armor"
            c.armorvalue = 13

        if ldr:
            magicarmor(c, 5)

        c.calc()

        b = Dice.tableroller(banditweapons)
        c.meleeweapon = b[1]
        c.damage = b[3]

        if ldr:
            magicweapon(c, 5)
            c.potion = genpotion(c.clas, c.level)
            c.scroll = genscroll(c.clas, c.level)
예제 #48
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
예제 #49
0
파일: Wizard.py 프로젝트: lowhrtz/gm
def prefill_chosen_spells( spell_type, spells_dict_list ):
    prechosen_ids = []
    prechosen_spells = []
    avail_list = [spell_dict for spell_dict in spells_dict_list if spell_dict['Type'] == spell_type and spell_dict['Level'] == 1]
    if spell_type == 'magic_user':
        prechosen_ids.append('read_magic')
        for spell in avail_list:
            if spell['spell_id'] == 'read_magic':
                avail_list.remove(spell)

    if spell_type == 'magic_user' or spell_type == 'illusionist':
        first_random = Dice.randomInt(0, len(avail_list) - 1)
        first_random_spell = avail_list.pop(first_random)
        prechosen_ids.append(first_random_spell['spell_id'])

        second_random = Dice.randomInt(0, len(avail_list) - 1)
        second_random_spell = avail_list.pop(second_random)
        prechosen_ids.append(first_random_spell['spell_id'])
        prechosen_ids.append(second_random_spell['spell_id'])

    for spell_dict in spells_dict_list:
        if spell_dict['spell_id'] in prechosen_ids:
            prechosen_spells.append((spell_dict['Name'], spell_dict, True))
    return prechosen_spells
예제 #50
0
파일: LevelUp.py 프로젝트: lowhrtz/gm
    def initialize_page( self, fields, pages, external_data ):
        pc = external_data['Character List Current']
        classes = pc['Classes'].split( '/' )
        level = str( pc['Level'] ).split( '/' )

        ready_dict_list = pages['Level Up'].ready_dict_list
        hp_add = 0
        for cl in ready_dict_list:
            pc_level = int( level[ classes.index( cl['unique_id'] ) ] )
            if pc_level < cl['Hit_Die_Max']:
                hp_roll = Dice.rollString( 'd{}'.format( cl['Hit_Die_Type'] ) )
            else:
                hp_roll = [ row for row in cl['Classes_meta'] if row['Level'] == 'each' ][0]['Hit_Dice']
#            print hp_roll
            hp_add += hp_roll / len( classes ) or 1

            return { 'Review Text' : '<b>Hit Points Added: </b>{}'.format( str( hp_add ) ) }
예제 #51
0
파일: Wizard.py 프로젝트: lowhrtz/gm
    def prefill_bought_list( self ):
        race_dict = self.fields['Race']
        class_dict = self.fields['Class']
        items_dict_list = DbQuery.getTable( 'Items' )
        item_id_list = []
        if race_dict['unique_id'] == 'elf' and 'fighter' in class_dict['unique_id']:
            percent = Dice.randomInt(1, 100)
            if percent <= 5:
                item_id_list.append( 'armour_elfin_chain' )
        if 'magic_user' in class_dict['unique_id'] or 'illusionist' in class_dict['unique_id']:
            item_id_list.append( 'spellbook' )
        if 'cleric' in class_dict['unique_id']:
            item_id_list.append( 'holy_symbol_pewter' )
        if 'druid' in class_dict['unique_id']:
            item_id_list.append( 'holy_symbol_wooden' )
        if 'thief' in class_dict['unique_id'] or 'assassin' in class_dict['unique_id']:
            item_id_list.append( 'thieves_tools' )
        item_list = []
        for item_dict in items_dict_list:
            if item_dict['unique_id'] in item_id_list:
                item_list.append( ( item_dict['Name'] + ' - ' + item_dict['Cost'], item_dict ) )

        return item_list
예제 #52
0
파일: Wizard.py 프로젝트: lowhrtz/gm
    def roll_age( self ):
        race_dict = self.fields['Race']
        class_dict = self.fields['Class']

        starting_ages = [ row for row in race_dict['Races_meta'] if row['Type'] == 'class' and row['Subtype'] == 'starting age' ]

        class_groups = {'Cleric': ['cleric', 'druid'],
                        'Fighter': ['fighter', 'ranger', 'paladin'],
                        'Magic User': ['magic_user', 'illusionist'],
                        'Thief': ['thief', 'assassin'],
                        'Druid': ['druid'],
                        }

        dice_string = ''
        if 'classes' in class_dict:
            bucket = []
            for cl in class_dict['classes']:
                for row in starting_ages:
                    if cl['unique_id'] in class_groups[row['Modified']]:
                        bucket.append( row )
            rating = 0
            best_dice = ''
            for row in bucket:
                new_rating = eval( row['Modifier'].replace( 'd', '*' ) )
                if new_rating > rating:
                    rating = new_rating
                    best_dice = row['Modifier']
            dice_string = best_dice
        else:
            for row in starting_ages:
                if class_dict['unique_id'] in class_groups[ row['Modified'] ]:
                    dice_string = row['Modifier']


        dice_string_list = dice_string.split( '+' )
        dice_string = dice_string_list[1].strip() + '+' + dice_string_list[0].strip()
        return Dice.rollString( dice_string )
예제 #53
0
파일: custom.py 프로젝트: joepfarley/pydie
def init(x=session):Dice.init(x)
def INIT(x=session):Dice.INIT(x)
예제 #54
0
import Dice

Dice.roller()
예제 #55
0
##
#### TODO:
##


import Dice

srdice = Dice.shadowrun_dice()
dice = Dice.dice()

class host(object):
    def __init__(self, color = "", difficulty = ""):
        if color == "":
            self.color = self.get_host_color()
        else:
            self.color = color
        if difficulty == "":
            self.difficulty = self.get_difficulty()
        else:
            self.difficulty = difficulty
        self.security_value = self.get_security_value()
        self.subsystems = {"Access": 0, "Control": 0, "Index": 0, "Files": 0, "Slave": 0}
        for subsystem in self.subsystems:
            self.subsystems[subsystem] = self.get_subsystem_rating()
        sheaf_object = security_sheaf(self.color, self.security_value)
        self.sheaf = sheaf_object.sheaf
        paydata_points = self.get_paydata_points()
        self.paydata = []
        for _ in range(paydata_points):
            self.paydata.append((self.get_paydata_size(), self.get_paydata_security()))
예제 #56
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)
예제 #57
0
파일: Wizard.py 프로젝트: lowhrtz/gm
    def roll_attributes( self, wiz_attr_dict, race_dict, class_dict ):
        is_warrior = False
        if 'classes' in class_dict:
            for cl in class_dict['classes']:
                if cl['Category'].lower() == 'warrior':
                    is_warrior = True
        else:
            if class_dict['Category'].lower() == 'warrior':
                is_warrior = True

        attr_dict = {}
        min_dict = {}
        if not wiz_attr_dict:
            if 'classes' in class_dict:
                for cl in class_dict['classes']:
                    min_scores_string = cl['Minimum_Scores']
                    min_scores_list = [ score.strip() for score in min_scores_string.split( ',' ) ]
                    for min_score in min_scores_list:
                        min_score_split = min_score.split()
                        attr = min_score_split[0]
                        min_score = int( min_score_split[1] )
                        if attr not in min_dict:
                            min_dict[attr] = min_score
                        else:
                            min_dict[attr] = max( min_score, min_dict[attr] )
            else:
                min_scores_string = class_dict['Minimum_Scores']
                min_scores_list = [ score.strip() for score in min_scores_string.split( ',' ) ]
                for min_score in min_scores_list:
                    min_score_split = min_score.split()
                    attr = min_score_split[0]
                    min_score = int( min_score_split[1] )
                    min_dict[attr] = min_score

            if len( min_dict ) < 6:
                for attr in get_attribute_names():
                    if attr.title() not in min_dict:
                        min_dict[ attr.title() ] = 3

            for attr in min_dict:
                minimum = max( min_dict[attr], race_dict['Minimum_' + attr] )
                maximum = race_dict[ 'Maximum_' + attr ]
                score = Dice.randomInt( minimum, maximum )
                attr_dict[ attr.upper() ] = str( score )
        else:
            attr_dict = self.adjust_attributes( wiz_attr_dict, race_dict )

        for attr in attr_dict:
            if attr.lower() == 'str' and attr_dict[attr] == '18' and is_warrior:
                score = 18
                exceptional_strength = Dice.randomInt( 1, 99 ) / float( 100 )
                attr_dict[attr] = '{0:.2f}'.format( score + exceptional_strength )

        self.attr_cache = attr_dict

        # Now that we have guaranteed attributes lets roll for hp and cache the results
        self.hp_cache = self.roll_hp( 1, attr_dict, class_dict )

        # Might as well roll age, height and weight too
        self.height_weight_cache = self.roll_height_weight()
        self.age_cache = self.roll_age()

        return '''\
<b>Str:</b> {STR}<br />
<b>Int:</b> {INT}<br />
<b>Wis:</b> {WIS}<br />
<b>Dex:</b> {DEX}<br />
<b>Con:</b> {CON}<br />
<b>Cha:</b> {CHA}
    '''.format(**attr_dict)