Skip to content

Commit

Permalink
fix ConfirmDemolishHouseGump logic around refunds
Browse files Browse the repository at this point in the history
  • Loading branch information
IcculusC authored and kamronbatman committed Aug 10, 2024
1 parent be4d53a commit b966c9b
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 117 deletions.
3 changes: 2 additions & 1 deletion Projects/UOContent/Gumps/Houses/AcceptHouseTransferGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected override void BuildLayout(ref StaticGumpBuilder builder)
builder.AddImageTiled(10, 40, 400, 200, 2624);
builder.AddAlphaRegion(10, 40, 400, 200);

/* Another player is attempting to initiate a house trade with you.
/*
* Another player is attempting to initiate a house trade with you.
* In order for you to see this window, both you and the other person are standing within two paces of the house to be traded.
* If you click OKAY below, a house trade scroll will appear in your trade window and you can complete the transaction.
* This scroll is a distinctive blue color and will show the name of the house, the name of the owner of that house, and the sextant coordinates of the center of the house when you hover your mouse over it.
Expand Down
175 changes: 64 additions & 111 deletions Projects/UOContent/Gumps/Houses/ConfirmDemolishHouseGump.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Server.Accounting;
using Server.Guilds;
using Server.Items;
using Server.Mobiles;
using Server.Multis;
using Server.Network;

Expand Down Expand Up @@ -30,7 +29,8 @@ protected override void BuildLayout(ref StaticGumpBuilder builder)
builder.AddImageTiled(10, 40, 400, 200, 2624);
builder.AddAlphaRegion(10, 40, 400, 200);

/* You are about to demolish your house.
/*
* You are about to demolish your house.
* You will be refunded the house's value directly to your bank box.
* All items in the house will remain behind and can be freely picked up by anyone.
* Once the house is demolished, anyone can attempt to place a new house on the vacant land.
Expand All @@ -56,126 +56,79 @@ public override void OnResponse(NetState state, in RelayInfo info)
return;
}

if (_house.IsOwner(state.Mobile))
if (!_house.IsOwner(state.Mobile))
{
if (_house.MovingCrate != null || _house.InternalizedVendors.Count > 0)
{
return;
}

if (!Guild.NewGuildSystem && _house.FindGuildstone() != null)
{
state.Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside.
return;
}
return;
}

/*else if (m_House.PlayerVendors.Count > 0)
{
state.Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
if (_house.HasRentedVendors && _house.VendorInventories.Count > 0)
{
// You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062679);
return;
}
if (_house.MovingCrate != null || _house.InternalizedVendors.Count > 0)
{
state.Mobile.SendLocalizedMessage(501320); // Only the house owner may do this.
return;
}

if (!Guild.NewGuildSystem && _house.FindGuildstone() != null)
{
state.Mobile.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside.
return;
}

/*else if (m_House.PlayerVendors.Count > 0)
{
state.Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
if (_house.HasRentedVendors && _house.VendorInventories.Count > 0)
{
// You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062679);
return;
}

if (_house.HasRentedVendors)
if (_house.HasRentedVendors)
{
// You cannot do that that while you still have contract vendors in your house.
state.Mobile.SendLocalizedMessage(1062680);
return;
}

if (_house.VendorInventories.Count > 0)
{
// You cannot do that that while you still have unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062681);
return;
}

if (state.Mobile.AccessLevel > AccessLevel.Player)
{
state.Mobile.SendMessage("You do not get a refund for your house as you are not a player");
_house.RemoveKeys(state.Mobile);
_house.Delete();
}
else
{
var toGive = !_house.IsAosRules || _house.Price <= 0 ? _house.GetDeed() : null;

if (toGive != null && !state.Mobile.BankBox.TryDropItem(state.Mobile, toGive, false))
{
// You cannot do that that while you still have contract vendors in your house.
state.Mobile.SendLocalizedMessage(1062680);
toGive.Delete();
state.Mobile.SendLocalizedMessage(500390); // Your bank box is full.

return;
}

if (_house.VendorInventories.Count > 0)
if (_house.Price <= 0 || !Banker.Deposit(state.Mobile, _house.Price))
{
// You cannot do that that while you still have unclaimed contract vendor inventory in your house.
state.Mobile.SendLocalizedMessage(1062681);
state.Mobile.SendMessage("Unable to refund house.");
return;
}

if (state.Mobile.AccessLevel >= AccessLevel.GameMaster)
{
state.Mobile.SendMessage("You do not get a refund for your house as you are not a player");
_house.RemoveKeys(state.Mobile);
_house.Delete();
}
else
{
Item toGive;

if (_house.IsAosRules)
{
if (_house.Price > 0)
{
toGive = new BankCheck(_house.Price);
}
else
{
toGive = _house.GetDeed();
}
}
else
{
toGive = _house.GetDeed();

if (toGive == null && _house.Price > 0)
{
toGive = new BankCheck(_house.Price);
}
}

var check = toGive as BankCheck;

if (AccountGold.Enabled && check != null)
{
var worth = check.Worth;

if (state.Mobile.Account?.DepositGold(worth) == true)
{
check.Delete();

// ~1_AMOUNT~ gold has been deposited into your bank box.
state.Mobile.SendLocalizedMessage(1060397, $"{worth:#,0}");

_house.RemoveKeys(state.Mobile);
_house.Delete();
return;
}
}

if (toGive != null)
{
var box = state.Mobile.BankBox;

if (box.TryDropItem(state.Mobile, toGive, false))
{
if (check != null)
{
// ~1_AMOUNT~ gold has been deposited into your bank box.
state.Mobile.SendLocalizedMessage(1060397, check.Worth.ToString());
}

_house.RemoveKeys(state.Mobile);
_house.Delete();
}
else
{
toGive.Delete();
state.Mobile.SendLocalizedMessage(500390); // Your bank box is full.
}
}
else
{
state.Mobile.SendMessage("Unable to refund house.");
}
}
// ~1_AMOUNT~ gold has been deposited into your bank box.
state.Mobile.SendLocalizedMessage(1060397, _house.Price.ToString());
}
else
{
state.Mobile.SendLocalizedMessage(501320); // Only the house owner may do this.
}
}

_house.RemoveKeys(state.Mobile);
_house.Delete();
}
}
5 changes: 5 additions & 0 deletions Projects/UOContent/Gumps/Houses/ConfirmResizeHouseGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ protected override void BuildLayout(ref StaticGumpBuilder builder)
builder.AddPage();

builder.AddBackground(0, 0, 420, 280, 0x13BE);

builder.AddImageTiled(10, 10, 400, 20, 0xA40);
builder.AddAlphaRegion(10, 10, 400, 20);

builder.AddHtmlLocalized(10, 10, 400, 20, 1060635, 0x7800); // <CENTER>WARNING</CENTER>

builder.AddImageTiled(10, 40, 400, 200, 0xA40);
builder.AddAlphaRegion(10, 40, 400, 200);

Expand All @@ -40,8 +43,10 @@ protected override void BuildLayout(ref StaticGumpBuilder builder)

builder.AddImageTiled(10, 250, 400, 20, 0xA40);
builder.AddAlphaRegion(10, 250, 400, 20);

builder.AddButton(10, 250, 0xFA5, 0xFA7, 1);
builder.AddButton(210, 250, 0xFA5, 0xFA7, 0);

builder.AddHtmlLocalized(40, 250, 170, 20, 1011036, 0x7FFF); // OKAY
builder.AddHtmlLocalized(240, 250, 170, 20, 1011012, 0x7FFF); // CANCEL
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Gumps/Houses/HouseGumpAOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ public override void OnResponse(NetState sender, in RelayInfo info)
}
else
{
from.SendGump(new ConfirmDemolishHouseGump(m_House), true);
from.SendGump(new ConfirmDemolishHouseGump(m_House));
}
}

Expand Down
9 changes: 6 additions & 3 deletions Projects/UOContent/Gumps/Houses/SetSecureLevelGump.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using Server.Guilds;
using Server.Multis;
using Server.Network;
Expand Down Expand Up @@ -52,7 +53,7 @@ protected override void BuildLayout(ref DynamicGumpBuilder builder)

var houseOwner = _house.Owner;
// Only the actual House owner AND guild master can set guild secures
if (Guild.NewGuildSystem && houseOwner?.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner)
if (Guild.NewGuildSystem && houseOwner?.Guild is Guild guild && guild.Leader == houseOwner)
{
builder.AddButton(10, 130, GetFirstID(SecureLevel.Guild), 4007, 5);
builder.AddHtmlLocalized(45, 130, 150, 20, 1063455, GetColor(SecureLevel.Guild)); // Guild Members
Expand All @@ -62,9 +63,11 @@ protected override void BuildLayout(ref DynamicGumpBuilder builder)
builder.AddHtmlLocalized(45, 130 + offset, 150, 20, 1061626, GetColor(SecureLevel.Anyone)); // Anyone
}

public int GetColor(SecureLevel level) => _info.Level == level ? 0x7F18 : 0x7FFF;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int GetColor(SecureLevel level) => _info.Level == level ? 0x7F18 : 0x7FFF;

public int GetFirstID(SecureLevel level) => _info.Level == level ? 4006 : 4005;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int GetFirstID(SecureLevel level) => _info.Level == level ? 4006 : 4005;

public override void OnResponse(NetState state, in RelayInfo info)
{
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Gumps/ViewHousesGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public override void OnResponse(NetState sender, in RelayInfo info)
case 3:
{
m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection));
m_From.SendGump(new ConfirmDemolishHouseGump(m_From, m_Selection));
m_From.SendGump(new ConfirmDemolishHouseGump(m_Selection));

break;
}
Expand Down

0 comments on commit b966c9b

Please sign in to comment.