diff options
author | alex | 2018-10-20 00:40:15 +0100 |
---|---|---|
committer | alex | 2018-10-20 00:45:25 +0100 |
commit | 289684b0f117181c03e4e5ef6616d574da9a1981 (patch) | |
tree | 1a803992f7bec0a46b5838141c72b5192c14ecc6 /osrc/watbot_player.py | |
parent | 64cbb5254ad6308e4dab42cc1e3fdcea9d8d6893 (diff) | |
download | watbot-289684b0f117181c03e4e5ef6616d574da9a1981.tar.gz watbot-289684b0f117181c03e4e5ef6616d574da9a1981.tar.bz2 watbot-289684b0f117181c03e4e5ef6616d574da9a1981.zip |
sorry for rehosting ur stuff (。◕ ‿ ◕。)
Added original source
Fixed readme typo (I fat fingered your username again whoops)
Fiddling with golang config
Diffstat (limited to 'osrc/watbot_player.py')
-rw-r--r-- | osrc/watbot_player.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/osrc/watbot_player.py b/osrc/watbot_player.py new file mode 100644 index 0000000..5c4267b --- /dev/null +++ b/osrc/watbot_player.py @@ -0,0 +1,46 @@ +#!/usr/bin/python + +import time + +class WatbotPlayer: + """class representing a player account""" + + def __init__(self, db, nick): + self.nick = nick + self.db = db + + ( + self.watting_exp, + self.anarchy_exp, + self.trickery_exp, + self.coins, + self.last_mine, + self.health, + self.last_rest + ) = db.get_account(nick) + + self.watting = self.get_level(self.watting_exp) + self.anarchy = self.get_level(self.anarchy_exp) + self.trickery = self.get_level(self.trickery_exp) + + now = time.time() + delta = now - self.last_rest + if delta > 60: + self.health += int(delta/60) + if self.health > 10: + self.health = 10 + + self.last_rest += int(delta/60) * 60 + + def get_level(self, exp): + if exp < 100: + level = int(exp/10) + elif exp < 900: + level = 10 + int(exp/100) + else: + level = 99 + + return level + + def update(self, log): + self.db.update_account(self.nick, self.watting_exp, self.anarchy_exp, self.trickery_exp, self.coins, self.last_mine, self.health, self.last_rest, log) |