mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-08 22:25:42 +12:00
Add bank interest
This commit is contained in:
parent
c1a0f2e370
commit
8b36407981
4 changed files with 29 additions and 10 deletions
|
@ -596,12 +596,28 @@ namespace HISP.Game
|
||||||
|
|
||||||
private static string buildBank(User user)
|
private static string buildBank(User user)
|
||||||
{
|
{
|
||||||
string messages = Messages.FormatBankCarryingMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
|
double moneyMade = 0;
|
||||||
messages += Messages.BankWhatToDo;
|
if (user.BankInterest > user.BankMoney)
|
||||||
messages += Messages.FormatBankOptionsMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
|
{
|
||||||
messages += Messages.ExitThisPlace;
|
moneyMade = user.BankMoney - user.BankInterest;
|
||||||
messages += Messages.MetaTerminator;
|
user.BankMoney = user.BankInterest;
|
||||||
return messages;
|
|
||||||
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace HISP.Player
|
||||||
value = 9999999999.9999;
|
value = 9999999999.9999;
|
||||||
|
|
||||||
Database.SetPlayerBankInterest(value, Id);
|
Database.SetPlayerBankInterest(value, Id);
|
||||||
BankInterest = value;
|
bankInterest = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double BankMoney
|
public double BankMoney
|
||||||
|
|
|
@ -2175,13 +2175,14 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoIntrestPayments()
|
public static void DoIntrestPayments(int intrestRate)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
MySqlCommand sqlCommand = db.CreateCommand();
|
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.Prepare();
|
||||||
sqlCommand.ExecuteNonQuery();
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace HISP.Server
|
||||||
private static void onGameTick(object state)
|
private static void onGameTick(object state)
|
||||||
{
|
{
|
||||||
World.TickWorldClock();
|
World.TickWorldClock();
|
||||||
|
|
||||||
gameTimer.Change(gameTickSpeed, gameTickSpeed);
|
gameTimer.Change(gameTickSpeed, gameTickSpeed);
|
||||||
}
|
}
|
||||||
private static void onMinuteTick(object state)
|
private static void onMinuteTick(object state)
|
||||||
|
@ -56,6 +56,8 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
Database.IncAllUsersFreeTime(1);
|
Database.IncAllUsersFreeTime(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database.DoIntrestPayments(ConfigReader.IntrestRate);
|
||||||
Database.IncPlayerTirednessForOfflineUsers();
|
Database.IncPlayerTirednessForOfflineUsers();
|
||||||
DroppedItems.Update();
|
DroppedItems.Update();
|
||||||
minuteTimer.Change(oneMinute, oneMinute);
|
minuteTimer.Change(oneMinute, oneMinute);
|
||||||
|
|
Loading…
Add table
Reference in a new issue