gestion item vide

aurian
Aurian JAULT 2 years ago
parent 13d78e82a7
commit f758144ee8

@ -0,0 +1,18 @@
@using Models;
<h3>Inventory</h3>
<div class="css-grid">
@for(int i = 0; i<InventoryList.size;i++)
{
if (inventory.InvItems[i] != null)
{
<InventoryItem item="@inventory.InvItems[i]" />
}
else
{
/*Empty case*/
<h3>0</h3>
}
}
</div>

@ -0,0 +1,10 @@
using Blazor.Models;
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
partial class Inventory
{
[Parameter]
public InventoryList inventory { get; set; }
}
}

@ -0,0 +1,6 @@
.css-grid {
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;
display: grid;
width: 286px;
}

@ -0,0 +1,11 @@
using Blazor.Models;
using Microsoft.AspNetCore.Components;
namespace Blazor.Components
{
public partial class InventoryItem
{
[Parameter]
public Models.InventoryItem item { get; set; }
}
}

@ -0,0 +1,15 @@
namespace Blazor.Models
{
public class InventoryItem
{
public Item item;
int stack;
public int Stack { get; set; }
public InventoryItem()
{
item = new Item();
Stack = 64;
}
}
}

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Http.Features;
namespace Blazor.Models
{
public partial class InventoryList
{
static public int size = 18;
List<InventoryItem> inventoryItems = new List<InventoryItem>(new InventoryItem[size]);
public List<InventoryItem> InvItems { get; set; }
public InventoryList()
{
InvItems = new List<InventoryItem>(new InventoryItem[size]);
/*InvItems[0] = new InventoryItem();*/
}
}
}

@ -12,5 +12,17 @@
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
public string ImageBase64 { get; set; }
public Item()
{
Id = 2;
DisplayName = "Dirt";
Name = "Block_of_dirt";
StackSize = 64;
MaxDurability= 9999;
EnchantCategories = new List<string>();
RepairWith = new List<string>();
CreatedDate= DateTime.Now;
UpdatedDate = DateTime.Now;
}
}
}

@ -1,5 +1,5 @@
@page "/"
@using Blazor.Components;
<div>
<Crafting Items="Items" Recipes="Recipes" />
<Inventory inventory="inventory"/>
</div>

@ -7,6 +7,12 @@ namespace Blazor.Pages
{
public partial class Index
{
/* TEST */
InventoryList inventory = new InventoryList();
[Inject]
public IDataService DataService { get; set; }

@ -7,7 +7,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="https://codefirst.iut.uca.fr/containers/blazor-web-remiarnal/" />
@*<base href="https://codefirst.iut.uca.fr/containers/blazor-web-remiarnal/" />*@
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="Blazor.styles.css" rel="stylesheet" />

Loading…
Cancel
Save