diff --git a/DataCollection/Useful Info/bank_tests.txt b/DataCollection/Useful Info/bank_tests.txt new file mode 100644 index 0000000..31ac17b --- /dev/null +++ b/DataCollection/Useful Info/bank_tests.txt @@ -0,0 +1 @@ +bank total @ 1/01/2021 : 14,961 \ No newline at end of file diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 2155eff..6454dcf 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -12,6 +12,10 @@ "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!", "random_movement":"You are sooo %STAT%. You wander dizzily in a different direction.", + "bank":{ + "deposit_format":"You deposited $%MONEY% into the bank.", + "withdraw_format":"You withdrew $%MONEY% from the bank." + }, "inn":{ "cant_afford":"You cannot afford that service!", "enjoyed_service":"You enjoyed your %ITEM% for $%PRICE%.", @@ -118,9 +122,15 @@ "back_to_map":"^M", "long_full_line":"^L", "fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z", + "bank":{ + "made_interest":"^LYou made $%MONEY% in interest since your last visit.^R1", + "carrying_message":"^L(You are carrying $%MONEY% and have $%BANKMONEY% in the bank.)^R1", + "what_to_do":"^LWhat would you like to do today?^R1", + "options":"^PMDeposit (up to $%MONEY%)|0^PMWithdraw (up to $%BANKMONEY%)|0^PS1|MAKE TRANSACTION" + }, "wishing_well":{ "no_coins":"
Unfortunately you have no Wishing Well coins!", - "wish_coins":"You have %AMOUNT% Wishing Well coins!", + "wish_coins":"
You have %AMOUNT% Wishing Well coins!", "wish_meta":"^I14^T6Toss a Coin in and wish for Money. ^BN1^R1^I14^T6Toss a Coin in and wish for Things. ^BN2^R1^I14^T6Toss a Coin in and wish for World Peace. ^BN3^R1", "wish_things":"The Wishing Well granted you a %ITEM% and a %ITEM2%!", diff --git a/Horse Isle Launcher/resources/app/src/inputHandler.js b/Horse Isle Launcher/resources/app/src/inputHandler.js index 7ccba81..849167c 100644 --- a/Horse Isle Launcher/resources/app/src/inputHandler.js +++ b/Horse Isle Launcher/resources/app/src/inputHandler.js @@ -1,12 +1,12 @@ const util = require('util'); - const exec = util.promisify(require('child_process').exec) +const { spawn } = require('child_process'); const urlInput = document.getElementById("urlInput") const ipInput = document.getElementById("ipInput") const portInput = document.getElementById("portInput") const enterButton = document.getElementById("enterButton") const settingsButton = document.getElementById("settingsButton") - +const path = require("path") let showServerList = false; const lastDetails = JSON.parse(localStorage.getItem("lastDetails")); @@ -16,7 +16,6 @@ if (lastDetails) { ipInput.value = lastDetails.ip; portInput.value = lastDetails.port; } - enterButton.addEventListener("click", async () => { const url = urlInput.value; const ip = ipInput.value; @@ -27,22 +26,13 @@ enterButton.addEventListener("click", async () => { ip, port })) - - runCommand(`hirunner.exe "${url}?SERVER=${ip}&PORT=${port}"`) - setTimeout(() => { - window.close() - }, 500); + + const _path = path.join(path.dirname(process.execPath), "hirunner.exe"); + spawn(_path, [`${url}?SERVER=${ip}&PORT=${port}`],{detached: true,stdio: 'ignore'}) + window.close(); }) -async function runCommand(command) { - const { stdout, stderr } = await exec(command); - if(DEBUG_MODE) - { - console.log('stdout:', stdout); - console.log('stderr:', stderr); - } - } serversList.addEventListener("click", (event) => { diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs index 2aeb1ba..10582f9 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs @@ -218,6 +218,15 @@ namespace HISP.Game public static string Sold1Format; public static string SoldAllFormat; + // Bank + public static string BankMadeInIntrestFormat; + public static string BankCarryingFormat; + public static string BankWhatToDo; + public static string BankOptionsFormat; + + public static string BankWithdrewMoneyFormat; + public static string BankDepositedMoneyFormat; + // Npc public static string NpcStartChatFormat; public static string NpcChatpointFormat; @@ -320,6 +329,28 @@ namespace HISP.Game // Click public static string NothingInterestingHere; + public static string FormatBankIntrestMadeMeta(UInt64 intrestMade) + { + return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0")); + } + public static string FormatBankCarryingMeta(int money, UInt64 bankMoney) + { + return BankCarryingFormat.Replace("%MONEY%", money.ToString("N0")).Replace("%BANKMONEY%", bankMoney.ToString("N0")); + } + public static string FormatBankOptionsMeta(int money, UInt64 bankMoney) + { + return BankOptionsFormat.Replace("%MONEY%", money.ToString("N0")).Replace("%BANKMONEY%", bankMoney.ToString("N0")); + } + + public static string FormatDepositedMoneyMessage(int money) + { + return BankDepositedMoneyFormat.Replace("%MONEY%", money.ToString("N0")); + } + public static string FormatWithdrawMoneyMessage(int money) + { + return BankWithdrewMoneyFormat.Replace("%MONEY%", money.ToString("N0")); + } + public static string FormatNumberOfWishingCoins(int amount) { return YouHaveWishingCoinsFormat.Replace("%AMOUNT%", amount.ToString("N0")); diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs index 501b04c..167c9fb 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs @@ -589,10 +589,22 @@ namespace HISP.Game return message; } - public static string buildFountain() + private static string buildFountain() { return Messages.FountainMeta; } + + private static string buildBank(User user) + { + string messages = Messages.FormatBankCarryingMeta(user.Money, user.BankMoney); + messages += Messages.BankWhatToDo; + messages += Messages.FormatBankOptionsMeta(user.Money, user.BankMoney); + messages += Messages.ExitThisPlace; + messages += Messages.MetaTerminator; + return messages; + } + + public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile) { string message = ""; @@ -650,9 +662,13 @@ namespace HISP.Game message += buildShopInfo(shop,user.Inventory); } + if(TileCode == "BANK") + { + message += buildBank(user); + } if(TileCode == "WISHINGWELL") { - message += Meta.buildWishingWell(user); + message += buildWishingWell(user); } if(TileCode == "INN") { diff --git a/Horse Isle Server/Horse Isle Server/Player/User.cs b/Horse Isle Server/Horse Isle Server/Player/User.cs index e1a0841..6bb6afa 100644 --- a/Horse Isle Server/Horse Isle Server/Player/User.cs +++ b/Horse Isle Server/Horse Isle Server/Player/User.cs @@ -191,6 +191,9 @@ namespace HISP.Player } set { + if (value > 9999999999) + value = 9999999999; + Database.SetPlayerBankMoney(value, Id); bankMoney = value; } @@ -265,7 +268,7 @@ namespace HISP.Player value = 1000; if (value <= 0) value = 0; - Database.SetPlayerHunger(Id, value); + Database.SetPlayerThirst(Id, value); thirst = value; } } diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs index d81ac1c..392cd6c 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs @@ -528,6 +528,16 @@ namespace HISP.Server Messages.AbuseReportFiled = gameData.messages.abuse_report.report_filed; Messages.AbuseReportProvideValidReason = gameData.messages.abuse_report.valid_reason; + // Bank + Messages.BankMadeInIntrestFormat = gameData.messages.meta.bank.made_interest; + Messages.BankCarryingFormat = gameData.messages.meta.bank.carrying_message; + Messages.BankWhatToDo = gameData.messages.meta.bank.what_to_do; + Messages.BankOptionsFormat = gameData.messages.meta.bank.options; + + + Messages.BankDepositedMoneyFormat = gameData.messages.bank.deposit_format; + Messages.BankWithdrewMoneyFormat = gameData.messages.bank.withdraw_format; + // Chat Messages.ChatViolationMessageFormat = gameData.messages.chat.violation_format; diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs index d3e2420..f6e32e1 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs @@ -99,10 +99,52 @@ namespace HISP.Server return; } - switch(inputId) // Private Notes + switch(inputId) { - case 7: - if(dynamicInput.Length >= 2) + case 1: // Bank + if (dynamicInput.Length >= 2) + { + int moneyDeposited = 0; + int moneyWithdrawn = 0; + try + { + moneyDeposited = int.Parse(dynamicInput[1]); + moneyWithdrawn = int.Parse(dynamicInput[2]); + } + catch (FormatException) + { + Logger.ErrorPrint(sender.LoggedinUser.Username + " tried to deposit/witthdraw NaN money...."); + break; + } + + if((moneyDeposited <= sender.LoggedinUser.Money) && moneyDeposited != 0) + { + sender.LoggedinUser.Money -= moneyDeposited; + sender.LoggedinUser.BankMoney += Convert.ToUInt64(moneyDeposited); + + byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatDepositedMoneyMessage(moneyDeposited), PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(chatPacket); + } + + if ((Convert.ToUInt64(moneyWithdrawn) <= sender.LoggedinUser.BankMoney) && moneyWithdrawn != 0) + { + sender.LoggedinUser.BankMoney -= Convert.ToUInt64(moneyWithdrawn); + sender.LoggedinUser.Money += moneyWithdrawn; + + byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatWithdrawMoneyMessage(moneyWithdrawn), PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(chatPacket); + } + + Update(sender); + break; + } + else + { + Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)"); + break; + } + case 7: // Private Notes + if (dynamicInput.Length >= 2) { sender.LoggedinUser.PrivateNotes = dynamicInput[1]; UpdateStats(sender); @@ -115,7 +157,7 @@ namespace HISP.Server Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)"); break; } - case 12: + case 12: // Abuse Report if (dynamicInput.Length >= 2) { string userName = dynamicInput[1];