rage and impatience
This commit is contained in:
parent
b3f5559348
commit
43e68e7da6
1 changed files with 11 additions and 10 deletions
|
@ -277,21 +277,22 @@ def create_sub2(v):
|
||||||
if not name: abort(400)
|
if not name: abort(400)
|
||||||
name = name.strip().lower()
|
name = name.strip().lower()
|
||||||
|
|
||||||
|
if v.id == MENTION_ID: cost = 0
|
||||||
|
else:
|
||||||
|
num = v.subs_created + 1
|
||||||
|
for a in v.alts:
|
||||||
|
num += a.subs_created
|
||||||
|
cost = num * 100
|
||||||
|
|
||||||
if not valid_sub_regex.fullmatch(name):
|
if not valid_sub_regex.fullmatch(name):
|
||||||
return render_template("sub/create_sub.html", v=v, error="Sub name not allowed."), 400
|
return render_template("sub/create_sub.html", v=v, cost=cost, error="Sub name not allowed."), 400
|
||||||
|
|
||||||
sub = g.db.query(Sub).filter_by(name=name).one_or_none()
|
sub = g.db.query(Sub).filter_by(name=name).one_or_none()
|
||||||
if not sub:
|
if not sub:
|
||||||
if v.id != MENTION_ID:
|
if v.coins < cost:
|
||||||
num = v.subs_created + 1
|
return render_template("sub/create_sub.html", v=v, cost=cost, error="You don't have enough coins!"), 403
|
||||||
for a in v.alts:
|
|
||||||
num += a.subs_created
|
|
||||||
cost = num * 100
|
|
||||||
|
|
||||||
if v.coins < cost:
|
v.coins -= cost
|
||||||
return render_template("sub/create_sub.html", v=v, error="You don't have enough coins!"), 403
|
|
||||||
|
|
||||||
v.coins -= cost
|
|
||||||
|
|
||||||
v.subs_created += 1
|
v.subs_created += 1
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue