-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
82 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
{% extends "layout.html" %} | ||
{% set page_title = "NPC Shop" %} | ||
{% set page_title = "The General Store" %} | ||
{% block body %} | ||
<h1>Vera Everly's Shop</h1> | ||
<img src="/static/img/npc/vera-everly.png" style="width:40%; float: left;"> | ||
<img src="/static/img/npc/evana-devree.png" style="width:40%; float: left;"> | ||
<img src="/static/img/npc/rufus-scippio.png" style="width:40%; float: left;"> | ||
<h1>The General Store</h1> | ||
<div class="npc-bust"> | ||
<img src="{{ random_character_image() }}" /> | ||
</div> | ||
<p> | ||
Heh, welcome to the General Store. The most general store in all of Saylua. | ||
We sell literally everything. | ||
</p> | ||
|
||
<div class="grid-container"> | ||
{% for item in items %} | ||
<div class="grid-element"> | ||
<a href="{{ item.url() }}"> | ||
<img src="{{ item.image_url() }}" class="item" /> | ||
{{ item.name }} | ||
</a> | ||
<p> | ||
{{ (item.buyback_price)|format_number }} Cloud Coins | ||
</p> | ||
<form method="post"> | ||
<input type="number" name="amount" value="1" /> | ||
<button class="subtle-button" name="item_id" value="{{ item.id }}"> | ||
Buy | ||
</button> | ||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" /> | ||
</form> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
from flask import render_template | ||
from saylua import db | ||
from flask import render_template, request, g, flash | ||
|
||
from saylua.modules.items.models.db import Item | ||
from saylua.modules.users.models.db import InvalidCurrencyException | ||
from saylua.utils import int_or_none | ||
|
||
|
||
def npc_shop_view(name): | ||
return render_template("shops/npc.html") | ||
items = db.session.query(Item).all() | ||
|
||
purchase_id = int_or_none(request.form.get('item_id')) | ||
amount = int_or_none(request.form.get('amount')) | ||
if purchase_id and purchase_id > 0 and amount and amount > 0: | ||
purchase = db.session.query(Item).get(purchase_id) | ||
entry = purchase.give_items(g.user.id, amount) | ||
|
||
try: | ||
price = purchase.buyback_price | ||
g.user.cloud_coins -= price * amount | ||
db.session.add(entry) | ||
db.session.commit() | ||
flash("You've successfully purchased %d %s for %d cloud coins." % (amount, purchase.name, amount * price)) | ||
except InvalidCurrencyException: | ||
flash('You do not have the funds to purchase this item.', 'error') | ||
return render_template("shops/npc.html", items=items) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters