1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Bugfix per il caricamento

This commit is contained in:
Steffo 2016-04-10 14:21:42 +02:00
parent 3e5df1e081
commit b843186495

View file

@ -160,7 +160,7 @@ class Game:
} }
for player in self.players: for player in self.players:
status[player.username] = { status[player.username] = {
"telegramid": player.username, "telegramid": player.telegramid,
"role": player.role, "role": player.role,
"alive": player.alive, "alive": player.alive,
} }
@ -185,14 +185,18 @@ def loadgame(chatid) -> Game:
loaded = configparser.ConfigParser() loaded = configparser.ConfigParser()
loaded.read(str(chatid) + ".ini") loaded.read(str(chatid) + ".ini")
# General non è un giocatore, quindi toglilo # General non è un giocatore, quindi toglilo
playerlist = loaded.sections().remove("General") playerlist = loaded.sections()
playerlist.remove("General")
for player in playerlist: for player in playerlist:
lp = Player() lp = Player()
lp.alive = bool(loaded[player]['alive']) lp.alive = bool(loaded[player]['alive'])
lp.username = player lp.username = player
lp.role = int(loaded[player]['role']) lp.role = int(loaded[player]['role'])
lp.telegramid = int(loaded[player]['alive']) lp.telegramid = int(loaded[player]['telegramid'])
partiteincorso.append(l) l.players.append(lp)
l.groupid = int(loaded['General']['groupid'])
l.adminid = int(loaded['General']['adminid'])
return l
while True: while True:
@ -208,6 +212,7 @@ while True:
g.message("Partita creata!") g.message("Partita creata!")
elif t['text'].startswith("/loadgame"): elif t['text'].startswith("/loadgame"):
g = loadgame(t['chat']['id']) g = loadgame(t['chat']['id'])
partiteincorso.append(g)
g.message("Partita caricata!\n_Forse._") g.message("Partita caricata!\n_Forse._")
elif t['text'].startswith("/status"): elif t['text'].startswith("/status"):
telegram.sendmessage("Nessuna partita in corso.", t['chat']['id'], t['message_id']) telegram.sendmessage("Nessuna partita in corso.", t['chat']['id'], t['message_id'])