Merge branch 'feature/faction-system' into develop

This commit is contained in:
hydrant
2018-09-28 17:52:09 +02:00
24 changed files with 720 additions and 10 deletions

View File

@@ -1,9 +1,11 @@
using GTANetworkAPI;
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;
/**
@@ -33,6 +35,7 @@ namespace reallife_gamemode.Server.Entities
[StringLength(64)]
public string Email { get; set; }
public AdminLevel AdminLevel { get; set; }
public float PositionX { get; set; }
public float PositionY { get; set; }
public float PositionZ { get; set; }
@@ -41,6 +44,45 @@ namespace reallife_gamemode.Server.Entities
public int? BanId { get; set; }
public Ban Ban { get; set; }
public int? FactionId { get; set; }
public Faction Faction { get; set; }
public bool FactionLeader { get; set; }
public int? FactionRankId { get; set; }
public FactionRank FactionRank { get;set; }
public Faction GetFaction()
{
using(var context = new DatabaseContext())
{
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
}
}
public FactionRank GetFactionRank()
{
using (var context = new DatabaseContext())
{
FactionRank toReturn = context.FactionRanks.FirstOrDefault(fR => fR.Id == FactionRankId);
if(toReturn == null)
{
toReturn = context.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == FactionId);
}
if(toReturn == null)
{
toReturn = new FactionRank
{
RankName = "Rang-Fehler"
};
}
return toReturn;
}
}
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
}
}