actions done

Storage done
master
Aurian JAULT 2 years ago
parent 909f0b01e0
commit ca5d6e4c88

@ -35,7 +35,8 @@ namespace Blazor.Components
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item));
this.Items = null;
Parent.inventory.inventoryItems[this.Index] = null ;
await LocalStorage.SetItemAsync<Models.InventoryItem>("data" + this.Index, this.Items);
await LocalStorage.RemoveItemAsync("data" + this.Index);
await LocalStorage.RemoveItemAsync("stack" + this.Index);
}
@ -51,7 +52,8 @@ namespace Blazor.Components
{
this.Items = Parent.CurrentDragItem;
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync<Models.InventoryItem>("data" + this.Index, this.Items);
await LocalStorage.SetItemAsync<Item>("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync<int>("stack" + this.Index, this.Items.Stack);
Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
@ -60,7 +62,8 @@ namespace Blazor.Components
{
this.Items = Parent.CurrentDragItem;
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync<Models.InventoryItem>("data" + this.Index, this.Items);
await LocalStorage.SetItemAsync<Item>("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync<int>("stack" + this.Index, this.Items.Stack);
Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
@ -71,7 +74,9 @@ namespace Blazor.Components
{
this.Items.Stack = this.Items.item.StackSize;
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync<Models.InventoryItem>("data" + this.Index, this.Items);
await LocalStorage.SetItemAsync<Item>("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync<int>("stack" + this.Index, this.Items.Stack);
Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
@ -79,7 +84,9 @@ namespace Blazor.Components
{
this.Items.Stack = total;
Parent.CurrentDragItem = null;
await LocalStorage.SetItemAsync<Models.InventoryItem>("data" + this.Index, this.Items);
await LocalStorage.SetItemAsync<Item>("data" + this.Index, this.Items.item);
await LocalStorage.SetItemAsync<int>("stack" + this.Index, this.Items.Stack);
Parent.Actions.Add(new InventoryAction("On drag drop",this.Index,Items.item));
return;
}
}
@ -105,9 +112,19 @@ namespace Blazor.Components
{
return;
}
Items = await LocalStorage.GetItemAsync<InventoryItem>("item" + this.Index);
var item = await LocalStorage.GetItemAsync<Item>("data" + this.Index);
int stack = await LocalStorage.GetItemAsync<int>("stack" + this.Index);
StateHasChanged();
if (item != null)
{
this.Items = new Models.InventoryItem(item, stack);
}
else
{
this.Items = null;
}
StateHasChanged();
return;
}
}
}

@ -1,4 +1,6 @@
namespace Blazor.Models
using System.Collections;
namespace Blazor.Models
{
public class InventoryItem
{
@ -16,5 +18,11 @@
this.item = item;
Stack = 1;
}
public InventoryItem(Item item, int stock)
{
this.item = item;
Stack = stock;
}
}
}

Loading…
Cancel
Save