feat: add items #wip
This commit is contained in:
35
Client/Domain/Entities/BaseItem.cs
Normal file
35
Client/Domain/Entities/BaseItem.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Client.Domain.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public abstract class BaseItem : EntityInterface
|
||||
{
|
||||
public uint Id { get; set; }
|
||||
public uint ItemId { get; set; }
|
||||
public ItemTypeEnum Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string IconName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int Mana { get { return mana; } set { mana = value; }}
|
||||
public uint Weight { get; set; }
|
||||
|
||||
public BaseItem(uint id, uint itemId, ItemTypeEnum type, string name, string iconName, string description, int mana, uint weight)
|
||||
{
|
||||
Id = id;
|
||||
ItemId = itemId;
|
||||
Type = type;
|
||||
Name = name;
|
||||
IconName = iconName;
|
||||
Description = description;
|
||||
this.mana = mana;
|
||||
Weight = weight;
|
||||
}
|
||||
|
||||
private int mana;
|
||||
}
|
||||
}
|
26
Client/Domain/Entities/EtcItem.cs
Normal file
26
Client/Domain/Entities/EtcItem.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Client.Domain.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public class EtcItem : BaseItem
|
||||
{
|
||||
public uint Amount { get => amount; set => amount = value; }
|
||||
public bool IsQuest { get; set; }
|
||||
public bool IsAutoused { get => isAutoused; set => isAutoused = value; }
|
||||
public EtcItem(uint id, uint itemId, ItemTypeEnum type, string name, string iconName, string description, int mana, uint weight, uint amount, bool isQuest, bool isAutoused) :
|
||||
base(id, itemId, type, name, iconName, description, mana, weight)
|
||||
{
|
||||
this.amount = amount;
|
||||
IsQuest = isQuest;
|
||||
this.isAutoused = isAutoused;
|
||||
}
|
||||
|
||||
private uint amount;
|
||||
private bool isAutoused;
|
||||
}
|
||||
}
|
17
Client/Domain/Enums/ItemTypeEnum.cs
Normal file
17
Client/Domain/Enums/ItemTypeEnum.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Enums
|
||||
{
|
||||
public enum ItemTypeEnum
|
||||
{
|
||||
None = -1,
|
||||
Etc,
|
||||
Armor,
|
||||
Weapon,
|
||||
Shield
|
||||
}
|
||||
}
|
19
Client/Domain/Events/ItemCreatedEvent.cs
Normal file
19
Client/Domain/Events/ItemCreatedEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class ItemCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly BaseItem Item;
|
||||
|
||||
public ItemCreatedEvent(BaseItem item)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
}
|
||||
}
|
19
Client/Domain/Events/ItemDeletedEvent.cs
Normal file
19
Client/Domain/Events/ItemDeletedEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class ItemDeletedEvent : EventInterface
|
||||
{
|
||||
public readonly uint Id;
|
||||
|
||||
public ItemDeletedEvent(uint id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
30
Client/Domain/Service/ItemHandler.cs
Normal file
30
Client/Domain/Service/ItemHandler.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Service
|
||||
{
|
||||
public class ItemHander : EntityHandler<BaseItem>
|
||||
{
|
||||
public override void OnCreate(BaseItem entity)
|
||||
{
|
||||
eventBus.Publish(new ItemCreatedEvent(entity));
|
||||
}
|
||||
public override void OnDelete(BaseItem entity)
|
||||
{
|
||||
eventBus.Publish(new ItemDeletedEvent(entity.Id));
|
||||
}
|
||||
|
||||
public ItemHander(EntityFactoryInterface<BaseItem> factory, EventBusInterface eventBus) : base(factory)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
private readonly EventBusInterface eventBus;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user