Show mana costs as emojis in mtg
This commit is contained in:
parent
91d178049b
commit
6fd36e0bb2
1 changed files with 21 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
|
@ -12,10 +13,12 @@ namespace Geekbot.net.Commands
|
||||||
public class Magicthegathering : ModuleBase
|
public class Magicthegathering : ModuleBase
|
||||||
{
|
{
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
|
private readonly IEmojiConverter _emojiConverter;
|
||||||
|
|
||||||
public Magicthegathering(IErrorHandler errorHandler)
|
public Magicthegathering(IErrorHandler errorHandler, IEmojiConverter emojiConverter)
|
||||||
{
|
{
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
|
_emojiConverter = emojiConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("mtg", RunMode = RunMode.Async)]
|
[Command("mtg", RunMode = RunMode.Async)]
|
||||||
|
@ -51,7 +54,7 @@ namespace Geekbot.net.Commands
|
||||||
if (!string.IsNullOrEmpty(card.Loyalty)) eb.AddInlineField("Loyality", card.Loyalty);
|
if (!string.IsNullOrEmpty(card.Loyalty)) eb.AddInlineField("Loyality", card.Loyalty);
|
||||||
if (!string.IsNullOrEmpty(card.Toughness)) eb.AddInlineField("Thoughness", card.Toughness);
|
if (!string.IsNullOrEmpty(card.Toughness)) eb.AddInlineField("Thoughness", card.Toughness);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(card.ManaCost)) eb.AddInlineField("Cost", card.ManaCost);
|
if (!string.IsNullOrEmpty(card.ManaCost)) eb.AddInlineField("Cost", ManaConverter(card.ManaCost));
|
||||||
if (!string.IsNullOrEmpty(card.Rarity)) eb.AddInlineField("Rarity", card.Rarity);
|
if (!string.IsNullOrEmpty(card.Rarity)) eb.AddInlineField("Rarity", card.Rarity);
|
||||||
|
|
||||||
if (card.Legalities != null)
|
if (card.Legalities != null)
|
||||||
|
@ -84,5 +87,21 @@ namespace Geekbot.net.Commands
|
||||||
return new Color(255, 252, 214);
|
return new Color(255, 252, 214);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string ManaConverter(string mana)
|
||||||
|
{
|
||||||
|
var rgx = new Regex("{(\\d)}");
|
||||||
|
var groups = rgx.Match(mana).Groups;
|
||||||
|
if (groups.Count == 2)
|
||||||
|
{
|
||||||
|
mana = mana.Replace(groups[0].Value, _emojiConverter.numberToEmoji(int.Parse(groups[1].Value)));
|
||||||
|
}
|
||||||
|
return mana
|
||||||
|
.Replace("{W}", ":sunny:")
|
||||||
|
.Replace("{U}", ":droplet:")
|
||||||
|
.Replace("{B}", ":skull:")
|
||||||
|
.Replace("{R}", ":fire:")
|
||||||
|
.Replace("{G}", ":deciduous_tree:");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue