From aba212e13062c43a1192ef885b05145ac1cc9fe7 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 23 May 2021 17:06:34 -0400 Subject: Bazaar with buy orders, sell orders, and order cancellation --- app/views/application/_navbar.html.erb | 3 + app/views/bazaar/index.html.erb | 128 +++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 app/views/bazaar/index.html.erb (limited to 'app/views') diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index ef81d6c..c0e2761 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -12,5 +12,8 @@
  • <%= link_to "Hearth", character_hearth_path(current_char) %>
  • +
  • + <%= link_to "Bazaar", bazaar_path %> +
  • <% end %> diff --git a/app/views/bazaar/index.html.erb b/app/views/bazaar/index.html.erb new file mode 100644 index 0000000..63d708f --- /dev/null +++ b/app/views/bazaar/index.html.erb @@ -0,0 +1,128 @@ +

    Numedite Bazaar

    + +

    The small, cloaked people known as the Numedites travel this way and that across the planes. + Because their ways are spiritual in nature, they use their innate magic to facilitate + distant trade at no cost to their clientele.

    + +

    You have <%= current_char.vestige %> vestige.

    + +
    +

    Post Order

    + +

    Sell orders can be posted with a caravan of numedites, offering items for vestige. + Buy orders can also be posted, offering vestige for items.

    + + <%= form_with url: bazaar_order_path, class: "my-4" do |f| %> +
    + <%= f.label :item_id, "Item" %> + <%= f.select :item_id, @items.map { |i| [i.name, i.id] } %> +
    +
    + <%= f.label :quantity, "Quantity" %> + <%= f.number_field :quantity, required: true, min: 1, max: 2_000_000_000 %> +
    +
    + <%= f.label :price_each, "Price Each" %> + <%= f.number_field :price_each, required: true, min: 1, max: 2_000_000_000 %> +
    +
    + <%= f.label :buy_order, "Post as buy order" %> + <%= f.check_box :buy_order %> +
    +
    + <%= f.submit "Post Order" %> +
    + <% end %> +
    + +
    +

    Your Orders

    + + + + + + + + + + + + <% @bazaar_orders.where(character: current_char).each do |bo| %> + + + + + + + + <% end %> + +
    ItemQuantityTypePrice EachCancel
    <%= bo.item.name %><%= bo.quantity %><%= bo.buy_order? ? "Buy" : "Sell" %><%= bo.price_each %> + <%= button_to "Cancel", bazzar_cancel_offer_path(id: bo.id), method: :delete %> +
    +
    + +
    +

    Sell Orders

    + + + + + + + + + + + + + <% @bazaar_orders.where(buy_order: false).each do |bo| %> + + + + + + + + <% end %> + +
    ItemQuantityFromPrice EachBuy
    <%= bo.item.name %><%= bo.quantity %><%= bo.character.name %><%= bo.price_each %> + <%= form_with url: bazzar_accept_offer_path(id: bo.id) do |f| %> + <%= f.number_field :quantity, value: 1, min: 1, max: 2_000_000_000, required: true %> + <%= f.submit "Buy" %> + <% end %> +
    +
    + +
    +

    Buy Orders

    + + + + + + + + + + + + + <% @bazaar_orders.where(buy_order: true).each do |bo| %> + + + + + + + + <% end %> + +
    ItemQuantityFromPrice EachSell
    <%= bo.item.name %><%= bo.quantity %><%= bo.character.name %><%= bo.price_each %> + <%= form_with url: bazzar_accept_offer_path(id: bo.id) do |f| %> + <%= f.number_field :quantity, value: 1, min: 1, max: 2_000_000_000, required: true %> + <%= f.submit "Sell" %> + <% end %> +
    +
    -- cgit v1.2.3