Skip to content

Commit

Permalink
Add the button to use the item as a weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadawoo committed Jan 9, 2025
1 parent 1c0f0cf commit d09eee7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/view/HtmlButtons.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function __construct()
],
'fight' => [
'icon' => '',
'name' => 'Attaquer avec',
'name' => 'Attaquer les zombies',
'title' => "",
'fields' => [
'api_name' => 'zone',
Expand Down Expand Up @@ -594,7 +594,7 @@ function use_item($button_alias, $item_id, $item_name)
$fields = $button['fields'];

return
'<form method="post" action="#popsuccess">
'<form method="post" action="#popsuccess" name="fight">
<input type="hidden" name="api_name" value="'.$fields['api_name'].'">
<input type="hidden" name="action" value="'.$fields['action'].'">
<input type="hidden" name="params[item_id]" value="'.$item_id.'">
Expand Down
6 changes: 5 additions & 1 deletion core/view/HtmlItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function item_template()
$buttons = new HtmlButtons();
$button_drop = $buttons->drop_item(0);
$button_pickup = $buttons->pickup_item(0);
$button_fight = $buttons->use_item('fight', 0, '');
$button_use = $buttons->use_item('{item_alias}', 0, '{item_name}');

return '
Expand Down Expand Up @@ -54,7 +55,10 @@ function item_template()
Cet objet est encombrant
</li>
</ul>
'.$button_use . $button_drop . $button_pickup.'
'.$button_fight
.$button_use
.$button_drop
.$button_pickup.'
</div>
</li>
</template>';
Expand Down
4 changes: 4 additions & 0 deletions public/resources/js/actionBlocks.func.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ function htmlItem(itemId, itemCaracs) {
if(itemCaracs["heaviness"] > 0) {
template.querySelector('.item_label .heaviness').classList.remove("hidden");
}
// Display the button to use the item as a weapon
if(itemCaracs["item_type"] === "weapon") {
template.querySelector("form[name='fight'] input[name='params[item_id]']").value = itemId;
}

return template;
}
Expand Down

0 comments on commit d09eee7

Please sign in to comment.