import dota

def serialize_player(player):
  friend = dota.Friend.get_or_none(steam_id=player.account_id)
  player_data = {
    'personaname': player.personaname,
    'nickname': friend.name if friend else '',
    'kills': player.kills,
    'deaths': player.deaths,
    'assists': player.assists,
    'total_gold': player.total_gold,
    'last_hits': player.last_hits,
    'denies': player.denies,
    'hero_damage': player.hero_damage,
    'party_id': player.party_id,
    'win': player.win,
    'level': player.level,
    'is_radiant': player.is_radiant,
    'hero': dota.Hero.get(hero_id=player.hero_id).localized_name,
  }
  return player_data
