GELD LOGS

This commit is contained in:
hydrant
2021-05-15 03:14:37 +02:00
parent 3c2d56f2ad
commit a2db770316
22 changed files with 448 additions and 306 deletions

View File

@@ -9,6 +9,8 @@ using ReallifeGamemode.Database.Models;
using Microsoft.EntityFrameworkCore;
using System;
using ReallifeGamemode.Server.Extensions;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
/**
* @overview Life of German Reallife - Server Factions Medic Medic.cs
@@ -20,6 +22,8 @@ namespace ReallifeGamemode.Server.Factions.Medic
{
public class Medic : Script
{
private static readonly ILogger logger = LogManager.GetLogger<Medic>();
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
public static List<MedicTask> HealTasks = new List<MedicTask>();
public static List<MedicTask> FireTasks = new List<MedicTask>();
@@ -34,7 +38,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public Player dTarget;
public int dPrice;
}
public static void AddTaskToList(MedicTask task)
{
if (task == null)
@@ -84,7 +88,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void UpdateReviveSperre()
{
var allRevivedPlayers = NAPI.Pools.GetAllPlayers().Where(c => c.HasData("reviveSperre"));
foreach(var player in allRevivedPlayers)
foreach (var player in allRevivedPlayers)
{
var timeLeft = player.GetData<int>("reviveSperre");
@@ -101,7 +105,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void CheckHealDecisionDistance()
{
foreach(var healAuftrag in HealDecisions.ToList())
foreach (var healAuftrag in HealDecisions.ToList())
{
if (healAuftrag.dMedic.Position.DistanceTo(healAuftrag.dTarget.Position) > 5)
{
@@ -117,9 +121,9 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void MakeHealDecision(Player target, bool decision)
{
var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target);
if(decision == false)
if (decision == false)
{
activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt",false);
activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt", false);
activeDecision.dTarget.SendNotification("Du hast den Heal ~r~abgelehnt", false);
}
else
@@ -141,6 +145,8 @@ namespace ReallifeGamemode.Server.Factions.Medic
targetUser.BankAccount.Balance -= bankMoney;
}
logger.LogInformation("Player {0} accepted a heal for {1} dollars from medic {2}", target.Name, activeDecision.dPrice, activeDecision.dMedic.Name);
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += activeDecision.dPrice / 2;
activeDecision.dMedic.GetUser(dbContext).Wage += activeDecision.dPrice / 2;
@@ -149,7 +155,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
activeDecision.dTarget.SafeSetHealth(100);
activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false);
activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false);
delHealTask(activeDecision.dTarget);
delHealTask(activeDecision.dTarget);
}
HealDecisions.Remove(activeDecision);
}
@@ -166,7 +172,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime));
task.TimeLeft = taskTimeLeft;
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
if(medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft);
if (medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft);
}
}
}
@@ -176,14 +182,14 @@ namespace ReallifeGamemode.Server.Factions.Medic
{
if (HealTasks.Count != 0)
{
foreach(var task in HealTasks)
foreach (var task in HealTasks)
{
if(task.MedicName != "none")
if (task.MedicName != "none")
{
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
var victim = PlayerService.GetPlayerByNameOrId(task.Victim);
if(medic == null || victim == null)
if (medic == null || victim == null)
{
continue;
}
@@ -241,11 +247,11 @@ namespace ReallifeGamemode.Server.Factions.Medic
{
reviveTask.MedicName = "none";
}
else
else
{
reviveTask.MedicName = player.Name;
}
ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Reviveauftrag von " + victim + " angenommen.", new List<int>() { 2 });
target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ eilt zur Rettung.");
break;
@@ -261,7 +267,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
healTask.MedicName = player.Name;
ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Healauftrag von " + victim + " angenommen.", new List<int>() { 2 });
target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ hat deinen Auftrag angenommen.");
}
}
break;
case 2:
@@ -275,7 +281,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
{
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name);
if (task != null)
{
{
player.SetData("healauftrag", false);
var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName);
if (medicPlayer != null)