Add bank interest

This commit is contained in:
SilicaAndPina 2021-01-01 22:04:07 +13:00
parent c1a0f2e370
commit 8b36407981
4 changed files with 29 additions and 10 deletions

View file

@ -596,12 +596,28 @@ namespace HISP.Game
private static string buildBank(User user)
{
string messages = Messages.FormatBankCarryingMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
messages += Messages.BankWhatToDo;
messages += Messages.FormatBankOptionsMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
messages += Messages.ExitThisPlace;
messages += Messages.MetaTerminator;
return messages;
double moneyMade = 0;
if (user.BankInterest > user.BankMoney)
{
moneyMade = user.BankMoney - user.BankInterest;
user.BankMoney = user.BankInterest;
}
user.BankInterest = user.BankMoney;
string message = "";
moneyMade = Math.Floor(moneyMade);
if (moneyMade > 0)
message += Messages.FormatBankIntrestMadeMeta(Convert.ToUInt64(moneyMade));
message += Messages.FormatBankCarryingMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
message += Messages.BankWhatToDo;
message += Messages.FormatBankOptionsMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
message += Messages.ExitThisPlace;
message += Messages.MetaTerminator;
return message;
}

View file

@ -195,7 +195,7 @@ namespace HISP.Player
value = 9999999999.9999;
Database.SetPlayerBankInterest(value, Id);
BankInterest = value;
bankInterest = value;
}
}
public double BankMoney

View file

@ -2175,13 +2175,14 @@ namespace HISP.Server
}
}
public static void DoIntrestPayments()
public static void DoIntrestPayments(int intrestRate)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE UserExt SET BankBalance=BankBalance * (1/@interestRate) AND NOT BankBalance * (1/@interestRate) > 9999999999.9999";
sqlCommand.CommandText = "UPDATE UserExt SET BankInterest=BankInterest * (1/@interestRate) AND NOT BankInterest * (1/@interestRate) > 9999999999.9999";
sqlCommand.Parameters.AddWithValue("@interest", intrestRate);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();

View file

@ -45,7 +45,7 @@ namespace HISP.Server
private static void onGameTick(object state)
{
World.TickWorldClock();
gameTimer.Change(gameTickSpeed, gameTickSpeed);
}
private static void onMinuteTick(object state)
@ -56,6 +56,8 @@ namespace HISP.Server
{
Database.IncAllUsersFreeTime(1);
}
Database.DoIntrestPayments(ConfigReader.IntrestRate);
Database.IncPlayerTirednessForOfflineUsers();
DroppedItems.Update();
minuteTimer.Change(oneMinute, oneMinute);