Esempio n. 1
0
class PokerApp:
    def __init__(self, interface):
        self.dice = Dice()
        self.money = 100
        self.interface = interface()

    def run(self):
        while (self.money >= 10 and self.interface.wantToPlay()):
            self.playRound()
        self.interface.close()

    def playRound(self):
        self.money = self.money - 10
        self.interface.setMoney(self.money)
        self.doRolls()
        result, score = self.dice.score()
        self.interface.showResult(result, score)
        self.money = self.money + score
        self.interface.setMoney(self.money)

    def doRolls(self):
        self.dice.rollAll()
        roll = 1
        self.interface.setDice(self.dice.values())
        if roll < 3:
            self.interface.chooseDice()
Esempio n. 2
0
 def __init__(self):
     self.car_dice = Dice()
     self.car_dice1 = Dice()
     self.car_dice2 = Dice()
     self.name = "Car"
     #self.distance = 0
     self.position = 0
Esempio n. 3
0
    def __init__(self, number_of_players, window_surface):
        pygame.init()
        WINDOW_WIDTH = 1000
        WINDOW_HEIGHT = 700
        BLACK = (0, 0, 0)
        self.window_surface = window_surface
        pygame.display.set_caption('QuickEscape!!')

        self.window_surface.fill(BLACK)

        self.player_list = []
        for i in range(number_of_players):
            self.player_list.append(
                Player("picture\\user%s.png" % str(i), (350, 200), 50, 50,
                       "player%s" % str(i + 1)))

        roomtype_list = [
            RoomtypeA, RoomtypeB, RoomtypeC, RoomtypeD, RoomtypeE, RoomtypeF,
            RoomtypeG
        ]
        # roomtype_list = [RoomtypeE]
        self.generate_map(roomtype_list)

        self.init_stay_button()
        self.init_rotate_button()
        self.init_dice_confirm_button()

        self.dice_list = [Dice(0), Dice(1), Dice(2)]

        self.move_button = [0] * 4
Esempio n. 4
0
    def generate_monster(self,floor_lvl):

        # TODO REFACTOR + CLEANUP

        dice = Dice()

        if floor_lvl > 100:
            floor_lvl = 100

        # hp
        hp_num_dice = 1
        hp_num_extra_dice = 4
        total_hp = 0
        for i in range(hp_num_dice):
            total_hp += dice.roll(1)[0]
        for i in range(hp_num_extra_dice):
            if randint(1,100) <= floor_lvl:
                total_hp += dice.roll(1)[0]

        # fs + op
        fs = randint(2,12)
        op = fs+randint(1,5)
        if op > 12:
            op = 12

        # ko
        ko_weps = ['bows','wands','swords'] 
        ko_num_dice = 1
        ko_num_extra_dice = 5
        ko = {}
        for i in range(ko_num_dice):
            wep = choice(ko_weps)
            if wep not in ko:
                ko[wep] = 0
            ko[wep] += 1
        for i in range(ko_num_extra_dice):
            if randint(1,100) <= floor_lvl:
                wep = choice(ko_weps)
                if wep not in ko:
                    ko[wep] = 0
                ko[wep] += 1

        # reward
        reward_roll = randint(0,99)
        reward = {}

        if reward_roll > 0 and reward_roll <= 9:
            # 10% key
            reward = {'keys':1}
        elif reward_roll > 9 and reward_roll <= 19:
            # 10% wep
            reward = {choice(ko_weps):1}
        elif reward_roll > 19 and reward_roll <= 49:
            # 30% nothing
            reward = {}
        else:
            # 50% gold
            reward = {'gold':SETTINGS['core_items']['gold']['find_qty']()}

        return Monster(total_hp,fs,op,ko,reward)
Esempio n. 5
0
def home():
    dice_one = []
    for dimension in request.json['diceListOne']:
        dice_one.append(Dice(dimension))
    dice_two = []
    for dimension in request.json['diceListTwo']:
        dice_two.append(Dice(dimension))
    dice_list_one = dice_one
    dice_list_two = dice_two

    player_one = Player(request.json['playerOneMoney'], dice_list_one)
    player_two = Player(request.json['playerTwoMoney'], dice_list_two)

    game = Game(request.json['roundCount'], player_one, player_two)
    game.play()
    result_1 = game.result_1
    result_2 = game.result_2
    round_count = game.round_count
    player_one_money = player_one.money
    player_two_money = player_two.money
    json = {}
    json['playerOneResult'] = result_1
    json['playerTwoResult'] = result_2
    json['playerOneMoney'] = player_one_money
    json['playerTwoMoney'] = player_two_money
    return json, 201
Esempio n. 6
0
    def __init__(self):
        self.dice = Dice()
        self.money = 100
        self.interface = interface

        def run(self):
            while self.money >= 10 and self.interface.wantToPlay():
                self.playRound()
            self.interface.close()

        def playRound(self):
            self.money = self.money - 10
            self.interface.setMoney(self.money)
            self.doRolls()
            result, score = self.money + score
            self.interface.showResults(result, score)
            self.money = self.money = score
            self.interface.setMoney(self.money)
            
        def doRoll(self):
            self.dice.rollAll()
            roll = 1
            self.interface.setDice(self.dice.values())
            toRoll = self.interface.chooseDice()
            while roll < 3 and toRoll != []:
                self.dice.roll(toRoll)
                roll = roll + 1
                self.interface.setDice(self.dice.values())
                if roll < 3:
                    toRoll = self.interface.chooseDice()
Esempio n. 7
0
def test_double_roll(sides, rolls):
    """ Check that the probability for the sum of two n-sided dice matches
        the expected distribution.
    """

    # Store the expected probabilities for the sum of two dice.
    exp = {}
    for x in range(2, 2*sides + 1):
        exp[x] = prob_double_roll(x, sides)

    # Create a dictionary to hold the tally for each outcome.
    tally = {}
    for key in exp:
        tally[key] = 0

    # Initialise the dice.
    dice = Dice(sides)

    # Roll two dice 'rolls' times.
    for i in range(0, rolls):

        # Sum the value of the two dice rolls.
        roll_sum = dice.roll() + dice.roll()

        # Increment the tally for the outcome.
        tally[roll_sum] += 1

    # Compute the probabilities and check with expected values.
    for key in tally:

        average = tally[key] / rolls
        assert average == pytest.approx(exp[key], rel=1e-2)
