Esempio n. 1
0
    def deleteinnocentkill(self,iid):
        try:
	    eid=InnocentKill.get(iid).event.id
	except SQLObjectNotFound:
	    flash("Error: you tried to delete an innocent kill that doesn't exist!")
	    raise redirect(url("/news"))
        InnocentKill.delete(iid)
	self.updatescores()
	flash("Innocent Kill removed!")
	raise redirect(url("/editevent/"+str(eid)))
Esempio n. 2
0
 def deleteinnocentkill(self, iid):
     try:
         eid = InnocentKill.get(iid).event.id
     except SQLObjectNotFound:
         flash(
             "Error: you tried to delete an innocent kill that doesn't exist!"
         )
         raise redirect(url("/news"))
     InnocentKill.delete(iid)
     self.updatescores()
     flash("Innocent Kill removed!")
     raise redirect(url("/editevent/" + str(eid)))
Esempio n. 3
0
    def updatescores(self):
	glicko={}
	innocent_vector=[0,1,2,4,6,9,13,17,23]
	for u in User.select():
	    glicko[u.user_name]=(1500,350,0.06)
	kills=Kill.select()
	gamestart=datetime.datetime(2008,6,13,17,0,0)
	for i in range(42):
	    glicko = glickostep( glicko, [x for x in kills if x.event.datetime >= gamestart + datetime.timedelta(i*14400) and x.event.datetime < gamestart + datetime.timedelta((i+1)*14400)])
	for u in glicko:
	    p=User.by_user_name(u)
	    i = 0
	    for ik in InnocentKill.select():
	    	if(ik.killer==p and not ik.licit):
		    i +=1
	    p.score=glicko[u][0]-glicko[u][1]+p.adjustment - 35 * innocent_vector[min(i,8)]
	return
Esempio n. 4
0
 def saveinnocentkill(self, eid, killer, licit):
     try:
         k = InnocentKill(event=Event.get(eid),
                          killer=User.by_user_name(killer),
                          licit=licit)
         self.updatescores()
         flash("Innocent Kill added!")
         for l in Kill.select():
             if ((l.victim == k.killer)
                     and l.event.datetime < k.event.datetime
                     and l.event.datetime >=
                 (k.event.datetime - datetime.timedelta(0, 14400))):
                 flash(
                     "Warning: %s is listed as being killed in the event %s, which was less than four hours before this event."
                     % (l.victim.user_name, str(l.event)))
         raise redirect(url("/editevent/" + str(eid)))
     except SQLObjectNotFound:
         flash(
             "Error: Tried to add an innocent kill to a nonexistent event.")
         raise redirect(url("/news"))
Esempio n. 5
0
 def updatescores(self):
     glicko = {}
     innocent_vector = [0, 1, 2, 4, 6, 9, 13, 17, 23]
     for u in User.select():
         glicko[u.user_name] = (1500, 350, 0.06)
     kills = Kill.select()
     gamestart = datetime.datetime(2008, 6, 13, 17, 0, 0)
     for i in range(42):
         glicko = glickostep(glicko, [
             x for x in kills if x.event.datetime >= gamestart +
             datetime.timedelta(i * 14400) and x.event.datetime <
             gamestart + datetime.timedelta((i + 1) * 14400)
         ])
     for u in glicko:
         p = User.by_user_name(u)
         i = 0
         for ik in InnocentKill.select():
             if (ik.killer == p and not ik.licit):
                 i += 1
         p.score = glicko[u][0] - glicko[u][
             1] + p.adjustment - 35 * innocent_vector[min(i, 8)]
     return