diff --git a/Blazor/Blazor/Components/Inventory.razor b/Blazor/Blazor/Components/Inventory.razor
index ac79db9..c02d63c 100644
--- a/Blazor/Blazor/Components/Inventory.razor
+++ b/Blazor/Blazor/Components/Inventory.razor
@@ -5,14 +5,15 @@
@for(int i = 0; i
+
}
else
{
- /*Empty case*/
-
0
+
+

+
}
}
\ No newline at end of file
diff --git a/Blazor/Blazor/Components/Inventory.razor.cs b/Blazor/Blazor/Components/Inventory.razor.cs
index 8c2fccb..cb45dde 100644
--- a/Blazor/Blazor/Components/Inventory.razor.cs
+++ b/Blazor/Blazor/Components/Inventory.razor.cs
@@ -1,4 +1,5 @@
using Blazor.Models;
+using Blazor.Pages;
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
@@ -6,5 +7,52 @@ namespace Blazor.Components
{
[Parameter]
public InventoryList inventory { get; set; }
+
+ public void Add(Item item)
+ {
+ foreach(InventoryItem element in inventory.inventoryItems)
+ {
+ if(item.Id == element.item.Id)
+ {
+ if(element.Stack == element.item.StackSize)
+ {
+ addEnd(item);
+ return;
+ }
+ else
+ {
+ element.Stack += 1;
+ return;
+ }
+ }
+ if(element == null)
+ {
+ element.item = item;
+ element.Stack = 1;
+ return;
+ }
+ }
+ /*Si c'est ici c'est que l'inventaire est plein jsais pas si il faut avertir le user*/
+ }
+
+ public void addEnd(Item item)
+ {
+ int i = 0;
+ while (inventory.inventoryItems[i]!=null)
+ {
+ i += 1;
+ }
+ if(i < InventoryList.size)
+ {
+ inventory.inventoryItems[i].item = item;
+ inventory.inventoryItems[i].Stack = 1;
+ }
+ else
+ {
+ /*Inventaire plein même cas que la fonction add*/
+ }
+ }
+
+
}
}
diff --git a/Blazor/Blazor/Components/Inventory.razor.css b/Blazor/Blazor/Components/Inventory.razor.css
index 5d012f5..1995814 100644
--- a/Blazor/Blazor/Components/Inventory.razor.css
+++ b/Blazor/Blazor/Components/Inventory.razor.css
@@ -2,5 +2,5 @@
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;
display: grid;
- width: 286px;
+ width: 40%;
}
\ No newline at end of file
diff --git a/Blazor/Blazor/Components/InventoryItem.razor b/Blazor/Blazor/Components/InventoryItem.razor
deleted file mode 100644
index 5037586..0000000
Binary files a/Blazor/Blazor/Components/InventoryItem.razor and /dev/null differ
diff --git a/Blazor/Blazor/Components/ItemInventory.razor b/Blazor/Blazor/Components/ItemInventory.razor
new file mode 100644
index 0000000..9053490
--- /dev/null
+++ b/Blazor/Blazor/Components/ItemInventory.razor
@@ -0,0 +1,3 @@
+
+ @items.item
+
\ No newline at end of file
diff --git a/Blazor/Blazor/Components/InventoryItem.razor.cs b/Blazor/Blazor/Components/ItemInventory.razor.cs
similarity index 57%
rename from Blazor/Blazor/Components/InventoryItem.razor.cs
rename to Blazor/Blazor/Components/ItemInventory.razor.cs
index 96ab613..92b0953 100644
--- a/Blazor/Blazor/Components/InventoryItem.razor.cs
+++ b/Blazor/Blazor/Components/ItemInventory.razor.cs
@@ -3,9 +3,9 @@ using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
- public partial class InventoryItem
+ public partial class ItemInventory
{
[Parameter]
- public Models.InventoryItem item { get; set; }
+ public InventoryItem items { get; set; }
}
}
diff --git a/Blazor/Blazor/Components/ItemInventory.razor.css b/Blazor/Blazor/Components/ItemInventory.razor.css
new file mode 100644
index 0000000..b2d4521
--- /dev/null
+++ b/Blazor/Blazor/Components/ItemInventory.razor.css
@@ -0,0 +1,6 @@
+.item {
+ width: 64px;
+ height: 64px;
+ border: 1px solid;
+ overflow: hidden;
+}
diff --git a/Blazor/Blazor/Models/InventoryList.cs b/Blazor/Blazor/Models/InventoryList.cs
index 4bac837..6dfd9fb 100644
--- a/Blazor/Blazor/Models/InventoryList.cs
+++ b/Blazor/Blazor/Models/InventoryList.cs
@@ -5,13 +5,11 @@ namespace Blazor.Models
public partial class InventoryList
{
static public int size = 18;
- List inventoryItems = new List(new InventoryItem[size]);
- public List InvItems { get; set; }
+ public List inventoryItems = new List(new InventoryItem[size]);
public InventoryList()
{
- InvItems = new List(new InventoryItem[size]);
- /*InvItems[0] = new InventoryItem();*/
+ inventoryItems[0] = new InventoryItem();
}
}
}