Esempio n. 8
0
class CrapsApp:
    def __init__(self, interface):
        self.dice = Dice()
        self.money = 100
        self.interface = interface

    def run(self):
        while self.money >= 10 and self.interface.want_to_play():
            self.playRound()
        self.interface.close()

    def playRound(self):
        self.doRolls()
        result, score = self.dice.score()
        self.interface.show_result(result, score)

    def doRolls(self):
        print(self.dice.rollAll())
        goal = self.dice.values()
        if goal == 7:
            print("win")
        elif goal == 2:
            print("lose")
        else:
            return goal
Esempio n. 9
0
def test_double_roll(sides, rolls):
    """ Check that the probability for the sum of two n-sided dice matches
        the expected distribution.
    """

    # Store the expected probabilities for the sum of two dice.
    exp = {}
    for x in range(2, 2 * sides + 1):
        exp[x] = prob_double_roll(x, sides)

    # Create a dictionary to hold the tally for each outcome.
    tally = {}
    for key in exp:
        tally[key] = 0

    # Initialise the dice.
    dice = Dice(sides)

    # Roll two dice 'rolls' times.
    for i in range(0, rolls):

        # Sum the value of the two dice rolls.
        roll_sum = dice.roll() + dice.roll()

        # Increment the tally for the outcome.
        tally[roll_sum] += 1

    # Compute the probabilities and check with expected values.
    for key in tally:

        average = tally[key] / rolls
        assert average == pytest.approx(exp[key], rel=1e-2)
Esempio n. 10
0
    def generate_enemy(self):
        """Creates Enemy"""
        types = ("Spider", "Snake", "Wolf", "Bear", "Rhino", "Panther", "Lion",
                 "Griffin", "Dragon", "Legendary Hydra")

        die = Dice(self.round)
        enemynum = die.roll()
        self.nextenemy = Enemy(types[enemynum - 1], enemynum)
        for key, value in self.nextenemy.stats.items():
            self.nextenemy.stats[key] = enemynum
        #compensate for default armor
        self.nextenemy.stats[traits[0]] += 1
        self.nextenemy.level = enemynum
        self.nextenemy.experience = enemynum
        die = Dice(10)
        if die.roll() == 10:
            if die.roll() > 5:
                traitdie = Dice(4)
                self.nextenemy.inventory.append(
                    Weapon(enemynum, traits[traitdie.roll() - 1]))
            else:
                self.nextenemy.inventory.append(Armor(enemynum))

        hpmod = 5
        if enemynum > 4:
            hpmod = 10
        elif enemynum > 9:
            hpmod = 20  #end game bonus to enemy health
            self.nextenemy.stats[
                "Strength"] += 5  #end game damage output increased
        self.nextenemy.hp = hpmod * self.nextenemy.stats["Constitution"]
Esempio n. 11
0
def test_arandom_negative_numbers():
    with pytest.raises(Exception):
        result = Exception('negative probabilities not allowed')
        dice_instance = Dice(6, [1, -1, 1, 1, 1, 1])
        assert dice_instance.value == result
        dice_instance = Dice(6, [1, 1, 1, 1, 1, -1])
        assert dice_instance.value == result
Esempio n. 12
0
    def from_file(cls, file):
        line_number = 1
        rows = []
        text = None
        with codecs.open(file, encoding='utf-8') as f:
            for line in f:
                if line_number == 1:
                    identifier = line.strip()
                elif line_number == 2:
                    parts = line.split(PART_SEPARATOR)
                    dice_part = parts[0]
                    if re.search(r"d\*", dice_part):
                        dice = None
                    else:
                        dice = Dice.from_string(parts[0])
                    title = parts[1].strip()
                    if len(parts) > 2:
                        text = parts[2].strip()
                else:
                    try:
                        rows.append(RollTableRow.from_string(line.strip()))
                    except MalformedRowError:
                        rows.append(
                            RollTableRow.from_string('{}{}{}'.format(
                                line_number - 2, PART_SEPARATOR,
                                line.strip())))
                line_number += 1

        if len(rows) == 0:
            raise Exception('Empty file: {}'.format('file'))

        if dice is None:
            dice = Dice([Die(len(rows))])
        table = cls(dice, rows, title, text)
        return (identifier, table)
Esempio n. 13
0
    def play_with_players(self, games): # plays with 2 bots on opposing strategies
        bot1 = Player(True) # only buys profitable properties
        bot2 = Player() # buys all properties

        wins_bot_1 = 0
        wins_bot_2 = 0

        for i in range(0, games):
            while True:
                bot1.current_space.current_place += Dice.roll(12)
                if bot1.current_space.current_place > 39:
                    bot1.current_space.current_place -= 40
                bot1.check_buy(bot1.current_space.current_place, bot2)

                bot2.current_space.current_place += Dice.roll(12)
                if bot2.current_space.current_place > 39:
                    bot2.current_space.current_place -= 40
                bot2.check_buy(bot2.current_space.current_place, bot1)

                if bot1.current_money <= 0:
                    wins_bot_2 += 1
                    break
                elif bot2.current_money <= 0:
                    wins_bot_1 += 1
                    break
        return wins_bot_1, wins_bot_2
Esempio n. 14
0
    def end_turn(self):
        for c in self.conditions.values():
            if c['cond_type'] == 's':
                r = None
                if self.pc:
                    print '{}: save against {}.'.format(self, c['name'])
                    r = easyinput.input_int('saving throw')
                else:
                    save_die = Dice.from_str('1d20')
                    r = save_die.roll()['total']

                if r >= 10:
                    self.remove_condition(c['index'])
                    print '{} successfully saved against {}.'.format(self, c['name'])
                else:
                    print '{} failed a save against {}.'.format(self, c['name'])

            elif c['cond_type'] == 't' and c['end_type'] == 'e':
                if c['duration'] <= 0:
                    self.remove_condition(c['index'])
                else:
                    print '{} is still affected by {} ({} round{} left).'.format(self, c['name'], c['duration'], 's'[c['duration']==1:])

        for r in self.recharges.values():
            if r['used']:
                if r['just_used']:
                    r['just_used'] = False
                    continue

                # Roll to recharge
                d = Dice.from_str('1d6')
                n = d.roll()['total']
                if n >= r['value']:
                    r['used'] = False
                    print '{} can use {} again!'.format(self, r['name'])
