[+] Weapon-Deal System

This commit is contained in:
Lukas Moungos
2019-10-02 19:40:02 +02:00
parent 8f7ba2a7b5
commit 9ec30fd419
11 changed files with 1426 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Inventory.Interfaces;
/**
* @overview Life of German Reallife - Event Key (Key.cs)
* @author VegaZ
@@ -235,11 +236,31 @@ namespace ReallifeGamemode.Server.Events
secondarys.Add("Keine");
melees.Add("Keine");
specials.Add("Keine");
using (var context = new DatabaseContext())
{
List<UserItem> fItem = context.UserItems.Where(u => u.UserId == user.Id).ToList();
foreach(var item in fItem)
{
IItem iItem = InventoryManager.GetItemById(item.ItemId);
if(iItem is IWeaponDealItem obj)
{
FactionWeapon weapon = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == iItem.Name).FirstOrDefault();
if (weapon == null)
continue;
weapon.Ammount += item.Amount;
ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefürgt.");
context.Remove(item);
}
}
context.SaveChanges();
List<FactionWeapon> weapons = context.FactionWeapons.Where(w => w.FactionId == user.FactionId).ToList();
Database.Entities.Faction faction = context.Factions.Where(fac => fac.Id == user.FactionId).FirstOrDefault();
if (faction.WeaponDealTime > 0)
dealTime = "noch " + faction.WeaponDealTime.ToString()+" min. übrig";
@@ -248,6 +269,8 @@ namespace ReallifeGamemode.Server.Events
foreach (var weapon in weapons)
{
if (weapon.Ammount <= 0)
continue;
switch (weapon.SlotID)
{
case 1: