mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
Add more auction checks
This commit is contained in:
parent
f35456385d
commit
35a1d00dd3
8 changed files with 689 additions and 4 deletions
|
@ -0,0 +1,43 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Events
|
||||
{
|
||||
public class RealTimeRiddle
|
||||
{
|
||||
public static List<RealTimeRiddle> RealTimeRiddles = new List<RealTimeRiddle>();
|
||||
public RealTimeRiddle(int riddleId, string riddleText, string[] answers, int reward)
|
||||
{
|
||||
RiddleId = riddleId;
|
||||
RiddleText = riddleText;
|
||||
Answers = answers;
|
||||
Reward = reward;
|
||||
RealTimeRiddles.Add(this);
|
||||
}
|
||||
public int RiddleId;
|
||||
public string RiddleText;
|
||||
public string[] Answers;
|
||||
public int Reward;
|
||||
|
||||
|
||||
public static RealTimeRiddle GetRandomRiddle()
|
||||
{
|
||||
int randomRiddleIndex = GameServer.RandomNumberGenerator.Next(0, RealTimeRiddles.Count);
|
||||
return RealTimeRiddles[randomRiddleIndex];
|
||||
}
|
||||
public bool CheckRiddle(string message)
|
||||
{
|
||||
string msgCheck = message.ToLower();
|
||||
foreach(string answer in Answers)
|
||||
{
|
||||
if (answer.ToLower().Contains(msgCheck))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,7 +147,7 @@ namespace HISP.Game.Horse
|
|||
|
||||
if(tries >= 100)
|
||||
{
|
||||
Logger.ErrorPrint("Wild Horse: " + Instance.Name + " " + Instance.Breed + " is stuck (cant move after 100 tries)");
|
||||
Logger.ErrorPrint("Wild Horse: " + Instance.Name + " " + Instance.Breed.Name + " is stuck (cant move after 100 tries) at " + x.ToString() + ", " + y.ToString());
|
||||
break;
|
||||
}
|
||||
tries++;
|
||||
|
@ -159,8 +159,8 @@ namespace HISP.Game.Horse
|
|||
{
|
||||
while(true)
|
||||
{
|
||||
int tryX = X + GameServer.RandomNumberGenerator.Next(-15, 15);
|
||||
int tryY = Y + GameServer.RandomNumberGenerator.Next(-15, 15);
|
||||
int tryX = X + GameServer.RandomNumberGenerator.Next(-5, 5);
|
||||
int tryY = Y + GameServer.RandomNumberGenerator.Next(-5, 5);
|
||||
|
||||
bool check = CanHorseBeHere(this.X, this.Y); // if the horse is allready in an invalid position..
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ namespace HISP.Game
|
|||
public static string AuctionCantAffordAuctionFee;
|
||||
public static string AuctionOneHorsePerPlayer;
|
||||
|
||||
public static string AuctionYouHaveTooManyHorses;
|
||||
public static string AuctionOnlyOneWinningBidAllowed;
|
||||
|
||||
public static string AuctionYouBroughtAHorseFormat;
|
||||
public static string AuctionNoHorseBrought;
|
||||
|
||||
|
|
|
@ -26,6 +26,13 @@ namespace HISP.Game.Services
|
|||
|
||||
public void PlaceBid(int bidAmount)
|
||||
{
|
||||
if(BidUser.HorseInventory.HorseList.Length >= BidUser.MaxHorses)
|
||||
{
|
||||
byte[] tooManyHorses = PacketBuilder.CreateChat(Messages.AuctionYouHaveTooManyHorses, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
BidUser.LoggedinClient.SendPacket(tooManyHorses);
|
||||
return;
|
||||
}
|
||||
|
||||
string yourBidRaisedTo = Messages.FormatAuctionBidRaised(BidAmount, BidAmount + bidAmount);
|
||||
|
||||
if(BidAmount >= MAX_BID)
|
||||
|
@ -35,6 +42,7 @@ namespace HISP.Game.Services
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (BidAmount + bidAmount > BidUser.Money && (AuctionItem.OwnerId != BidUser.Id))
|
||||
{
|
||||
|
||||
|
@ -53,6 +61,20 @@ namespace HISP.Game.Services
|
|||
|
||||
if (BidAmount > AuctionItem.HighestBid)
|
||||
{
|
||||
|
||||
foreach(Auction room in AuctionRooms)
|
||||
{
|
||||
foreach(Auction.AuctionEntry entry in room.AuctionEntries)
|
||||
{
|
||||
if(entry.RandomId != AuctionItem.RandomId)
|
||||
{
|
||||
byte[] cantWinTooMuch = PacketBuilder.CreateChat(Messages.AuctionOnlyOneWinningBidAllowed, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
BidUser.LoggedinClient.SendPacket(cantWinTooMuch);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int oldBid = AuctionItem.HighestBid;
|
||||
AuctionItem.HighestBid = BidAmount;
|
||||
if(AuctionItem.HighestBidder != BidUser.Id && oldBid > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue