From 69e7ef1baad36654495809398cbc36bb1ee153d2 Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Sun, 21 Feb 2021 15:41:03 +1300 Subject: [PATCH] Finish Auctions? (finally??) --- DataCollection/gamedata.json | 10 +- .../Game/Horse/HorseInstance.cs | 18 +++- .../Game/Inventory/HorseInventory.cs | 16 +++- .../HorseIsleServer/Game/Messages.cs | 15 ++- .../HorseIsleServer/Game/Meta.cs | 2 +- .../HorseIsleServer/Game/Services/Auction.cs | 80 ++++++++++++++-- .../HorseIsleServer/Player/User.cs | 23 +++++ .../HorseIsleServer/Server/Database.cs | 21 ++++- .../HorseIsleServer/Server/GameDataJson.cs | 94 ++++++++++--------- .../HorseIsleServer/Server/GameServer.cs | 25 ++++- 10 files changed, 235 insertions(+), 69 deletions(-) diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index c61ddef..ea09f74 100755 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -213,20 +213,24 @@ "auction":{ "auctions_running":"The following auctions are running:
", "players_here":"^HPlayers Here: %USERNAMES%", - "auction_horse_entry":"^I252^T8%USERNAME%'s %COLOR% %BREED% %GENDER% (%EXP%exp)^B3L%RANDOMID%^R1", - "going_to":"^T8In %TIME%m going to %WINNINGPLAYER% for $%WINNINGBID%^R1^B72%AUCTIONRANDOMID%^B73%AUCTIONRANDOMID%^B74%AUCTIONRANDOMID%^B75%AUCTIONRANDOMID%^B76%RANDOMID%^B77%AUCTIONRANDOMID%^B78%AUCTIONRANDOMID%^R1", - "not_sold":"^T8Auction Ended. Horse was not sold.", + "auction_horse_entry":"^I252^T8%USERNAME%'s %COLOR% %BREED% %GENDER% (%EXP%exp)%LOOKBUTTON%^R1", + "view_button":"^B3L%RANDOMID%", + "going_to":"^T8In %TIME%m going to %WINNINGPLAYER% for $%WINNINGBID%^R1^B72%AUCTIONRANDOMID%^B73%AUCTIONRANDOMID%^B74%AUCTIONRANDOMID%^B75%AUCTIONRANDOMID%^B76%AUCTIONRANDOMID%^B77%AUCTIONRANDOMID%^B78%AUCTIONRANDOMID%^R1", + "not_sold":"^T8Auction Ended. Horse was not sold.^R1", "sold_to":"^T8Auction Ended. %PLAYERNAME% won it for $%PRICE%^R1", "auction_horse":"^T0(2b max)^D41|AUCTION A HORSE^R1", + "one_horse_at_a_time":"Only one horse per player allowed up for auction at a time.", "list_horse":"^HIt costs you $1,000 to auction. If you wish to set a minimum bid for your horse, bid on it yourself. All auctions run for 8 minutes.
Select from one of your horses to auction:^R1", "horse_list_entry":"^I252^T3%HORSENAME%%TACKEDORNO%^D42c%RANDOMID%|AUCTION^R1", "tacked":"[tacked!]", + "max_bid":"Max auction bidding is 2b.", "bid_raised":"Your bid raised $%AMOUNT% to $%NEWAMOUNT%.", "top_bid":" TOP BID", "existing_higher":" Existing Bid is Higher", + "no_other_transaction_allowed":"No other money transactions allowed while bidding on a Horse at auction.", "outbid_by":"You have been outbid by %USERNAME%. High bid is now $%AMOUNT%.", "cant_afford_bid":"You cannot afford that bid.", "cant_afford_listing":"You cannot afford the auction fee.", diff --git a/Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs b/Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs index 4c11951..a75862d 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Horse/HorseInstance.cs @@ -6,10 +6,10 @@ namespace HISP.Game.Horse { public class HorseInstance { - public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0, string loadCategory="KEEPER", int loadMagicUsed=0, int loadAutoSell=0, int leaseTimer=0, bool loadHidden=false) + public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0, string loadCategory="KEEPER", int loadMagicUsed=0, int loadAutoSell=0, int leaseTimer=0, bool loadHidden=false, int loadOwner=0) { RandomId = RandomID.NextRandomId(randomId); - Owner = 0; + owner = loadOwner; if(loadName == null) { @@ -61,7 +61,19 @@ namespace HISP.Game.Horse } public int Leaser; public int RandomId; - public int Owner; + public int owner; + public int Owner + { + get + { + return owner; + } + set + { + owner = value; + Database.SetHorseOwner(RandomId, owner); + } + } public bool Hidden { diff --git a/Horse Isle Server/HorseIsleServer/Game/Inventory/HorseInventory.cs b/Horse Isle Server/HorseIsleServer/Game/Inventory/HorseInventory.cs index 03ac309..3be3de2 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Inventory/HorseInventory.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Inventory/HorseInventory.cs @@ -30,6 +30,17 @@ namespace HISP.Game.Inventory Database.LoadHorseInventory(this, baseUser.Id); } + public void UnHide(int randomId) + { + foreach(HorseInstance inst in horsesList) + { + if (inst.RandomId == randomId) + { + inst.Hidden = false; + break; + } + } + } public void AddHorse(HorseInstance horse, bool addToDb=true) { if (HorseList.Length + 1 > baseUser.MaxHorses) @@ -41,9 +52,10 @@ namespace HISP.Game.Inventory horsesList.Add(horse); } - public void DeleteHorse(HorseInstance horse) + public void DeleteHorse(HorseInstance horse, bool removeFromDb=true) { - Database.RemoveHorse(horse.RandomId); + if(removeFromDb) + Database.RemoveHorse(horse.RandomId); horsesList.Remove(horse); } diff --git a/Horse Isle Server/HorseIsleServer/Game/Messages.cs b/Horse Isle Server/HorseIsleServer/Game/Messages.cs index 6864f3e..2c3175a 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Messages.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Messages.cs @@ -22,8 +22,10 @@ namespace HISP.Game public static string AuctionListHorse; public static string AuctionHorseListEntryFormat; + public static string AuctionHorseViewButton; public static string AuctionHorseIsTacked; + public static string AuctionBidMax; public static string AuctionBidRaisedFormat; public static string AuctionTopBid; public static string AuctionExistingBidHigher; @@ -31,6 +33,7 @@ namespace HISP.Game public static string AuctionYouveBeenOutbidFormat; public static string AuctionCantAffordBid; public static string AuctionCantAffordAuctionFee; + public static string AuctionOneHorsePerPlayer; public static string AuctionYouBroughtAHorseFormat; public static string AuctionNoHorseBrought; @@ -41,6 +44,8 @@ namespace HISP.Game public static string AuctionNotSold; public static string AuctionGoingToFormat; + public static string AuctionNoOtherTransactionAllowed; + // Warp Command public static string SuccessfullyWarpedToLocation; public static string SuccessfullyWarpedToPlayer; @@ -894,7 +899,7 @@ namespace HISP.Game public static string FormatAuctionSoldTo(string playerName, int money) { - return AuctionSoldToFormat.Replace("%PLAYERNAME%", playerName).Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture)); + return AuctionSoldToFormat.Replace("%PLAYERNAME%", playerName).Replace("%PRICE%", money.ToString("N0", CultureInfo.InvariantCulture)); } public static string FormatAuctionGoingTo(int timeRemaining, string winningPlayer, int winningBid, int auctionRandomId) { @@ -920,11 +925,15 @@ namespace HISP.Game { return AuctionHorseListEntryFormat.Replace("%HORSENAME%", horseName).Replace("%TACKEDORNO%", tacked ? Messages.AuctionHorseIsTacked : "").Replace("%RANDOMID%", randomId.ToString()); } - public static string FormatAuctionHorseEntry(string username, string color, string breedName, string gender, int experience, int horseRandomId) + public static string FormatAuctionHorseEntry(string username, string color, string breedName, string gender, int experience, string lookButton) { - return AuctionHorseEntryFormat.Replace("%USERNAME%", username).Replace("%COLOR%", color).Replace("%BREED%", breedName).Replace("%GENDER%", gender).Replace("%EXP%", experience.ToString("N0", CultureInfo.InvariantCulture)).Replace("%RANDOMID%", horseRandomId.ToString()); + return AuctionHorseEntryFormat.Replace("%USERNAME%", username).Replace("%COLOR%", color).Replace("%BREED%", breedName).Replace("%GENDER%", gender).Replace("%EXP%", experience.ToString("N0", CultureInfo.InvariantCulture)).Replace("%LOOKBUTTON%", lookButton); } + public static string FormatAuctionViewHorseButton(int randomId) + { + return AuctionHorseViewButton.Replace("%RANDOMID%", randomId.ToString()); + } public static string FormatAuctionPlayersHere(string usernames) { return AuctionPlayersHereFormat.Replace("%USERNAMES%", usernames); diff --git a/Horse Isle Server/HorseIsleServer/Game/Meta.cs b/Horse Isle Server/HorseIsleServer/Game/Meta.cs index f7ff0fc..afcefc8 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Meta.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Meta.cs @@ -1469,7 +1469,7 @@ namespace HISP.Game message += Messages.AuctionsRunning; foreach(Auction.AuctionEntry entry in auction.AuctionEntries.ToArray()) { - message += Messages.FormatAuctionHorseEntry(Database.GetUsername(entry.OwnerId), entry.Horse.Color, entry.Horse.Breed.Name, entry.Horse.Gender, entry.Horse.BasicStats.Experience, entry.Horse.RandomId); + message += Messages.FormatAuctionHorseEntry(Database.GetUsername(entry.OwnerId), entry.Horse.Color, entry.Horse.Breed.Name, entry.Horse.Gender, entry.Horse.BasicStats.Experience, entry.Completed ? "" : Messages.FormatAuctionViewHorseButton(entry.Horse.RandomId)); if (!entry.Completed) message += Messages.FormatAuctionGoingTo(entry.TimeRemaining, Database.GetUsername(entry.HighestBidder), entry.HighestBid, entry.RandomId); else diff --git a/Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs b/Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs index eabbfb6..f9cca7f 100644 --- a/Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs @@ -18,19 +18,44 @@ namespace HISP.Game.Services public class AuctionBid { + public const int MAX_BID = 2000000000; public User BidUser; public AuctionEntry AuctionItem; public int BidAmount; + public void PlaceBid(int bidAmount) { string yourBidRaisedTo = Messages.FormatAuctionBidRaised(BidAmount, BidAmount + bidAmount); + if(BidAmount >= MAX_BID) + { + byte[] maxBidReached = PacketBuilder.CreateChat(Messages.AuctionBidMax, PacketBuilder.CHAT_BOTTOM_RIGHT); + BidUser.LoggedinClient.SendPacket(maxBidReached); + return; + } + + if (BidAmount + bidAmount > BidUser.Money && (AuctionItem.OwnerId != BidUser.Id)) + { + + byte[] cantAffordBid = PacketBuilder.CreateChat(Messages.AuctionCantAffordBid, PacketBuilder.CHAT_BOTTOM_RIGHT); + BidUser.LoggedinClient.SendPacket(cantAffordBid); + return; + } + + BidAmount += bidAmount; + if(BidAmount > MAX_BID) // no u + { + yourBidRaisedTo = Messages.FormatAuctionBidRaised(BidAmount, MAX_BID); + BidAmount = MAX_BID; + } + if (BidAmount > AuctionItem.HighestBid) { - AuctionItem.HighestBid += BidAmount; - if(AuctionItem.HighestBidder != BidUser.Id) + int oldBid = AuctionItem.HighestBid; + AuctionItem.HighestBid = BidAmount; + if(AuctionItem.HighestBidder != BidUser.Id && oldBid > 0) { if (GameServer.IsUserOnline(AuctionItem.HighestBidder)) { @@ -42,7 +67,6 @@ namespace HISP.Game.Services AuctionItem.HighestBidder = BidUser.Id; yourBidRaisedTo += Messages.AuctionTopBid; - } else { @@ -51,6 +75,7 @@ namespace HISP.Game.Services byte[] bidPlacedMsg = PacketBuilder.CreateChat(yourBidRaisedTo, PacketBuilder.CHAT_BOTTOM_RIGHT); BidUser.LoggedinClient.SendPacket(bidPlacedMsg); + } } public class AuctionEntry @@ -65,7 +90,8 @@ namespace HISP.Game.Services public HorseInstance Horse; public int OwnerId; - + public List Bidders = new List(); + public bool Completed { get @@ -77,26 +103,42 @@ namespace HISP.Game.Services done = value; if(done) { - Horse.Owner = HighestBidder; + Horse.Owner = highestBidder; Horse.Hidden = false; + if(OwnerId == highestBidder) + { + if(GameServer.IsUserOnline(OwnerId)) + { + User auctionRunner = GameServer.GetUserById(highestBidder); + auctionRunner.HorseInventory.UnHide(Horse.RandomId); + byte[] notSold = PacketBuilder.CreateChat(Messages.AuctionNoHorseBrought, PacketBuilder.CHAT_BOTTOM_RIGHT); + auctionRunner.LoggedinClient.SendPacket(notSold); + } + return; + } + + if(GameServer.IsUserOnline(highestBidder)) { User userWon = GameServer.GetUserById(highestBidder); byte[] wonAuction = PacketBuilder.CreateChat(Messages.FormatAuctionBroughtHorse(highestBid), PacketBuilder.CHAT_BOTTOM_RIGHT); userWon.LoggedinClient.SendPacket(wonAuction); userWon.Money -= highestBid; + userWon.HorseInventory.AddHorse(Horse, false); } else { Database.SetPlayerMoney(Database.GetPlayerMoney(highestBidder) - highestBid, highestBidder); } + if(GameServer.IsUserOnline(OwnerId)) { - User userSold = GameServer.GetUserById(highestBidder); + User userSold = GameServer.GetUserById(OwnerId); byte[] horseSold = PacketBuilder.CreateChat(Messages.FormatAuctionHorseSold(highestBid), PacketBuilder.CHAT_BOTTOM_RIGHT); userSold.LoggedinClient.SendPacket(horseSold); userSold.Money += highestBid; + userSold.HorseInventory.DeleteHorse(Horse, false); } else { @@ -104,6 +146,13 @@ namespace HISP.Game.Services } } Database.SetAuctionDone(RandomId, done); + + foreach(AuctionBid bid in Bidders) // Cleanup some stuffs + { + if(bid.BidUser != null) + bid.BidUser.Bids.Remove(bid); + } + Bidders.Clear(); } } @@ -115,6 +164,7 @@ namespace HISP.Game.Services if (bid.AuctionItem.RandomId == this.RandomId) { bid.PlaceBid(bidAmount); + auctionRoomPlacedIn.UpdateAuctionRoom(); return; } } @@ -122,11 +172,17 @@ namespace HISP.Game.Services AuctionBid newBid = new AuctionBid(); newBid.AuctionItem = this; newBid.BidUser = bidder; - newBid.BidAmount = 0; + if (HighestBidder == bidder.Id) + newBid.BidAmount = HighestBid; + else + newBid.BidAmount = 0; newBid.PlaceBid(bidAmount); bidder.Bids.Add(newBid); + Bidders.Add(newBid); + auctionRoomPlacedIn.UpdateAuctionRoom(); } + public Auction auctionRoomPlacedIn; public int RandomId; private int timeRemaining; private bool done; @@ -200,6 +256,7 @@ namespace HISP.Game.Services public void AddEntry(AuctionEntry entry) { + entry.auctionRoomPlacedIn = this; Database.AddAuctionRoom(entry, this.RoomId); AuctionEntries.Add(entry); @@ -232,6 +289,15 @@ namespace HISP.Game.Services throw new KeyNotFoundException("Auction Entry with RandomID: " + randomId + " NOT FOUND"); } + public bool HasUserPlacedAuctionAllready(User user) + { + foreach(AuctionEntry entry in AuctionEntries) + { + if (entry.OwnerId == user.Id) + return true; + } + return false; + } public static Auction GetAuctionRoomById(int roomId) { foreach(Auction auction in AuctionRooms) diff --git a/Horse Isle Server/HorseIsleServer/Player/User.cs b/Horse Isle Server/HorseIsleServer/Player/User.cs index 80ab5cc..3713a9c 100755 --- a/Horse Isle Server/HorseIsleServer/Player/User.cs +++ b/Horse Isle Server/HorseIsleServer/Player/User.cs @@ -555,6 +555,29 @@ namespace HISP.Player LoggedinClient = baseClient; Inventory = new PlayerInventory(this); Quests = new PlayerQuests(this); + + // Get auctions + foreach(Auction auction in Auction.AuctionRooms) + { + foreach(Auction.AuctionEntry auctionEntry in auction.AuctionEntries) + { + if(auctionEntry.HighestBidder == this.Id) + { + Auction.AuctionBid bid = new Auction.AuctionBid(); + bid.BidUser = this; + bid.BidAmount = auctionEntry.HighestBid; + bid.AuctionItem = auctionEntry; + + if(bid.BidAmount > 0) + { + Bids.Add(bid); + auctionEntry.Bidders.Add(bid); + } + + } + } + } + } } } diff --git a/Horse Isle Server/HorseIsleServer/Server/Database.cs b/Horse Isle Server/HorseIsleServer/Server/Database.cs index b91a923..8bd88dd 100755 --- a/Horse Isle Server/HorseIsleServer/Server/Database.cs +++ b/Horse Isle Server/HorseIsleServer/Server/Database.cs @@ -1481,9 +1481,10 @@ namespace HISP.Server int autosell = reader.GetInt32(29); int leaseTime = reader.GetInt32(2); bool hidden = reader.GetString(34) == "YES"; + int owner = reader.GetInt32(1); - HorseInstance inst = new HorseInstance(horseBreed, randomId, name, description, spoiled, category, magicUsed, autosell, leaseTime); - inst.Owner = reader.GetInt32(1); + HorseInstance inst = new HorseInstance(horseBreed, randomId, name, description, spoiled, category, magicUsed, autosell, leaseTime, hidden, owner); + inst.Leaser = reader.GetInt32(3); inst.Gender = reader.GetString(7); inst.Color = reader.GetString(8); @@ -1568,6 +1569,7 @@ namespace HISP.Server auctionEntry.Horse = GetPlayerHorse(horseId); auctionEntry.OwnerId = reader.GetInt32(3); auctionEntry.Completed = reader.GetString(7) == "YES"; + auctionEntry.auctionRoomPlacedIn = auction; auction.AuctionEntries.Add(auctionEntry); } @@ -2402,6 +2404,21 @@ namespace HISP.Server } + public static void SetHorseOwner(int randomId, int owner) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "UPDATE Horses SET ownerId=@owner WHERE randomId=@randomId"; + sqlCommand.Parameters.AddWithValue("@owner", owner); + sqlCommand.Parameters.AddWithValue("@randomId", randomId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + sqlCommand.Dispose(); + } + } + public static void SetHorseHidden(int randomId, bool hidden) { using (MySqlConnection db = new MySqlConnection(ConnectionString)) diff --git a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs index 3c88657..fe3c8a2 100755 --- a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs +++ b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs @@ -15,10 +15,10 @@ namespace HISP.Server { public class GameDataJson { - + public static void ReadGamedata() { - if(!File.Exists(ConfigReader.GameDataFile)) + if (!File.Exists(ConfigReader.GameDataFile)) { Logger.ErrorPrint("Game Data JSON File: " + ConfigReader.GameDataFile + " Does not exist!"); throw new FileNotFoundException(ConfigReader.GameDataFile + " Not found :("); @@ -76,7 +76,7 @@ namespace HISP.Server // Register Isles int totalIsles = gameData.places.isles.Count; - for(int i = 0; i < totalIsles; i++) + for (int i = 0; i < totalIsles; i++) { World.Isle isle = new World.Isle(); @@ -92,7 +92,7 @@ namespace HISP.Server } int totalWaypoints = gameData.places.waypoints.Count; - for(int i = 0; i < totalWaypoints; i++) + for (int i = 0; i < totalWaypoints; i++) { World.Waypoint waypoint = new World.Waypoint(); waypoint.Name = gameData.places.waypoints[i].name; @@ -101,7 +101,7 @@ namespace HISP.Server waypoint.Type = gameData.places.waypoints[i].type; waypoint.Description = gameData.places.waypoints[i].description; waypoint.WeatherTypesAvalible = gameData.places.waypoints[i].weather_avalible.ToObject(); - Logger.DebugPrint("Registered Waypoint: "+waypoint.PosX.ToString()+", "+waypoint.PosY.ToString() +" TYPE: "+waypoint.Type); + Logger.DebugPrint("Registered Waypoint: " + waypoint.PosX.ToString() + ", " + waypoint.PosY.ToString() + " TYPE: " + waypoint.Type); World.Waypoints.Add(waypoint); } @@ -116,9 +116,9 @@ namespace HISP.Server specialTile.Title = gameData.places.special_tiles[i].title; specialTile.Description = gameData.places.special_tiles[i].description; specialTile.Code = gameData.places.special_tiles[i].code; - if(gameData.places.special_tiles[i].exit_x != null) + if (gameData.places.special_tiles[i].exit_x != null) specialTile.ExitX = gameData.places.special_tiles[i].exit_x; - if(gameData.places.special_tiles[i].exit_x != null) + if (gameData.places.special_tiles[i].exit_x != null) specialTile.ExitY = gameData.places.special_tiles[i].exit_y; specialTile.AutoplaySwf = gameData.places.special_tiles[i].autoplay_swf; specialTile.TypeFlag = gameData.places.special_tiles[i].type_flag; @@ -129,7 +129,7 @@ namespace HISP.Server // Register Filter Reasons int totalReasons = gameData.messages.chat.reason_messages.Count; - for(int i = 0; i < totalReasons; i++) + for (int i = 0; i < totalReasons; i++) { Chat.Reason reason = new Chat.Reason(); reason.Name = gameData.messages.chat.reason_messages[i].name; @@ -141,7 +141,7 @@ namespace HISP.Server // Register Filters int totalFilters = gameData.messages.chat.filter.Count; - for(int i = 0; i < totalFilters; i++) + for (int i = 0; i < totalFilters; i++) { Chat.Filter filter = new Chat.Filter(); filter.FilteredWord = gameData.messages.chat.filter[i].word; @@ -149,7 +149,7 @@ namespace HISP.Server filter.Reason = Chat.GetReason((string)gameData.messages.chat.filter[i].reason_type); Chat.FilteredWords.Add(filter); - Logger.DebugPrint("Registered Filtered Word: " + filter.FilteredWord + " With reason: "+filter.Reason.Name+" (Matching all: " + filter.MatchAll + ")"); + Logger.DebugPrint("Registered Filtered Word: " + filter.FilteredWord + " With reason: " + filter.Reason.Name + " (Matching all: " + filter.MatchAll + ")"); } // Register Corrections @@ -161,7 +161,7 @@ namespace HISP.Server correction.ReplacedWord = gameData.messages.chat.correct[i].new_word; Chat.CorrectedWords.Add(correction); - Logger.DebugPrint("Registered Word Correction: " + correction.FilteredWord + " to "+correction.ReplacedWord); + Logger.DebugPrint("Registered Word Correction: " + correction.FilteredWord + " to " + correction.ReplacedWord); } // Register Transports @@ -190,7 +190,7 @@ namespace HISP.Server transportPlace.LocationTitle = gameData.transport.transport_places[i].place_title; Transport.TransportLocations.Add(transportPlace); - Logger.DebugPrint("Registered Transport Location: "+ transportPlace.LocationTitle+" To Goto X: " + transportPlace.GotoX + " Y: " + transportPlace.GotoY); + Logger.DebugPrint("Registered Transport Location: " + transportPlace.LocationTitle + " To Goto X: " + transportPlace.GotoX + " Y: " + transportPlace.GotoY); } // Register Items @@ -212,7 +212,7 @@ namespace HISP.Server int effectsCount = gameData.item.item_list[i].effects.Count; Item.Effects[] effectsList = new Item.Effects[effectsCount]; - for(int ii = 0; ii < effectsCount; ii++) + for (int ii = 0; ii < effectsCount; ii++) { effectsList[ii] = new Item.Effects(); effectsList[ii].EffectsWhat = gameData.item.item_list[i].effects[ii].effect_what; @@ -227,12 +227,12 @@ namespace HISP.Server item.SpawnParamaters.SpawnOnSpecialTile = gameData.item.item_list[i].spawn_parameters.spawn_on_special_tile; item.SpawnParamaters.SpawnNearSpecialTile = gameData.item.item_list[i].spawn_parameters.spawn_near_special_tile; - Logger.DebugPrint("Registered Item ID: " + item.Id + " Name: " + item.Name + " spawns on: "+item.SpawnParamaters.SpawnOnTileType); + Logger.DebugPrint("Registered Item ID: " + item.Id + " Name: " + item.Name + " spawns on: " + item.SpawnParamaters.SpawnOnTileType); Item.Items.Add(item); } int totalThrowable = gameData.item.throwable.Count; - for(int i = 0; i < totalThrowable; i++) + for (int i = 0; i < totalThrowable; i++) { Item.ThrowableItem throwableItem = new Item.ThrowableItem(); throwableItem.Id = gameData.item.throwable[i].id; @@ -243,7 +243,7 @@ namespace HISP.Server // Register NPCs Logger.DebugPrint("Registering NPCS: "); int totalNpcs = gameData.npc_list.Count; - for(int i = 0; i < totalNpcs; i++) + for (int i = 0; i < totalNpcs; i++) { int id = gameData.npc_list[i].id; int x = gameData.npc_list[i].x; @@ -259,12 +259,12 @@ namespace HISP.Server udlrStartY = gameData.npc_list[i].udlr_start_y; Npc.NpcEntry npcEntry = new Npc.NpcEntry(id, x, y, moves, udlrStartX, udlrStartY); - + npcEntry.Name = gameData.npc_list[i].name; npcEntry.AdminDescription = gameData.npc_list[i].admin_description; npcEntry.ShortDescription = gameData.npc_list[i].short_description; npcEntry.LongDescription = gameData.npc_list[i].long_description; - + if (gameData.npc_list[i].stay_on != null) npcEntry.StayOn = gameData.npc_list[i].stay_on; @@ -320,12 +320,12 @@ namespace HISP.Server Logger.DebugPrint("Registering Quests: "); int totalQuests = gameData.quest_list.Count; - for(int i = 0; i < totalQuests; i++) + for (int i = 0; i < totalQuests; i++) { Quest.QuestEntry quest = new Quest.QuestEntry(); quest.Id = gameData.quest_list[i].id; quest.Notes = gameData.quest_list[i].notes; - if(gameData.quest_list[i].title != null) + if (gameData.quest_list[i].title != null) quest.Title = gameData.quest_list[i].title; quest.RequiresQuestIdCompleteStatsMenu = gameData.quest_list[i].requires_questid_statsmenu.ToObject(); if (gameData.quest_list[i].alt_activation != null) @@ -341,7 +341,7 @@ namespace HISP.Server int itemsRequiredCount = gameData.quest_list[i].items_required.Count; List itmInfo = new List(); - for(int ii = 0; ii < itemsRequiredCount; ii++) + for (int ii = 0; ii < itemsRequiredCount; ii++) { Quest.QuestItemInfo itemInfo = new Quest.QuestItemInfo(); itemInfo.ItemId = gameData.quest_list[i].items_required[ii].item_id; @@ -349,7 +349,7 @@ namespace HISP.Server itmInfo.Add(itemInfo); } quest.ItemsRequired = itmInfo.ToArray(); - if(gameData.quest_list[i].fail_npc_chat != null) + if (gameData.quest_list[i].fail_npc_chat != null) quest.FailNpcChat = gameData.quest_list[i].fail_npc_chat; quest.MoneyEarned = gameData.quest_list[i].money_gained; @@ -367,13 +367,13 @@ namespace HISP.Server quest.QuestPointsEarned = gameData.quest_list[i].quest_points; quest.SetNpcChatpoint = gameData.quest_list[i].set_npc_chatpoint; quest.GotoNpcChatpoint = gameData.quest_list[i].goto_npc_chatpoint; - if(gameData.quest_list[i].warp_x != null) + if (gameData.quest_list[i].warp_x != null) quest.WarpX = gameData.quest_list[i].warp_x; - if(gameData.quest_list[i].warp_y != null) + if (gameData.quest_list[i].warp_y != null) quest.WarpY = gameData.quest_list[i].warp_y; - if(gameData.quest_list[i].success_message != null) + if (gameData.quest_list[i].success_message != null) quest.SuccessMessage = gameData.quest_list[i].success_message; - if(gameData.quest_list[i].success_npc_chat != null) + if (gameData.quest_list[i].success_npc_chat != null) quest.SuccessNpcChat = gameData.quest_list[i].success_npc_chat; if (gameData.quest_list[i].requires_awardid != null) quest.AwardRequired = gameData.quest_list[i].requires_awardid; @@ -387,12 +387,12 @@ namespace HISP.Server if (gameData.quest_list[i].chained_questid != null) quest.ChainedQuestId = gameData.quest_list[i].chained_questid; quest.Minigame = gameData.quest_list[i].minigame; - Logger.DebugPrint("Registered Quest: " + quest.Id +" - "+ quest.Title); + Logger.DebugPrint("Registered Quest: " + quest.Id + " - " + quest.Title); Quest.QuestList.Add(quest); } int totalShops = gameData.shop_list.Count; - for(int i = 0; i < totalShops; i++) + for (int i = 0; i < totalShops; i++) { Shop shop = new Shop(gameData.shop_list[i].stocks_itemids.ToObject()); @@ -400,8 +400,8 @@ namespace HISP.Server shop.BuyPricePercentage = gameData.shop_list[i].buy_percent; shop.SellPricePercentage = gameData.shop_list[i].sell_percent; shop.BuysItemTypes = gameData.shop_list[i].buys_item_types.ToObject(); - - Logger.DebugPrint("Registered Shop ID: "+ shop.Id + " Selling items at " + shop.SellPricePercentage + "% and buying at " + shop.BuyPricePercentage); + + Logger.DebugPrint("Registered Shop ID: " + shop.Id + " Selling items at " + shop.SellPricePercentage + "% and buying at " + shop.BuyPricePercentage); } // Register awards @@ -412,7 +412,7 @@ namespace HISP.Server { Award.AwardEntry award = new Award.AwardEntry(); - award.Id = i+1; + award.Id = i + 1; award.Sort = gameData.award_list[i].sort_by; award.Title = gameData.award_list[i].title; award.IconId = gameData.award_list[i].icon_id; @@ -428,7 +428,7 @@ namespace HISP.Server // Register Abuse Report Reasons int totalAbuseReportReasons = gameData.messages.meta.abuse_report.reasons.Count; - for(int i = 0; i < totalAbuseReportReasons; i++) + for (int i = 0; i < totalAbuseReportReasons; i++) { AbuseReport.ReportReason reason = new AbuseReport.ReportReason(); reason.Id = gameData.messages.meta.abuse_report.reasons[i].id; @@ -469,7 +469,7 @@ namespace HISP.Server } int totalPoets = gameData.poetry.Count; - for(int i = 0; i < totalPoets; i++) + for (int i = 0; i < totalPoets; i++) { Brickpoet.PoetryEntry entry = new Brickpoet.PoetryEntry(); entry.Id = gameData.poetry[i].id; @@ -482,7 +482,7 @@ namespace HISP.Server // Register Horse Breeds int totalBreeds = gameData.horses.breeds.Count; - for(int i = 0; i < totalBreeds; i++) + for (int i = 0; i < totalBreeds; i++) { HorseInfo.Breed horseBreed = new HorseInfo.Breed(); @@ -513,7 +513,7 @@ namespace HISP.Server } // Register Breed Prices @ Pawneer Order int totalBreedPrices = gameData.horses.pawneer_base_price.Count; - for(int i = 0; i < totalBreedPrices; i++) + for (int i = 0; i < totalBreedPrices; i++) { int id = gameData.horses.pawneer_base_price[i].breed_id; int price = gameData.horses.pawneer_base_price[i].price; @@ -523,7 +523,7 @@ namespace HISP.Server } int totalCategories = gameData.horses.categorys.Count; - for(int i = 0; i < totalCategories; i++) + for (int i = 0; i < totalCategories; i++) { HorseInfo.Category category = new HorseInfo.Category(); category.Name = gameData.horses.categorys[i].name; @@ -533,7 +533,7 @@ namespace HISP.Server Logger.DebugPrint("Registered horse category type: " + category.Name); } int totalTrackedItems = gameData.messages.meta.misc_stats.tracked_items.Count; - for(int i = 0; i < totalTrackedItems; i++) + for (int i = 0; i < totalTrackedItems; i++) { Tracking.TrackedItemStatsMenu trackedItem = new Tracking.TrackedItemStatsMenu(); trackedItem.What = gameData.messages.meta.misc_stats.tracked_items[i].id; @@ -610,14 +610,14 @@ namespace HISP.Server wkShop.X = gameData.workshop[i].pos_x; wkShop.Y = gameData.workshop[i].pos_y; int totalCraftableItems = gameData.workshop[i].craftable_items.Count; - for(int ii = 0; ii < totalCraftableItems; ii++) + for (int ii = 0; ii < totalCraftableItems; ii++) { Workshop.CraftableItem craftableItem = new Workshop.CraftableItem(); craftableItem.Id = gameData.workshop[i].craftable_items[ii].id; craftableItem.GiveItemId = gameData.workshop[i].craftable_items[ii].give_item; craftableItem.MoneyCost = gameData.workshop[i].craftable_items[ii].money_cost; int totalItemsRequired = gameData.workshop[i].craftable_items[ii].required_items.Count; - for(int iii = 0; iii < totalItemsRequired; iii++) + for (int iii = 0; iii < totalItemsRequired; iii++) { Workshop.RequiredItem requiredItem = new Workshop.RequiredItem(); requiredItem.RequiredItemId = gameData.workshop[i].craftable_items[ii].required_items[iii].req_item; @@ -646,9 +646,9 @@ namespace HISP.Server building.Cost = cost; building.Title = title; building.Description = description; - + Ranch.RanchBuilding.RanchBuildings.Add(building); - Logger.DebugPrint("Registered Ranch Building: "+building.Title); + Logger.DebugPrint("Registered Ranch Building: " + building.Title); } // Register Ranch Upgrades @@ -701,7 +701,7 @@ namespace HISP.Server // Register BBCODE int totalBBocdes = gameData.bbcode.Count; - for(int i = 0; i < totalBBocdes; i++) + for (int i = 0; i < totalBBocdes; i++) { string tag = gameData.bbcode[i].tag; string meta = gameData.bbcode[i].meta; @@ -728,7 +728,7 @@ namespace HISP.Server // Register Arenas int totalArenas = gameData.arena.Count; - for(int i = 0; i < totalArenas; i++) + for (int i = 0; i < totalArenas; i++) { int arenaId = gameData.arena[i].arena_id; string arenaType = gameData.arena[i].arena_type; @@ -738,7 +738,7 @@ namespace HISP.Server int timeout = gameData.arena[i].timeout; Arena arena = new Arena(arenaId, arenaType, arenaEntryCost, raceEvery, slots, timeout); - Logger.DebugPrint("Registered Arena: " + arena.Id.ToString()+" as " + arena.Type); + Logger.DebugPrint("Registered Arena: " + arena.Id.ToString() + " as " + arena.Type); } // Register Leaser int totalLeasers = gameData.leaser.Count; @@ -771,7 +771,7 @@ namespace HISP.Server leaser.Gender = gameData.leaser[i].horse.gender; leaser.Height = gameData.leaser[i].horse.hands; leaser.Experience = gameData.leaser[i].horse.exp; - leaser.HorseName = gameData.leaser[i].horse.name; + leaser.HorseName = gameData.leaser[i].horse.name; leaser.Health = gameData.leaser[i].horse.basic_stats.health; leaser.Hunger = gameData.leaser[i].horse.basic_stats.hunger; @@ -829,15 +829,19 @@ namespace HISP.Server Messages.AuctionListHorse = gameData.messages.meta.auction.list_horse; Messages.AuctionHorseListEntryFormat = gameData.messages.meta.auction.horse_list_entry; + Messages.AuctionHorseViewButton = gameData.messages.meta.auction.view_button; Messages.AuctionHorseIsTacked = gameData.messages.meta.auction.tacked; + Messages.AuctionBidMax = gameData.messages.meta.auction.max_bid; Messages.AuctionBidRaisedFormat = gameData.messages.meta.auction.bid_raised; Messages.AuctionTopBid = gameData.messages.meta.auction.top_bid; Messages.AuctionExistingBidHigher = gameData.messages.meta.auction.existing_higher; + Messages.AuctionOneHorsePerPlayer = gameData.messages.meta.auction.one_horse_at_a_time; Messages.AuctionYouveBeenOutbidFormat = gameData.messages.meta.auction.outbid_by; Messages.AuctionCantAffordBid = gameData.messages.meta.auction.cant_afford_bid; Messages.AuctionCantAffordAuctionFee = gameData.messages.meta.auction.cant_afford_listing; + Messages.AuctionNoOtherTransactionAllowed = gameData.messages.meta.auction.no_other_transaction_allowed; Messages.AuctionYouBroughtAHorseFormat = gameData.messages.meta.auction.brought_horse; Messages.AuctionNoHorseBrought = gameData.messages.meta.auction.no_one_brought; diff --git a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs index 471b07e..af6ae6f 100755 --- a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs +++ b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs @@ -152,8 +152,7 @@ namespace HISP.Server entry.TimeRemaining--; if (entry.Completed) auction.DeleteEntry(entry); - - if (entry.TimeRemaining <= 0) + else if (entry.TimeRemaining <= 0) entry.Completed = true; auction.UpdateAuctionRoom(); @@ -2582,7 +2581,12 @@ namespace HISP.Server return; } Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1])); - + if(auctionRoom.HasUserPlacedAuctionAllready(sender.LoggedinUser)) + { + byte[] cantPlaceAuction = PacketBuilder.CreateChat(Messages.AuctionOneHorsePerPlayer, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(cantPlaceAuction); + break; + } if (sender.LoggedinUser.Money >= 1000) { sender.LoggedinUser.Money -= 1000; @@ -4020,6 +4024,14 @@ namespace HISP.Server } } + if (sender.LoggedinUser.Bids.Count > 0) + { + byte[] cantBuyWhileAuctioning = PacketBuilder.CreateChat(Messages.AuctionNoOtherTransactionAllowed, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(cantBuyWhileAuctioning); + return; + } + + if (sender.LoggedinUser.Money >= cost) { string swfToLoad = Messages.BoatCutscene; @@ -5401,6 +5413,13 @@ namespace HISP.Server if (shop != null) { int buyCost = shop.CalculateBuyCost(itemInfo) * count; + if (sender.LoggedinUser.Bids.Count > 0) + { + byte[] cantBuyWhileAuctioning = PacketBuilder.CreateChat(Messages.AuctionNoOtherTransactionAllowed, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(cantBuyWhileAuctioning); + return; + } + if (sender.LoggedinUser.Money < buyCost) { byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.CantAfford1, PacketBuilder.CHAT_BOTTOM_RIGHT);