Fix interest.

This commit is contained in:
SilicaAndPina 2021-01-01 22:57:16 +13:00
parent 8b36407981
commit b939c9e142
6 changed files with 20 additions and 17 deletions

View file

@ -12,6 +12,11 @@
"click_nothing_message":"Nothing interesting here...", "click_nothing_message":"Nothing interesting here...",
"playtime_timeout":"You have run out of playtime for now. In one minute you will be disconnected. You gain one minute of playtime every 8 minutes. Please come back later!", "playtime_timeout":"You have run out of playtime for now. In one minute you will be disconnected. You gain one minute of playtime every 8 minutes. Please come back later!",
"random_movement":"You are sooo <B>%STAT%</B>. You wander dizzily in a different direction.", "random_movement":"You are sooo <B>%STAT%</B>. You wander dizzily in a different direction.",
"new_user":{
"starting_message":"<B>Welcome Newest Rider of Horse Isle!</B><BR>Start by talking to Welcome Willy in the cabin. Click the TALK button by his name in the right hand window. He will know the location of a buried treasure on this island! Move to the spot he describes using the arrow keys. Then Click the WRENCH Icon at the lower right.",
"starting_x":522,
"starting_y":138
},
"bank":{ "bank":{
"deposit_format":"You deposited $%MONEY% into the bank.", "deposit_format":"You deposited $%MONEY% into the bank.",
"withdraw_format":"You withdrew $%MONEY% from the bank." "withdraw_format":"You withdrew $%MONEY% from the bank."
@ -35248,11 +35253,6 @@
{"id":156,"cost":250,"goto_x":405,"goto_y":28,"type":"BOAT","place_title":"Glacier Isle"} {"id":156,"cost":250,"goto_x":405,"goto_y":28,"type":"BOAT","place_title":"Glacier Isle"}
] ]
}, },
"new_user":{
"starting_message":"<B>Welcome Newest Rider of Horse Isle!</B><BR>Start by talking to Welcome Willy in the cabin. Click the TALK button by his name in the right hand window. He will know the location of a buried treasure on this island! Move to the spot he describes using the arrow keys. Then Click the WRENCH Icon at the lower right.",
"starting_x":522,
"starting_y":138
},
"places":{ "places":{
"zones":[ "zones":[
{"start_x":862,"end_x":967,"start_y":37,"end_y":123,"name":"Zebra"}, {"start_x":862,"end_x":967,"start_y":37,"end_y":123,"name":"Zebra"},

View file

@ -599,7 +599,7 @@ namespace HISP.Game
double moneyMade = 0; double moneyMade = 0;
if (user.BankInterest > user.BankMoney) if (user.BankInterest > user.BankMoney)
{ {
moneyMade = user.BankMoney - user.BankInterest; moneyMade = user.BankInterest - user.BankMoney;
user.BankMoney = user.BankInterest; user.BankMoney = user.BankInterest;
} }

View file

@ -187,7 +187,7 @@ namespace HISP.Player
{ {
get get
{ {
return bankInterest; return Database.GetPlayerBankInterest(Id);
} }
set set
{ {
@ -195,7 +195,6 @@ namespace HISP.Player
value = 9999999999.9999; value = 9999999999.9999;
Database.SetPlayerBankInterest(value, Id); Database.SetPlayerBankInterest(value, Id);
bankInterest = value;
} }
} }
public double BankMoney public double BankMoney
@ -318,7 +317,6 @@ namespace HISP.Player
private int money; private int money;
private int questPoints; private int questPoints;
private double bankMoney; private double bankMoney;
private double bankInterest;
private int experience; private int experience;
private int hunger; private int hunger;
private int thirst; private int thirst;
@ -422,7 +420,6 @@ namespace HISP.Player
privateNotes = Database.GetPlayerNotes(UserId); privateNotes = Database.GetPlayerNotes(UserId);
hunger = Database.GetPlayerHunger(UserId); hunger = Database.GetPlayerHunger(UserId);
thirst = Database.GetPlayerThirst(UserId); thirst = Database.GetPlayerThirst(UserId);
bankInterest = Database.GetPlayerBankInterest(UserId);
tired = Database.GetPlayerTiredness(UserId); tired = Database.GetPlayerTiredness(UserId);
Gender = Database.GetGender(UserId); Gender = Database.GetGender(UserId);

View file

@ -2177,12 +2177,17 @@ namespace HISP.Server
public static void DoIntrestPayments(int intrestRate) public static void DoIntrestPayments(int intrestRate)
{ {
if (intrestRate == 0)
{
Logger.WarnPrint("Intrest rate is 0, as deviding by 0 causes the universe to implode, adding intrest has been skipped.");
return;
}
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 BankInterest=BankInterest * (1/@interestRate) AND NOT BankInterest * (1/@interestRate) > 9999999999.9999"; sqlCommand.CommandText = "UPDATE UserExt SET BankInterest = BankInterest + (BankInterest * (1/@interestRate)) WHERE NOT BankInterest + (BankInterest * (1/@interestRate)) > 9999999999.9999";
sqlCommand.Parameters.AddWithValue("@interest", intrestRate); sqlCommand.Parameters.AddWithValue("@interestRate", intrestRate);
sqlCommand.Prepare(); sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery(); sqlCommand.ExecuteNonQuery();

View file

@ -447,9 +447,9 @@ namespace HISP.Server
Item.WishingCoin = gameData.item.special.wishing_coin; Item.WishingCoin = gameData.item.special.wishing_coin;
// New Users // New Users
Messages.NewUserMessage = gameData.new_user.starting_message; Messages.NewUserMessage = gameData.messages.new_user.starting_message;
Map.NewUserStartX = gameData.new_user.starting_x; Map.NewUserStartX = gameData.messages.new_user.starting_x;
Map.NewUserStartY = gameData.new_user.starting_y; Map.NewUserStartY = gameData.messages.new_user.starting_y;
// Records // Records
Messages.ProfileSavedMessage = gameData.messages.profile_save; Messages.ProfileSavedMessage = gameData.messages.profile_save;

View file

@ -57,7 +57,9 @@ namespace HISP.Server
Database.IncAllUsersFreeTime(1); Database.IncAllUsersFreeTime(1);
} }
Database.DoIntrestPayments(ConfigReader.IntrestRate); if(totalMinutesElapsed % 24 == 0)
Database.DoIntrestPayments(ConfigReader.IntrestRate);
Database.IncPlayerTirednessForOfflineUsers(); Database.IncPlayerTirednessForOfflineUsers();
DroppedItems.Update(); DroppedItems.Update();
minuteTimer.Change(oneMinute, oneMinute); minuteTimer.Change(oneMinute, oneMinute);
@ -364,7 +366,6 @@ namespace HISP.Server
byte[] MotdData = PacketBuilder.CreateMotd(); byte[] MotdData = PacketBuilder.CreateMotd();
sender.SendPacket(MotdData); sender.SendPacket(MotdData);
} }
public static void OnWish(GameClient sender, byte[] packet) public static void OnWish(GameClient sender, byte[] packet)