Esempio n. 15
0
    def __init__(self):
        self.nb_maison_dispo = 32
        self.nb_hotel_dispo = 12

        self.dice = Dice()

        # instanciation des cartes
        self.carte_chance = Carte_chance()
        self.carte_communaute = Carte_communaute()

        # self.proprietes = proprietes_data

        # instanciation des cases propriété
        self.proprietes = []
        for i in proprietes_data:
            self.proprietes.append(Propriete(i))
        # for p in self.proprietes: p.fiche()

        # instanciation des cases gare
        self.gares = []
        for i in gares_data:
            self.gares.append(Gare(i))
        # for g in self.gares: g.fiche()

        # instanciation des cases compagnie
        self.compagnies = []
        for i in compagnies_data:
            self.compagnies.append(Compagnie(i))
        # for c in self.compagnies: c.fiche()

        # instanciation de la prison
        self.prison = Prison()

        # tableau des joueurs
        self.joueurs = []
Esempio n. 16
0
def round(player):
	print "\nYour turn, %s." % player.name
	dice = Dice()
	roll1 = dice.first_roll()
	roll2 = dice.second_roll(roll1)
	roll3 = dice.third_roll(roll2)
	player.cat_choice(roll3)
	player.round += 1
Esempio n. 17
0
 def create_bone_on_canvas(self, i, canvas):
     a = random.randint(90, 510)
     b = random.randint(90, 510)
     angle = random.randint(0, 360)
     value = random.randint(1, 6)
     dice = Dice(a, b, angle)
     dice.draw(canvas, value)
     self.value_list[i] = value
def round(player):
	print ("\nYour turn, %s." % player.name)
	dice = Dice()
	roll1 = dice.first_roll()
	roll2 = dice.second_roll(roll1)
	roll3 = dice.third_roll(roll2)
	player.cat_choice(roll3)
	player.round += 1
Esempio n. 19
0
 def add_connection(self, connection):
     """Adds the connection to the board. It creates a new dice object,
         a roll button and the current_player whose turn it is.
     """
     self.connection = connection
     self.dice_object = Dice(connection, self.my_player)
     self.ROLL_BUTTON = Button("ROLL", 900, 430, 200, 30, GREEN, 0,
                               BRIGHTGREEN, self.dice_object.roll_dice)
     self.current_player = connection.current_player
Esempio n. 20
0
 def __init__(self, color: bool, piece_color: ForegroundPalette):
     self.color: bool = color  # barva hráče "černá"/"bílá"
     self.pieces = 15  # počet kamenů doposud mimo hru (tj. ty na hrací ploše jsou už odečteny)
     self.dice = Dice(6, 5)  # hráčova kostka (každé číslo 5×)
     self.must_reenter = 0  # počet kamenů, které je nutné opět vložit do hry než bude moci hrát
     self.turn = [0, 0, 0]  # hod kostkami během jednoho tahu
     self.path = [0 for _ in range(36)
                  ]  # oddělená cesta od začátku do konce pro jednoho hráče
     self.piece_color = piece_color  # barva hracích kamenů
Esempio n. 21
0
 def __init__(self,name,roundnum):
     """creaes random enemy"""
     super(Enemy,self).__init__(name)
     self.roll_character()
     factor = Dice(roundnum)
     base = roundnum
     for stat,value in self.stats.items():
         if factor.roll() >= 2:
             self.stats[stat] = value + factor.roll()
Esempio n. 22
0
 def __init__(self, maxMoney=10000.00, initalPlayersMoney=1500.00):
     self.maxMoney = maxMoney
     self.bank = maxMoney - initalPlayersMoney
     # Resources
     self.dice = Dice(6)
     self.player = Player(0, initalPlayersMoney)
     self.machine = Player(1, initalPlayersMoney)
     # self.houses = housesInformations.copy()
     self.houses = testeHouse.copy()
Esempio n. 23
0
 def __init__(self):
     super().__init__()
     self.state = 'peace'
     self.health = 10
     self.health_max = 10
     self.room = 1
     self.gold = 0
     self.monster = None
     self._dice = [Dice(6), Dice(6), Dice(6)]
 def __init__(self, n, parent):
     Frame.__init__(self, parent)
     Dice.__init__(self, n)
     self.loadimages()
     self.n = n
     self.labels = [Label(self) for i in range(self.n)]
     for i in range(self.n):
         self.setimage(i)
         self.labels[i].pack(side="left")
Esempio n. 25
0
def roll_pair():
    """
    Rolls a pair of dice
    Returns a list with the results
    """
    d1 = Dice()
    roll =  d1.roll()
    print "You rolled a %s and a %s" % (roll[0], roll[1])

    return roll
Esempio n. 26
0
 def __init__(self, lst_player):
     self.player_count = len(lst_player)
     self.lst_player = lst_player
     self.lst_boards = []
     for index in range(self.player_count):
         self.lst_boards.append(Board())
     self.completed_lines = [False, False, False, False]     # anybody able to complete line --> variable in game and not board
     self.dice = Dice()
     for player in lst_player:
         player.start_new_game()
Esempio n. 27
0
 def __init__(self, playerName, colour, tokensOnHome, tokensOnBase, tokenOnTrack, allTokens=None):
     self.playerName = playerName
     self.colour = colour
     self.tokensOnHome = tokensOnHome
     self.tokensOnBase = tokensOnBase
     self.tokensOnPath = tokenOnTrack
     self.allTokens = allTokens
     self.myDice = Dice()
     self.tokenPoly = [[27.5, 30.5], [27.0, 30.5], [27.0, 26.5], [23.5, 14.5], [23.5, 14.5], [24.5, 13.5], [24.5, 13.0], [23.5, 12.0], [23.5, 12.0], [25.5, 7.0], [18.5, 0.0], [11.0, 7.0], [13.5, 12.0], [13.0, 12.0], [12.0, 13.0], [12.0, 13.5], [13.0, 14.5], [13.5, 14.5], [10.0, 26.5], [10.0, 30.5], [9.0, 30.5], [8.0, 31.5], [8.0, 34.0], [9.0, 35.0], [9.0, 35.0], [9.0, 37.0], [27.5, 37.0], [27.5, 35.0], [28.5, 34.0], [28.5, 31.5], [27.5, 30.5]]
     self.BLACK = 0, 0, 0
Esempio n. 28
0
def basicCollection():
    _collection = Collection()
    _dice = Dice(DICE_6)
    _diceSet = DiceSet([_dice] * 3, Gear.DIRECT)
    _collection.addToCollection(_diceSet.Gear, _diceSet)

    _dice = Dice(DICE_3, Gear.TURN)
    _diceSet = DiceSet([_dice] * 2, Gear.TURN)
    _collection.addToCollection(_diceSet.Gear, _diceSet)
    return _collection
Esempio n. 29
0
 def __init__(self, interface, hi_scores):
     """
     Initialize dice, money, and interface (could be text or GUI)
     :param interface: obj -> interface object
     :param hi_scores: obj -> high scores object
     """
     self.dice = Dice()
     self.money = 100
     self.interface = interface
     self.hi_scores = hi_scores  # added for high score feature
     self.played_once = False  # added for high score feature
Esempio n. 30
0
    def test_roll_dice(self):
        """Test that the rolled value is in the list above."""
        dice = Dice()
        exp = random.randint(dice.lowest, dice.highest)
        res = dice.lowest <= exp <= dice.highest
        self.assertIn(exp, self.faces)
        self.assertTrue(res)

        # another assertion
        dice.roll_dice()
        self.assertIn(dice.rolled_dice, self.faces)
Esempio n. 31
0
    def __init__(self):
        """
        Constructeur. Aucun paramètre nécessaire
        """

        # création d'un attribut "dice1" représentant 1 dé
        self.dice1 = Dice()
        # création d'un attribut "dice1" représentant 1 autre dé
        self.dice2 = Dice()
        # création d'un attribut représentant la somme des 2 dés
        self.sum_dices = 0
Esempio n. 32
0
def test_valid_roll():
    """ Test that a dice roll is valid. """

    # Intialise a standard, six-sided dice.
    dice = Dice()

    # Roll the dice.
    roll = dice.roll()

    # Check that the value is valid.
    assert roll > 0 and roll < 7
Esempio n. 33
0
def test_always_valid_roll():
    """ Test that a dice roll is "always" valid. """

    # Intialise a standard, six-sided dice.
    dice = Dice()

    # Roll the dice lots of times.
    for i in range(0, 10000):
        roll = dice.roll()

        # Check that the value is valid.
        assert roll > 0 and roll < 7
def run_game():
    """游戏运行的主函数"""
    # 初始化游戏并创建一个屏幕对象
    pygame.init()

    # 导入设置文件中对窗口的设置
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))

    # 创建“开始游戏”按钮
    play_button = Button(screen, ai_settings.play_button)

    # 设置窗口顶部导航栏标题
    pygame.display.set_caption("OUC Billionaire")

    # 地点编组
    locations = []
    # 地点坐标信息编组
    location_points = []
    # 创建所有地点格子
    gf.create_all_locations(ai_settings, screen, locations, location_points)

    # 创建游戏玩家游戏回合顺序队列
    player_que = PlayerQueue()
    gf.create_player_queue(ai_settings, screen, locations, player_que)

    # 创建信息板
    messageboard = Messageboard(ai_settings, screen, locations)

    # 创建骰子
    dice = Dice(screen, messageboard)

    # 绘制骰子初始状态
    dice.draw_dice(dice.cur_dice)

    # 读取事件并创建事件字典
    events_dict = gf.read_events_list(ai_settings)
    # 读取事件图片并创建列表
    event_images = gf.read_event_images(ai_settings)

    # 游戏当前的状态
    gs = GameState(ai_settings)

    # 游戏的主循环
    while True:
        # 检测游戏中的鼠标、键盘事件
        gf.check_events(ai_settings, gs, play_button, locations, events_dict,
                        event_images, messageboard, dice, player_que)
        # 更新屏幕显示
        gf.update_screen(ai_settings, screen, gs, play_button, locations,
                         location_points, events_dict, event_images,
                         messageboard, dice, player_que)
class ChuckALuck:
    def __init__(self):
        self.dice = Dice(3)
        self.score = 0
        
    def play(self):
        choice = int(input("Choose a number (0 to stop): "))
        while choice != 0:
            self.dice.rollall()
            print("The roll:", self.dice)
            matches = self.dice.count(choice)
            self.score += matches if matches > 0 else -1
            print("Current score:", self.score)
            choice = int(input("Choose a number (0 to stop): "))
        print("Thanks for playing.")
Esempio n. 36
0
 def __init__(self):
     self.car_dice = Dice()
     self.car_dice1 = Dice()
     self.car_dice2 = Dice()
     self.name = "Car"
     #self.distance = 0
     self.position = 0
Esempio n. 37
0
    def start(self):

        sleep(1)
        print("Game is about to start!")
        sleep(2)

        while len(self.winners) < 1:

            sleep(1)
            print("---------- ROUND " + str(self.round) + " ----------")
            for player in self.players:
                results = []
                for i in range(player.dice):
                    result = Dice.roll()
                    results.append(result)
                    if result == 6:
                        player.dice -= 1

                print(player.name + " rolled the numbers " + str(results))
                print(player.name + " has " + str(player.dice) + " dice remaining.")

                if player.dice < 1:
                    self.winners.append(player)

            self.round +=1

        print("--------------------------")
        print("Game Over!")
        sleep(1)
        for player in self.winners:
            print(player.name + " has " + str(player.dice) + " remaining dice and won the game!")
Esempio n. 38
0
 def __init__(self, game, point_config='STD_CONFIG', uid=1, max_turns=3):
     self.game = game
     self.id = uid
     self.turn = 0
     self.points = Points(config=point_config)
     self.dice = Dice()
     self.max_turns = max_turns
Esempio n. 39
0
    def __init__(self, parent, hpRoll=10,
                 Str=12, Dex=12,
                 Con=12, Int=12,
                 Wis=12, Cha=12):

        self.parent = parent
        self.mbox = msgBox()
        self.dice = Dice()

        self.Str = Str
        self.Dex = Dex
        self.Con = Con
        self.Int = Int
        self.Wis = Wis
        self.Cha = Cha
        
        self.baseAttack = 2
        self.baseDefense = 2
        
        self.attackRoll
        
        self.hp = hpRoll + bonus[str(Con)]
        self.maxHP = self.hp
        self.mp = baseMP + bonus[str(Int)]
        self.maxMP = self.mp
        
        self.xp = 0
        self.xpForNextLevel = 1000
class PokerApp:

    def __init__(self, interface):
        self.dice = Dice()
        self.money = 100
        self.interface = interface

    def run(self):
        while self.money >= 10 and self.interface.wantToPlay():
            self.playRound()            
        self.interface.close()

    def playRound(self):
        self.money = self.money - 10
        self.interface.setMoney(self.money)
        self.doRolls()
        result, score = self.dice.score()
        self.interface.showResult(result, score)
        self.money = self.money + score
        self.interface.setMoney(self.money)        

    def doRolls(self):
        self.dice.rollAll()
        roll = 1
        self.interface.setDice(self.dice.values())
        toRoll = self.interface.chooseDice()
        while roll < 3 and toRoll != []:
            self.dice.roll(toRoll)
            roll = roll + 1
            self.interface.setDice(self.dice.values())
            if roll < 3:
                toRoll = self.interface.chooseDice()
Esempio n. 41
0
class Vehicle(object):
    def __init__(self):
        self.vehicle_dice = Dice()
        self.name = "Vehicle"
        self.distance = 0

    def run(self):
        self.distance += self.vehicle_dice.get_value()

    def get_distance(self):
        return self.distance
Esempio n. 42
0
    def play(self):
        self.dice = Dice()
        while True:
            try:
                self.command_prompt()
            except WrongCommandException:
                print_message('wrongcommand')
            except TurnEndException:
                break

        self.turn = 0
Esempio n. 43
0
class Bike(Vehicle):
    def __init__(self):
        self.bike_dice = Dice()
        self.name = "Bike"
        #self.distance = 0
        self.position = 0
    def run(self):
        # self.distance += self.motor_dice.get_value()
        # self.distance += self.motor_dice1.get_value()
        space = self.bike_dice.get_value()
        # + self.car_dice1.get_value() + self.car_dice2.get_value()
        return space
Esempio n. 44
0
class PokerApp:
    def __init__(self, interface):
        self.dice = Dice()
        self.money = 100
        self.interface = interface

    def processScore(self, score):
        h = HighScores()
        if h.isElgible(score):
            nameentry = GraphWin("Name Entry", 200, 100)
            entry = Entry(Point(50, 50), 10)
            entry.draw(nameentry)
            okbutton = Button(nameentry, Point(150, 50), 90, 50, "Save Name")
            okbutton.activate()
            while 1:
                m = nameentry.getMouse()
                if okbutton.clicked(m):
                    h.addToList(score, entry.getText())
                    nameentry.close()
                    return

    def run(self):
        while self.money >= 10:
            result = self.interface.wantToPlay()
            if result == "Roll Dice":
                self.playRound()
            elif result == "Help":
                h = HelpScreen()
                h.DoEvents()
            elif result == "Quit":
                self.processScore(self.money)
                break
        self.interface.close()

    def playRound(self):
        self.money = self.money - 10
        self.interface.setMoney(self.money)
        self.doRolls()
        result, score = self.dice.score()
        self.interface.showResult(result, score)
        self.money = self.money + score
        self.interface.setMoney(self.money)

    def doRolls(self):
        self.dice.rollAll()
        roll = 1
        self.interface.setDice(self.dice.values())
        toRoll = self.interface.chooseDice()
        while roll < 3 and toRoll != []:
            self.dice.roll(toRoll)
            roll = roll + 1
            self.interface.setDice(self.dice.values())
            if roll < 3:
                toRoll = self.interface.chooseDice()
Esempio n. 45
0
    def gen_siblings(self):
        d = Dice()
        roll = d.roll(1, 10)
        self.relations = []
        self.siblings = []
        self.gender_table = []
        self.gender_table.append('Male')
        self.gender_table.append('Female')
        self.read_file('lifepath/family/family_siblings.txt', self.relations)
        little_num = 1
        big_num= 1
        if roll>0 and roll<8:
            for i in range(0, roll):
                gender = choice(self.gender_table)
                first=self.contr.get_r_name('first', gender)
                second=self.contr.get_r_name('second', gender)
                last=self.contr.datasets['last name']
                nick = self.contr.get_r_name('nick', gender)
                name = first + ' ' + second + ' ' + nick + ' ' + last.get()
                age=int(self.contr.datasets['age'].get())
                relative_age = d.Roll(1,2)
                if relative_age ==1:
                    age= age-little_num
                    little_num = little_num +1
                else:
                    age= age + big_num
                    big_num = big_num +1

                relation = choice(self.relations)
                member = family_member(name, relation, gender, age)
                self.siblings.append(member)
            self.sibling_var.set('you have ' +str(roll) + ' siblings')
            self.contr.datasets['siblings'] = self.siblings
        else:
            self.sibling_var.set('you are the only child')
            member = family_member('you are the only child','none','none',0)
            self.siblings.append(member)
            self.contr.datasets['siblings'] = self.siblings
Esempio n. 46
0
    def __init__(self, player1, player2):
        # Private variables (Start "__")
        self.__players = []
        self.__players.append(player1)
        self.__players.append(player2)
        self.__the_dices = Dice()
        self.__random_value = self.__the_dices.get_total_number()

        class_name = self.__class__.__name__
        print("""
        ************************
            {class_name}, created
        ************************
        """.format(class_name=class_name))
Esempio n. 47
0
class Car(Vehicle):
    def __init__(self):
        self.car_dice = Dice()
        self.car_dice1 = Dice()
        self.car_dice2 = Dice()
        self.name = "Car"
        #self.distance = 0
        self.position = 0
    def run(self):
        # self.distance += self.car_dice.get_value()
        # self.distance += self.car_dice1.get_value()
        # self.distance += self.car_dice2.get_value()
        space = self.car_dice.get_value()
        # + self.car_dice1.get_value() + self.car_dice2.get_value()
        return space
Esempio n. 48
0
class Player(object):

    def __init__(self, game, point_config='STD_CONFIG', uid=1, max_turns=3):
        self.game = game
        self.id = uid
        self.turn = 0
        self.points = Points(config=point_config)
        self.dice = Dice()
        self.max_turns = max_turns

    def save_dice(self, values):
        self.dice.save(values)

    def entry_points(self, field, column, values, preview=False):
        score = self.points.entry(field, column, values, self.game, preview=preview)
        if not preview:
            self.game.next_player()
            self.turn = 0
            if all([all([i[1] for i in column.points.values()]) for column in self.points.columns]):
                raise PlayerFinishedException()
        return score

    def roll_dice(self):
        if self.turn >= self.max_turns:
            raise NoTurnsLeftException()
        self.dice.roll()
        self.turn += 1

    def delete(self):
        if self.game.active_player == self:
            self.game.next_player()
        del self.game.players[self.game.players.index(self)]

    @classmethod
    def generate_players(cls, game, count, point_config):
        return [cls(game, point_config=point_config, uid=i) for i in range(1, count+1)]
Esempio n. 49
0
    def __init__(self):
        print "Welcome to Farkle, also known as 10,000!"
        self.players = [] #initialize list of players
        self.num_players = int(raw_input("How many players? "))  #initialize number of players
        for i in xrange(self.num_players):
            #get name of player
            player = raw_input("Name of Player {0}: ".format(i+1))
            self.players.append(player) #append player to list of players

        #initialize scores, scores['_highest'][0] will hold the highest score
        self.scores = {'_highest':[0, '']}
        for player in self.players: #set each player's score to 0 in a dict
            self.scores[player] = 0

        self.round_count = 0 #initialize round counter
        self.dice = Dice()
Esempio n. 50
0
    def parse_roll_command(text):
        # print 'Parsing roll command "{0}" ... '.format(text)
        regex = re.compile(ur'(?P<roll_command>^[!]\w+)\s*'
                           ur'(?P<number_of_dice>\d+)[d](?P<dice_sides>\d+)\s*'
                           ur'(?P<modifier>(?P<modifier_operator>[-+*/])\s*(?P<modifier_value>\d+))*', re.IGNORECASE)
        match = re.search(regex, text)
        if match:
            number_of_dice = match.group('number_of_dice')
            dice_sides = match.group('dice_sides')
            modifier_operator = match.group('modifier_operator')
            modifier_value = match.group('modifier_value')

            # print 'Match: {0}'.format(match.group())
            return Dice.roll(number_of_dice, dice_sides, modifier_operator, modifier_value)
        else:
            print 'Invalid roll command syntax'
            return None
Esempio n. 51
0
    def __init__(self, minimum, players, max_rolls, input_rolls):
        self.players = players
        self.dice = Dice()
        self.input_rolls = input_rolls
        self.minimum = minimum
        self.max_rolls = max_rolls

        # metadata
        self.shooters = 1
        self.rolls = 1
        self.longest_roll = 0
        self.points_made = 0
        self.seven_outs = 0
        self.come_out_naturals = 0
        self.come_out_craps = 0
        self.roll_history = []
        self.roll_status = (0, 0, None)
        self.table_status = []
Esempio n. 52
0
    def __init__(self, width=DEFAULT_MAP_CELLS_X, height=DEFAULT_MAP_CELLS_Y):
        self.map = []
        self.viewport = []
        self.width, self.height = width, height
        self.playableArea = Rect(Position(1, 1), width - 2, height - 2)
        self.batch = pyglet.graphics.Batch()
        self.mapGroup = pyglet.graphics.OrderedGroup(0)
        self.monsterGroup = pyglet.graphics.OrderedGroup(1)
        self.playerGroup = pyglet.graphics.OrderedGroup(2)
        self.player = Player(map=self, pos=Position(), batch=self.batch, group=self.playerGroup)

        self.dice = Dice()

        self.initViewport()

        self.initGameMap()

        self.initBSP()

        self.drawTunnels()
Esempio n. 53
0
    def __init__(self):
        self.no_of_fields_h = 10
        self.no_of_fields_v = 10
        self.field_size = 72
        self.floor_image = PhotoImage(file="assets/floor.png")
        self.wall_image = PhotoImage(file="assets/wall.png")
        self.canvas = canvas
        self.dice = Dice()

        dice_result_1 = self.dice.roll_the_dice()
        self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
        draw_hero(self.hero)

        dice_result_2 = self.dice.roll_the_dice()
        self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
        draw_boss(self.boss)

        dice_result_3 = self.dice.roll_the_dice()
        self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
        draw_skeleton_1(self.skeleton_1)

        dice_result_4 = self.dice.roll_the_dice()
        self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
        draw_skeleton_2(self.skeleton_2)

        dice_result_5 = self.dice.roll_the_dice()
        self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
        draw_skeleton_3(self.skeleton_3)

        self.map_1 = [[1,0,0,1,0,1,0,0,0,0],
                    [0,0,0,1,0,1,0,1,1,0],
                    [0,1,1,1,0,1,0,1,1,0],
                    [0,0,0,0,0,1,0,0,0,0],
                    [1,1,1,1,0,1,1,1,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,0,0,0,0,1,1,0,1,0],
                    [0,1,1,1,0,0,0,0,1,0],
                    [0,0,0,1,0,1,1,0,1,0],
                    [0,1,0,1,0,1,0,0,0,0]]
Esempio n. 54
0
    def __init__(self, minimum, player):
        self.bet = Bet()
        self.player = player
        self.dice = Dice()

        self.point = None
        self.minimum = minimum

        # metadata
        self.shooters = 1
        self.rolls = 1
        self.longest_roll = 0
        self.points_won = 0
        self.points_lost = 0
        self.naturals_won = 0
        self.naturals_lost = 0
        self.come_out_naturals = 0
        self.craps_won = 0
        self.craps_lost = 0
        self.come_out_craps = 0
        self.roll_history = []
        self.delta = (0, 0)
 def __init__(self, interface):
     self.dice = Dice()
     self.money = 100
     self. interface = interface
