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' try: request.session[PRESSED] except KeyError: request.session[PRESSED] = 0 if request.method == "POST": request.session[PRESSED] += 1 response = { PRESSED: request.session[PRESSED], ACHIEVE: achievements.get(request.session[PRESSED]) } return JsonResponse(response) pressed = request.session[PRESSED] 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) def smooth(request): return render(request, "ui/smooth.html")