Spaces:
Sleeping
Sleeping
Commit
·
1996f8e
1
Parent(s):
53e55d4
added function build_iventory_block
Browse files- block_builder.py +140 -1
block_builder.py
CHANGED
@@ -97,6 +97,9 @@ def build_blocks(user_input, block_id):
|
|
97 |
security_id += 1
|
98 |
list_of_blocks.append(security_block)
|
99 |
|
|
|
|
|
|
|
100 |
|
101 |
return list_of_blocks
|
102 |
|
@@ -104,7 +107,7 @@ def build_blocks(user_input, block_id):
|
|
104 |
def process_into_html(item_type,item, block_id):
|
105 |
item_html = f"""<tr>
|
106 |
<td align="left"><strong>{item_type}</strong></td>
|
107 |
-
<td align="right"><textarea class="string-action-description-textarea" id="
|
108 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-{block_id}t" hx-swap="outerHTML"
|
109 |
title="">{item}</textarea></td>
|
110 |
</tr>"""
|
@@ -372,6 +375,142 @@ def build_section_entry_block(section, entry, entry_id, block_id):
|
|
372 |
|
373 |
return section_block_html
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
#Text Area Template
|
376 |
"""<textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
377 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
|
|
97 |
security_id += 1
|
98 |
list_of_blocks.append(security_block)
|
99 |
|
100 |
+
inventory_block = build_inventory_block(user_input['inventory'], block_id)
|
101 |
+
block_id = block_id + 1
|
102 |
+
list_of_blocks.append(inventory_block)
|
103 |
|
104 |
return list_of_blocks
|
105 |
|
|
|
107 |
def process_into_html(item_type,item, block_id):
|
108 |
item_html = f"""<tr>
|
109 |
<td align="left"><strong>{item_type}</strong></td>
|
110 |
+
<td align="right"><textarea class="string-action-description-textarea" id="{item_type}-{block_id}"
|
111 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-owners-{block_id}t" hx-swap="outerHTML"
|
112 |
title="">{item}</textarea></td>
|
113 |
</tr>"""
|
|
|
375 |
|
376 |
return section_block_html
|
377 |
|
378 |
+
def build_inventory_block(inventory, block_id):
|
379 |
+
inventory_block_html = f""""""
|
380 |
+
inventory_block_html += f"""<div class="block-item" data-block-id="{block_id}">"""
|
381 |
+
inventory_block_html += f"""<div class="block classTable frame decoration">
|
382 |
+
<h5 id="inventory">Inventory</h5>
|
383 |
+
<table>
|
384 |
+
<thead>
|
385 |
+
<tr>
|
386 |
+
<th align="center">Name</th>
|
387 |
+
<th align="center">Type</th>
|
388 |
+
<th align="left">Cost</th>
|
389 |
+
<th align="center">Properties</th>
|
390 |
+
</tr>
|
391 |
+
</thead>
|
392 |
+
<tbody>"""
|
393 |
+
# Create a list of the keys in the inventory, each key is the type of items
|
394 |
+
list_of_type = list(inventory.keys())
|
395 |
+
# Iterate through keys and check if the value is greater than an empty list
|
396 |
+
for type in list_of_type:
|
397 |
+
inventory_type = inventory[type]
|
398 |
+
if len(inventory_type) > 0 :
|
399 |
+
# iterate through items in inventory type list, each item is a dictionary with prescribed values.
|
400 |
+
# Need to check for list in properties.
|
401 |
+
for item in inventory_type:
|
402 |
+
item['properties'] = ', '.join(item['properties'])
|
403 |
+
item_block_html = f"""<tr>
|
404 |
+
<td align="center"><textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
405 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
406 |
+
title={type}>{item['name']}</textarea></td>
|
407 |
+
<td align="center"><textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
408 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
409 |
+
title={type}>{item['type']}</textarea></td>
|
410 |
+
<td align="center"><textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
411 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
412 |
+
title={type}>{item['cost']}</textarea></td>
|
413 |
+
<td align="center"><textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
414 |
+
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|
415 |
+
title={type}>{item['properties']}</textarea></td>
|
416 |
+
</tr>"""
|
417 |
+
|
418 |
+
inventory_block_html += item_block_html
|
419 |
+
inventory_block_html += f"""</tbody>
|
420 |
+
</table>
|
421 |
+
</div>
|
422 |
+
</div>"""
|
423 |
+
return inventory_block_html
|
424 |
+
"""<div class="Block_13">
|
425 |
+
<div class="block classTable frame decoration">
|
426 |
+
<h5 id="inventory">Inventory</h5>
|
427 |
+
<table>
|
428 |
+
<thead>
|
429 |
+
<tr>
|
430 |
+
<th align="center">Name</th>
|
431 |
+
<th align="center">Type</th>
|
432 |
+
<th align="left">Cost</th>
|
433 |
+
<th align="center">Properties</th>
|
434 |
+
</tr>
|
435 |
+
</thead>
|
436 |
+
<tbody>
|
437 |
+
<tr>
|
438 |
+
<td align="center">Poultry Drumsticks</td>
|
439 |
+
<td align="center">Meat</td>
|
440 |
+
<td align="left">1 gp per lbs</td>
|
441 |
+
<td align="center"></td>
|
442 |
+
</tr>
|
443 |
+
<tr>
|
444 |
+
<td align="center">Ground Beef</td>
|
445 |
+
<td align="center">Meat</td>
|
446 |
+
<td align="left">1 gp per lbs</td>
|
447 |
+
<td align="center"></td>
|
448 |
+
</tr>
|
449 |
+
<tr>
|
450 |
+
<td align="center">Pork Chops</td>
|
451 |
+
<td align="center">Meat</td>
|
452 |
+
<td align="left">1 gp per lbs</td>
|
453 |
+
<td align="center"></td>
|
454 |
+
</tr>
|
455 |
+
<tr>
|
456 |
+
<td align="center">Bacon Strips</td>
|
457 |
+
<td align="center">Meat</td>
|
458 |
+
<td align="left">1 gp per lbs</td>
|
459 |
+
<td align="center"></td>
|
460 |
+
</tr>
|
461 |
+
<tr>
|
462 |
+
<td align="center">Sausage Links</td>
|
463 |
+
<td align="center">Meat</td>
|
464 |
+
<td align="left">1 gp per lbs</td>
|
465 |
+
<td align="center"></td>
|
466 |
+
</tr>
|
467 |
+
<tr>
|
468 |
+
<td align="center">Mystic Minotaur Steak</td>
|
469 |
+
<td align="center">Exotic Meat</td>
|
470 |
+
<td align="left">25 gold per pound</td>
|
471 |
+
<td align="center">Grants temporary strength boost when consumed, Requires fine culinary skills to cook properly</td>
|
472 |
+
</tr>
|
473 |
+
<tr>
|
474 |
+
<td align="center">Quantum Quail</td>
|
475 |
+
<td align="center">Exotic Poultry</td>
|
476 |
+
<td align="left">15 gold each</td>
|
477 |
+
<td align="center">“Phases in and out of existence”, “Can enhance one’s agility”</td>
|
478 |
+
</tr>
|
479 |
+
<tr>
|
480 |
+
<td align="center">Invisible Bacon</td>
|
481 |
+
<td align="center">Mystical Meat</td>
|
482 |
+
<td align="left">10 gold per slice</td>
|
483 |
+
<td align="center">“Invisible to the naked eye”, “Tastes incredibly savory”, “Can only be seen with a special spell”</td>
|
484 |
+
</tr>
|
485 |
+
<tr>
|
486 |
+
<td align="center">Hydra Sausage</td>
|
487 |
+
<td align="center">Mythical Meat</td>
|
488 |
+
<td align="left">50 gold per link</td>
|
489 |
+
<td align="center">“Each bite regenerates after a while”, “Consuming too much may cause mild hallucinations”</td>
|
490 |
+
</tr>
|
491 |
+
<tr>
|
492 |
+
<td align="center">Cursed Cleaver</td>
|
493 |
+
<td align="center">Kitchen Equipment</td>
|
494 |
+
<td align="left">100 gold</td>
|
495 |
+
<td align="center">“Cuts through any meat effortlessly”, “Occasionally whispers in a long-forgotten language”, “Rumored to be haunted”</td>
|
496 |
+
</tr>
|
497 |
+
<tr>
|
498 |
+
<td align="center">Vampire Spice Mix</td>
|
499 |
+
<td align="center">Cooking Ingredient</td>
|
500 |
+
<td align="left">20 gold per pouch</td>
|
501 |
+
<td align="center">“Adds a distinct flavor”, “Enhances blood flow in the consumer”, “Leaves a lingering aftertaste of garlic”</td>
|
502 |
+
</tr>
|
503 |
+
<tr>
|
504 |
+
<td align="center">Phoenix Feather Skewers</td>
|
505 |
+
<td align="center">Cooking Utensil</td>
|
506 |
+
<td align="left">75 gold per set</td>
|
507 |
+
<td align="center">“Prevents meat from overcooking”, “Gives a slight warmth to cooked items”, “Reusable endlessly”</td>
|
508 |
+
</tr>
|
509 |
+
</tbody>
|
510 |
+
</table>
|
511 |
+
</div> <!--Close Block_12-->
|
512 |
+
</div>"""
|
513 |
+
|
514 |
#Text Area Template
|
515 |
"""<textarea class="string-action-description-textarea" id="user-store-rumors-{block_id}"
|
516 |
hx-post="/update-stats" hx-trigger="change" hx-target="#user-store-rumors-{block_id}t" hx-swap="outerHTML"
|