summaryrefslogtreecommitdiffstats
path: root/alcogotchi-server
diff options
context:
space:
mode:
authorLeightonGinty <57670831+LeightonGinty@users.noreply.github.com>2024-11-17 00:21:37 +0000
committerGitHub <noreply@github.com>2024-11-17 00:21:37 +0000
commit63b690578b51d2058797b4db89502dbb49b15706 (patch)
tree8a212d43dea501f8091b1b6f130a13f0ccd8e463 /alcogotchi-server
parent25a3947a1dc4233b43b2e4e8e79b127fa7dc57f7 (diff)
Add post buy api point
Diffstat (limited to 'alcogotchi-server')
-rw-r--r--alcogotchi-server/alcogotchi.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/alcogotchi-server/alcogotchi.py b/alcogotchi-server/alcogotchi.py
index 7832ca2..4b2a1c1 100644
--- a/alcogotchi-server/alcogotchi.py
+++ b/alcogotchi-server/alcogotchi.py
@@ -11,6 +11,7 @@ class Alcogotchi:
self.drunk = 0
self.health = 100
self.alco_coin = 100
+ self.items = {}
def get_alcogotchi(self):
return self.__dict__
@@ -22,7 +23,13 @@ class Alcogotchi:
return self.get_alcogotchi()
else:
raise Exception("You got no coin")
-
+ def buy_item(self, data):
+ item = dict(data)["item"]
+ self.alco_coin -= 3
+ if item in self.items:
+ self.items[item] += 1
+ else:
+ self.items[item] = 1
def drink(self):
if self.last_drunkentime + 60 < time.time():
self.last_drunkentime = time.time()
@@ -89,7 +96,7 @@ class Server:
ap = network.WLAN(network.AP_IF)
ap.active(True)
-ap.config(essid="Cool Server", password="password123")
+ap.config(essid="Cool Server1", password="password123")
print("Connection avalible on {0}".format(ap.ifconfig()))
@@ -99,5 +106,5 @@ server.add_route("/text", lambda: "Hello World!")
server.add_route("/", alcogotchi.get_alcogotchi)
server.add_route("/drink", alcogotchi.drink)
server.add_route("/gamble", alcogotchi.double_or_nothing)
-
+server.add_route("/buy", alcogotchi.buy_item)
server.start()