Merge develop into feature/inventory-system

This commit is contained in:
VegaZ
2018-11-26 17:53:25 +01:00
66 changed files with 4533 additions and 1302 deletions

View File

@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/**
* @overview Life of German Reallife - Entities CharacterCloth CharacterCloth.cs
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class CharacterCloth
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("User")]
public int UserId { get; set; }
public User User { get; set; }
public bool Duty { get; set; }
public byte SlotType { get; set; }
public int SlotId { get; set; }
public int ClothId { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
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 ClothCombination
{
[Key]
public int Id { get; set; }
public bool Gender { get; set; }
public int Top { get; set; }
public int Torso { get; set; }
public int Undershirt { get; set; }
}
}

33
Server/Entities/Door.cs Normal file
View File

@@ -0,0 +1,33 @@
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 Door (Door.cs)
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class Door
{
[Key]
public int Id { get; set; }
public string Category { get; set; }
public string Name { get; set; }
public bool Locked { get; set; }
public int Model { get; set; }
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }
public float Radius { get; set; }
[ForeignKey("FactionId")]
public int? FactionId { get; set; }
public Faction Faction { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
/**
* @overview Life of German Reallife - Entities DutyCloth DutyCloth.cs
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class DutyCloth
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("Faction")]
public int FactionId { get; set; }
public Faction Faction { get; set; }
public bool Gender { get; set; }
public byte SlotType { get; set; }
public int SlotId { get; set; }
public int ClothId { get; set; }
}
}

View File

@@ -1,8 +1,11 @@
using Microsoft.EntityFrameworkCore;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
/**
@@ -13,14 +16,28 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class Faction
public class Faction : IBankAccountOwner
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[StringLength(32)]
public string Name { get; set; }
public int BankAccount { get; set; }
public bool StateOwned { get; set; }
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
{
if (databaseContext == null)
{
using (databaseContext = new DatabaseContext())
{
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
}
}
else
{
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
}
}
}
}

View File

@@ -13,7 +13,7 @@ using System.Text;
*/
namespace reallife_gamemode.Server.Entities
{
public class FactionBankAccount
public class FactionBankAccount : IBankAccount
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]

24
Server/Entities/News.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class News
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("User")]
public int? UserId { get; set; }
public User User { get; set; }
public string Caption { get; set; }
public string Content { get; set; }
public bool Active { get; set; }
public int Timestamp { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Util;
using System;
using System.Collections.Generic;
@@ -16,7 +17,7 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class User
public class User : IBankAccountOwner
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -28,8 +29,8 @@ namespace reallife_gamemode.Server.Entities
[StringLength(64)]
public string Password { get; set; }
public int LogUserId { get; set; }
[Timestamp]
public byte[] RegistrationDate { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public DateTime RegistrationDate { get; set; }
[EmailAddress]
[StringLength(64)]
@@ -122,12 +123,11 @@ namespace reallife_gamemode.Server.Entities
{
using (var unbanUser = new DatabaseContext())
{
var targetUser = unbanUser.Bans.FirstOrDefault(u => u.Id == BanId);
unbanUser.Bans.Remove(targetUser);
User user = admin.GetUser();
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == user.Id);
targetUser.BanId = null;
unbanUser.SaveChanges();
}
admin.SendChatMessage(this.Name + " wurde entbannt.");
//TODO ***Admin Info: {ADMIN-NAME} hat {USER-NAME} entbannt.
}
public List<UserItem> GetItems()
@@ -138,5 +138,20 @@ namespace reallife_gamemode.Server.Entities
}
}
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
{
if (databaseContext == null)
{
using (databaseContext = new DatabaseContext())
{
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
}
}
else
{
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
}
}
}
}

View File

@@ -17,8 +17,9 @@ using System.Linq;
namespace reallife_gamemode.Server.Entities
{
public class UserBankAccount
public class UserBankAccount : IBankAccount
{
[NotMapped]
private int _balance;
[Key]
@@ -38,7 +39,7 @@ namespace reallife_gamemode.Server.Entities
_balance = value;
using(var dbContext = new DatabaseContext())
{
ClientService.GetClientByName(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value);
ClientService.GetClientByNameOrId(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value);
}
}
}