Add socials to the game.

This commit is contained in:
SilicaAndPina 2021-03-01 13:36:22 +13:00
parent 4e333d1387
commit ba64c364f4
11 changed files with 699 additions and 122 deletions

View file

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HISP.Game.Chat
{
public class SocialType
{
public SocialType(string type)
{
Socials = new List<Social>();
Type = type;
SocialTypes.Add(this);
}
public static List<SocialType> SocialTypes = new List<SocialType>();
public string Type;
public List<Social> Socials;
public class Social
{
public SocialType BaseSocialType;
public int Id;
public string ButtonName;
public string ForSender;
public string ForTarget;
public string ForEveryone;
public string SoundEffect;
}
public static Social GetSocial(int socialId)
{
foreach (SocialType sType in SocialTypes)
foreach (Social social in sType.Socials)
if (social.Id == socialId)
return social;
throw new KeyNotFoundException("Social " + socialId.ToString() + " not found!");
}
public static SocialType GetSocialType(string type)
{
foreach (SocialType stype in SocialTypes)
if (stype.Type == type)
return stype;
throw new KeyNotFoundException("SocialType " + type + " NOT FOUND!");
}
public static void AddNewSocial(string type, Social social)
{
foreach(SocialType stype in SocialTypes)
{
if(stype.Type == type)
{
social.BaseSocialType = stype;
stype.Socials.Add(social);
return;
}
}
SocialType sType = new SocialType(type);
social.BaseSocialType = sType;
sType.Socials.Add(social);
return;
}
}
}

View file

@ -13,6 +13,11 @@ namespace HISP.Game
// Mod isle
public static string ModIsleMessage;
// Socials
public static string SocialButton;
public static string SocialMessageFormat;
public static string SocialTypeFormat;
// Trading
public static string TradeWithPlayerFormat;
@ -85,7 +90,6 @@ namespace HISP.Game
// Player Interaction
public static string PlayerHereMenuFormat;
public static string PlayerHereMulitpleMenuFormat;
public static string PlayerHereProfileButton;
public static string PlayerHereSocialButton;
@ -577,6 +581,8 @@ namespace HISP.Game
public static string ViewBaiscStats;
public static string ViewAdvancedStats;
public static string HorseBuckedYou;
public static string HorseLlamaBuckedYou;
public static string HorseCamelBuckedYou;
public static string HorseRidingMessageFormat;
public static string HorseNameYoursFormat;
@ -905,6 +911,7 @@ namespace HISP.Game
public static string BackToMapHorse;
public static string LongFullLine;
public static string MetaTerminator;
public static string R1;
// Pawneer
public static string PawneerUntackedHorsesICanBuy;
@ -985,7 +992,23 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
// Socials
public static string FormatSocialButton(int socialId, string buttonName)
{
string id = "" + Convert.ToChar(0x21 + socialId);
return SocialButton.Replace("%ID%", id).Replace("%SOCIALNAME%", buttonName);
}
public static string FormatSocialMessage(string socialMsg, string targetName, string senderName)
{
return SocialMessageFormat.Replace("%SOCIALMSG%", socialMsg.Replace("%TARGETNAME%", targetName).Replace("%SENDERNAME%", senderName));
}
public static string FormatSocialMenuType(string type)
{
return SocialTypeFormat.Replace("%TYPE%", Converters.CapitalizeFirstLetter(type.ToLower()));
}
// Trading
public static string FormatTradeYouReceived(int money)
{
return TradeYouReceivedMoneyMessageFormat.Replace("%MONEY%", money.ToString("N0", CultureInfo.InvariantCulture));

View file

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using HISP.Game.Chat;
namespace HISP.Game
{
@ -62,7 +63,14 @@ namespace HISP.Game
}
if(count >= 2)
playersHere += Messages.PlayerHereMulitpleMenuFormat;
{
SocialType stype = SocialType.GetSocialType("GROUP");
foreach(SocialType.Social social in stype.Socials)
{
playersHere += Messages.FormatSocialButton(social.Id, social.ButtonName);
}
playersHere += Messages.R1;
}
if (count <= 0)
return "";
@ -141,7 +149,7 @@ namespace HISP.Game
message += Messages.ThingsIAmSelling;
foreach (InventoryItem item in itemList)
{
message += "^R1";
message += Messages.R1;
Item.ItemInformation itemInfo = Item.GetItemById(item.ItemId);
int count = item.ItemInstances.Count;
@ -163,7 +171,7 @@ namespace HISP.Game
}
// Check whats avalilble to be sold
message += "^R1" + Messages.ThingsYouSellMe;
message += Messages.R1 + Messages.ThingsYouSellMe;
InventoryItem[] shopperItemList = shopperInventory.GetItemList();
foreach (InventoryItem shopperitem in shopperItemList)
@ -179,14 +187,14 @@ namespace HISP.Game
string countStr = count.ToString();
message += "^R1";
message += Messages.R1;
message += Messages.FormatShopEntry(itemInfo.IconId, countStr, itemInfo.Name, shop.CalculateSellCost(itemInfo));
message += Messages.FormatSellButton(shopperitem.ItemInstances[0].RandomId);
message += Messages.FormatSellAllButton(itemInfo.Id);
message += Messages.FormatItemInformationButton(shopperitem.ItemInstances[0].RandomId);
}
message += "^R1" + Messages.ExitThisPlace;
message += Messages.R1 + Messages.ExitThisPlace;
return message;
}
@ -363,7 +371,7 @@ namespace HISP.Game
{
message += Messages.NpcNoChatpoints;
}
message += "^R1";
message += Messages.R1;
}
return message;
}
@ -445,6 +453,28 @@ namespace HISP.Game
return message;
}
public static string BuildSocialMenu(bool onHorse)
{
string message = "";
foreach(SocialType sType in SocialType.SocialTypes)
{
if (sType.Type == "GROUP")
continue;
if (sType.Type == "HORSE")
if (!onHorse)
continue;
message += Messages.FormatSocialMenuType(sType.Type);
foreach(SocialType.Social social in sType.Socials)
{
message += Messages.FormatSocialButton(social.Id, social.ButtonName);
}
message += Messages.R1;
}
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildTradeAddItem(int totalItems)
{
@ -1957,7 +1987,7 @@ namespace HISP.Game
message += Messages.FormatItemThrowButton(randomId);
message += Messages.FormatItemInformationButton(randomId);
message += "^R1";
message += Messages.R1;
}
message += Messages.BackToMap;
@ -2101,7 +2131,7 @@ namespace HISP.Game
}
else
{
message += "^R1";
message += Messages.R1;
}
}