Exemplo n.º 1
0
def main(filename, champions, display, one, melee):
    util.Logger.install(os.path.basename(filename).replace('.cor', '.stdout.log'), 'w+')
    (win, defeat, reports) = blindtest.run(filename, champions, display, one = one, melee = melee)

    if win + defeat != 0:
        ratio = float(win) / (win + defeat) * 100
    else:
        ratio = 0
    if display:
        ratio_str = '%s / %s / %s / %s' % (colored('Win: %d' % (win), 'green', attrs = ['bold']),
                                           colored('Defeat: %d' % (defeat), 'red', attrs = ['bold']),
                                           colored('Total: %d' % (win + defeat), 'white', attrs = ['bold']),
                                           colored('%d%%' % (ratio), 'yellow', attrs = ['bold']))
        util.tprint('Ratio', ratio_str)
        print ''

    logfilename = os.path.basename(filename).replace('.cor', '.log')
    logfile = open('logs/%s' % (logfilename), 'w+')
    writelog(logfile, filename, win, defeat, ratio, reports)
    logfile.close()

if __name__ == "__main__":
    args = parser.parse_args()
    try:
        champions = args.champions
        for wdir in args.winners:
            champions += util.find(wdir, '*.cor')
        main(args.champion, champions, args.display, args.one, args.melee)
    except KeyboardInterrupt, e:
        print 'Exiting...'
Exemplo n.º 2
0
        rank.defeat += defeat

        count += 1
    print ''

    ranks = sorted(ranks.values(), key = lambda rank: rank.ratio(), reverse = True)
    winner = ranks[0]
    util.tprint('Winner', '%s %s %s' % (colored('%-32s' % (winner.champion.name), 'green', attrs = ['bold']),
                                        colored('->', 'white', attrs = ['bold']),
                                        ratio_str(winner.win, winner.defeat)))

    result_file = open('logs/result.json', 'w+')
    result_file.write(json.dumps([rank.encode() for rank in ranks], indent=4, separators=(',', ': '), sort_keys = False))
    result_file.close()

if __name__ == "__main__":
    args = parser.parse_args()
    util.Logger.install('tournoi.log', 'w+')
    champions = args.champions
    for d in args.directory:
        champions += util.find(d, '*.cor')
    champions = blindtest.remove_duplicate_champs(champions)
    if len(champions) > 0:
        try:
            main(champions)
        except KeyboardInterrupt, e:
            print 'Exiting...'
            sys.exit(0)
    else:
        print 'There are no champions!'