f.close()
+config_score_annee=1
+config_score_bonus_mois=3
+config_score_bonus_jour=4
+
def reussi(message,answer,auteur):
- print message, "#?#", answer
if auteur in config_level3:
return answer in message
if auteur in config_level2:
print tuple(date)
except ThisIsNotADate:
return False
- as_string="%02d/%02d/%04d"%(date[2],date[1],date[0])
- print as_string
- if as_string==answer:
- return True
- else:
- return False
+ realdate=map(lambda x:int(x), answer.split('/'))
+ realdate.reverse()
+ print date,"#?#",realdate
+ score=0
+ if date[0]==realdate[0]:
+ score=config_score_annee
+ if date[1]==realdate[1]:
+ score+=config_score_mois
+ if date[2]==realdate[2]:
+ score+=config_score_jour
+ return score
def is_something(chain,matches,avant=u".*(?:^| )",apres=u"(?:$|\.| |,|;).*",case_sensitive=False,debug=False):
if case_sensitive:
if tryother:
if self.play_status.get(canal,[-1])[0] in [1,2]:
answer=self.play_status[canal][1]
- if reussi(message.decode("utf8"),answer,auteur):
- serv.privmsg(canal,(u"%s: bravo ! (C'était le %s)"%(auteur,answer)).encode("utf8"))
+ score_obtenu=reussi(message.decode("utf8"),answer,auteur)
+ if score_obtenu:
+ bonusmsg=" [+bonus_moi"*(score_obtenu>config_score_annee)+"+bonus_anne"*(score_obtenu>config_score_annee+config_score_mois)+"]"
+ serv.privmsg(canal,(u"%s: bravo ! (C'était le %s)%s"%(auteur,answer,bonusmsg)).encode("utf8"))
log(self.serveur,canal,auteur+"$win",message)
- self.add_score(auteur,1)
+ self.add_score(auteur,score_obtenu)
token=time.time()
self.play_status[canal]=[0,token]
serv.execute_delayed(random.randrange(Ttrig*5,Ttrig*10),self.start_enigme,(serv,canal,token))