Skip to content

Commit

Permalink
can now supply exchange amount in /drops/exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsndk committed Oct 13, 2024
1 parent dfe54be commit 1de502f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ def map_to_html(m):
@app.route('/drops/exchange')
def serve_drops_exchange():
domain=gdi(request)
table=gdmul(request,"table")
table,exchanges=gdmul(request,"table","exchanges")

if not exchanges:
exchanges = 100

def drop_table_to_html(m):
return """
Expand Down Expand Up @@ -345,7 +348,7 @@ def drop_table_to_html(m):

return html

return whtml(request,"utility/htmls/drops/exchange.html",domain=domain,table=table)
return whtml(request,"utility/htmls/drops/exchange.html",domain=domain,table=table,exchanges=exchanges)

@app.route('/privacy')
def serve_privacy():
Expand Down
12 changes: 10 additions & 2 deletions utility/htmls/drops/exchange.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
</style>
<script>
const table = G.drops.{{table}};//G.drops.invasion_accessoriesbox_tier0;
const ROLL_COUNT = 100;
const ROLL_COUNT = {{exchanges}};

function hide_row(element) {
console.log("parent", this, $(element).closest("tr"));
Expand Down Expand Up @@ -299,7 +299,7 @@


// collect rolls and summerize them and render that
const rollsByItem = {};
let rollsByItem = {};
const rolls = []
for (let index = 0; index < ROLL_COUNT; index++) {
const [roll, itemKey] = exchange(table)
Expand All @@ -312,6 +312,14 @@
rolls.push([roll, itemKey])
}

// Sort by the first roll (index 0) of each item in ascending order
const sortedRollsByItem = Object.entries(rollsByItem).sort((a, b) => {
return b[1][0] - a[1][0];
});

// If you want to convert it back to an object:
rollsByItem = Object.fromEntries(sortedRollsByItem);

html = `<h1>Summery for ${ROLL_COUNT} exchanges</h1>`
html += "<div id=\"rolls-summery\">"

Expand Down

0 comments on commit 1de502f

Please sign in to comment.