import json


def save(player): #salva o ultimo vencedor em um arquivo json
    info = {
        "name": player.nome,
        "team":[],
        "cheater":player.cheater,
    }
    
    for i in player.team:
        info["team"].append(i.nome)


    with open('save.json', 'r') as openfile:
 
        lastVictor = json.load(openfile)

    lastVictor["team"] = info["team"]
    lastVictor["name"].append(info["name"])
    lastVictor["cheater"].append(info["cheater"])

    # Writing to sample.json
    with open("save.json", "w") as outfile:
        json.dump(lastVictor, outfile)

