mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
push becaz im tired (probably crashes...)
This commit is contained in:
parent
905dc1a6ce
commit
cc22dbcf0b
10 changed files with 395 additions and 5 deletions
|
@ -48,7 +48,7 @@ namespace HISP.Game.Horse
|
|||
|
||||
return false;
|
||||
}
|
||||
public WildHorse(HorseInstance horse, int MapX = -1, int MapY = -1, int despawnTimeout=60, bool addToDatabase = true)
|
||||
public WildHorse(HorseInstance horse, int MapX = -1, int MapY = -1, int despawnTimeout=1440, bool addToDatabase = true)
|
||||
{
|
||||
Instance = horse;
|
||||
timeout = despawnTimeout;
|
||||
|
|
|
@ -13,7 +13,14 @@ namespace HISP.Game.Inventory
|
|||
{
|
||||
get
|
||||
{
|
||||
return horsesList.ToArray();
|
||||
List<HorseInstance> filteredHorseList = new List<HorseInstance>();
|
||||
foreach(HorseInstance horse in horsesList)
|
||||
{
|
||||
if (!horse.Hidden)
|
||||
filteredHorseList.Add(horse);
|
||||
}
|
||||
|
||||
return filteredHorseList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,28 @@ namespace HISP.Game
|
|||
public static string ModIsleMessage;
|
||||
|
||||
// Auction House
|
||||
public static string AuctionCurrentRunning;
|
||||
public static string AuctionsRunning;
|
||||
public static string AuctionHorseEntryFormat;
|
||||
public static string AuctionPlayersHereFormat;
|
||||
|
||||
public static string AuctionAHorse;
|
||||
public static string AuctionListHorse;
|
||||
|
||||
public static string AuctionHorseListEntryFormat;
|
||||
public static string AuctionHorseIsTacked;
|
||||
|
||||
public static string AuctionBidRaisedFormat;
|
||||
public static string AuctionTopBid;
|
||||
public static string AuctionExistingBidHigher;
|
||||
|
||||
public static string AuctionYouveBeenOutbidFormat;
|
||||
public static string AuctionCantAffordBid;
|
||||
public static string AuctionCantAffordAuctionFee;
|
||||
|
||||
public static string AuctionYouBroughtAHorseFormat;
|
||||
public static string AuctionNoHorseBrought;
|
||||
|
||||
public static string AuctionHorseSoldFormat;
|
||||
|
||||
// Warp Command
|
||||
public static string SuccessfullyWarpedToLocation;
|
||||
|
@ -868,6 +888,37 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatAuctionHorseSold(int money)
|
||||
{
|
||||
return AuctionHorseSoldFormat.Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
public static string FormatAuctionBroughtHorse(int money)
|
||||
{
|
||||
return AuctionYouBroughtAHorseFormat.Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
public static string FormatAuctionYourOutbidBy(string username, int amount)
|
||||
{
|
||||
return AuctionYouveBeenOutbidFormat.Replace("%USERNAME%", username).Replace("%AMOUNT%", amount.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
public static string FormatAuctionBidRaised(int prevAmount, int newAmount)
|
||||
{
|
||||
return AuctionBidRaisedFormat.Replace("%AMOUNT%", prevAmount.ToString("N0", CultureInfo.InvariantCulture)).Replace("%NEWAMOUNT%", newAmount.ToString("N0", CultureInfo.InvariantCulture));
|
||||
}
|
||||
public static string FormatAuctionHorseListEntry(string horseName, bool tacked, int randomId)
|
||||
{
|
||||
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, int timeRemaining, string winningPlayer, int winningBid, int auctionRandomId)
|
||||
{
|
||||
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()).Replace("%TIME%", timeRemaining.ToString()).Replace("%WINNINGPLAYER%", winningPlayer).Replace("%WINNINGBID%", winningBid.ToString("N0", CultureInfo.InvariantCulture)).Replace("%AUCTIONRANDOMID%", auctionRandomId.ToString());
|
||||
|
||||
}
|
||||
public static string FormatAuctionPlayersHere(string usernames)
|
||||
{
|
||||
return AuctionPlayersHereFormat.Replace("%USERNAMES%", usernames);
|
||||
}
|
||||
|
||||
|
||||
public static string FormatHorseReturnedToOwner(string horseName)
|
||||
{
|
||||
return HorseLeaserReturnedToOwnerFormat.Replace("%HORSENAME%", horseName);
|
||||
|
|
|
@ -1444,6 +1444,46 @@ namespace HISP.Game
|
|||
|
||||
return message;
|
||||
}
|
||||
public static string BuildAuctionHorseList(User user)
|
||||
{
|
||||
string message = Messages.AuctionListHorse;
|
||||
foreach(HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
if (horse.Leaser > 0)
|
||||
continue;
|
||||
if (horse.Category != "TRADING")
|
||||
continue;
|
||||
|
||||
bool tacked = (horse.Equipment.Saddle != null || horse.Equipment.SaddlePad != null || horse.Equipment.Bridle != null || horse.Equipment.Companion != null);
|
||||
|
||||
message += Messages.FormatAuctionHorseListEntry(horse.Name, tacked, horse.RandomId);
|
||||
}
|
||||
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildAuction(User user, Auction auction)
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.AuctionsRunning;
|
||||
foreach(Auction.AuctionEntry entry in auction.AuctionEntries)
|
||||
{
|
||||
message += Messages.FormatAuctionHorseEntry(Database.GetUsername(entry.OwnerId), entry.Horse.Color, entry.Horse.Breed.Name, entry.Horse.Gender, entry.Horse.BasicStats.Experience, entry.Horse.RandomId, entry.TimeRemaining, Database.GetUsername(entry.HighestBidder), entry.HighestBid, entry.RandomId);
|
||||
}
|
||||
User[] users = GameServer.GetUsersAt(user.X, user.Y, true, true);
|
||||
List<string> usernames = new List<string>();
|
||||
foreach(User userInst in users)
|
||||
{
|
||||
usernames.Add(userInst.Username);
|
||||
}
|
||||
message += Messages.FormatAuctionPlayersHere(string.Join(", ", usernames.ToArray()));
|
||||
message += Messages.AuctionAHorse;
|
||||
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildWorkshop(User user)
|
||||
{
|
||||
Workshop shop = Workshop.GetWorkshopAt(user.X, user.Y);
|
||||
|
@ -2442,6 +2482,11 @@ namespace HISP.Game
|
|||
{
|
||||
message += buildArena(user, Arena.GetAreaById(int.Parse(TileArg)));
|
||||
}
|
||||
if(TileCode == "AUCTION")
|
||||
{
|
||||
user.MetaPriority = false;
|
||||
message += buildAuction(user, Auction.GetAuctionRoomById(int.Parse(TileArg)));
|
||||
}
|
||||
if(TileCode == "TRAINER")
|
||||
{
|
||||
message += buildTrainer(user, Trainer.GetTrainerById(int.Parse(TileArg)));
|
||||
|
@ -2480,6 +2525,7 @@ namespace HISP.Game
|
|||
}
|
||||
if (TileCode == "MULTIROOM")
|
||||
{
|
||||
user.MetaPriority = false;
|
||||
if (TileArg != "")
|
||||
message += buildMultiroom(TileArg, user);
|
||||
}
|
||||
|
|
141
Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs
Normal file
141
Horse Isle Server/HorseIsleServer/Game/Services/Auction.cs
Normal file
|
@ -0,0 +1,141 @@
|
|||
using HISP.Game.Horse;
|
||||
using HISP.Security;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
public class Auction
|
||||
{
|
||||
public static List<Auction> AuctionRooms = new List<Auction>();
|
||||
public Auction(int id)
|
||||
{
|
||||
RoomId = id;
|
||||
AuctionEntries = new List<AuctionEntry>();
|
||||
Database.LoadAuctionRoom(this, RoomId);
|
||||
}
|
||||
public class AuctionEntry
|
||||
{
|
||||
public AuctionEntry(int timeRemaining, int highestBid, int highestBidder, int randomId=-1)
|
||||
{
|
||||
RandomId = RandomID.NextRandomId(randomId);
|
||||
this.timeRemaining = timeRemaining;
|
||||
this.highestBid = highestBid;
|
||||
this.highestBidder = highestBidder;
|
||||
}
|
||||
|
||||
public HorseInstance Horse;
|
||||
public int OwnerId;
|
||||
|
||||
public int RandomId;
|
||||
private int timeRemaining;
|
||||
|
||||
private int highestBid;
|
||||
private int highestBidder;
|
||||
|
||||
public int TimeRemaining
|
||||
{
|
||||
get
|
||||
{
|
||||
return timeRemaining;
|
||||
}
|
||||
set
|
||||
{
|
||||
timeRemaining = value;
|
||||
Database.SetAuctionTimeout(RandomId, value);
|
||||
}
|
||||
}
|
||||
public int HighestBid
|
||||
{
|
||||
get
|
||||
{
|
||||
return highestBid;
|
||||
}
|
||||
set
|
||||
{
|
||||
highestBid = value;
|
||||
Database.SetAuctionHighestBid(RandomId, value);
|
||||
}
|
||||
}
|
||||
|
||||
public int HighestBidder
|
||||
{
|
||||
get
|
||||
{
|
||||
return highestBidder;
|
||||
}
|
||||
set
|
||||
{
|
||||
highestBidder = value;
|
||||
Database.SetAuctionHighestBidder(RandomId, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void AddEntry(AuctionEntry entry)
|
||||
{
|
||||
Database.AddAuctionRoom(entry, this.RoomId);
|
||||
AuctionEntries.Add(entry);
|
||||
}
|
||||
|
||||
public List<AuctionEntry> AuctionEntries;
|
||||
public int RoomId;
|
||||
|
||||
|
||||
public bool HasAuctionEntry(int randomId)
|
||||
{
|
||||
foreach (AuctionEntry entry in AuctionEntries)
|
||||
{
|
||||
if (entry.RandomId == randomId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public AuctionEntry GetAuctionEntry(int randomId)
|
||||
{
|
||||
foreach(AuctionEntry entry in AuctionEntries)
|
||||
{
|
||||
if(entry.RandomId == randomId)
|
||||
{
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Auction Entry with RandomID: " + randomId + " NOT FOUND");
|
||||
}
|
||||
|
||||
public static Auction GetAuctionRoomById(int roomId)
|
||||
{
|
||||
foreach(Auction auction in AuctionRooms)
|
||||
{
|
||||
if(auction.RoomId == roomId)
|
||||
{
|
||||
return auction;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Auction with roomID " + roomId + " NOT FOUND!");
|
||||
}
|
||||
|
||||
public static void LoadAllAuctionRooms()
|
||||
{
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles)
|
||||
{
|
||||
if(tile.Code != null)
|
||||
{
|
||||
if(tile.Code.StartsWith("AUCTION-"))
|
||||
{
|
||||
int code = int.Parse(tile.Code.Split('-')[1]);
|
||||
Auction loadAuctionRoom = new Auction(code);
|
||||
AuctionRooms.Add(loadAuctionRoom);
|
||||
Logger.InfoPrint("Loading Auction Room: " + code.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue