|
|
|
@ -16,7 +16,7 @@ try:
|
|
|
|
|
with open (configFileName, 'r') as configFile:
|
|
|
|
|
config = json.load(configFile)
|
|
|
|
|
except IOError:
|
|
|
|
|
print "Config file not found! Loading defaults"
|
|
|
|
|
print("Config file not found! Loading defaults")
|
|
|
|
|
config = {}
|
|
|
|
|
config['ip'] = '0.0.0.0'
|
|
|
|
|
config['port'] = 5000
|
|
|
|
@ -49,7 +49,7 @@ class Person(UserMixin):
|
|
|
|
|
@staticmethod
|
|
|
|
|
def leaderboard():
|
|
|
|
|
leaderboard = []
|
|
|
|
|
for name,person in people.iteritems():
|
|
|
|
|
for name,person in people.items():
|
|
|
|
|
entry = {}
|
|
|
|
|
entry['name'] = name
|
|
|
|
|
entry['score'] = person.kukPoints
|
|
|
|
@ -98,11 +98,11 @@ class Meal(object):
|
|
|
|
|
self.accounted = "yes"
|
|
|
|
|
eaterCount = len(self.eaters)
|
|
|
|
|
points = config['points'][eaterCount]
|
|
|
|
|
print "kuk {} clears {} points".format(self.kuk, points)
|
|
|
|
|
print("kuk {} clears {} points".format(self.kuk, points))
|
|
|
|
|
Person.get(self.kuk).kukPoints -= points
|
|
|
|
|
for eater in self.eaters:
|
|
|
|
|
Person.get(eater).kukPoints += points / eaterCount
|
|
|
|
|
print "+{} gets {} points ".format(eater, points / eaterCount)
|
|
|
|
|
print("+{} gets {} points ".format(eater, points / eaterCount))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def getCurrent():
|
|
|
|
@ -120,13 +120,13 @@ class Meal(object):
|
|
|
|
|
def save():
|
|
|
|
|
with open(config['mealHistoryFile'], 'w') as outfile:
|
|
|
|
|
mealListJson = []
|
|
|
|
|
for mid,meal in mealHistory.iteritems():
|
|
|
|
|
for mid,meal in mealHistory.items():
|
|
|
|
|
mealListJson.append(meal.serialized())
|
|
|
|
|
json.dump(mealListJson, outfile)
|
|
|
|
|
|
|
|
|
|
with open(config['peopleFile'], 'w') as outfile:
|
|
|
|
|
peopleJson = []
|
|
|
|
|
for name,person in people.iteritems():
|
|
|
|
|
for name,person in people.items():
|
|
|
|
|
peopleJson.append(person.serialized())
|
|
|
|
|
json.dump(peopleJson, outfile)
|
|
|
|
|
|
|
|
|
@ -137,7 +137,7 @@ def load():
|
|
|
|
|
with open(config['mealHistoryFile'], 'r') as infile:
|
|
|
|
|
fileData = json.load(infile)
|
|
|
|
|
except:
|
|
|
|
|
print "no meal history file!"
|
|
|
|
|
print("no meal history file!")
|
|
|
|
|
return
|
|
|
|
|
for meal in fileData:
|
|
|
|
|
Meal.fromFile(meal['mid'], meal['kuk'], meal['eaters'], meal['date'], meal['flavorText'], meal['accounted'])
|
|
|
|
@ -146,7 +146,7 @@ def load():
|
|
|
|
|
with open(config['peopleFile'], 'r') as infile:
|
|
|
|
|
fileData = json.load(infile)
|
|
|
|
|
except:
|
|
|
|
|
print "no people file!"
|
|
|
|
|
print("no people file!")
|
|
|
|
|
return
|
|
|
|
|
for person in fileData:
|
|
|
|
|
Person.fromFile(person['name'], person['kukPoints'], person['password'])
|
|
|
|
@ -176,21 +176,21 @@ def index():
|
|
|
|
|
leaderboard.sort(key=lambda tup : tup['score'], reverse = True)
|
|
|
|
|
leaders = [p['name'] for p in leaderboard if p['score'] == leaderboard[0]['score']]
|
|
|
|
|
if len(leaders) > 1:
|
|
|
|
|
print "tie breaking!"
|
|
|
|
|
print("tie breaking!")
|
|
|
|
|
mid = Meal.getCurrent().mid-1
|
|
|
|
|
while len(leaders)>1:
|
|
|
|
|
thatkuk = mealHistory[mid].kuk
|
|
|
|
|
print "meal " + str(mid)
|
|
|
|
|
print thatkuk + " cooked that time"
|
|
|
|
|
print("meal " + str(mid))
|
|
|
|
|
print(thatkuk + " cooked that time")
|
|
|
|
|
if thatkuk in leaders:
|
|
|
|
|
print "found one!"
|
|
|
|
|
print("found one!")
|
|
|
|
|
leaders.remove(thatkuk)
|
|
|
|
|
mid-=1
|
|
|
|
|
if mid == 0:
|
|
|
|
|
leaders.sort()
|
|
|
|
|
print "beaking!"
|
|
|
|
|
print("beaking!")
|
|
|
|
|
break
|
|
|
|
|
print str(len(leaders)) + " remaining"
|
|
|
|
|
print(str(len(leaders)) + " remaining")
|
|
|
|
|
cook['name'] = leaders[0]
|
|
|
|
|
else:
|
|
|
|
|
cook['name'] = leaders[0]
|
|
|
|
@ -208,7 +208,7 @@ def login():
|
|
|
|
|
if request.method == 'POST':
|
|
|
|
|
username = request.form['username']
|
|
|
|
|
password = request.form['password']
|
|
|
|
|
print len(people)
|
|
|
|
|
print(len(people))
|
|
|
|
|
if Person.get(username).password == password:
|
|
|
|
|
login_user(Person.get(username))
|
|
|
|
|
return redirect(request.args.get("next"))
|
|
|
|
|