class PokerApp:
    def __init__(self, interface):
        self.dice = Dice()
        self.money = 100
        self. interface = interface

    def run(self):
        while self.money >= 10:
            choice = self.interface.wantToPlay()
            if choice == "Roll Dice":
                self.playRound()
            elif choice == "Help":
                self.interface.help()
            elif choice == "Quit":
                #Figure out if high score
                score = self.getMoney()
                if self.isHighScore():
                    # Change list
                    self.removePerson()
                    list = self.addPerson()
                    # Print info to file to save for next time
                    self.printToFile(list)
                # close window
                self.interface.close()
                break
        # close window
        self.interface.close()

    def playRound(self):
        self.money = self.money - 10
        self.interface.setMoney(self.money)
        self.doRolls()
        result, score = self.dice.score()
        self.interface.showResult(result, score)
        self.money = self.money + score
        self.interface.setMoney(self.money)

    def doRolls(self):
        self.dice.rollAll()
        roll = 1
        self.interface.setDice(self.dice.values())
        toRoll = self.interface.chooseDice()
        while roll < 3 and toRoll != []:
            self.dice.roll(toRoll)
            roll = roll +1
            self.interface.setDice(self.dice.values())
            if roll < 3:
                toRoll = self.interface.chooseDice()

    def getMoney(self):
        return self.money

    def makeScoreList(self):
        scoreList = []
        infile = open("HighScores", 'r')
        for line in infile:
            name, score = line.split()
            tuple = (name, score)
            scoreList.append(tuple)
        return scoreList

    def isHighScore(self):
        newScore = self.getMoney()
        list = self.makeScoreList()
        flag = False
        if len(list) == 10:
            for tuple in list:
                score = int(tuple[1])
                if newScore > score:
                    flag = True
        else:
            flag = True
        return flag

    def addPerson(self):
        score = self.getMoney()
        name = self.interface.inputNameHighScore()
        tuple = (name, score)
        list = self.removePerson()
        list.append(tuple)
        return list

    def removePerson(self):
        list = self.makeScoreList()
        if len(list) == 10:
            trackerNumber = 10000
            trackerTuple = None
            for tuple in list:
                score = int(tuple[1])
                if score < trackerNumber:
                    trackerNumber = score
                    trackerTuple = tuple
            list.remove(trackerTuple)
        return list

    def printToFile(self, list):
        outfile = open('HighScores', 'w')
        for tuple in list:
            name, score = tuple
            print (name, score, file = outfile)
        outfile.close()
Esempio n. 57
0
class DiceGame(object):

    def __init__(self, player1, player2):
        # Private variables (Start "__")
        self.__players = []
        self.__players.append(player1)
        self.__players.append(player2)
        self.__the_dices = Dice()
        self.__random_value = self.__the_dices.get_total_number()

        class_name = self.__class__.__name__
        print("""
        ************************
            {class_name}, created
        ************************
        """.format(class_name=class_name))

    def info_game(self):
        return """
        *******************************
                Game Started
            {player} began to edge game.
                  Players
            1. Player = {player1}
            2. Player = {player2}
                Random Value
            {random_value}   
        *******************************
        """.format(player=self.__players[0], player1=self.__players[0], 
                   player2=self.__players[1], random_value=self.__random_value)

    def get_players(self):
        return self.__players

    def select_player(self):
        random_player = []

        random_player.append(random.choice(self.__players))
        list_difference = list(set(self.__players) - set(random_player))
        random_player += list_difference

        return random_player
 
    def start_game(self):
        self.__players = self.select_player()
        self.info_game()

    def get_winner_player(self):
        player1_diff = abs(self.__random_value - self.__players[0].get_sum_of_dices())
        player2_diff = abs(self.__random_value - self.__players[1].get_sum_of_dices())

        if player1_diff == player2_diff:
            return None

        return self.__players[0] if player1_diff < player2_diff else self.__players[1]

    def game_report(self):
        self.__winner_player = self.get_winner_player()

        print("""
        *****************************
                    Winner
            {winner_player} 
                  Random Value
            {random_value}
                  Player's Value
            {player1} = {player1_value}
            {player2} = {player2_value}
        *****************************
        """.format(winner_player=self.__winner_player if self.__winner_player else "Draw", 
                   random_value=self.__random_value,
                   player1=self.__players[0].__str__(), player2=self.__players[1].__str__(),
                   player1_value=self.__players[0].get_sum_of_dices(), 
                   player2_value=self.__players[1].get_sum_of_dices()))

    @staticmethod
    def __str__():
        return "Dice Game"

    def __del__(self):
        class_name = self.__class__.__name__
        print("""
        ************************
            {class_name}, deleted
        ************************
        """.format(class_name=class_name))
Esempio n. 58
0
class Stats(object):
    def __init__(self, parent, hpRoll=10,
                 Str=12, Dex=12,
                 Con=12, Int=12,
                 Wis=12, Cha=12):

        self.parent = parent
        self.mbox = msgBox()
        self.dice = Dice()

        self.Str = Str
        self.Dex = Dex
        self.Con = Con
        self.Int = Int
        self.Wis = Wis
        self.Cha = Cha
        
        self.baseAttack = 2
        self.baseDefense = 2
        
        self.attackRoll
        
        self.hp = hpRoll + bonus[str(Con)]
        self.maxHP = self.hp
        self.mp = baseMP + bonus[str(Int)]
        self.maxMP = self.mp
        
        self.xp = 0
        self.xpForNextLevel = 1000

    def dmg(self):
        damage = self.dice.roll('1d6+' + str(bonus[str(self.Str)]))
#        damage = randint(1,6 + bonus[str(self.Str)])
        if damage < 1:
            damage = 1
        return damage

    def attackOther(self, other):
        if other.dead:
            return
        if isinstance(self.parent, player.Player):
            self.parent.map.objectUpdateRequired = 1
        if self.attackRoll() >= other.stats.defenseRoll():
            self.doHit(other)
        else:
            pass        
        
    def attackRoll(self):
        return self.baseAttack + \
               bonus[str((self.Str + self.Dex) / 2)] + self.dice.roll('1d20')

    def defenseRoll(self):
        return self.baseDefense + bonus[str(self.Dex)] + self.dice.roll('1d20')

    def doHit(self, other):
        damage = self.dmg()
        other.stats.gotHit(self.parent, damage)
        if isinstance(self.parent, player.Player):
            self.mbox.addMsg(
                'You hit %s for %i damage!' % (other.name, damage))
            self.mbox.addMsg(
                '%s hp: %i/%i' % (other.name,
                                  other.stats.hp,
                                  other.stats.maxHP))

    def gotHit(self, other, damage):
        self.hp -= damage
        if self.hp < 0:
            self.hp = 0
        if isinstance(self.parent, player.Player):
            self.mbox.addMsg(
                'You got hit for %i damage by %s' % (damage,other.name))
            self.mbox.addMsg(
                'Current hp: %i/%i' % (self.hp,self.maxHP))
        if self.hp == 0:
            self.gotKilled(other)

    def gotKilled(self, other):
        self.parent.dead = True
        self.parent.blocked = False
        self.parent.image = getCorpseSprite()
        if isinstance(self.parent, player.Player):
            self.mbox.addMsg('You got killed by a %s!' % other.name)
        else:
            other.stats.xp += 150
            other.statuswindow.updateStats()
