Shop System [Clothes] base
This commit is contained in:
committed by
Lukas Moungos
parent
461b9aa4cb
commit
834c5cb22d
14
ReallifeGamemode.Server/Shop/Clothing/Clothe.cs
Normal file
14
ReallifeGamemode.Server/Shop/Clothing/Clothe.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||
{
|
||||
public class Clothe : ShopClothe
|
||||
{
|
||||
public string clothe;
|
||||
public int undershirtId;
|
||||
public int torsoId;
|
||||
}
|
||||
}
|
||||
92
ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs
Normal file
92
ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||
{
|
||||
public class ClotheShop
|
||||
{
|
||||
public int category { get; set; } = 1;
|
||||
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
||||
|
||||
|
||||
public ClotheShop(int category)
|
||||
{
|
||||
this.category = category;
|
||||
LoadClothes();
|
||||
}
|
||||
|
||||
public void LoadClothes()
|
||||
{
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Command("buyclothes")]
|
||||
public void LoadShopNUI(Client client)
|
||||
{
|
||||
LoadClothes();
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<Clothe> clothes = new List<Clothe>();
|
||||
bool gender = client.GetUser().Character.Gender;
|
||||
foreach (var clothe in clotheList)
|
||||
{
|
||||
if(clothe.TypeId == "clothes" )
|
||||
{
|
||||
switch (clothe.ComponentId)
|
||||
{
|
||||
case 11: //tops
|
||||
List<ClothCombination> combinations = dbContext.ClothCombinations.Where(c => c.Top == clothe.ClotheId && c.Gender == gender).ToList();
|
||||
foreach (var combination in combinations)
|
||||
{
|
||||
var top = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = combination.Undershirt,
|
||||
torsoId = combination.Torso
|
||||
};
|
||||
clothes.Add(top);
|
||||
}
|
||||
break;
|
||||
default: //everything else
|
||||
var garment = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = -1, //will not be used unless top
|
||||
torsoId = -1 //will not be used unless top
|
||||
};
|
||||
clothes.Add(garment);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user