Ich erkläre dir mal warum ich Netto anderen Discountern bevorzuge. Bei uns ist es auch Ghettogebiet. Kunden wir bei jedem anderen Netto auch - braucht man nicht weiter drauf eingehen. Obst und Gemüse auch oft verschimmelt. Sortiment unbeständig. Pfandautomat immer voll so das man jemanden rufen muss. Kassierinnen so derbe das quasi nur noch das Schalke Trikot fehlt und ich mich frage wie lange es dauert bevor die Kasse durch einen Fliesentisch ersetzt wird. Und die machen auch keinen Hehl daraus, das sie gar keinen Bock haben da zu sein. Aber genau das sind die Pluspunkte, denn: wenn ich bei Netto arbeiten würde wäre ich genauso drauf. Mit diesen Hypermotivierten Könnern von Lidl oder (noch krasser) Aldi kann ich mich nicht identifizieren. Viel zu kompetent, schnell und die lächeln auch noch. Und wenn da irgend ein Besoffener eine Pulle auf den Boden fallen lässt ist instant jemand da um es weg zu wischen. Ich persönlich würde Gemüse verschimmeln, Pfandautomat voll und zweite Kasse zu lassen, wenn nicht aus Faulheit dann schon alleine aus Prinzip, und mich lieber mit meiner Maxi Schachtel Power zum Hintertürchen verpissen. Netto ist einfach realer als diese anderen aufgespielten Discounter. Dafür kann man sich ruhig mal in der Schlange anpöbeln lassen oder eine verschimmelte Kirsche wegwerfen.
164 lines
4.9 KiB
C#
164 lines
4.9 KiB
C#
/***
|
|
@overview Life of German - Economy
|
|
@author kookroach
|
|
@copyright (c) 2008 - 2019 Life of German
|
|
*/
|
|
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using GTANetworkAPI;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using ReallifeGamemode.Database.Entities;
|
|
using ReallifeGamemode.Server.Extensions;
|
|
using ReallifeGamemode.Database.Models;
|
|
using ReallifeGamemode.Server.Services;
|
|
|
|
namespace ReallifeGamemode.Server.Finance
|
|
{
|
|
public class Economy
|
|
{
|
|
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
|
|
|
public static (int, float, float) GetEconomyClass(Player client, int wage)
|
|
{
|
|
int bankAccount = client.GetUser().BankAccount.Balance;
|
|
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
|
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
|
if (financialInterest >= 0.7)
|
|
financialInterest = 0.7f;
|
|
|
|
if (financialHelp > 2500)
|
|
financialHelp = 2500;
|
|
|
|
return (bankAccount, financialHelp, financialInterest);
|
|
}
|
|
|
|
public static int GetVehicleTaxation(Player client)
|
|
{
|
|
int vehicleTaxation = 0;
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
User user = client.GetUser(dbContext);
|
|
foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id))
|
|
{
|
|
if (uVeh.Price == null)
|
|
{
|
|
vehicleTaxation += 400;
|
|
continue;
|
|
}
|
|
vehicleTaxation += (int)(uVeh.Price * 0.005f);
|
|
}
|
|
|
|
}
|
|
return vehicleTaxation;
|
|
}
|
|
|
|
public static float GetPropertyTaxation(Player client)
|
|
{
|
|
float propertyTaxation = 0;
|
|
User user = client.GetUser();
|
|
if (user.HouseId != null)
|
|
{
|
|
propertyTaxation += user.House.Price * 0.005f;
|
|
}
|
|
|
|
return propertyTaxation;
|
|
}
|
|
|
|
|
|
public static void SetPaycheck(Player client, int wage)
|
|
{
|
|
User user = client.GetUser();
|
|
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
|
float propertyTax = GetPropertyTaxation(client);
|
|
int vehicleTaxation = GetVehicleTaxation(client);
|
|
int rentalFees = GetRentalFees(client);
|
|
|
|
int healthInsurance = (int)(user.BankAccount.Balance * 0.001);
|
|
|
|
int amount = wage - (int)(wage * financialInterest) - vehicleTaxation - (int)propertyTax + (int)financialHelp - rentalFees - healthInsurance;
|
|
|
|
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount, rentalFees, healthInsurance);
|
|
Paychecks[user.Id] = paycheck;
|
|
ReleasePayDay(client, paycheck);
|
|
}
|
|
|
|
private static int GetRentalFees(Player client)
|
|
{
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
User user = client.GetUser();
|
|
return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee);
|
|
}
|
|
}
|
|
|
|
public static void ReleasePayDay(Player client, Paycheck paycheck)
|
|
{
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
User u = client.GetUser(dbContext);
|
|
u.BankAccount.Balance += paycheck.Amount;
|
|
u.Wage = 0;
|
|
|
|
var rentals = dbContext.HouseRentals
|
|
.Include(hR => hR.House)
|
|
.ThenInclude(h => h.BankAccount)
|
|
.Where(hR => hR.UserId == u.Id);
|
|
|
|
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1);
|
|
|
|
foreach (var rental in rentals)
|
|
{
|
|
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7);
|
|
}
|
|
|
|
dbContext.SaveChanges();
|
|
}
|
|
if (paycheck.Amount > 0)
|
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~.");
|
|
else
|
|
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~.");
|
|
|
|
}
|
|
/*
|
|
public static void PaydayTimer()
|
|
{
|
|
System.Timers.Timer timer = new System.Timers.Timer(60000);
|
|
timer.Start();
|
|
timer.Elapsed += Timer_Elapsed;
|
|
}
|
|
*/
|
|
public static void Timer_Elapsed()
|
|
{
|
|
foreach (var player in NAPI.Pools.GetAllPlayers())
|
|
{
|
|
User user = player.GetUser();
|
|
if (player.IsLoggedIn())
|
|
{
|
|
if (user.PaydayTimer <= 0)
|
|
{
|
|
Economy.SetPaycheck(player, user.Wage);
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
player.GetUser(dbContext).PaydayTimer = 60;
|
|
dbContext.SaveChanges();
|
|
}
|
|
return;
|
|
}
|
|
if (user.PaydayTimer > 0)
|
|
{
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
player.GetUser(dbContext).PaydayTimer -= 1;
|
|
dbContext.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|