mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-08 22:25:42 +12:00
Change bank balance to double
This commit is contained in:
parent
26245c66c3
commit
c1a0f2e370
5 changed files with 95 additions and 12 deletions
|
@ -596,9 +596,9 @@ namespace HISP.Game
|
||||||
|
|
||||||
private static string buildBank(User user)
|
private static string buildBank(User user)
|
||||||
{
|
{
|
||||||
string messages = Messages.FormatBankCarryingMeta(user.Money, user.BankMoney);
|
string messages = Messages.FormatBankCarryingMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
|
||||||
messages += Messages.BankWhatToDo;
|
messages += Messages.BankWhatToDo;
|
||||||
messages += Messages.FormatBankOptionsMeta(user.Money, user.BankMoney);
|
messages += Messages.FormatBankOptionsMeta(user.Money, Convert.ToUInt64(Math.Floor(user.BankMoney)));
|
||||||
messages += Messages.ExitThisPlace;
|
messages += Messages.ExitThisPlace;
|
||||||
messages += Messages.MetaTerminator;
|
messages += Messages.MetaTerminator;
|
||||||
return messages;
|
return messages;
|
||||||
|
|
|
@ -183,7 +183,22 @@ namespace HISP.Player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UInt64 BankMoney
|
public double BankInterest
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return bankInterest;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 9999999999.9999)
|
||||||
|
value = 9999999999.9999;
|
||||||
|
|
||||||
|
Database.SetPlayerBankInterest(value, Id);
|
||||||
|
BankInterest = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double BankMoney
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -191,8 +206,8 @@ namespace HISP.Player
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value > 9999999999)
|
if (value > 9999999999.9999)
|
||||||
value = 9999999999;
|
value = 9999999999.9999;
|
||||||
|
|
||||||
Database.SetPlayerBankMoney(value, Id);
|
Database.SetPlayerBankMoney(value, Id);
|
||||||
bankMoney = value;
|
bankMoney = value;
|
||||||
|
@ -302,7 +317,8 @@ namespace HISP.Player
|
||||||
private int y;
|
private int y;
|
||||||
private int money;
|
private int money;
|
||||||
private int questPoints;
|
private int questPoints;
|
||||||
private UInt64 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;
|
||||||
|
@ -406,6 +422,7 @@ 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);
|
||||||
|
|
|
@ -38,6 +38,10 @@ enable_corrections=true
|
||||||
# Wether or not to consider all users "Subscribers"
|
# Wether or not to consider all users "Subscribers"
|
||||||
all_users_subscribed=false
|
all_users_subscribed=false
|
||||||
|
|
||||||
|
# Equation is: BANK_BALANCE * (1/INTREST_RATE);
|
||||||
|
# on All servers except Black its 8, on black its 3.
|
||||||
|
# but of course you can make it whatever you want
|
||||||
|
intrest_rate=8
|
||||||
|
|
||||||
# Should print extra debug logs
|
# Should print extra debug logs
|
||||||
debug=false
|
debug=false
|
|
@ -14,7 +14,7 @@ namespace HISP.Server
|
||||||
public static string DatabaseName;
|
public static string DatabaseName;
|
||||||
public static string DatabasePassword;
|
public static string DatabasePassword;
|
||||||
public static int DatabasePort;
|
public static int DatabasePort;
|
||||||
|
public static int IntrestRate;
|
||||||
public static string Motd;
|
public static string Motd;
|
||||||
public static string MapFile;
|
public static string MapFile;
|
||||||
public static string GameDataFile;
|
public static string GameDataFile;
|
||||||
|
@ -102,6 +102,9 @@ namespace HISP.Server
|
||||||
case "enable_word_filter":
|
case "enable_word_filter":
|
||||||
DoCorrections = data == "true";
|
DoCorrections = data == "true";
|
||||||
break;
|
break;
|
||||||
|
case "intrest_rate":
|
||||||
|
IntrestRate = int.Parse(data);
|
||||||
|
break;
|
||||||
case "debug":
|
case "debug":
|
||||||
Debug = data == "true";
|
Debug = data == "true";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
db.Open();
|
db.Open();
|
||||||
string UserTable = "CREATE TABLE Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))";
|
string UserTable = "CREATE TABLE Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))";
|
||||||
string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance BIGINT, ProfilePage Text(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)";
|
string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance DOUBLE, BankInterest DOUBLE, ProfilePage Text(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)";
|
||||||
string MailTable = "CREATE TABLE Mailbox(IdTo INT, PlayerFrom TEXT(16),Subject TEXT(128), Message Text(1028), TimeSent INT)";
|
string MailTable = "CREATE TABLE Mailbox(IdTo INT, PlayerFrom TEXT(16),Subject TEXT(128), Message Text(1028), TimeSent INT)";
|
||||||
string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)";
|
string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)";
|
||||||
string WorldTable = "CREATE TABLE World(Time INT,Day INT, Year INT, Weather TEXT(64))";
|
string WorldTable = "CREATE TABLE World(Time INT,Day INT, Year INT, Weather TEXT(64))";
|
||||||
|
@ -1444,7 +1444,7 @@ namespace HISP.Server
|
||||||
throw new Exception("Userid " + id + " Allready in userext.");
|
throw new Exception("Userid " + id + " Allready in userext.");
|
||||||
|
|
||||||
MySqlCommand sqlCommand = db.CreateCommand();
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,@timestamp,0,0,0,'','',0,0,'NO',0,0,1000,1000,1000, 180)";
|
sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,@timestamp,0,0,0,0,'','',0,0,'NO',0,0,1000,1000,1000, 180)";
|
||||||
sqlCommand.Parameters.AddWithValue("@id", id);
|
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||||
sqlCommand.Parameters.AddWithValue("@timestamp", Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()));
|
sqlCommand.Parameters.AddWithValue("@timestamp", Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()));
|
||||||
sqlCommand.Parameters.AddWithValue("@x", Map.NewUserStartX);
|
sqlCommand.Parameters.AddWithValue("@x", Map.NewUserStartX);
|
||||||
|
@ -2129,7 +2129,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UInt64 GetPlayerBankMoney(int userId)
|
public static double GetPlayerBankMoney(int userId)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
|
@ -2140,7 +2140,7 @@ namespace HISP.Server
|
||||||
sqlCommand.CommandText = "SELECT BankBalance FROM UserExt WHERE Id=@id";
|
sqlCommand.CommandText = "SELECT BankBalance FROM UserExt WHERE Id=@id";
|
||||||
sqlCommand.Parameters.AddWithValue("@id", userId);
|
sqlCommand.Parameters.AddWithValue("@id", userId);
|
||||||
sqlCommand.Prepare();
|
sqlCommand.Prepare();
|
||||||
UInt64 BankMoney = Convert.ToUInt64(sqlCommand.ExecuteScalar());
|
double BankMoney = Convert.ToDouble(sqlCommand.ExecuteScalar());
|
||||||
|
|
||||||
sqlCommand.Dispose();
|
sqlCommand.Dispose();
|
||||||
return BankMoney;
|
return BankMoney;
|
||||||
|
@ -2152,7 +2152,66 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPlayerBankMoney(UInt64 bankMoney, int id)
|
public static double GetPlayerBankInterest(int userId)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
if (CheckUserExtExists(userId))
|
||||||
|
{
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "SELECT BankInterest FROM UserExt WHERE Id=@id";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@id", userId);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
double BankInterest = Convert.ToDouble(sqlCommand.ExecuteScalar());
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
return BankInterest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException("Id " + userId + " not found in database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoIntrestPayments()
|
||||||
|
{
|
||||||
|
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.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetPlayerBankInterest(double interest, int id)
|
||||||
|
{
|
||||||
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
if (CheckUserExist(id))
|
||||||
|
{
|
||||||
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
|
sqlCommand.CommandText = "UPDATE UserExt SET BankInterest=@interest WHERE Id=@id";
|
||||||
|
sqlCommand.Parameters.AddWithValue("@interest", interest);
|
||||||
|
sqlCommand.Parameters.AddWithValue("@id", id);
|
||||||
|
sqlCommand.Prepare();
|
||||||
|
sqlCommand.ExecuteNonQuery();
|
||||||
|
|
||||||
|
sqlCommand.Dispose();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new KeyNotFoundException("Id " + id + " not found in database.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SetPlayerBankMoney(double bankMoney, int id)
|
||||||
{
|
{
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue