]> gitweb.pimeys.fr Git - bots/hung.git/blobdiff - hung.py
On peut mettre autre chose après une proposition de mot
[bots/hung.git] / hung.py
diff --git a/hung.py b/hung.py
index dbeff29e5c60d0736ed6209c62eeaedfd195907d..d91e4e0fa995cd837316c6c45d78589866ee514d 100755 (executable)
--- a/hung.py
+++ b/hung.py
@@ -75,7 +75,7 @@ def is_mot(mot,liste):
     real_word = "".join([lettre[0] for lettre in liste])
     real_word = real_word.decode("utf8").lower()
     mot=remplace_accents(mot.decode("utf8"))
-    return mot==real_word
+    return mot.startswith(real_word)
 
 class Hung(ircbot.SingleServerIRCBot):
     def __init__(self,serveur,debug=False):
@@ -433,7 +433,7 @@ class Hung(ircbot.SingleServerIRCBot):
                         # On perd une chance
                         self.lives[canal] -= 1
                         if self.lives[canal] > 0:
-                            serv.privmsg(canal, "Pas de %s. Plus que %s chances…" % (giv_let, self.lives[canal]))
+                            serv.privmsg(canal, "Pas de %s. Plus que %s chance%s…" % (giv_let, self.lives[canal], "s" * (self.lives[canal] > 1)))
                         if self.lives[canal] == 0:
                             serv.privmsg(canal, "Pas de %s." % (giv_let))
                             self.perd(serv, canal)
@@ -512,7 +512,7 @@ class Hung(ircbot.SingleServerIRCBot):
     def gagne(self, serv, canal, bonus=None, bonusvalue=2):
         serv.privmsg(canal,"Bravo !")
         realword = self.reveal_word(serv, canal)
-        nlettre=float(len(realword.replace("'","").replace("-","")))
+        nlettre=float(len([l for l in realword if not l in config.non_guess_chars]))
         contribs=["%s:%s%%%s"%(pseudo,str(int(100*contrib/nlettre)),("+bonus(%s)"%(bonusvalue))*(bonus==pseudo)) for pseudo,contrib in self.play_status[canal][2].items()]
         contribs_score={pseudo:int(10*contrib/nlettre) for pseudo,contrib in self.play_status[canal][2].items()}
         self.add_score(contribs_score)