diff --git a/Model/DatabaseContext.cs b/Model/DatabaseContext.cs index 79250b55..4ab459b7 100644 --- a/Model/DatabaseContext.cs +++ b/Model/DatabaseContext.cs @@ -35,8 +35,7 @@ namespace reallife_gamemode.Model public DbSet Characters { get; set; } public DbSet CharacterClothes { get; set; } public DbSet DutyClothes { get; set; } - public DbSet MaleCombinations { get; set; } - public DbSet FemaleCombinations { get; set; } + public DbSet ClothCombinations { get; set; } public DbSet Users { get; set; } public DbSet UserVehicles { get; set; } public DbSet UserBankAccounts { get; set; } diff --git a/Server/Entities/FemaleCombination.cs b/Server/Entities/FemaleCombination.cs deleted file mode 100644 index e5e7fd50..00000000 --- a/Server/Entities/FemaleCombination.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Numerics; -using System.Text; - -/** -* @overview Life of German Reallife - Entities FemaleCombination (FemaleCombination.cs) -* @author VegaZ -* @copyright (c) 2008 - 2018 Life of German -*/ - -namespace reallife_gamemode.Server.Entities -{ - public class FemaleCombination - { - [Key] - public int Id { get; set; } - public int Top { get; set; } - public int Torso { get; set; } - public int Undershirt { get; set; } - } -} diff --git a/Server/Entities/MaleCombination.cs b/Server/Entities/MaleCombination.cs deleted file mode 100644 index 30361ee2..00000000 --- a/Server/Entities/MaleCombination.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Numerics; -using System.Text; - -/** -* @overview Life of German Reallife - Entities MaleCombination (MaleCombination.cs) -* @author VegaZ -* @copyright (c) 2008 - 2018 Life of German -*/ - -namespace reallife_gamemode.Server.Entities -{ - public class MaleCombination - { - [Key] - public int Id { get; set; } - public int Top { get; set; } - public int Torso { get; set; } - public int Undershirt { get; set; } - } -} diff --git a/Server/Events/UpdateCharacterCloth.cs b/Server/Events/UpdateCharacterCloth.cs index 2c5cf4c0..7e646a41 100644 --- a/Server/Events/UpdateCharacterCloth.cs +++ b/Server/Events/UpdateCharacterCloth.cs @@ -34,25 +34,14 @@ namespace reallife_gamemode.Server.Events //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) using (var context = new DatabaseContext()) { - if (player.GetUser().GetCharacter().Gender == false) + var character = player.GetUser().GetCharacter(); + + var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender); + player.SetClothes(11, componentVariation, 0); + if (combination != null) { - var combination = context.MaleCombinations.FirstOrDefault(c => c.Top == componentVariation); - player.SetClothes(11, componentVariation, 0); - if (combination != null) - { - player.SetClothes(3, combination.Torso, 0); - player.SetClothes(8, combination.Undershirt, 0); - } - } - else - { - var combination = context.FemaleCombinations.FirstOrDefault(c => c.Top == componentVariation); - player.SetClothes(11, componentVariation, 0); - if (combination != null) - { - player.SetClothes(3, combination.Torso, 0); - player.SetClothes(8, combination.Undershirt, 0); - } + player.SetClothes(3, combination.Torso, 0); + player.SetClothes(8, combination.Undershirt, 0); } } } @@ -74,6 +63,8 @@ namespace reallife_gamemode.Server.Events User user = client.GetUser(); user = context.Users.FirstOrDefault(u => u.Id == user.Id); + var character = client.GetUser().GetCharacter(); + var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id); if (charClothes == null) { @@ -101,7 +92,7 @@ namespace reallife_gamemode.Server.Events SlotType = 0, SlotId = 3, - ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso }; CharacterCloth newUndershirt = new CharacterCloth { @@ -111,32 +102,7 @@ namespace reallife_gamemode.Server.Events SlotType = 0, SlotId = 8, - ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt - }; - context.CharacterClothes.Add(newTorso); - context.CharacterClothes.Add(newUndershirt); - } - else - { - CharacterCloth newTorso = new CharacterCloth - { - UserId = user.Id, - - Duty = true, - - SlotType = 0, - SlotId = 3, - ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso - }; - CharacterCloth newUndershirt = new CharacterCloth - { - UserId = user.Id, - - Duty = true, - - SlotType = 0, - SlotId = 8, - ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt }; context.CharacterClothes.Add(newTorso); context.CharacterClothes.Add(newUndershirt); @@ -151,16 +117,9 @@ namespace reallife_gamemode.Server.Events } CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8); - if (user.GetCharacter().Gender == false) - { - torso.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso; - undershirt.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt; - } - else - { - torso.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso; - undershirt.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt; - } + + torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso; + undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt; } context.SaveChanges(); }