72 lines
1.9 KiB
Python
72 lines
1.9 KiB
Python
from django.shortcuts import render
|
|
from django.http import JsonResponse
|
|
|
|
achievements = {
|
|
1: "Clicked!",
|
|
2: "Clicked Twice!",
|
|
4: "2^2",
|
|
8: "2^3",
|
|
16: "2^4",
|
|
24: "I'm that old",
|
|
32: "2^5",
|
|
64: "2^6",
|
|
69: "Nice",
|
|
100: "one hundred",
|
|
128: "2^7",
|
|
200: "two hundred",
|
|
250: "quarter thousand",
|
|
256: "2^8",
|
|
300: "three hundred",
|
|
400: "four hundred",
|
|
420: "Blaze it",
|
|
500: "half thousand",
|
|
512: "2^9",
|
|
600: "six hundred",
|
|
700: "seven hundred",
|
|
800: "eight hundred",
|
|
900: "nine hundred",
|
|
1000: "full thousand",
|
|
1024: "2^10",
|
|
1776: "America",
|
|
1914: "Some War here",
|
|
1938: "Some more war here",
|
|
1950: "Lots of war in here",
|
|
2000: "Computers die",
|
|
2008: "Houses die",
|
|
2019: "People die",
|
|
2048: "2048!",
|
|
2500: "Keep going!",
|
|
3000: "three thousand",
|
|
4000: "four thousand",
|
|
4096: "2^11",
|
|
5000: "halfway to ten thousand",
|
|
10001: "ten thousand one",
|
|
100000: "one hundred thousand",
|
|
1000000: "one million?",
|
|
10000000: "ten millions???",
|
|
100000000: "one hundo billion",
|
|
1000000000: "JK this is actually a billion though",
|
|
10000000000: "I'm not going to create another achievement",
|
|
100000000000: "one hundred billion",
|
|
1000000000000: "It's physically impossible to click this high"
|
|
}
|
|
|
|
|
|
def button(request):
|
|
PRESSED = 'pressed'
|
|
ACHIEVE = 'achievement'
|
|
current = request.session.get(PRESSED, 0)
|
|
request.session[PRESSED] = current + 1
|
|
|
|
if request.method == "POST":
|
|
response = {
|
|
PRESSED: current,
|
|
ACHIEVE: achievements.get(current)
|
|
}
|
|
return JsonResponse(response)
|
|
|
|
pressed = current
|
|
response = {PRESSED: pressed}
|
|
achieved = {k:v for k,v in achievements.items() if k <= pressed}
|
|
response.update({ACHIEVE: achieved})
|
|
return render(request, "ui/button.html", response) |