Add limitation to start Gangwar @Turf.cs
This commit is contained in:
@@ -9,6 +9,7 @@ using ReallifeGamemode.Database.Models;
|
|||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Gangwar
|
namespace ReallifeGamemode.Server.Gangwar
|
||||||
{
|
{
|
||||||
@@ -122,7 +123,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
if (this.Def_Score <= 0)
|
if (this.Def_Score <= 0)
|
||||||
{
|
{
|
||||||
this.takeOver(this.Attacker);
|
this.takeOver(this.Attacker);
|
||||||
} else if (this.Att_Score <= 0)
|
}
|
||||||
|
else if (this.Att_Score <= 0)
|
||||||
{
|
{
|
||||||
this.takeOver(this.Owner);
|
this.takeOver(this.Owner);
|
||||||
}
|
}
|
||||||
@@ -137,7 +139,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
this.takeOver(this.Owner);
|
this.takeOver(this.Owner);
|
||||||
this.Att_Score = 0;
|
this.Att_Score = 0;
|
||||||
}else if(this.Def_Score < this.Att_Score)
|
}
|
||||||
|
else if (this.Def_Score < this.Att_Score)
|
||||||
{
|
{
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||||
{
|
{
|
||||||
@@ -179,7 +182,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerInside.Find(c => c == client) == null) {
|
if (playerInside.Find(c => c == client) == null)
|
||||||
|
{
|
||||||
playerInside.Add(client);
|
playerInside.Add(client);
|
||||||
client.SetData("GotInsideOfTurf", true);
|
client.SetData("GotInsideOfTurf", true);
|
||||||
}
|
}
|
||||||
@@ -252,6 +256,30 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
public void attack(string attacker)
|
public void attack(string attacker)
|
||||||
{
|
{
|
||||||
|
Player[] usersInGangwar;
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
||||||
|
|
||||||
|
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
||||||
|
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getAttacker()).Select(u => u.Player).ToList();
|
||||||
|
|
||||||
|
if (ownersInGangwar.Count < 5 && attackersInGangwar.Count < 5)
|
||||||
|
{
|
||||||
|
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getAttacker() && u.FactionLeader).Select(u => u.Player).ToList();
|
||||||
|
foreach(var l in leaders)
|
||||||
|
{
|
||||||
|
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder online haben.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Player> inGangwar = new List<Player>();
|
||||||
|
inGangwar.AddRange(ownersInGangwar);
|
||||||
|
inGangwar.AddRange(attackersInGangwar);
|
||||||
|
|
||||||
|
usersInGangwar = inGangwar.ToArray();
|
||||||
|
}
|
||||||
if (this.status == "normal")
|
if (this.status == "normal")
|
||||||
{
|
{
|
||||||
if (this.timer != null)
|
if (this.timer != null)
|
||||||
@@ -261,11 +289,9 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
this.Attacker = attacker;
|
this.Attacker = attacker;
|
||||||
this.status = "attack";
|
this.status = "attack";
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
List<Player> clientsInGangwar = new List<Player>();
|
List<Player> clientsInGangwar = new List<Player>();
|
||||||
|
|
||||||
Player[] usersInGangwar = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && (c.GetUser().Faction.Name == getOwner() || c.GetUser().Faction.Name == getAttacker())).ToArray();
|
|
||||||
foreach (var u in usersInGangwar)
|
foreach (var u in usersInGangwar)
|
||||||
{
|
{
|
||||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||||
@@ -275,7 +301,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
clientsInGangwar.Add(u);
|
clientsInGangwar.Add(u);
|
||||||
}
|
}
|
||||||
playerInGangwar = clientsInGangwar.ToArray();
|
playerInGangwar = clientsInGangwar.ToArray();
|
||||||
}
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
||||||
this.TurfTick();
|
this.TurfTick();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user