Inventory done, the addition of an item in the inventory via the chest and adjustment of the duplication and the deletion on the crafting table is also done, and the improvement of the view of the list of items has been made #17

Merged
emre.kartal merged 1 commits from Emre_Inventaire into master 2 years ago

@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<div class="body"> <div class="body">
<div class="row"> <div class="row">
<div>Recipe</div> <div>Table de craft</div>
<div> <div>
@ -34,6 +34,10 @@
{ {
<CraftingItem Item="item" NoDrop="true"/> <CraftingItem Item="item" NoDrop="true"/>
} }
@for (int i = 0; i < 64 - Items.Count; i++)
{
<CraftingItem/>
}
</div> </div>
</div> </div>

@ -7,7 +7,8 @@
@ondragstart="@OnDragStart" @ondragstart="@OnDragStart"
@ondrop="@OnDrop" @ondrop="@OnDrop"
@ondragenter="@OnDragEnter" @ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave"> @ondragleave="@OnDragLeave"
@ondragend="@OnDragEnd">
@if (Item != null) @if (Item != null)
{ {

@ -28,6 +28,18 @@ namespace CraftSharp.Components
Parent.Actions.Add(new CraftingAction { Action = "Drag Enter", Item = this.Item, Index = this.Index }); Parent.Actions.Add(new CraftingAction { Action = "Drag Enter", Item = this.Item, Index = this.Index });
} }
internal void OnDragEnd()
{
if (NoDrop)
{
return;
}
Parent.RecipeItems[this.Index] = null;
Item = null;
Parent.CheckRecipe();
}
internal void OnDragLeave() internal void OnDragLeave()
{ {
if (NoDrop) if (NoDrop)

@ -9,5 +9,15 @@
public List<Item> Inventory { get; set; } = new List<Item>(); public List<Item> Inventory { get; set; } = new List<Item>();
public List<UserRoles> Roles { get; set; } = new List<UserRoles>() { UserRoles.User }; public List<UserRoles> Roles { get; set; } = new List<UserRoles>() { UserRoles.User };
public void addItem(Item item)
{
Inventory.Add(item);
}
public int getSizeInventory()
{
return Inventory.Count;
}
} }
} }

@ -20,7 +20,7 @@ namespace CraftSharp.Models
public int StackSize { get; set; } public int StackSize { get; set; }
[Required] [Required]
[Range(1, 125)] [Range(0, 125)]
public int MaxDurability { get; set; } public int MaxDurability { get; set; }
public List<string> EnchantCategories { get; set; } public List<string> EnchantCategories { get; set; }

@ -20,13 +20,12 @@ namespace CraftSharp.Pages
bool isChestClosed = true; bool isChestClosed = true;
int itemOpacity = 0; int itemOpacity = 0;
[Inject] [Inject]
public IDataService DataService { get; set; } public IDataService DataService { get; set; }
[Inject] [Inject]
public CustomStateProvider AuthService { get; set; } public CustomStateProvider AuthService { get; set; }
[Inject]
public CustomStateProvider AuthStateProvider { get; set; }
[CascadingParameter] [CascadingParameter]
public Task<AuthenticationState> Context { get; set; } public Task<AuthenticationState> Context { get; set; }
@ -61,6 +60,14 @@ namespace CraftSharp.Pages
{ {
NumberOfKeys=NumberOfKeys-CostInKeys; NumberOfKeys=NumberOfKeys-CostInKeys;
randomItem = ItemFactory.GetRandomItem(items); randomItem = ItemFactory.GetRandomItem(items);
if (AuthStateProvider.GetCurrentUser().getSizeInventory() <= 64)
{
//Vérifie quel n'existe pas déjà dans la liste
if (!AuthStateProvider.GetCurrentUser().Inventory.Any(n => n.Id == randomItem.Id))
{
AuthStateProvider.GetCurrentUser().addItem(randomItem);
}
}
Console.WriteLine(randomItem.Name); Console.WriteLine(randomItem.Name);
openingAnimation(); openingAnimation();
} }

@ -9,9 +9,9 @@ namespace CraftSharp.Pages
{ {
[Inject] [Inject]
public IDataService DataService { get; set; } public IDataService DataService { get; set; }
public List<Item> Items { get; set; } = new List<Item>(); public List<Item> Items { get; set; } = new List<Item>();
[Inject]
public CustomStateProvider AuthStateProvider { get; set; }
private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>(); private List<CraftingRecipe> Recipes { get; set; } = new List<CraftingRecipe>();
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
@ -23,7 +23,8 @@ namespace CraftSharp.Pages
return; return;
} }
Items = await DataService.List(0, await DataService.Count()); //Items = await DataService.List(0, await DataService.Count());
Items = AuthStateProvider.GetCurrentUser().Inventory;
Recipes = await DataService.GetRecipes(); Recipes = await DataService.GetRecipes();
StateHasChanged(); StateHasChanged();

@ -1,26 +0,0 @@
@inherits LayoutComponentBase
<PageTitle>CraftSharp</PageTitle>
<div class="page">
<div class="wrap">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
<div class="px-4">
<CultureSelector/>
</div>
</div>
<article class="content">
@Body
</article>
</main>
</div>
</div>

@ -1,73 +0,0 @@
.page {
display: flex;
}
main {
flex: 1;
}
.wrap {
display: flex;
flex-direction: column;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(120,51,174) 0%, #411186 90%);
}
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}
.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}
.top-row.auth {
justify-content: space-between;
}
.top-row a, .top-row .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 100%;
position: sticky;
top: 0;
}
.top-row {
position: sticky;
top: 0;
z-index: 1;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}

@ -1,47 +0,0 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav>
<div class="nav-item px-2">
<NavLink class="nav-link" href="opening" Match="NavLinkMatch.All">
<span class="oi oi-key"></span> Ouverture
</NavLink>
</div>
<div>
<img class="nav-image" src="Images/CraftSharp-Logo.png" alt="Logo Application"/>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus"></span> Magasin
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-box"></span> Inventaire
</NavLink>
</div>
<div>
<div class="button"> Se connecter
</div>
<div class="button"> Se déconnecter
</div>
</div>
</nav>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}

@ -1,85 +0,0 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}
.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.oi {
width: 3rem;
font-size: 1.7rem;
top: -2px;
}
.nav-image {
width: 20rem;
color: #ffffff;
}
.button {
height: 6rem;
width: 13rem;
text-decoration: none;
text-align: center;
color: white;
cursor: pointer;
background: url('Images/btn1.png') no-repeat;
font-family: SilkscreenNormal;
line-height: 26px;
padding-top: 6px;
}
.button:hover {
background: url('Images/btn2.png') no-repeat;
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
font-family: SuperDario;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}
.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}

@ -18,6 +18,10 @@ a, .btn-link {
border-color: #1861ac; border-color: #1861ac;
} }
.table {
color: #ffffff;
}
.content { .content {
padding-top: 1.1rem; padding-top: 1.1rem;
} }

Loading…
Cancel
Save