Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,609 @@
using Server;
using System;
using Server.Mobiles;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
using Server.Engines.NewMagincia;
using System.Globalization;
using Server.Items;
namespace Server.Engines.Auction
{
[PropertyObject]
public class Auction : IDisposable
{
public static void Configure()
{
Auctions = new List<Auction>();
}
public static void Initialize()
{
Timer.DelayCall(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), () =>
{
Auctions.ForEach(a =>
{
if (a.OnGoing && a.EndTime < DateTime.Now && !a.InClaimPeriod)
{
a.EndAuction();
}
else if (a.InClaimPeriod && DateTime.UtcNow > a.ClaimPeriod)
{
a.EndClaimPeriod();
}
});
});
}
public const int DefaultDuration = 10080;
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public AuctionSafe Safe { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Item AuctionItem { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public long CurrentBid { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public long StartBid { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public long Buyout { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Description { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Duration { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime StartTime { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime EndTime { get { return StartTime + TimeSpan.FromMinutes(Duration); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ClaimPeriod { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool OnGoing { get; set; }
public List<BidEntry> Bids;
public BidEntry HighestBid { get; set; }
public bool HasBegun { get { return StartTime != DateTime.MinValue; } }
public bool InClaimPeriod { get { return HasBegun && ClaimPeriod != DateTime.MinValue; } }
public bool CanModify { get { return !HasBegun; } }
public int CurrentGoldBid { get { return (int)(CurrentBid >= Account.CurrencyThreshold ? CurrentBid - (CurrentPlatBid * Account.CurrencyThreshold) : CurrentBid); } }
public int CurrentPlatBid { get { return (int)(CurrentBid >= Account.CurrencyThreshold ? CurrentBid / Account.CurrencyThreshold : 0); } }
public int BuyoutGold { get { return (int)(Buyout >= Account.CurrencyThreshold ? Buyout - (BuyoutPlat * Account.CurrencyThreshold) : Buyout); } }
public int BuyoutPlat { get { return (int)(Buyout >= Account.CurrencyThreshold ? Buyout / Account.CurrencyThreshold : 0); } }
public List<HistoryEntry> BidHistory { get; set; }
public List<PlayerMobile> Viewers { get; set; }
public static List<Auction> Auctions { get; set; }
public Auction(Mobile owner, AuctionSafe safe)
{
Safe = safe;
Owner = owner;
Bids = new List<BidEntry>();
Duration = DefaultDuration;
}
~Auction()
{
Dispose();
}
public bool AuctionItemOnDisplay()
{
if(AuctionItem == null || AuctionItem.Deleted || Safe == null)
return false;
return !AuctionItem.Movable && AuctionItem.X == Safe.X && AuctionItem.Y == Safe.Y && AuctionItem.Z == Safe.Z + 7;
}
public void OnBegin()
{
if (Safe == null || Safe.Deleted)
return;
if (!OnGoing)
{
BidHistory = null;
}
StartTime = DateTime.Now;
OnGoing = true;
CurrentBid = StartBid;
Auctions.Add(this);
}
public bool CheckModifyAuction(Mobile m, bool checkingItem = false)
{
if (Safe == null)
return false;
if (AuctionItem != null && InClaimPeriod)
{
if (!checkingItem)
m.SendLocalizedMessage(1156430); // You must wait for your auctioned item to be claimed before modifying this auction safe.
else
m.SendLocalizedMessage(1156429); // You must wait for your auctioned item to be claimed before adding a new item.
return false;
}
if (!CanModify)
{
m.SendLocalizedMessage(1156431); // You cannot modify this while an auction is in progress.
return false;
}
return true;
}
public bool TryPlaceBid(Mobile m, long bidTotal)
{
if (!OnGoing || InClaimPeriod)
{
m.SendLocalizedMessage(1156432); // There is no active auction to complete this action.
return false;
}
BidEntry entry = GetBidEntry(m);
Account acct = m.Account as Account;
long highestBid = HighestBid != null ? HighestBid.CurrentBid : CurrentBid;
if (acct == null || Banker.GetBalance(m) < bidTotal)
{
m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
return false;
}
else if (bidTotal < entry.CurrentBid || entry == HighestBid)
{
m.SendLocalizedMessage(1156445); // You have been out bid.
return false;
}
if (bidTotal <= highestBid)
{
m.SendLocalizedMessage(1156445); // You have been out bid.
}
else
{
acct.WithdrawGold(bidTotal);
entry.CurrentBid = bidTotal;
CurrentBid = highestBid + 1;
if (HighestBid != null)
{
string name = "Unknown Item";
if(AuctionItem.Name != null)
name = AuctionItem.Name;
else
name = String.Format("#{0}", AuctionItem.LabelNumber.ToString());
var message = new NewMaginciaMessage(null, new TextDefinition(1156427), String.Format("{0}\t{1}\t{2}",
name,
CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));
/* You have been out bid in an auction for ~1_ITEMNAME~. The current winning bid amount is
* ~2_BIDAMT~plat and ~3_BIDAMT~gp.*/
MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message);
Account a = HighestBid.Mobile.Account as Account;
if(a != null)
a.DepositGold(HighestBid.CurrentBid);
HighestBid.CurrentBid = 0;
}
m.SendLocalizedMessage(1156433); // Your bid has been placed.
AuctionMap map = new AuctionMap(Safe);
if (m.Backpack == null || !m.Backpack.TryDropItem(m, map, false))
{
map.Delete();
}
else
{
m.SendLocalizedMessage(1156478); // The auction safe map has been placed in your backpack.
}
HighestBid = entry;
AddToHistory(m, entry.CurrentBid);
return true;
}
return false;
}
public bool TryBuyout(Mobile m)
{
if (!OnGoing || InClaimPeriod || Buyout <= 0)
return false;
Account acct = m.Account as Account;
if (acct != null)
{
if (!acct.WithdrawGold(Buyout))
{
m.SendLocalizedMessage(1155867); // The amount entered is invalid. Verify that there are sufficient funds to complete this transaction.
return false;
}
else
{
HighestBid = GetBidEntry(m, true);
HighestBid.CurrentBid = Buyout - (int)((double)Buyout * .05);
CurrentBid = Buyout;
EndAuction();
ClaimPrize(m);
return true;
}
}
return false;
}
private void AddToHistory(Mobile m, long highBid)
{
if (BidHistory == null)
BidHistory = new List<HistoryEntry>();
BidHistory.Add(new HistoryEntry(m, highBid));
}
public BidEntry GetBidEntry(Mobile m, bool create = true)
{
BidEntry entry = Bids.FirstOrDefault(e => m == e.Mobile);
if (entry == null && create && m is PlayerMobile)
{
entry = new BidEntry((PlayerMobile)m);
Bids.Add(entry);
}
return entry;
}
public void EndAuction()
{
if (HighestBid != null && HighestBid.Mobile != null)
{
Mobile m = HighestBid.Mobile;
string name = "Unknown Item";
if (AuctionItem.Name != null)
name = AuctionItem.Name;
else
name = String.Format("#{0}", AuctionItem.LabelNumber.ToString());
NewMaginciaMessage message = new NewMaginciaMessage(null, new TextDefinition(1156426), TimeSpan.FromHours(24) ,String.Format("{0}\t{1}\t{2}",
name,
CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));
/* You have won an auction for ~1_ITEMNAME~! Your bid amount of ~2_BIDAMT~plat and ~3_BIDAMT~gp won the auction.
* You have 3 days from the end of the auction to claim your item or it will be lost.*/
MaginciaLottoSystem.SendMessageTo(HighestBid.Mobile, message);
Account a = m.Account as Account;
Account b = Owner.Account as Account;
long dif = HighestBid.CurrentBid - CurrentBid;
if (a != null && dif > 0)
a.DepositGold(dif);
if (b != null)
b.DepositGold(HighestBid.CurrentBid);
message = new NewMaginciaMessage(null, new TextDefinition(1156428), TimeSpan.FromHours(24), String.Format("{0}\t{1}\t{2}",
name,
CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))));
/*Your auction for ~1_ITEMNAME~ has ended with a winning bid of ~2_BIDAMT~plat and ~3_BIDAMT~gp. The winning bid has
*been deposited into your currency account.*/
MaginciaLottoSystem.SendMessageTo(Owner, message);
ClaimPeriod = DateTime.UtcNow + TimeSpan.FromDays(3);
}
else
{
TrayAuction();
}
CloseGumps();
}
private void CloseGumps()
{
if (Viewers != null)
Viewers.ForEach(pm =>
{
pm.CloseGump(typeof(AuctionBidGump));
pm.CloseGump(typeof(AuctionOwnerGump));
});
}
public void HouseCollapse()
{
Item item = AuctionItem;
if (Bids != null)
{
Bids.ForEach(bid =>
{
string name = "Unknown Item";
if (item.Name != null)
name = item.Name;
else
name = String.Format("#{0}", item.LabelNumber.ToString());
var mes = new NewMaginciaMessage(null, new TextDefinition(1156454), String.Format("{0}\t{1}\t{2}",
CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US")),
name));
/*Your winning bid amount of ~1_BIDAMT~plat and ~2_BIDAMT~gp for ~3_ITEMNAME~ has been refunded to you due to house collapse.*/
MaginciaLottoSystem.SendMessageTo(bid.Mobile, mes);
Account a = bid.Mobile.Account as Account;
if (a != null)
a.DepositGold(bid.CurrentBid);
});
RemoveAuction();
}
if (item != null)
{
item.Movable = true;
if (Owner != null)
{
Owner.BankBox.DropItem(item);
}
}
}
public void ClaimPrize(Mobile m)
{
if (AuctionItem != null)
{
AuctionItem.Movable = true;
if (m.Backpack == null || !m.Backpack.TryDropItem(m, AuctionItem, false))
{
m.BankBox.DropItem(AuctionItem);
if (AuctionItem.LabelNumber != 0)
{
m.SendLocalizedMessage(1156322, String.Format("#{0}", AuctionItem.LabelNumber)); // A reward of ~1_ITEM~ has been placed in your bank.
}
else
{
m.SendLocalizedMessage(1156322, AuctionItem.Name); // A reward of ~1_ITEM~ has been placed in your bank.
}
}
else
{
if (AuctionItem.LabelNumber != 0)
{
m.SendLocalizedMessage(1152339, String.Format("#{0}", AuctionItem.LabelNumber)); // A reward of ~1_ITEM~ has been placed in your backpack.
}
else
{
m.SendLocalizedMessage(1152339, AuctionItem.Name); // A reward of ~1_ITEM~ has been placed in your backpack.
}
}
AuctionItem = null;
}
RemoveAuction();
Safe.Auction = new Auction(Owner, Safe);
}
public void EndClaimPeriod()
{
if (AuctionItem != null)
{
TrayAuction();
}
}
public void TrayAuction()
{
OnGoing = false;
ClaimPeriod = DateTime.MinValue;
StartTime = DateTime.MinValue;
Bids = new List<BidEntry>();
HighestBid = null;
CurrentBid = 0;
StartBid = 0;
Buyout = 0;
Duration = DefaultDuration;
}
public void RemoveAuction()
{
Auctions.Remove(this);
Safe.Auction = null;
OnGoing = false;
AuctionItem = null;
ClaimPeriod = DateTime.MinValue;
}
public void Dispose()
{
try
{
if (Bids != null)
ColUtility.Free(Bids);
if (BidHistory != null)
ColUtility.Free(BidHistory);
if (Viewers != null)
ColUtility.Free(Viewers);
Bids = null;
BidHistory = null;
Viewers = null;
}
catch { }
}
public void ResendGumps(PlayerMobile player)
{
if (Viewers == null)
return;
ColUtility.ForEach(Viewers.Where(pm => pm != player), pm =>
{
AuctionBidGump g = pm.FindGump(typeof(AuctionBidGump)) as AuctionBidGump;
if(g == null)
pm.SendGump(new AuctionOwnerGump(pm, Safe));
else
g.Refresh();
});
}
public void AddViewer(PlayerMobile pm)
{
if (Viewers == null)
Viewers = new List<PlayerMobile>();
if (!Viewers.Contains(pm))
Viewers.Add(pm);
}
public void RemoveViewer(PlayerMobile pm)
{
if (Viewers == null)
return;
if (Viewers.Contains(pm))
Viewers.Remove(pm);
if (Viewers.Count == 0)
{
ColUtility.Free(Viewers);
Viewers = null;
}
}
public Auction(AuctionSafe safe, GenericReader reader)
{
Safe = safe;
int version = reader.ReadInt();
switch (version)
{
case 2:
ClaimPeriod = reader.ReadDateTime();
goto case 1;
case 1:
Owner = reader.ReadMobile();
AuctionItem = reader.ReadItem();
CurrentBid = reader.ReadLong();
StartBid = reader.ReadLong();
Buyout = reader.ReadLong();
Description = reader.ReadString();
Duration = reader.ReadInt();
StartTime = reader.ReadDateTime();
OnGoing = reader.ReadBool();
Bids = new List<BidEntry>();
int count = reader.ReadInt();
for (int i = 0; i < count; i++)
{
PlayerMobile m = reader.ReadMobile() as PlayerMobile;
BidEntry entry = new BidEntry(m, reader);
if (m != null)
{
Bids.Add(entry);
if (entry.CurrentBid > 0 && (HighestBid == null || entry.CurrentBid > HighestBid.CurrentBid))
HighestBid = entry;
}
}
count = reader.ReadInt();
if (count > 0)
BidHistory = new List<HistoryEntry>();
for (int i = 0; i < count; i++)
{
BidHistory.Add(new HistoryEntry(reader));
}
break;
}
if (HasBegun)
Auctions.Add(this);
}
public void Serialize(GenericWriter writer)
{
writer.Write(2);
writer.Write(ClaimPeriod);
writer.Write(Owner);
writer.Write(AuctionItem);
writer.Write(CurrentBid);
writer.Write(StartBid);
writer.Write(Buyout);
writer.Write(Description);
writer.Write(Duration);
writer.Write(StartTime);
writer.Write(OnGoing);
writer.Write(Bids.Count);
Bids.ForEach(b =>
{
writer.Write(b.Mobile);
b.Serialize(writer);
});
writer.Write(BidHistory != null ? BidHistory.Count : 0);
if (BidHistory != null)
BidHistory.ForEach(e => e.Serialize(writer));
}
}
}

View File

@@ -0,0 +1,353 @@
using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.ContextMenus;
using Server.Multis;
using Server.Engines.Auction;
namespace Server.Items
{
public class AuctionMap : MapItem
{
public readonly int TeleportCost = 1000;
public readonly int DeleteDelayMinutes = 30;
[CommandProperty(AccessLevel.GameMaster)]
public AuctionSafe AuctionSafe { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Item AuctionItem { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D SafeLocation { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Map SafeMap { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string HouseName { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D SetLocation { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Map SetMap { get; set; }
public AuctionMap(AuctionSafe auctionsafe)
: base(auctionsafe.Map)
{
AuctionSafe = auctionsafe;
AuctionItem = auctionsafe.Auction.AuctionItem;
SafeLocation = auctionsafe.Location;
SafeMap = auctionsafe.Map;
BaseHouse house = GetHouse();
if (house != null)
{
HouseName = house.Sign.GetName();
}
else
{
HouseName = "Unknown";
}
Hue = RecallRune.CalculateHue(auctionsafe.Map, null, true);
LootType = LootType.Blessed;
Width = 400;
Height = 400;
Bounds = new Rectangle2D(auctionsafe.X - 100, auctionsafe.Y - 100, 200, 200);
AddWorldPin(auctionsafe.X, auctionsafe.Y);
}
public override bool DropToWorld(Mobile from, Point3D p)
{
from.SendLocalizedMessage(500424); // You destroyed the item.
Delete();
return true;
}
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
{
return false;
}
public override void AddNameProperty(ObjectPropertyList list)
{
if (AuctionItem == null)
{
list.Add(1156474, string.Format("{0}\t{1}", HouseName, "Unknown")); // Map to Auction ~1_ITEMNAME~: ~2_HOUSE~
}
else if (AuctionItem.LabelNumber != 0)
{
list.Add(1156474, string.Format("{0}\t#{1}", HouseName, AuctionItem.LabelNumber)); // Map to Auction ~1_ITEMNAME~: ~2_HOUSE~
}
else
{
list.Add(1156474, string.Format("{0}\t{1}", HouseName, AuctionItem.Name)); // Map to Auction ~1_ITEMNAME~: ~2_HOUSE~
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
string[] coord = GetCoords();
list.Add(1154639, string.Format("{0}\t{1}", coord[0], coord[1])); // Vendor Located at ~1_loc~ (~2_facet~)
if (!CheckItem())
{
list.Add(1154700); // Item no longer for sale.
}
list.Add(1075269); // Destroyed when dropped
}
public string[] GetCoords()
{
string[] array = new string[2];
Point3D loc = Point3D.Zero;
Map locmap = Map.Internal;
if (SetLocation != Point3D.Zero && SetMap != Map.Internal)
{
loc = SetLocation;
locmap = SetMap;
}
else if (SafeLocation != Point3D.Zero && SafeMap != Map.Internal)
{
loc = SafeLocation;
locmap = SafeMap;
}
if (loc != Point3D.Zero && locmap != Map.Internal)
{
int x = loc.X;
int y = loc.Y;
int z = loc.Z;
Map map = locmap;
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if (Sextant.Format(new Point3D(x, y, z), map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
{
return new string[] { string.Format("{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W"), map.ToString() };
}
}
return new string[] { "an unknown location", "Unknown" };
}
public BaseHouse GetHouse()
{
if (AuctionSafe != null)
return BaseHouse.FindHouseAt(AuctionSafe);
return null;
}
public void OnBeforeTravel(Mobile from)
{
Banker.Withdraw(from, TeleportCost);
from.SendLocalizedMessage(1060398, TeleportCost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
if (SetLocation != Point3D.Zero)
{
SetLocation = Point3D.Zero;
SetMap = null;
}
else
{
SetLocation = from.Location;
SetMap = from.Map;
}
InvalidateProperties();
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
base.GetContextMenuEntries(from, list);
list.Add(new OpenMapEntry(from, this));
list.Add(new TeleportEntry(from, this));
}
public bool CheckItem()
{
return GetHouse() != null && AuctionItem != null && AuctionSafe.CheckAuctionItem(AuctionItem);
}
public Point3D GetLocation(Mobile m)
{
BaseHouse h = null;
if (SetLocation != Point3D.Zero)
{
h = BaseHouse.FindHouseAt(SetLocation, SetMap, 16);
}
else if (AuctionSafe != null)
{
h = BaseHouse.FindHouseAt(AuctionSafe);
}
if (h != null)
{
m.SendLocalizedMessage(1070905); // Strong magics have redirected you to a safer location!
return h.BanLocation;
}
return SetLocation != Point3D.Zero ? SetLocation : Point3D.Zero;
}
public Map GetMap()
{
if (SetLocation != Point3D.Zero)
return SetMap;
if (AuctionSafe != null)
{
return AuctionSafe.Map;
}
return null;
}
public class OpenMapEntry : ContextMenuEntry
{
public AuctionMap VendorMap { get; set; }
public Mobile Clicker { get; set; }
public OpenMapEntry(Mobile from, AuctionMap map)
: base(3006150, -1) // Open Map
{
VendorMap = map;
Clicker = from;
}
public override void OnClick()
{
VendorMap.DisplayTo(Clicker);
}
}
public class TeleportEntry : ContextMenuEntry
{
public AuctionMap VendorMap { get; set; }
public Mobile Clicker { get; set; }
public TeleportEntry(Mobile from, AuctionMap map)
: base(1154558, -1) // Teleport To Vendor
{
VendorMap = map;
Clicker = from;
Enabled = map.CheckItem();
}
public override void OnClick()
{
if (Clicker is PlayerMobile)
{
BaseGump.SendGump(new ConfirmTeleportGump(VendorMap, (PlayerMobile)Clicker));
}
}
}
public AuctionMap(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(AuctionSafe);
writer.Write(AuctionItem);
writer.Write(SafeLocation);
writer.Write(SafeMap);
writer.Write(HouseName);
writer.Write(SetLocation);
writer.Write(SetMap);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
AuctionSafe = (AuctionSafe)reader.ReadItem();
AuctionItem = reader.ReadItem();
SafeLocation = reader.ReadPoint3D();
SafeMap = reader.ReadMap();
HouseName = reader.ReadString();
SetLocation = reader.ReadPoint3D();
SetMap = reader.ReadMap();
}
public class ConfirmTeleportGump : BaseGump
{
public AuctionMap AuctionMap { get; set; }
public ConfirmTeleportGump(AuctionMap map, PlayerMobile pm)
: base(pm, 10, 10)
{
AuctionMap = map;
}
public override void AddGumpLayout()
{
AddPage(0);
AddBackground(0, 0, 414, 214, 0x7752);
AddHtmlLocalized(27, 47, 380, 80, 1156475, String.Format("@{0}@{1}@{2}", AuctionMap.TeleportCost.ToString(), AuctionMap.HouseName, AuctionMap.DeleteDelayMinutes.ToString()), 0xFFFF, false, false); // Please select 'Accept' if you would like to pay ~1_cost~ gold to teleport to auction house ~2_name~. For this price you will also be able to teleport back to this location within the next ~3_minutes~ minutes.
AddButton(7, 167, 0x7747, 0x7747, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(47, 167, 100, 40, 1150300, 0x4E73, false, false); // CANCEL
AddButton(377, 167, 0x7746, 0x7746, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(267, 167, 100, 40, 1114514, "#1150299", 0xFFFF, false, false); // // <DIV ALIGN=RIGHT>~1_TOKEN~</DIV>
}
public override void OnResponse(RelayInfo info)
{
switch (info.ButtonID)
{
default: break;
case 1:
{
if (Banker.GetBalance(User) < AuctionMap.TeleportCost)
{
User.SendLocalizedMessage(1154672); // You cannot afford to teleport to the vendor.
}
else if (!AuctionMap.CheckItem())
{
User.SendLocalizedMessage(1154643); // That item is no longer for sale.
}
else if (AuctionMap.SetLocation != Point3D.Zero && (!Utility.InRange(AuctionMap.SetLocation, User.Location, 100) || AuctionMap.SetMap != User.Map))
{
User.SendLocalizedMessage(501035); // You cannot teleport from here to the destination.
}
else
{
new Spells.Fourth.RecallSpell(User, AuctionMap, AuctionMap).Cast();
}
break;
}
}
}
}
}
}

View File

@@ -0,0 +1,286 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.Multis;
using Server.Gumps;
using Server.ContextMenus;
using System.Collections.Generic;
using Server.Engines.VeteranRewards;
namespace Server.Engines.Auction
{
public class AuctionSafe : BaseAddon, ISecurable
{
private Auction _Auction;
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Auction Auction
{
get { return _Auction; }
set
{
if (value == null && _Auction != null)
{
Item item = Auction.AuctionItem;
if (item != null && _Auction.Owner != null)
{
item.Movable = true;
_Auction.Owner.BankBox.DropItem(item);
}
}
_Auction = value;
}
}
public bool CheckAuctionItem(Item item)
{
if (_Auction == null || !_Auction.OnGoing || _Auction.AuctionItem == null)
return false;
if (_Auction.AuctionItem == item)
{
return true;
}
else
{
return false;
}
}
public override BaseAddonDeed Deed { get { return new AuctionSafeDeed(); } }
public AuctionSafe(Mobile from, bool south)
{
AddComponent(new InternalComponent(), 0, 0, 0);
Auction = new Auction(from, this);
Level = SecureLevel.Anyone;
}
public override void OnComponentUsed(AddonComponent component, Mobile from)
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (!from.InRange(component.Location, 3))
{
from.SendLocalizedMessage(500332); // I am too far away to do that.
}
else if (house != null && from is PlayerMobile)
{
if (house.IsOwner(from))
{
if (!from.HasGump(typeof(AuctionBidGump)))
{
from.SendGump(new AuctionOwnerGump((PlayerMobile)from, this));
}
}
else if (Auction != null)
{
if (house.HasSecureAccess(from, Level))
{
if (Auction.InClaimPeriod)
{
if (Auction.HighestBid != null && from == Auction.HighestBid.Mobile)
{
Auction.ClaimPrize(from);
}
else
{
if (!from.HasGump(typeof(AuctionBidGump)))
{
from.SendGump(new AuctionBidGump((PlayerMobile)from, this));
}
}
}
else
{
if (!from.HasGump(typeof(AuctionBidGump)))
{
from.SendGump(new AuctionBidGump((PlayerMobile)from, this));
}
}
}
else
{
from.SendLocalizedMessage(1156447); // This auction is private.
}
}
else
{
from.SendLocalizedMessage(1156432); // There is no active auction to complete this action.
}
}
}
public override void OnChop(Mobile from)
{
if (Auction != null && Auction.AuctionItemOnDisplay())
from.SendLocalizedMessage(1156452); // You can't use a bladed item on an auction safe that has an auction item or is currently active.
else
base.OnChop(from);
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> entries)
{
base.GetContextMenuEntries(from, entries);
SetSecureLevelEntry.AddTo(from, this, entries);
}
public override void Delete()
{
base.Delete();
if (Auction != null)
{
Auction.HouseCollapse();
Auction = null;
}
}
public AuctionSafe(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
writer.Write((int)Level);
if (Auction != null)
{
writer.Write(1);
Auction.Serialize(writer);
}
else
writer.Write(0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
Level = (SecureLevel)reader.ReadInt();
if (reader.ReadInt() == 1)
Auction = new Auction(this, reader);
}
[Flipable(0x9C18, 0x9C19)]
public class InternalComponent : AddonComponent
{
public override bool ForceShowProperties { get { return true; } }
public override int LabelNumber { get { return 1156371; } } // Auction Safe
public InternalComponent()
: base(0x9C18)
{
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
list.Add(501643); // locked down
}
public InternalComponent(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}
public class AuctionSafeDeed : BaseAddonDeed, IRewardItem
{
public bool SouthFacing { get; set; }
public Mobile From { get; set; }
public override BaseAddon Addon { get { return new AuctionSafe(From, SouthFacing); } }
public override int LabelNumber { get { return 1156371; } } // Auction Safe
public bool IsRewardItem { get; set; }
[Constructable]
public AuctionSafeDeed()
{
LootType = LootType.Blessed;
}
public override void OnDoubleClick(Mobile from)
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null)
{
if (house.Owner == from || house.IsCoOwner(from))
{
if (house.Public)
{
From = from;
base.OnDoubleClick(from);
}
else
{
from.SendLocalizedMessage(1156437); // Auction Safes can only be placed in public type houses.
}
}
}
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (IsRewardItem)
list.Add(1076217); // 1st Year Veteran Reward
}
public AuctionSafeDeed(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(1);
writer.Write((bool)IsRewardItem);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if (version > 0)
IsRewardItem = reader.ReadBool();
if (LootType != LootType.Blessed)
LootType = LootType.Blessed;
}
}
}

View File

@@ -0,0 +1,48 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.Multis;
using Server.Accounting;
using System.Collections.Generic;
namespace Server.Engines.Auction
{
public class BidEntry : IComparable<BidEntry>
{
public PlayerMobile Mobile { get; set; }
public long CurrentBid { get; set; }
//Converts to gold/plat
public int TotalGoldBid { get { return (int)(CurrentBid >= Account.CurrencyThreshold ? CurrentBid - (TotalPlatBid * Account.CurrencyThreshold) : CurrentBid); } }
public int TotalPlatBid { get { return (int)(CurrentBid >= Account.CurrencyThreshold ? CurrentBid / Account.CurrencyThreshold : 0); } }
public BidEntry(PlayerMobile m, long bid = 0)
{
Mobile = m;
CurrentBid = bid;
}
public BidEntry(PlayerMobile m, GenericReader reader)
{
Mobile = m;
int version = reader.ReadInt();
CurrentBid = reader.ReadLong();
}
public void Serialize(GenericWriter writer)
{
writer.Write(0);
writer.Write(CurrentBid);
}
public int CompareTo(BidEntry entry)
{
if (CurrentBid > entry.CurrentBid)
return 1;
return 0;
}
}
}

View File

@@ -0,0 +1,43 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.Multis;
using System.Collections.Generic;
namespace Server.Engines.Auction
{
public class HistoryEntry
{
public Mobile Mobile { get; set; }
public long Bid { get; set; }
public bool ShowRealBid { get; set; }
public DateTime BidTime { get; set; }
public HistoryEntry(Mobile m, long bid)
{
Mobile = m;
Bid = bid;
BidTime = DateTime.Now;
}
public HistoryEntry(GenericReader reader)
{
int version = reader.ReadInt();
Mobile = reader.ReadMobile();
Bid = reader.ReadLong();
ShowRealBid = reader.ReadBool();
BidTime = reader.ReadDateTime();
}
public void Serialize(GenericWriter writer)
{
writer.Write(0);
writer.Write(Mobile);
writer.Write(Bid);
writer.Write(ShowRealBid);
writer.Write(BidTime);
}
}
}

View File

@@ -0,0 +1,771 @@
using Server;
using System;
using Server.Mobiles;
using Server.Items;
using Server.Gumps;
using Server.Accounting;
using Server.Targeting;
using System.Globalization;
using Server.Network;
using System.Linq;
namespace Server.Engines.Auction
{
public class BaseAuctionGump : Gump
{
public const int Blue = 0x1FF;
public const int Yellow = 0x6B45;
public const int White = 0x7FFF;
public const int Gray = 0x4E73;
public const string HGray = "BFBFBF";
public const int Length = 400;
public const int Height = 600;
public AuctionSafe Safe { get; set; }
public bool Owner { get; set; }
public PlayerMobile User { get; set; }
public Auction Auction { get; set; }
public BaseAuctionGump(PlayerMobile p, AuctionSafe safe)
: base(100, 100)
{
Safe = safe;
Auction = safe.Auction;
User = p;
AddGumpLayout();
}
public void Refresh()
{
Entries.Clear();
Entries.TrimExcess();
AddGumpLayout();
User.CloseGump(GetType());
User.SendGump(this, false);
}
public string Color(string color, string str)
{
return String.Format("<basefont color=#{0}>{1}", color, str);
}
public virtual void AddGumpLayout()
{
AddPage(0);
AddBackground(0, 0, Length, Height, 39925);
AddHtmlLocalized(15, 25, 360, 18, 1114513, "#1156371", White, false, false); // <DIV ALIGN=CENTER>~1_TOKEN~</DIV>
AddHtmlLocalized(15, 52, 360, 18, 1114513, Owner ? "#1150328" : "#1156442", Blue, false, false); // <DIV ALIGN=CENTER>~1_TOKEN~</DIV>
AddHtmlLocalized(80, 88, 110, 22, 3000098, Yellow, false, false); // Information
AddButton(40, 88, 4005, 4007, 100, GumpButtonType.Reply, 0);
AddHtmlLocalized(265, 88, 110, 22, 3010004, Yellow, false, false); // History
AddButton(225, 88, 4005, 4007, 101, GumpButtonType.Reply, 0);
Account acct = User.Account as Account;
AddHtmlLocalized(15, 117, 175, 18, 1114514, "#1156044", Yellow, false, false); // Total Gold:
AddHtml(200, 117, 175, 18, Color(HGray, acct != null ? acct.TotalGold.ToString("N0", CultureInfo.GetCultureInfo("en-US")) : "0"), false, false);
AddHtmlLocalized(15, 137, 175, 18, 1114514, "#1156045", Yellow, false, false); // Total Platinum:
AddHtml(200, 137, 175, 18, Color(HGray, acct != null ? acct.TotalPlat.ToString("N0", CultureInfo.GetCultureInfo("en-US")) : "0"), false, false);
if (Auction != null)
Auction.AddViewer(User);
}
public override void OnResponse(NetState state, RelayInfo info)
{
switch (info.ButtonID)
{
case 0: break;
case 100: Refresh(); User.SendGump(new AuctionInfoGump(User)); break;
case 101: Refresh(); User.SendGump(new BidHistoryGump(User, Auction)); break;
}
if (Auction != null)
Auction.RemoveViewer(User);
}
}
public class AuctionOwnerGump : BaseAuctionGump
{
private long _TempBid;
private long _TempBuyout;
private bool _NoBid;
public AuctionOwnerGump(PlayerMobile pm, AuctionSafe safe)
: base(pm, safe)
{
Owner = true;
}
public override void AddGumpLayout()
{
base.AddGumpLayout();
_TempBid = 0;
_TempBuyout = 0;
_NoBid = false;
if (Auction == null)
{
if (Safe.Auction != null)
Auction = Safe.Auction;
else
Safe.Auction = Auction = new Auction(User, Safe);
}
int y = 166;
// Add Auction Item
AddHtmlLocalized(200, y, 175, 22, 1156421, Yellow, false, false); // Select New Auction Item
AddButton(160, y, 4005, 4007, 1, GumpButtonType.Reply, 0);
y += 24;
// Description
AddHtmlLocalized(15, y, 175, 110, 1114514, "#1156400", Yellow, false, false); // Description:
AddButton(345, y, 4014, 4016, 2, GumpButtonType.Reply, 0);
AddBackground(200, y, 140, 110, 9350);
AddTextEntry(202, y + 2, 136, 106, 0, 1, Auction.Description, 140);
// Display Item
if (Auction.AuctionItem != null)
{
Item i = Auction.AuctionItem;
AddImageTiledButton(102, 212, 0x918, 0x918, 0x0, GumpButtonType.Page, 0, i.ItemID, i.Hue, 23, 5);
AddItemProperty(i.Serial);
}
y += 112;
AddHtmlLocalized(15, y, 175, 18, 1114514, "#1156404", Yellow, false, false); // Time Remaining:
if (Auction.HasBegun)
{
TimeSpan left = Auction.EndTime - DateTime.Now;
int cliloc;
double v;
if (left.TotalSeconds < 0 || Auction.InClaimPeriod)
{
AddHtmlLocalized(200, y, 175, 18, 1114513, "#1156438", Gray, false, false); // Auction Ended
}
else
{
if (left.TotalDays >= 1)
{
cliloc = 1153091; // Lifespan: ~1_val~ days
v = left.TotalDays;
}
else if (left.TotalHours >= 1)
{
cliloc = 1153090; // Lifespan: ~1_val~ hours
v = left.TotalHours;
}
else
{
cliloc = 1153089; // Lifespan: ~1_val~ minutes
v = left.TotalMinutes;
}
AddHtmlLocalized(200, y, 175, 18, cliloc, ((int)v).ToString(), Gray, false, false);
}
}
else
{
TimeSpan ts = TimeSpan.FromMinutes(Auction.Duration);
if (ts.TotalMinutes > 60)
{
AddHtmlLocalized(200, y, 175, 18, 1153091, String.Format("{0}", ts.TotalDays), Gray, false, false); // Lifespan: ~1_val~ days
}
else
{
AddHtmlLocalized(200, y, 175, 18, 1153089, String.Format("{0}", ts.TotalMinutes), Gray, false, false); // Lifespan: ~1_val~ minutes
}
}
y += 20;
AddHtmlLocalized(200, y, 140, 20, 1114514, "#1156455", Yellow, false, false); // One Hour
AddButton(345, y, 4014, 4016, 3, GumpButtonType.Reply, 0);
y += 20;
AddHtmlLocalized(200, y, 140, 20, 1114514, "#1156418", Yellow, false, false); // Three Days
AddButton(345, y, 4014, 4016, 4, GumpButtonType.Reply, 0);
y += 20;
AddHtmlLocalized(Length / 2, y, 140, 20, 1114514, "#1156419", Yellow, false, false); // Five Days
AddButton(345, y, 4014, 4016, 5, GumpButtonType.Reply, 0);
y += 20;
AddHtmlLocalized(200, y, 140, 20, 1114514, "#1156420", Yellow, false, false); // Seven Days
AddButton(Length - 55, y, 4014, 4016, 6, GumpButtonType.Reply, 0);
y += 24;
int[] startbid = GetPlatGold(Auction.StartBid);
// Start Bid Plat/Gold
AddHtmlLocalized(15, y, 175, 22, 1114514, "#1156410", Yellow, false, false); // Item Starting Bid Plat:
AddBackground(200, y, 175, 22, 9350);
AddTextEntry(202, y, 171, 18, 0, 2, startbid[0] > 0 ? startbid[0].ToString() : "", 9);
y += 24;
AddHtmlLocalized(15, y, 175, 22, 1114514, "#1156411", Yellow, false, false); // Item Starting Bid Gold:
AddBackground(200, y, 175, 22, 9350);
AddTextEntry(202, y, 171, 18, 0, 3, startbid[1] > 0 ? startbid[1].ToString() : "", 9);
y += 24;
AddHtmlLocalized(200, y, 175, 22, 1156416, Yellow, false, false); // Set Starting Bids
AddButton(160, y, 4005, 4007, 7, GumpButtonType.Reply, 0);
y += 26;
// Buy Now
AddHtmlLocalized(15, y, 175, 22, 1114514, "#1156413", Yellow, false, false); // Buy Now Plat Price:
AddBackground(200, y, 175, 22, 9350);
AddTextEntry(202, y + 2, 171, 18, 0, 4, Auction.BuyoutPlat > 0 ? Auction.BuyoutPlat.ToString() : "", 9);
y += 26;
AddHtmlLocalized(15, y, 175, 22, 1114514, "#1156412", Yellow, false, false); // Buy Now Gold Price:
AddBackground(200, y, 175, 22, 9350);
AddTextEntry(202, y, 171, 18, 0, 5, Auction.BuyoutGold > 0 ? Auction.BuyoutGold.ToString() : "", 9);
y += 24;
AddHtmlLocalized(200, y, 175, 22, 1156417, Yellow, false, false); // Set Buy Now Price
AddButton(160, y, 4005, 4007, 8, GumpButtonType.Reply, 0);
y += 24;
if (Auction.AuctionItemOnDisplay() && !Auction.OnGoing)
{
AddHtmlLocalized(200, y, 175, 22, 1156414, Yellow, false, false); // Start Auction
AddButton(160, y, 4005, 4007, 9, GumpButtonType.Reply, 0);
}
if (Auction.OnGoing && Auction.HighestBid == null)
{
AddHtmlLocalized(200, y, 175, 22, 1156415, Yellow, false, false); // Stop Auction
AddButton(160, y, 4005, 4007, 23, GumpButtonType.Reply, 0);
}
}
public int[] GetPlatGold(long amount)
{
int plat = 0;
int gold = 0;
if (amount >= Account.CurrencyThreshold)
{
plat = (int)(amount / Account.CurrencyThreshold);
gold = (int)(amount - (plat * Account.CurrencyThreshold));
}
else
{
gold = (int)amount;
}
return new int[] { plat, gold };
}
private class InternalTarget : Target
{
private Auction Auction;
private BaseAuctionGump Gump;
public InternalTarget(Auction auction, BaseAuctionGump g)
: base(-1, false, TargetFlags.None)
{
Auction = auction;
Gump = g;
}
private bool IsBadItem(Item item)
{
return item == null || item.Weight > 300 || (item is Container && !(item is BaseQuiver)) || item is Gold || item is BankCheck || !item.Movable || item.Items.Count > 0;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (Auction == null || Auction.Safe == null || Auction.Safe.Deleted)
{
return;
}
if (targeted is Item)
{
Item item = targeted as Item;
if (!IsBadItem(item))
{
if (item.IsChildOf(from.Backpack))
{
Auction.AuctionItem = item;
item.Movable = false;
item.MoveToWorld(new Point3D(Gump.Safe.X, Gump.Safe.Y, Gump.Safe.Z + 7), Gump.Safe.Map);
Gump.Refresh();
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
from.Target = new InternalTarget(Auction, Gump);
}
}
else
{
from.Target = new InternalTarget(Auction, Gump);
}
}
else
{
from.Target = new InternalTarget(Auction, Gump);
}
}
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
Gump.Refresh();
from.SendLocalizedMessage(1149667); // Invalid target.
}
}
public override void OnResponse(NetState state, RelayInfo info)
{
base.OnResponse(state, info);
Mobile from = state.Mobile;
switch (info.ButtonID)
{
case 1:
{
if (Auction.CheckModifyAuction(User, true))
{
if (Auction.AuctionItem != null)
{
if (Auction.AuctionItem.LabelNumber != 0)
{
from.SendLocalizedMessage(1152339, String.Format("#{0}", Auction.AuctionItem.LabelNumber)); // A reward of ~1_ITEM~ has been placed in your backpack.
}
else
{
from.SendLocalizedMessage(1152339, Auction.AuctionItem.Name); // A reward of ~1_ITEM~ has been placed in your backpack.
}
Auction.AuctionItem.Movable = true;
from.AddToBackpack(Auction.AuctionItem);
Auction.AuctionItem = null;
}
from.Target = new InternalTarget(Auction, this);
}
else
{
Refresh();
}
break;
}
case 2:
{
if (Auction.CheckModifyAuction(User))
{
TextRelay relay = info.GetTextEntry(1);
string str = null;
if (relay != null)
str = relay.Text;
if (str != null || Guilds.BaseGuildGump.CheckProfanity(str, 140))
{
Auction.Description = Utility.FixHtml(str.Trim());
}
else
{
from.SendLocalizedMessage(1150315); // That text is unacceptable.
}
}
Refresh();
break;
}
case 3:
{
if (Auction.CheckModifyAuction(User))
Auction.Duration = 60;
Refresh();
break;
}
case 4:
{
if (Auction.CheckModifyAuction(User))
Auction.Duration = 4320;
Refresh();
break;
}
case 5:
{
if (Auction.CheckModifyAuction(User))
Auction.Duration = 7200;
Refresh();
break;
}
case 6:
{
if (Auction.CheckModifyAuction(User))
Auction.Duration = 10080;
Refresh();
break;
}
case 7:
{
if (Auction.CheckModifyAuction(User))
{
TextRelay relay1 = info.GetTextEntry(2);
string plat1 = null;
string gold1 = null;
if (relay1 != null)
plat1 = relay1.Text;
relay1 = info.GetTextEntry(3);
if (relay1 != null)
gold1 = relay1.Text;
long platAmnt = Utility.ToInt64(plat1);
long goldAmnt = Utility.ToInt64(gold1);
if (platAmnt >= 0 && goldAmnt >= 0)
{
_TempBid += platAmnt * Account.CurrencyThreshold;
_TempBid += goldAmnt;
}
else
{
from.SendLocalizedMessage(1150315); // That text is unacceptable.
_NoBid = true;
}
if (!_NoBid)
{
if (Auction.OnGoing && Auction.BidHistory == null)
{
Auction.CurrentBid = _TempBid;
}
Auction.StartBid = _TempBid;
}
}
Refresh();
break;
}
case 8:
{
if (Auction.CheckModifyAuction(User))
{
TextRelay relay2 = info.GetTextEntry(4);
string plat2 = null;
string gold2 = null;
if (relay2 != null)
plat2 = relay2.Text;
relay2 = info.GetTextEntry(5);
if (relay2 != null)
gold2 = relay2.Text;
long platAmnt2 = Utility.ToInt64(plat2);
long goldAmnt2 = Utility.ToInt64(gold2);
if (platAmnt2 >= 0 && goldAmnt2 >= 0)
{
_TempBuyout += platAmnt2 * Account.CurrencyThreshold;
_TempBuyout += goldAmnt2;
}
else
{
from.SendLocalizedMessage(1150315); // That text is unacceptable.
}
Auction.Buyout = _TempBuyout;
}
Refresh();
break;
}
case 9:
{
if (Auction.StartBid <= 0)
{
User.SendLocalizedMessage(1156434); // You must set a starting bid.
}
else
{
Auction.OnBegin();
}
Refresh();
break;
}
case 23:
{
if (Auction.OnGoing && Auction.HighestBid == null)
{
Auction.ClaimPrize(User);
}
break;
}
}
}
}
public class AuctionBidGump : BaseAuctionGump
{
public long TempBid { get; set; }
public AuctionBidGump(PlayerMobile pm, AuctionSafe safe)
: base(pm, safe)
{
}
public override void AddGumpLayout()
{
base.AddGumpLayout();
TempBid = 0;
// Display Item
if (Auction.AuctionItem != null)
{
Item i = Auction.AuctionItem;
AddImageTiledButton(200, 166, 0x918, 0x918, 0x0, GumpButtonType.Page, 0, i.ItemID, i.Hue, 23, 5);
AddItemProperty(i.Serial);
}
AddHtmlLocalized(15, 238, 175, 90, 1114514, "#1156400", Yellow, false, false); // Description:
AddHtml(200, 238, 175, 90, Auction.Description, true, true);
AddHtmlLocalized(15, 330, 175, 18, 1114514, "#1156404", Yellow, false, false); // Time Remaining:
if (Auction.HasBegun)
{
TimeSpan left = Auction.EndTime - DateTime.Now;
int cliloc;
double v;
if (left.TotalSeconds < 0 || Auction.InClaimPeriod)
{
AddHtmlLocalized(200, 330, 175, 18, 1114513, "#1156438", Gray, false, false); // Auction Ended
}
else
{
if (left.TotalDays >= 1)
{
cliloc = 1153091; // Lifespan: ~1_val~ days
v = left.TotalDays;
}
else if (left.TotalHours >= 1)
{
cliloc = 1153090; // Lifespan: ~1_val~ hours
v = left.TotalHours;
}
else
{
cliloc = 1153089; // Lifespan: ~1_val~ minutes
v = left.TotalMinutes;
}
AddHtmlLocalized(200, 330, 175, 18, cliloc, ((int)v).ToString(), Gray, false, false);
}
}
else
{
AddHtmlLocalized(200, 330, 175, 18, 1114513, "#1156440", Gray, false, false); // Auction Pending
}
AddHtmlLocalized(15, 350, 175, 18, 1114514, "#1156436", Yellow, false, false); // Current Platinum Bid:
AddHtml(200, 350, 175, 18, Color(HGray, Auction.CurrentPlatBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtmlLocalized(15, 370, 175, 18, 1114514, "#1156435", Yellow, false, false); // Current Gold Bid:
AddHtml(200, 370, 175, 18, Color(HGray, Auction.CurrentGoldBid.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtmlLocalized(15, 392, 175, 22, 1114514, "#1156406", Yellow, false, false); // Your Current Platinum Bid:
AddBackground(200, 392, 175, 22, 9350);
AddTextEntry(202, 394, 171, 18, 0, 1, "", 9);
AddHtmlLocalized(15, 418, 175, 22, 1114514, "#1156405", Yellow, false, false); // Your Current Gold Bid:
AddBackground(200, 418, 175, 22, 9350);
AddTextEntry(202, 420, 171, 18, 0, 2, "", 9);
AddHtmlLocalized(200, 442, 175, 22, 1156407, Yellow, false, false); // Place Bid
AddButton(160, 442, 4005, 4007, 1, GumpButtonType.Reply, 0);
if (Auction.Buyout > 0 && (Auction.HighestBid == null || Auction.HighestBid != null && Auction.HighestBid.Mobile != User))
{
AddHtmlLocalized(15, 484, 175, 18, 1114514, "#1156413", Yellow, false, false); // Buy Now Plat Price:
AddHtml(200, 484, 175, 18, Color(HGray, Auction.BuyoutPlat.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtmlLocalized(15, 502, 175, 18, 1114514, "#1156412", Yellow, false, false); // Buy Now Gold Price:
AddHtml(200, 502, 175, 18, Color(HGray, Auction.BuyoutGold.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtmlLocalized(200, 520, 175, 22, 1156409, Yellow, false, false); // Buy Now
AddButton(160, 520, 4005, 4007, 2, GumpButtonType.Reply, 0);
}
}
public override void OnResponse(NetState state, RelayInfo info)
{
base.OnResponse(state, info);
switch (info.ButtonID)
{
case 1:
{
TextRelay relay = info.GetTextEntry(1);
string gold = null;
string plat = null;
if (relay != null)
plat = relay.Text;
relay = info.GetTextEntry(2);
if (relay != null)
gold = relay.Text;
long val = Utility.ToInt64(plat);
if (val < 0) val = 0;
TempBid += val * Account.CurrencyThreshold;
val = Utility.ToInt64(gold);
if (val < 0) val = 0;
TempBid += val;
Auction.TryPlaceBid(User, TempBid);
Refresh();
Auction.ResendGumps(User);
break;
}
case 2:
{
Auction.TryBuyout(User);
User.SendGump(new AuctionBidGump(User, Safe));
break;
}
}
}
}
public class AuctionInfoGump : Gump
{
public AuctionInfoGump(PlayerMobile pm)
: base(100, 200)
{
AddPage(0);
AddBackground(0, 0, 600, 400, 0x9BF5);
AddHtmlLocalized(50, 10, 500, 18, 1114513, "#1156371", 0x7FFF, false, false); // <DIV ALIGN=CENTER>~1_TOKEN~</DIV>
/*<DIV ALIGN=CENTER>Auction Safe</DIV><DIV ALIGN=LEFT><BR>Auction Safe deeds can be obtained from the veteran reward system.<BR>An Auction
* Safe can be placed within public houses. When placed in a home the owner will be able to set access security on which users are allowed
* to place bids.<br>Setting up an auction first requires you to select an item from your backpack for auction. This item cannot be gold,
* a container, over 399 stones in weight, and must meet <A HREF="http://uo.com/wiki/ultima-online-wiki/gameplay/npc-commercial-transactions/npcs-player-owned">
* requirements for adding an item to a vendor.</A>Once the item has been added it will be placed on the auction safe to be displayed.
* A starting bid and auction length must be set before you can start the auction and cannot be changed once the auction begins. 140
* characters can be used to describe your auction item which can be updated at any time. A Buy Now price can be set which will allow
* customers to skip a bidding war and purchase the item at listed cost, but by doing so includes an approximate 5% fee on the purchase
* price.<br>On completion of the auction the owner account will receive their payment immediately and will be notified by in game mail
* of the outcome. The winning bidder will now have 3 days to retrieve their item from the auction safe or it will revert back to the
* owner. Once the auctioned item has been retrieved the auction safe will once again be available to start a new auction.<br><br>In order
* to bid on an auction, players must have<A HREF="http://uo.com/wiki/ultima-online-wiki/player/money"> currency available in their
* account.</A> Bidders can then place a bid for the maximum amount they are willing to pay for the listed item. Funds will immediately
* be removed from your account if your bid is successful. If your bid is higher than the current maximum bid yours will become the current
* winning bid. If you are out bid as the winning bid you will be notified by in game mail and your bid will be refunded to your account.
* On completion of the auction if you are the winning bid you will be notified that you have three days to claim your item. Upon claiming
* your item if you have any change as a result of your maximum bid it will be refunded to you.</DIV>*/
AddHtmlLocalized(50, 37, 500, 313, 1156441, 0x4100, true, true);
}
}
public class BidHistoryGump : Gump
{
private readonly int Green = 0x208;
public const string HGray = "BFBFBF";
public Auction Auction { get; set; }
public BidHistoryGump(PlayerMobile pm, Auction auction)
: base(100, 200)
{
Auction = auction;
AddPage(0);
AddBackground(0, 0, 600, 400, 0x9BF5);
AddHtmlLocalized(50, 10, 500, 18, 1114513, "#1156422", Green, false, false); // <DIV ALIGN=CENTER>~1_TOKEN~</DIV>
AddHtmlLocalized(50, 46, 58, 22, 1078924, Green, false, false); // Name:
AddHtmlLocalized(118, 46, 117, 22, 1156423, Green, false, false); // Platinum Bid:
AddHtmlLocalized(245, 46, 117, 22, 1156424, Green, false, false); // Gold Bid:
AddHtmlLocalized(372, 46, 176, 22, 1156425, Green, false, false); // Bid Time:
if (Auction == null || Auction.BidHistory == null)
return;
int y = 70;
for (int i = Auction.BidHistory.Count - 1; i >= 0; i--)
{
if (i < Auction.BidHistory.Count - 13)
break;
HistoryEntry h = Auction.BidHistory[i];
long bid = i != Auction.BidHistory.Count - 1 || h.ShowRealBid ? h.Bid : Auction.CurrentBid;
long plat = bid >= Account.CurrencyThreshold ? bid / Account.CurrencyThreshold : 0;
long gold = bid >= Account.CurrencyThreshold ? bid - ((bid / Account.CurrencyThreshold) * Account.CurrencyThreshold) : bid;
AddHtml(50, y, 58, 22, Color(HGray, String.Format("{0}*****", h.Mobile != null ? h.Mobile.Name.Trim()[0].ToString() : "?")), false, false);
AddHtml(118, y, 117, 22, Color(HGray, plat.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtml(245, y, 117, 22, Color(HGray, gold.ToString("N0", CultureInfo.GetCultureInfo("en-US"))), false, false);
AddHtml(372, y, 176, 22, Color(HGray, String.Format("{0}-{1}-{2} {3}", h.BidTime.Year, h.BidTime.Month, h.BidTime.Day, h.BidTime.ToShortTimeString())), false, false);
y += 24;
}
}
public string Color(string color, string str)
{
return String.Format("<basefont color=#{0}>{1}", color, str);
}
}
}