-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
385 lines (333 loc) · 19.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BDO Ship Upgrade Recipe Tracker</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/brython_stdlib.js"></script>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
</head>
<body onload=brython({"debug":0})>
<section class="main">
<p>This site uses local storage to save your choices and requires Javascript to function properly<span style="font-family: monospace;">.</span></p>
<p>24/17/8 Added overview keep lists for trade items and ship material barter.</p>
<p>24/12/8 Added Panokseon. Fixed a couple recipes.</p>
<p>Updated to reflect <a href="https://www.naeu.playblackdesert.com/en-US/News/Detail?groupContentNo=7391&countryType=en-US" target="_blank">Patch Notes - August 8, 2024</a> price changes.</p>
<br /><b>Select a ship: </b><span id="shiplist"></span><br /><br />
<span id="shipparts"></span>
<br /><span id="reset"></span>(warning not reversible)
<br/><br/>
<p>
<a href="https://github.com/xanthics/bdo_ship_upgrade/discussions" target="_blank">Suggestions</a>
<br/>
<a href="https://github.com/xanthics/bdo_ship_upgrade/issues" target="_blank">Bugs</a>
</p>
<div id="sponsor">
<div id="patreon_image"><a href="https://www.patreon.com/xanthics"><img alt="Become a Patron!" src="img/[email protected]" class="sponsor_img"></a></div>
</div>
</section>
<script type="text/python">
from browser import document as doc
from browser import html, bind
from browser.html import TABLE, TR, TH, TD, BR, H3, H4, SPAN, B, P, SELECT, OPTION, INPUT
from browser.local_storage import storage
from recipes import recipes
from tradein import barters
from shipbarter import shipbarters
from vendor_items import items
from sea_coins import coins
from ships import ships
from information import gen_info
from totals import tccost
storage_key = "bdo_ship_upgrade"
# Setter storage so that we can differentiate values on this site from others at the same domain
def set_storage(key, val):
storage["{}-{}".format(storage_key, key)] = val
# Getting for storage so that we can differentiate values on this site from others at the same domain
def get_storage(key):
return storage["{}-{}".format(storage_key, key)]
# Check if a value exists in storage
def check_storage(key):
return "{}-{}".format(storage_key, key) in storage
# Reset that only deletes values for this site
def reset_data(ev):
for key in storage.keys():
if key.startswith(storage_key):
del storage[key]
set_storage('ship', "Information")
doc['ship'].value = get_storage('ship')
update(None)
# Given a part name, returns a string with information about that part
# returns empty string if no information
def notes(val):
ret = []
tbart = []
sbart = []
if val in coins:
ret.append("{} Crow Coins".format(coins[val]) + BR())
if val in items:
for i in items[val]:
ret.append(i + BR())
if val in recipes and val not in ships:
for i in recipes[val]:
if i in ["Sangpyeong Coin"]:
ret.append("Exchange: {}x {}".format(recipes[val][i], i) + BR())
else:
ret.append("Recipe: {}x {}".format(recipes[val][i], i) + BR())
if val in barters:
ret.append(B("Trade Item Barter") + BR())
for entry in barters[val]:
for item in entry["input"]:
tbart.append(item)
ret.append("{} per ".format(entry['count']) + SPAN(item, Class="trade{}".format(item[item.find(']') - 1])) + BR())
if val in shipbarters:
ret.append(B("Ship Material Barter") + BR())
for entry in shipbarters[val]:
for item in entry["input"]:
sbart.append(item)
ret.append("{} per ".format(entry['count']) + SPAN(item, Class="trade{}".format(item[item.find(']') - 1])) + BR())
return ret, tbart, sbart
# add a list to a dict key
def addlist(target, source, item):
for key in source:
if key not in target:
target[key] = []
target[key].append(item)
# update missing parts
def update_missing():
missing = {}
for item in doc.select(".current"):
count = int(item['data-max']) - int(doc[item['id']].value)
if count:
if "+" not in item['data-name']:
if item['data-name'] not in missing:
missing[item['data-name']] = 0
missing[item['data-name']] += count
else:
count = 1
if item['data-name'] in ships:
continue
queue = [(item['data-name'], count)]
while queue:
current, c_count = queue.pop()
if current in recipes:
for i in recipes[current]:
n_count = c_count * recipes[current][i]
if "+" not in i:
if i not in missing:
missing[i] = 0
missing[i] += n_count
if "+10" not in i:
queue.append((i, n_count))
if any(["+{} ".format(int(doc[item['id']].value)) in x or x.startswith("Epheria") for x in recipes[current]]):
queue = []
t = TABLE(TR(TH("Count")+TH("Name")+TH("Notes")))
tcoins = TABLE(TR(TH("Name") + TH("Total (Crow Coins)")))
total_remain = 0
tbartitems = {}
sbartitems = {}
for item in sorted(missing):
snotes, tbart, sbart = notes(item)
addlist(tbartitems, tbart, item)
addlist(sbartitems, sbart, item)
t <= TR(TD(missing[item])+TD(item)+TD(snotes))
if item in coins:
cost = coins[item] * missing[item]
total_remain += cost
tcoins <= TR(TD(item) + TD("{:,}".format(cost)))
doc['missing'].text = ''
if total_remain:
tcoins <= TR(TD(B("Total Remaining ({:.2%}) done".format((tccost[get_storage('ship')] - total_remain) / tccost[get_storage('ship')])))+TD("{:,}".format(total_remain)))
doc['missing'] <= H4("Coin tracker") + tcoins
doc['missing'] <= H4("Item tracker") + t
if tbartitems:
tb = TABLE(TR(TH("Name")+TH("Notes")))
for tbp in sorted(tbartitems):
tb <= TR(TD(SPAN(tbp, Class="trade{}".format(tbp[tbp.find(']') - 1])))+TD("<br />".join(tbartitems[tbp])))
doc['missing'] <= H4("Keep for Trade Item Barter") + tb
if sbartitems:
sb = TABLE(TR(TH("Name")+TH("Notes")))
for sbp in sorted(sbartitems):
sb <= TR(TD(SPAN(sbp, Class="trade{}".format(sbp[sbp.find(']') - 1])))+TD("<br />".join(sbartitems[sbp])))
doc['missing'] <= H4("Keep for Ship Material Barter") + sb
# Update the stored value of an item
def update_count(ev):
set_storage(ev.currentTarget['id'], ev.currentTarget.value)
update(None)
# Change what is displayed to match current selection
def update(ev):
if ev:
set_storage('ship', ev.currentTarget.value)
eventname = get_storage('ship')
if eventname == "Information":
show_info()
return
t = TABLE()
t <= TR(TH("Count") + TH("Max") + TH("Name"))
ids = []
recipe_extra = {}
optiontemplate = "<option>{0}</option>"
for part in recipes[eventname]:
newid = "{}-{}".format(eventname, part)
ids.append(newid)
val = 10 if '+' in part else recipes[eventname][part]
name = part[4:] if '+' in part else part
options = [optiontemplate.format(x) for x in range(val+1)]
sel = SELECT(''.join(options), size=1, multiple=False, id=newid, Class="current")
sel['data-name'] = part
sel['data-max'] = val
sel.bind("change", update_count)
titletext = []
if name in coins:
titletext.append("{} Crow Coins".format(coins[name]))
if name in items:
titletext.extend(items[name])
if name in barters:
for barter in barters[name]:
for b in barter["input"]:
titletext.append("{} per {}".format(barter['count'], b))
if name in recipes:
if name not in ships and "Epheria" in name and ((not check_storage(newid)) or get_storage(newid) == "0"):
recipe_extra[name] = 1
titletext.append("**RECIPE**")
titletext.extend(["{}: {}".format(recipes[name][x], x) for x in recipes[name]])
if titletext:
t <= TR(TD(sel) + TD(val) + TD(SPAN("{} (select level)".format(name) if '+' in part else part, title="\n".join(titletext))))
else:
t <= TR(TD(sel) + TD(val) + TD("{} (select level)".format(name) if '+' in part else part))
rec = ''
for item in recipe_extra:
tn = TABLE(TR(TH("Count")+TH("Max")+TH("Name")))
for piece in recipes[item]:
newid = "{}-{}-{}".format(eventname, item, piece)
ids.append(newid)
val = (10 if '+' in piece else recipes[item][piece]) * recipe_extra[item]
name = piece[4:] if '+' in piece else piece
options = [optiontemplate.format(x) for x in range(val+1)]
sel = SELECT(''.join(options), size=1, multiple=False, id=newid, Class="current")
sel['data-name'] = piece
sel['data-max'] = val
sel.bind("change", update_count)
titletext = []
if name in coins:
titletext.append("{} Crow Coins".format(coins[name]))
if name in items:
titletext.extend(items[name])
if name in barters:
for barter in barters[name]:
for b in barter["input"]:
titletext.append("{} per {}".format(barter['count'], b))
if name in recipes:
titletext.append("**RECIPE**")
titletext.extend(["{}: {}".format(recipes[name][x], x) for x in recipes[name]])
if titletext:
tn <= TR(TD(sel) + TD(val) + TD(SPAN("{} (select level)".format(name) if '+' in piece else piece, title="\n".join(titletext))))
else:
tn <= TR(TD(sel) + TD(val) + TD("{} (select level)".format(name) if '+' in piece else piece))
rec += H4("{} {}".format(recipe_extra[item], item)) + tn
doc['shipparts'].text = ''
doc['shipparts'] <= P(B("Ship parts need to be 100% durability for upgrade recipe.") + BR() + "You will need to recover durability with Memory Fragments or the base item." + BR() +"This additional cost is not reflected in the Missing Parts list.")
doc['shipparts'] <= P("Barters for [Level #] items are unlocked based on the total number of barters you have done,<br /> They can randomly appear during any reset once unlocked.")
doc['shipparts'] <= t
if rec:
doc['shipparts'] <= H3("Recipe Subparts") + rec
doc['shipparts'] <= H3("Missing parts (Automatically generated)")
if "Carrack" in eventname:
doc['shipparts'] <= P("Tidal Black Stone upgrades can fail. The number shown is the minimum.")
doc['shipparts'] <= SPAN(id="missing")
# iterate over selection boxes and set to values in local storage.
for id in ids:
if check_storage(id):
doc[id].value = get_storage(id)
else:
doc[id].value = 0
update_missing()
# Initialize our list of ships and select the previous one if a choice exists
def create_ship_list():
sel = html.SELECT(size=1, multiple=False, id="ship", step="1")
for ship in ships:
sel <= html.OPTION(ship)
sel.bind("change", update)
doc['shiplist'] <= sel
if check_storage('ship') and get_storage('ship') in ships:
doc['ship'].value = get_storage('ship')
update(None)
# Code to show an about page and miscellaneous information.
def show_info():
def draw_line(cotx, sx, sy, tx, ty):
cotx.moveTo(sx, sy);
cotx.lineTo(tx, ty);
cotx.stroke();
doc['shipparts'].text = ''
doc['shipparts'] <= gen_info()
font = 16
canvas = doc["shipchart"]
ctx = canvas.getContext("2d")
ctx.font = "{}px monospace".format(font)
voffset = canvas.height/font+10
hval = [
0,
ctx.measureText("Bartali Sailboat").width,
max(ctx.measureText("Epheria Sailboat").width, ctx.measureText("Epheria Frigate").width),
max(ctx.measureText("Improved Sailboat").width, ctx.measureText("Improved Frigate").width),
max(ctx.measureText("Epheria Caravel").width, ctx.measureText("Epheria Galleass").width),
ctx.measureText("Epheria Carrack").width
]
hoffset = []
for idx in range(1,len(hval)+1):
hoffset.append(sum(hval[:idx]))
center = canvas.height/2
# draw background
ctx.fillStyle = "rgb(100,100,100)"
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.fillStyle = "rgb(40,40,40)"
draw_line(ctx, hoffset[0] + hval[1]/2, center , hoffset[1] + hval[2]/2, center - 3*voffset) # Bartali -> Sailboat
draw_line(ctx, hoffset[1] + hval[2]/2, center - 3*voffset, hoffset[2] + hval[3]/2, center - 1*voffset) # sailboat -> improved
draw_line(ctx, hoffset[1] + hval[2]/2, center - 3*voffset, hoffset[3] + hval[4]/2, center - 3*voffset) # sailboat -> caravel
draw_line(ctx, hoffset[2] + hval[3]/2, center - 1*voffset, hoffset[3] + hval[4]/2, center - 3*voffset) # improved -> caravel
draw_line(ctx, hoffset[3] + hval[4]/2, center - 3*voffset, hoffset[4] + hval[5]/2, center - 5*voffset) # caravel -> carrack (advance)
draw_line(ctx, hoffset[3] + hval[4]/2, center - 3*voffset, hoffset[4] + hval[5]/2, center - 1*voffset) # caravel -> carrack (balance)
draw_line(ctx, hoffset[0] + hval[1]/2, center , hoffset[1] + hval[2]/2, center + 3*voffset) # Bartali -> Frigate
draw_line(ctx, hoffset[1] + hval[2]/2, center + 3*voffset, hoffset[2] + hval[3]/2, center + 1*voffset) # frigate -> improved
draw_line(ctx, hoffset[1] + hval[2]/2, center + 3*voffset, hoffset[3] + hval[4]/2, center + 3*voffset) # frigate -> galleass
draw_line(ctx, hoffset[2] + hval[3]/2, center + 1*voffset, hoffset[3] + hval[4]/2, center + 3*voffset) # improved -> galleass
draw_line(ctx, hoffset[3] + hval[4]/2, center + 3*voffset, hoffset[4] + hval[5]/2, center + 1*voffset) # galleass -> carrack (valor)
draw_line(ctx, hoffset[3] + hval[4]/2, center + 3*voffset, hoffset[4] + hval[5]/2, center + 5*voffset) # galleass -> carrack (volante)
ctx.fillRect(0, center-font, ctx.measureText("Bartali Sailboat").width, font*1.5)
ctx.fillRect(hoffset[1], center-font - 3*voffset, ctx.measureText("Epheria Sailboat").width, font*1.5)
ctx.fillRect(hoffset[2], center-font - 1*voffset, ctx.measureText("Improved Sailboat").width, font*1.5)
ctx.fillRect(hoffset[3], center-font - 3*voffset, ctx.measureText("Epheria Caravel").width, font*1.5)
ctx.fillRect(hoffset[4], center-font - 5*voffset, ctx.measureText("Epheria Carrack").width, font*2.5)
ctx.fillRect(hoffset[4], center-font - 1*voffset, ctx.measureText("Epheria Carrack").width, font*2.5)
ctx.fillRect(hoffset[1], center-font + 3*voffset, ctx.measureText("Epheria Frigate").width, font*1.5)
ctx.fillRect(hoffset[2], center-font + 1*voffset, ctx.measureText("Improved Frigate").width, font*1.5)
ctx.fillRect(hoffset[3], center-font + 3*voffset, ctx.measureText("Epheria Galleass").width, font*1.5)
ctx.fillRect(hoffset[4], center-font + 1*voffset, ctx.measureText("Epheria Carrack").width, font*2.5)
ctx.fillRect(hoffset[4], center-font + 5*voffset, ctx.measureText("Epheria Carrack").width, font*2.5)
ctx.fillStyle = "rgb(200,200,200)"
ctx.textAlign = "left"
ctx.fillText("Bartali Sailboat", 0, center)
ctx.fillText("Epheria Sailboat", hoffset[1], center - 3*voffset)
ctx.fillText("Epheria Frigate", hoffset[1], center + 3*voffset)
ctx.fillText("Improved Sailboat", hoffset[2], center - 1*voffset)
ctx.fillText("Improved Frigate", hoffset[2], center + 1*voffset)
ctx.fillText("Epheria Caravel", hoffset[3], center - 3*voffset)
ctx.fillText("Epheria Galleass", hoffset[3], center + 3*voffset)
ctx.fillText("Epheria Carrack", hoffset[4], center - 5*voffset)
ctx.fillText("(Advance)", hoffset[4], center - 5*voffset+font+2)
ctx.fillText("Epheria Carrack", hoffset[4], center - 1*voffset)
ctx.fillText("(Balance)", hoffset[4], center - 1*voffset+font+2)
ctx.fillText("Epheria Carrack", hoffset[4], center + 5*voffset)
ctx.fillText("(Volante)", hoffset[4], center + 5*voffset+font+2)
ctx.fillText("Epheria Carrack", hoffset[4], center + 1*voffset)
ctx.fillText("(Valor)", hoffset[4], center + 1*voffset+font+2)
if (not check_storage('ship')) or get_storage('ship') not in ships:
set_storage('ship', "Information")
b_reset = html.BUTTON("Reset Data")
b_reset.bind("click", reset_data)
doc["reset"] <= b_reset
create_ship_list()
</script>
</body>
</html>