Skip to content

Commit

Permalink
Mention game players
Browse files Browse the repository at this point in the history
  • Loading branch information
reflectronic committed May 11, 2024
1 parent 52ab0ed commit 2f69c0e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DiscordMonies/Board/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed record LuckCard(
string Description,
string Command);

public record ColorSet(int Index);
public readonly record struct ColorSet(int Index);

public class Space : IOwnable
{
Expand Down
4 changes: 2 additions & 2 deletions DiscordMonies/Game/Embeds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static Embed Dropped(GamePlayer player, GamePlayer? transferTo, IEnumerab
{
var builder = new EmbedBuilder()
.WithTitle("Bankruptcy")
.WithDescription($"**{player}** has declared bankruptcy and is now removed from the game. All of their remaining assets will be transferred to {$"**{transferTo?.DisplayName}**" ?? "**the bank**, where it will be auctioned off to the highest bidder"}.")
.WithDescription($"{player} has declared bankruptcy and is now removed from the game. All of their remaining assets will be transferred to {$"**{transferTo?.ToString()}**" ?? "**the bank**, where it will be auctioned off to the highest bidder"}.")
.WithColour(PrettyColors.Red);

var materials = billOfMaterials.ToList();
Expand Down Expand Up @@ -369,7 +369,7 @@ public static Embed Space(Space space)
.AddField("Name", space.Info.Name, true).Get()
.AddField("Position", space.PositionCode, true).Get()
.AddField("Value", space.Info is ValueSpace vs ? vs.Value.MoneyString() : "N/A", true).Get()
.AddField("Owner", space.Info is PropertySpace ? space.Owner?.DisplayName ?? "Unowned" : "Not ownable", true).Get()
.AddField("Owner", space.Info is PropertySpace ? space.Owner?.ToString() ?? "Unowned" : "Not ownable", true).Get()
.AddField("Mortgaged?", space.IsMortgaged ? "Yes" : "No", true).Get()
.AddField("Color", space.Info is RoadSpace rs ? space.Board.GroupNames[rs.Group] : "N/A", true).Get()
.AddField("Buildings", space.BuiltHouses switch
Expand Down
1 change: 1 addition & 0 deletions DiscordMonies/Game/Emoji.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public static class Emoji
public const string OncomingPoliceCar = "\U0001F694";
public const string CircledM = "\u24C2\uFE0F";
public const string ArrowRight = "\u27A1\uFE0F";
public const string TwistedArrows = "\U0001F500";
public const string FlyingMoney = "\U0001F4B8";
public const string Die = "\U0001F3B2";
public const string Judge = "\U0001F9D1\u200D\u2696\uFE0F";
Expand Down
10 changes: 3 additions & 7 deletions DiscordMonies/Game/GameCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
using System.Diagnostics;
using DiscordMonies.Board;
using DiscordMonies.Extensions;
using DiscordMonies.Game.Trade;
using DiscordMonies.Game.UnresolvedMatters;
using DiscordMonies.Game.UnresolvedMatters.AuctionMatter;
using DiscordMonies.Game.UnresolvedMatters.DiceRoll;
using DiscordMonies.Game.UnresolvedMatters.Payment;
using DiscordMonies.Remora;
using OneOf.Types;
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Discord.API.Abstractions.Objects;
Expand All @@ -18,7 +15,6 @@
using Remora.Discord.Commands.Attributes;
using Remora.Discord.Commands.Contexts;
using Remora.Discord.Commands.Feedback.Services;
using Remora.Discord.Extensions.Formatting;
using Remora.Discord.Interactivity;
using Remora.Results;

Expand Down Expand Up @@ -106,7 +102,7 @@ public async Task<Result> Nudge()
// TODO: Auctions
var current = gameState.CurrentPlayer;
await feedback.SendContextualAsync(
$"{Mention.User(current.Id)}, {gameState.GetById(ctx.GetUserId()).DisplayName} wished to remind you that it is your turn to play by giving you a gentle nudge. *Nudge!*");
$"{current}, {gameState.GetById(ctx.GetUserId()).DisplayName} wished to remind you that it is your turn to play by giving you a gentle nudge. *Nudge!*");
return Result.Success;
}

Expand All @@ -123,7 +119,7 @@ await feedback.SendContextualAsync(
return Result.Success;
}

await feedback.SendContextualAsync($"Title deed for {space}", embeds: new([space.TitleDeedEmbed()]));
await feedback.SendContextualEmbedAsync(space.TitleDeedEmbed());
return Result.Success;
}

Expand Down Expand Up @@ -448,7 +444,7 @@ public async Task<Result> AuctionBidOther()
public async Task<Result> AuctionTitleDeed()
{
var space = ((AuctionMatter)gameState.CurrentlyResolvingMatter).AuctionSpace;
await feedback.SendContextualAsync($"Title deed for {space}", embeds: new([space.TitleDeedEmbed()]));
await feedback.SendContextualEmbedAsync(space.TitleDeedEmbed());
return Result.Success;
}

Expand Down
15 changes: 9 additions & 6 deletions DiscordMonies/Game/GameControllerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public async Task<bool> TryPay(GamePlayer? from, GamePlayer? to, int value, bool
{
if (value < 0) return await TryPay(to, from, -value, bankruptcyPayment);

var payer = from?.DisplayName ?? "The Bank";
var receiver = to?.DisplayName ?? (Random.Shared.Next(1000) == 253 ? "theBank" : "The Bank");
var payer = from?.ToString() ?? "The Bank";
var receiver = to?.ToString() ?? (Random.Shared.Next(1000) == 253 ? "theBank" : "The Bank");

// Decrease the money of the payer if they exist
if (from != null)
Expand Down Expand Up @@ -689,9 +689,11 @@ public IList<Space> DevelopOptions(GamePlayer player, ColorSet colorSet, out Not

public async Task DevelopProperties(GamePlayer player, ColorSet colorSet, IEnumerable<int> targets)
{
string groupName = state.Board.GroupNames[colorSet.Index];

if (ColorSetOwner(colorSet) != player)
{
await service.SendContextualAsync(Strings.UnableToDevelopOnColourSet(state.Board.GroupNames[colorSet.Index]));
await service.SendContextualAsync(Strings.UnableToDevelopOnColourSet(groupName));
return;
}

Expand Down Expand Up @@ -720,8 +722,9 @@ await service.SendContextualAsync(
// Everything is okay!

var embedBuilder = new EmbedBuilder()
.WithTitle($"Development on {state.Board.GroupNames[colorSet.Index]}")
.WithDescription($"Development on {state.Board.GroupNames[colorSet.Index]} has been completed by **{player}**. The changes are as follows:")
.WithTitle($"Development on {groupName}")
.WithColour(PrettyColors.ColorMap[groupName])
.WithDescription($"Development on {groupName} has been completed by {player}.")
.WithImageUrl("attachment://board.png");

foreach (var (target, index) in targets.Take(spaces.Count).Select((x, i) => (x, i)))
Expand Down Expand Up @@ -922,7 +925,7 @@ public async Task Mortgage(GamePlayer player, Space space)
public async Task DropPlayer(GamePlayer player)
{
var transferredAssets = state.CurrentlyResolvingMatter is PaymentMatter matter ? matter.To : null;
var transferredName = transferredAssets?.DisplayName ?? "the bank";
var transferredName = transferredAssets?.ToString() ?? "the bank";

// Transfer all of player's assets to transferredAssets
List<string> billOfMaterials = [];
Expand Down
6 changes: 3 additions & 3 deletions DiscordMonies/Game/GamePlayer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Immutable;
using DiscordMonies.Board;
using DiscordMonies.Board;

using Remora.Discord.API.Abstractions.Objects;
using Remora.Rest.Core;

using System.Drawing;
using DiscordMonies.Game.Trade;
using Remora.Discord.Extensions.Formatting;

namespace DiscordMonies.Game;

Expand Down Expand Up @@ -42,7 +42,7 @@ public override int GetHashCode()

public override string ToString()
{
return DisplayName;
return Mention.User(Id);
}

#region IUser Implementation
Expand Down
2 changes: 1 addition & 1 deletion DiscordMonies/Game/Trade/TradeCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<Result> Open([Description("The player to trade with")] GamePla
CopyOf = null
};

await feedback.SendContextualAsync($"{player} is creating a trade...", options: MessageOptions.SuppressNotifications);
await feedback.SendContextualAsync($"{player} is creating a trade...");
await feedback.SendContextualAsync($"Opened a new trade table. Add items to the trade table, and then offer it to {Mention.User(otherPlayer)} when you're ready.", options: MessageOptions.Ephemeral);
return Result.Success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class PaymentMatterHandler(GameState state, IFeedbackService service, Gam
{
public async Task Resolve(PaymentMatter matter)
{
var payer = matter.From?.DisplayName ?? "The Bank";
var receiver = matter.To?.DisplayName ?? (Random.Shared.Next(1000) == 253 ? "theBank" : "the Bank");
var payer = matter.From?.ToString() ?? "The Bank";
var receiver = matter.To?.ToString() ?? (Random.Shared.Next(1000) == 253 ? "theBank" : "The Bank");

// Only process a forced payment if it has not yet been processed
if (!matter.PaymentComplete)
Expand Down

0 comments on commit 2f69c0e

Please sign in to comment.