Skip to content

Commit

Permalink
Enhance trade summary and payment details
Browse files Browse the repository at this point in the history
Refined the trade summary output to only include a footer if the trade involves mortgaged properties. Additionally, changes ensure that payment details are only added to the bill of materials when the player has a positive balance. This eliminates unnecessary information and clarifies the transaction summary provided to players.
  • Loading branch information
vicr123 committed May 11, 2024
1 parent 228560a commit 708fa51
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion DiscordMonies/Game/GameControllerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,12 @@ public async Task DropPlayer(GamePlayer player)
List<string> billOfMaterials = [];

// Use TryPay because Pay will queue up a payment
if (player.Money > 0)
{
billOfMaterials.Add($"{player.Money.MoneyString()} {Emoji.ArrowRight} **{transferredName}**");
}

await TryPay(player, transferredAssets, player.Money, true);
billOfMaterials.Add($"{player.Money.MoneyString()} {Emoji.ArrowRight} **{transferredName}**");

List<IOwnable> playerAssets = [];
playerAssets.AddRange(state.Board.Spaces.Where(space => space.Owner == player));
Expand Down
14 changes: 10 additions & 4 deletions DiscordMonies/Game/Trade/TradeTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ public TradeTable Copy()

public Embed PrintTradeTable(bool asGiving)
{
return new EmbedBuilder()
var builder = new EmbedBuilder()
.WithTitle("Trade")
.AddField($"{From} gives", string.Join("\n", Giving.Select(OwnableEntry).Append(Money > 0 ? Money.MoneyString() : string.Empty))).Get()
.AddField($"{To} gives", string.Join("\n", Receiving.Select(OwnableEntry).Append(Money < 0 ? (-Money).MoneyString() : string.Empty))).Get()
.WithFooter($"{Emoji.CircledM} indicates mortgaged properties, which if traded, will need to be immediately unmortgaged or a 10% mortgage transfer fee paid to the bank.")
.Build().Get();
.AddField($"{To} gives", string.Join("\n", Receiving.Select(OwnableEntry).Append(Money < 0 ? (-Money).MoneyString() : string.Empty))).Get();

if (Giving.Concat(Receiving).Any(x => x is Space { IsMortgaged: true }))
{
builder = builder.WithFooter(
$"{Emoji.CircledM} indicates mortgaged properties, which if traded, will need to be immediately unmortgaged or a 10% mortgage transfer fee paid to the bank by the recipient.");
}

return builder.Build().Get();
}

private static string OwnableEntry(IOwnable ownable)
Expand Down

0 comments on commit 708fa51

Please sign in to comment.