summaryrefslogtreecommitdiff
path: root/models/user.py
blob: dcf35ab194c0cf67235a82d106a615f96f77c03f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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