# coding: utf8
# vim:fileencoding=utf-8

API_VERSION = 'API_v1.0'
MOD_NAME = 'clan_icons'
MOD_VERSION = '1.0'
__author__ = "Roslich"

with open('empty.png', 'rb') as f:
    data = f.read()

def copy_icons(name, _data):
    if name =='sfm.battleLoadingStarted':
        for player in battle.getPlayersInfo().keys():
            clanTag = battle.getPlayerInfo(player).clanTag
            if not utils.isFile(utils.getModDir() + '/../../gui/clan_icons/' + clanTag + '.png'):
                with open(utils.getModDir() + '/../../gui/clan_icons/' + clanTag + '.png', 'wb') as f:
                    f.write(data)

events.onSFMEvent(copy_icons)