log(self.serveur,"priv",auteur," ".join(message)+"[failed]")
else:
self.play_channels.append(message[1])
- self.play_status[message[1]]=[[None,None]]
+ self.play_status[message[1]]=[[None,None,None]]
serv.privmsg(auteur,"Play channels : "+" ".join(self.play_channels))
log(self.serveur,"priv",auteur," ".join(message)+"[successful]")
else:
elif cmd in ["states","status"]:
if auteur in self.overops:
for k in self.play_status.keys():
- serv.privmsg(auteur,"%s : %s (%s)"%(k,"".join([str(i[0]) for i in self.play_status[k][0]])
- ,self.play_status[k][1]))
+ serv.privmsg(auteur,"%s : %s (%s) [%s]"%(k,"".join([str(i[0]) for i in self.play_status[k][0]])
+ ,self.play_status[k][1], self.play_status[k][2]))
elif cmd=="die":
if auteur in self.overops:
log(self.serveur,"priv",auteur," ".join(message)+"[successful]")
mot,definition=mots[indice],defs[indice]
# ' et - sont considérés comme déjà devinés
mot = [(lettre,lettre in "'-") for lettre in list(mot)]
- self.play_status[canal]=[mot,definition]
+ self.play_status[canal]=[mot,definition,{}]
self.affiche_mot(serv, canal, begin="Devinez")
def on_pubmsg(self, serv, ev):
elif cmd in ["play","jeu","encore","again","partie","pendu","game","mot","go","allez"]:
if not canal in self.quiet_channels and canal in self.play_channels:
if self.play_status.has_key(canal):
- if self.play_status[canal]==[[None,None]]:
+ if self.play_status[canal]==[[None,None,None]]:
self.start_partie(serv, canal)
else:
self.affiche_mot(serv, canal, begin="%s: Rappel"%(auteur))
else:
- self.play_status[canal]=[[None,None]]
+ self.play_status[canal]=[[None,None,None]]
self.start_partie(serv, canal)
elif not canal in self.play_channels:
serv.privmsg(canal,"%s: pas ici…"%(auteur))
elif (cmd in list("azertyuiopqsdfghjklmwxcvbn") and canal in self.play_channels
- and self.play_status.has_key(canal) and self.play_status[canal]!=[[None,None]]):
+ and self.play_status.has_key(canal) and self.play_status[canal]!=[[None,None,None]]):
giv_let=cmd.upper()
liste=self.play_status[canal][0]
listeapres=[(lettre[0],lettre[1] or lettre[0]==giv_let) for lettre in liste]
if liste!=listeapres:
+ nbtrouvees=(sum([lettre[1] for lettre in listeapres if not lettre[0] in "'-"])
+ - sum([lettre[1] for lettre in liste if not lettre[0] in "'-"]))
+ if self.play_status[canal][2].has_key(auteur):
+ self.play_status[canal][2][auteur]+= nbtrouvees
+ else:
+ self.play_status[canal][2][auteur] = nbtrouvees
self.play_status[canal][0]=listeapres
self.affiche_mot(serv, canal, begin="%s placé"%(giv_let))
if all([lettre[1] for lettre in listeapres]):
definition = self.play_status[canal][1]
serv.privmsg(canal,"Bravo ! C'était %s"%(realword))
serv.privmsg(canal,definition)
- self.play_status[canal]=[[None,None]]
+ nlettre=float(len(realword.replace("'","").replace("-","")))
+ contribs=["%s:%s%%"%(pseudo,int(100*contrib/nlettre)) for pseudo,contrib in self.play_status[canal][2].items()]
+ serv.privmsg(canal,"Contributions : %s"%(" ".join(contribs)) )
+ self.play_status[canal]=[[None,None,None]]
if cmd in ["meur", "meurt","meurre","meurres"] and not canal in self.quiet_channels: