Heal Decision / JobManager dadurch angepasst
This commit is contained in:
@@ -8,6 +8,7 @@ using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Server Factions Medic Medic.cs
|
||||
@@ -22,10 +23,18 @@ namespace ReallifeGamemode.Server.Factions.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>();
|
||||
public static List<HealDecision> HealDecisions = new List<HealDecision>();
|
||||
public static int ReviveIncome = 100;
|
||||
public static int dutyMedics = 0;
|
||||
public static int reviveTaskTime = 240;
|
||||
|
||||
public class HealDecision
|
||||
{
|
||||
public Player dMedic;
|
||||
public Player dTarget;
|
||||
public int dPrice;
|
||||
}
|
||||
|
||||
public static void AddTaskToList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
@@ -72,6 +81,45 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
}
|
||||
}
|
||||
|
||||
public static void MakeHealDecision(Player target, bool decision)
|
||||
{
|
||||
var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target);
|
||||
if(decision == false)
|
||||
{
|
||||
ChatService.SendMessage(activeDecision.dMedic, activeDecision.dTarget + " hat den Heal abgelehnt");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatService.SendMessage(activeDecision.dMedic, activeDecision.dTarget + " hat den Heal akzeptiert");
|
||||
using var dbContext = new DatabaseContext();
|
||||
{
|
||||
User targetUser = target.GetUser(dbContext);
|
||||
|
||||
if (targetUser.Handmoney >= activeDecision.dPrice)
|
||||
{
|
||||
targetUser.Handmoney -= activeDecision.dPrice;
|
||||
}
|
||||
else
|
||||
{
|
||||
int bankMoney = activeDecision.dPrice - targetUser.Handmoney;
|
||||
targetUser.Handmoney = 0;
|
||||
targetUser.BankAccount.Balance -= bankMoney;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
activeDecision.dTarget.Health = 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);
|
||||
}
|
||||
HealDecisions.Remove(activeDecision);
|
||||
}
|
||||
|
||||
public static void UpdateTaskTimeLeft()
|
||||
{
|
||||
DateTime actualTime = DateTime.Now;
|
||||
@@ -139,7 +187,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
public static void delHealTask(Player player)
|
||||
{
|
||||
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
RemoveTaskFromList(task);
|
||||
if(task != null) RemoveTaskFromList(task);
|
||||
player.SetData("healauftrag", false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user