diff --git a/files/classes/user.py b/files/classes/user.py index b5cca7bb9..bc27aaee4 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -68,6 +68,7 @@ class User(Base): fail2_utc = Column(Integer, default=0) admin_level = Column(Integer, default=0) coins_spent = Column(Integer, default=0) + lootboxes_bought = Column(Integer, default=0) agendaposter = Column(Boolean, default=False) agendaposter_expires_utc = Column(Integer, default=0) changelogsub = Column(Boolean, default=False) diff --git a/files/routes/awards.py b/files/routes/awards.py index ad6d6493c..ca3953487 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -128,11 +128,9 @@ def buy(v, award): - g.db.add(v) g.db.flush() if award == "lootbox": - send_notification(995, f"@{v.username} bought a lootbox!") for i in [1,2,3,4,5]: thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id thing += 1 @@ -140,12 +138,24 @@ def buy(v, award): award = AwardRelationship(id=thing, user_id=v.id, kind=award) g.db.add(award) g.db.flush() + v.lootboxes_bought += 1 + if v.lootboxes_bought == 10 and not v.has_badge(76): + new_badge = Badge(badge_id=76, user_id=v.id) + g.db.add(new_badge) + elif v.lootboxes_bought == 50 and not v.has_badge(77): + new_badge = Badge(badge_id=77, user_id=v.id) + g.db.add(new_badge) + elif v.lootboxes_bought == 150 and not v.has_badge(78): + new_badge = Badge(badge_id=78, user_id=v.id) + g.db.add(new_badge) + else: thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id thing += 1 award = AwardRelationship(id=thing, user_id=v.id, kind=award) g.db.add(award) + g.db.add(v) g.db.commit() return {"message": "Award bought!"}