diff options
author | Joe Robinson <joe@lc8n.com> | 2021-11-25 03:25:44 +0000 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2021-11-25 03:25:44 +0000 |
commit | 439022f058cb2b9bbf6e2b46c067f4c828a1cab0 (patch) | |
tree | e1f40f477d3bb3597f52250541326885f9dbfdf8 /models |
Initial commit
Diffstat (limited to 'models')
-rw-r--r-- | models/user.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/models/user.py b/models/user.py new file mode 100644 index 0000000..dcf35ab --- /dev/null +++ b/models/user.py @@ -0,0 +1,28 @@ +from peewee import TextField, IntegerField, DateTimeField +import datetime +import random + +from base import BaseModel + + +class User(BaseModel): + + username = TextField() + display_name = TextField() + discord_id = TextField() + level = IntegerField() + exp = IntegerField() + currency = IntegerField() + message_count = IntegerField() + joined_date = DateTimeField(default=datetime.datetime.now) + + def add_coins(self, additional_coins: int): + self.currency = self.currency + additional_coins + + def remove_coins(self, lost_coins: int): + self.currency = self.currency - lost_coins + + def add_message(self): + self.message_count += 1 + gained_exp = random.randrange(10, 15) + self.exp += gained_exp |