Skip to content

Instantly share code, notes, and snippets.

@ethanholda
Created August 22, 2013 20:52
Show Gist options
  • Save ethanholda/6312653 to your computer and use it in GitHub Desktop.
Save ethanholda/6312653 to your computer and use it in GitHub Desktop.
achievement calculcation
def get_achievements_from_run(run_data):
# DEBUG ONLY
te = float(200)
ke = float(500)
##
achvs = []
tot_e = te + ke
err_margin = 0.02
if (team_id):
team = Team.objects.with_id(run_data['team_id'])
else:
team = Team.get_default()
team_runs = ActivityData.objects(team = team, active = True)
mat = SlideMat.objects(name = run_data['mat'])
#ke = at least 2/3 kinetic energy
if (ke >= ((2/3) * tot_e)):
achvs.append('kinetic')
#te = at least 2/3 thermal energy
if (te >= ((2/3) * tot_e)):
achvs.append('thermal')
#50/50 = 1/2 each
if (abs((ke/tot_e) - 0.5) <= err_margin):
achvs.append('50_50')
#first slider = first run for team
if (len(team_runs) == 0):
achvs.append('first')
#mat magician = 2 runs on same mat, look for other run
#theoretically we don't care which mat, because would just mark against
#total number of mats
for (run in team_runs):
if (run['mat'] == mat):
achv.append('magician')
#super slider = all achievements complete
#?
return achvs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment