Esempio n. 1
0
    def move_hero(self, direction):
        direction = direction.lower()

        x = self.hero_position_X
        y = self.hero_position_Y

        if direction == 'up':
            x -= 1
        if direction == 'down':
            x += 1
        if direction == 'left':
            y -= 1
        if direction == 'right':
            y += 1

        if x in range(0, self.X) and y in range(0, self.Y):
            enemy = Enemy(self.level * 15, self.level * 10)
            fight = Fight(self.hero, enemy, self.tmp_map, self.X, self.Y)
            if self.tmp_map[x][y] != '#':
                self.hero.take_mana()
                if self.tmp_map[x][y] == 'T':
                    self.treasure_found()
                if self.tmp_map[x][y] == 'E':
                    enemy = Enemy(self.level * 15, self.level * 10)
                    fight.fight()
                self._update_tmp_map(x, y)
                if self.hero.can_cast():
                    fight.remote_battle(x, y)
                return True
        else:
            print('Invalid. Your move was out of the map!')

        return False
Esempio n. 2
0
 def __battle_helper(challenger: Fighter, opponent: Fighter,
                     skill: str) -> None:
     """
     Serves as a "bridge" between Fighter and Fight classes and determines
     who the winner/loser from a fight is. This method should not be
     accessed outside of this class.
     :param challenger: Fighter involved in battle
     :param opponent: Fighter involved in battle
     :param skill: skill to be fought with
     :return: None
     """
     from Fight import Fight
     challenger_skill = challenger.__skills.get(skill)
     opponent_skill = opponent.__skills.get(skill)
     fight = Fight(challenger, opponent, challenger_skill, opponent_skill)
     fight.fight()
     challenger.__has_fought = True
     opponent.__has_fought = True
     Fighter.__prizes(skill, fight.winner, fight.loser)
     print(fight.winner)
     print(fight.loser)
Esempio n. 3
0
 def start(self):
     old_players = {} # an string-Player dict
     result = {}
     for row in self.candidates:
         new_player = Player(row['Name'], int(row['Health']), int(row['Damage']), int(row['Attacks']))
         for pname in old_players:
             f = Fight(old_players[pname], new_player)
             winner = f.fight()
             print '\n##########################################\n'
             # sleep(1)
             if result.has_key(winner):
                 result[winner] += 1
             else:
                 result[winner] = 1
         # add new player to the old player list
         old_players[row['Name']] = new_player
     result = sorted(result.items(), key=operator.itemgetter(1), reverse=True)
     print 'Number of winnings: '+str(result)
     print 'Final winner is '+result[0][0]
Esempio n. 4
0
def worker(matchups):
    global lock, total_games_played, total_games_skipped, player_classes, games_won, games_played
    for i, game_players in enumerate(matchups):
        # print(f"Games between {game_players[0]} and {game_players[1]}")
        games_count = 0
        last_winner = None
        consecutive_wins = 0
        while games_count < games_per_matchup:
            # game setup
            f = Fight(random.randint(15, 35))
            p1, p2 = get_players(game_players)
            f.add_players([p1, p2])

            # play game
            winner = f.fight()
            with lock:
                total_games_played.value += 1

            # evaluate winner
            if winner is not None:
                games_won[winner[0]] += 1

                # count consecutive wins
                if last_winner == winner[0]:
                    consecutive_wins += 1
                else:
                    consecutive_wins = 0
                last_winner = winner[0]
            
            # count games played up
            games_played[p1.name] += 1
            games_played[p2.name] += 1

            games_count += 1
            # check if next games can be skipped because of consecutive wins
            if consecutive_wins == consec_wins_before_skip:
                with lock:
                    total_games_skipped.value += games_per_matchup - games_count
                break
    print(f'worker finished with following matchups: {matchups}' + ' '*30)
Esempio n. 5
0
 def start(self):
     old_players = {}  # an string-Player dict
     result = {}
     for row in self.candidates:
         new_player = Player(row['Name'], int(row['Health']),
                             int(row['Damage']), int(row['Attacks']))
         for pname in old_players:
             f = Fight(old_players[pname], new_player)
             winner = f.fight()
             print '\n##########################################\n'
             # sleep(1)
             if result.has_key(winner):
                 result[winner] += 1
             else:
                 result[winner] = 1
         # add new player to the old player list
         old_players[row['Name']] = new_player
     result = sorted(result.items(),
                     key=operator.itemgetter(1),
                     reverse=True)
     print 'Number of winnings: ' + str(result)
     print 'Final winner is ' + result[0][0]
Esempio n. 6
0
from random import randint
from Monstros import Monstros
from Status import Status
from Torneio import Torneio
from Fight import Fight
from Jsonarchive import Jsonarchive
import Decode

import json

data_json = Decode.Decode.decode("champions.json")

part = []

for n in range(0, Decode.Decode.count_monster):

    monster = Monstros(data_json[0][n], data_json[1][n], data_json[2][n],
                       data_json[3][n], data_json[4][n], data_json[5][n],
                       data_json[6][n])
    part.append(monster)

Fight.fight(part)

Fight.fight(Monstros.quartas)

Fight.fight(Monstros.semif)

Fight.fight(Monstros.final)