forked from MarseyWorld/MarseyWorld
fsd
parent
f1fdeb866c
commit
cc2b6eb006
|
@ -193,6 +193,23 @@ class User(Base):
|
|||
|
||||
return time.strftime("%d %b %Y", time.gmtime(self.created_utc))
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def discount(self):
|
||||
if self.patron == 1: discount = 0.90
|
||||
elif self.patron == 2: discount = 0.85
|
||||
elif self.patron == 3: discount = 0.80
|
||||
elif self.patron == 4: discount = 0.75
|
||||
elif self.patron == 5: discount = 0.70
|
||||
elif self.patron == 6: discount = 0.65
|
||||
else: discount = 1
|
||||
|
||||
for badge in [69,70,71,72,73]:
|
||||
if self.has_badge(badge): discount -= discounts[badge]
|
||||
|
||||
return discount
|
||||
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def user_awards(self):
|
||||
|
|
|
@ -21,21 +21,9 @@ def shop(v):
|
|||
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all():
|
||||
if useraward.kind in AWARDS: AWARDS[useraward.kind]["owned"] += 1
|
||||
|
||||
if v.patron == 1: discount = 0.90
|
||||
elif v.patron == 2: discount = 0.85
|
||||
elif v.patron == 3: discount = 0.80
|
||||
elif v.patron == 4: discount = 0.75
|
||||
elif v.patron == 5: discount = 0.70
|
||||
elif v.patron == 6: discount = 0.65
|
||||
elif v.patron == 7: discount = 0.60
|
||||
else: discount = 1
|
||||
|
||||
for badge in [69,70,71,72,73]:
|
||||
if v.has_badge(badge): discount -= discounts[badge]
|
||||
|
||||
for val in AWARDS.values():
|
||||
val["baseprice"] = int(val["price"])
|
||||
val["price"] = int(val["price"]*discount)
|
||||
val["price"] = int(val["price"] * v.discount)
|
||||
|
||||
sales = g.db.query(func.sum(User.coins_spent)).scalar()
|
||||
return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
|
||||
|
@ -55,18 +43,7 @@ def buy(v, award):
|
|||
if award not in AWARDS: abort(400)
|
||||
price = AWARDS[award]["price"]
|
||||
|
||||
if v.patron == 1: discount = 0.90
|
||||
elif v.patron == 2: discount = 0.85
|
||||
elif v.patron == 3: discount = 0.80
|
||||
elif v.patron == 4: discount = 0.75
|
||||
elif v.patron == 5: discount = 0.70
|
||||
elif v.patron == 6: discount = 0.65
|
||||
else: discount = 1
|
||||
|
||||
for badge in [69,70,71,72,73]:
|
||||
if v.has_badge(badge): discount -= discounts[badge]
|
||||
|
||||
price = int(price*discount)
|
||||
price = int(price * v.discount)
|
||||
|
||||
if request.values.get("mb"):
|
||||
if v.procoins < price: return {"error": "Not enough marseybux."}, 400
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<input type="hidden" name="formkey", value="{{v.formkey}}">
|
||||
<div class="card-columns award-columns awards-wrapper">
|
||||
{% for award in v.user_awards %}
|
||||
<a role="button" id="{{award.kind}}" class="card" onclick="pick('{{award.kind}}', {{award.price}} <= {{v.procoins}}, {{award.price}} <= {{v.coins}})">
|
||||
<a role="button" id="{{award.kind}}" class="card" onclick="pick('{{award.kind}}', {{award.price}}*{{v.discount}} <= {{v.procoins}}, {{award.price}}*{{v.discount}} <= {{v.coins}})">
|
||||
<i class="{{award.icon}} {{award.color}}"></i>
|
||||
<div class="pt-2" style="font-weight: bold; font-size: 14px; color:#E1E1E1">{{award.title}}</div>
|
||||
<div class="text-muted"><span id="{{award.kind}}-owned">{{award.owned}}</span> owned</div>
|
||||
|
|
|
@ -94,4 +94,4 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/assets/js/emoji_modal.js?v=265"></script>
|
||||
<script src="/assets/js/emoji_modal.js?v=266"></script>
|
Loading…
Reference in New Issue