Esempio n. 59
0
		self.critical_multiplier = critical_multiplier or {'light': 1.5, 'medium': 2.0, 'heavy': 3.0}[size]
		self.critical_chance = critical_chance or {'light': 15, 'medium': 10, 'heavy': 5}[size]
		self.price = price

	@classmethod
	def random(cls):
		global _weapon_id
		name = u'weapon%d' % _weapon_id
		_weapon_id += 1
		size = random.choice(cls.sizes)
		type = random.choice(cls.types)
		class_ = random.choice(cls.classes)
		damage = Dice(random.randrange(1, 4), random.randrange(4, 11, 2))
		damage_type = set([random.choice(cls.damage_types)])
		magic_enchantment = random.randrange(11)
		return cls(name, size, type, class_, damage, damage_type, magic_enchantment, price = 10)

	def __repr__(self):
		return 'Weapon(%r, %r, %r, %r, %r, %r, %r)' % (self.name, self.size, self.type, self.class_, self.damage, self.damage_type, self.magic_enchantment)

	def __str__(self):
		return '%s (%s %s %s %s+%d %s)' % (self.name or 'Weapon', self.size, self.type, self.class_, self.damage, self.magic_enchantment, '/'.join(self.damage_type))

weapons = {}
for name, type, size, dmg_type, dmg_roll, crit_mult, crit_chance, min_range, max_range, price in weapon_data:
	dmg_roll = Dice(*map(int, dmg_roll.split('d')))
	weapons[name] = Weapon(name, size, type, None, dmg_roll, set(dmg_type), 0, crit_mult, crit_chance, price)

default = Weapon('fist', 'light', 'melee', None, Dice(0, 0), set(['bludgeoning']), 0, 1, 0, 0)

Esempio n. 60
0
class DrawMap(object):

    def __init__(self):
        self.no_of_fields_h = 10
        self.no_of_fields_v = 10
        self.field_size = 72
        self.floor_image = PhotoImage(file="assets/floor.png")
        self.wall_image = PhotoImage(file="assets/wall.png")
        self.canvas = canvas
        self.dice = Dice()

        dice_result_1 = self.dice.roll_the_dice()
        self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
        draw_hero(self.hero)

        dice_result_2 = self.dice.roll_the_dice()
        self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
        draw_boss(self.boss)

        dice_result_3 = self.dice.roll_the_dice()
        self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
        draw_skeleton_1(self.skeleton_1)

        dice_result_4 = self.dice.roll_the_dice()
        self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
        draw_skeleton_2(self.skeleton_2)

        dice_result_5 = self.dice.roll_the_dice()
        self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
        draw_skeleton_3(self.skeleton_3)

        self.map_1 = [[1,0,0,1,0,1,0,0,0,0],
                    [0,0,0,1,0,1,0,1,1,0],
                    [0,1,1,1,0,1,0,1,1,0],
                    [0,0,0,0,0,1,0,0,0,0],
                    [1,1,1,1,0,1,1,1,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,1,0,1,0,0,0,0,1,0],
                    [0,0,0,0,0,1,1,0,1,0],
                    [0,1,1,1,0,0,0,0,1,0],
                    [0,0,0,1,0,1,1,0,1,0],
                    [0,1,0,1,0,1,0,0,0,0]]

    def screen_drawer(self):
        for i in range(self.no_of_fields_h):
            for j in range(self.no_of_fields_v):
                if self.map_1[j][i] == 0:
                    self.canvas.create_image(i * self.field_size, j * self.field_size, anchor=NW, image=self.floor_image)
                elif self.map_1[j][i] == 1:
                    self.canvas.create_image(i * self.field_size, j * self.field_size, anchor=NW, image=self.wall_image)

    def draw_hero(dice_result_1):
        if self.map_1.is_obstacle(dice_result_1[0], dice_result_1[1]) == False:
            self.hero = Hero(dice_result_1[0], dice_result_1[1], canvas)
            self.hero.draw()
        else:
            draw_hero(dice_result_1)

    def draw_boss(dice_result_2):
        if self.map_1.is_obstacle(dice_result_2[0], dice_result_2[1]) == False:
            self.boss = Boss(dice_result_2[0], dice_result_2[1], canvas)
            self.boss.draw()
        else:
            draw_boss(dice_result_2)

    def draw_skeleton_1(dice_result_3):
        if self.map_1.is_obstacle(dice_result_3[0], dice_result_3[1]) == False:
            self.skeleton_1 = Skeleton(dice_result_3[0], dice_result_3[1], canvas)
            self.skeleton_1.draw()
        else:
            draw_skeleton_1(dice_result_3)

    def draw_skeleton_2(dice_result_4):
        if self.map_1.is_obstacle(dice_result_4[0], dice_result_4[1]) == False:
            self.skeleton_2 = Skeleton(dice_result_4[0], dice_result_4[1], canvas)
            self.skeleton_2.draw()
        else:
            draw_skeleton_2(dice_result_4)

    def draw_skeleton_3(dice_result_5):
        if self.map_1.is_obstacle(dice_result_5[0], dice_result_5[1]) == False:
            self.skeleton_3 = Skeleton(dice_result_5[0], dice_result_5[1], canvas)
            self.skeleton_3.draw()
        else:
            draw_skeleton_3(dice_result_5)

    def stats_drawer(self):
        self.info_box_height = 80
        self.canvas.create_rectangle(0, self.field_size * self.no_of_fields_v, self.field_size * self.no_of_fields_h, self.field_size * self.no_of_fields_h + self.info_box_height, fill="grey")
        self.canvas.create_rectangle(10, self.field_size * self.no_of_fields_v + 10, self.field_size * self.no_of_fields_h + 10, self.field_size * self.no_of_fields_h + self.info_box_height - 10, fill="white")
        self.canvas.create_text(self.field_size * self.no_of_fields_h/2, self.field_size * self.no_of_fields_h + self.info_box_height/2, text='Hero (Level 1) HP: 8/10 | DP: 8 | SP: 6', font=('Arial', 24, 'bold'))

    def is_obstacle(self, x, y):
        if self.map_1[x][y] == 0:
            return True
        else:
            return False

    def move_down(event):
        self.hero.move_down()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_up(event):
        self.hero.move_up()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_left(event):
        self.hero.move_left()
        screen_drawer(no_of_fields_h, no_of_fields_v)

    def move_right(event):
        self.hero.move_right()
        screen_drawer(no_of_fields_h, no_of_fields_v)