Make "View Tack" work, still some ordering problems though >_>

This commit is contained in:
SilicaPi 2021-01-31 03:01:49 +13:00
parent 3c25795188
commit 6ea23e5870
6 changed files with 112 additions and 32 deletions

View file

@ -292,9 +292,7 @@
"breed_preview_format":"<B>Viewing %NAME%:</B><BR>%DESCRIPTION%^D4|RETURN TO BREED LIST^R2^H",
"tack":{
"view_tack_set":"^I%ICONID%^T7View %SETNAME% Tack Set:^BM%SWF%^R1^H",
"set_peice_format":"<B>%ITEMNAME%</B>: %ITEMDESC% <br> <B><font color='#880000'>[ BONUS: %BONUS% ]</font></B><BR>",
"bonus_format":"+%BOOST% %STAT%",
"and":" & "
"set_peice_format":"<B>%ITEMNAME%</B>: %ITEMDESC%<BR>",
}
},
"multiroom":{

View file

@ -16,6 +16,13 @@ namespace HISP.Game.Items
tackItems = new List<Item.ItemInformation>();
}
public int IconId
{
get
{
return GetSaddle().IconId;
}
}
public string SetName;
private List<Item.ItemInformation> tackItems;
public void Add(Item.ItemInformation item)
@ -23,6 +30,48 @@ namespace HISP.Game.Items
Logger.DebugPrint("Added "+item.Name+" To Tack Set: "+this.SetName);
tackItems.Add(item);
}
public Item.ItemInformation GetSaddle()
{
foreach(Item.ItemInformation tackItem in TackItems)
{
if(tackItem.MiscFlags[0] == 1) // Saddle
return tackItem;
}
throw new KeyNotFoundException("Saddle not found.");
}
public Item.ItemInformation GetSaddlePad()
{
foreach(Item.ItemInformation tackItem in TackItems)
{
if(tackItem.MiscFlags[0] == 2) // SaddlePad
return tackItem;
}
throw new KeyNotFoundException("SaddlePad not found.");
}
public Item.ItemInformation GetBridle()
{
foreach(Item.ItemInformation tackItem in TackItems)
{
if(tackItem.MiscFlags[0] == 3) // Bridle
return tackItem;
}
throw new KeyNotFoundException("GetBridle not found.");
}
public string[] GetSwfNames()
{
string[] swfs = new string[3];
swfs[0] = GetSaddle().EmbedSwf;
swfs[1] = GetSaddlePad().EmbedSwf;
swfs[2] = GetBridle().EmbedSwf;
return swfs;
}
public Item.ItemInformation[] TackItems
{
get
@ -37,7 +86,7 @@ namespace HISP.Game.Items
return firstChar + str.Substring(1);
}
private static List<TackSet> tackSets = new List<TackSet>();
public TackSet[] TackSets
public static TackSet[] TackSets
{
get
{
@ -69,18 +118,24 @@ namespace HISP.Game.Items
set.Add(itemInfo);
}
catch(KeyNotFoundException)
{
continue;
{
TackSet tackSet = new TackSet();
tackSet.SetName = capitalizeFirstLetter(itemInfo.EmbedSwf);
Logger.DebugPrint("Created Tack Set: "+tackSet.SetName);
tackSet.Add(itemInfo);
tackSets.Add(tackSet);
}
TackSet tackSet = new TackSet();
tackSet.SetName = capitalizeFirstLetter(itemInfo.EmbedSwf);
tackSet.Add(itemInfo);
tackSets.Add(tackSet);
Logger.DebugPrint("Created Tack Set: "+tackSet.SetName);
}
}
foreach(TackSet set in TackSets)
{
if(set.TackItems.Length < 3)
{
Logger.DebugPrint("Removing set: "+set.SetName);
tackSets.Remove(set);
}
}
}
}
}

View file

@ -518,14 +518,10 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatTackBoost(string stat, int amount)
{
return TackBonusFormat.Replace("%BOOST%",amount.ToString("N0")).Replace("%STAT%",stat);
}
public static string FormatTackSetPeice(string itemName, string itemDescription, string bonus)
public static string FormatTackSetPeice(string itemName, string itemDescription)
{
return TackSetPeiceFormat.Replace("%ITEMNAME%",itemName).Replace("%ITEMDESC%", itemDescription).Replace("%BONUS%",bonus);
return TackSetPeiceFormat.Replace("%ITEMNAME%",itemName).Replace("%ITEMDESC%", itemDescription);
}
public static string FormatTackSetView(int iconId, string tackSetName, string swf)

View file

@ -319,6 +319,48 @@ namespace HISP.Game
throw new Exception("A mathematically impossible error occured. please check wether the laws of physics still apply.");
}
public static string buildTackPeiceLibary(Item.ItemInformation item)
{
string message = "";
message += Messages.FormatTackSetPeice(item.Name, item.Description);
return message;
}
public static string BuildTackLibary()
{
string message = "";
foreach(Tack.TackSet set in Tack.TackSets)
{
string[] setSwfs = set.GetSwfNames();
string swf = "breedviewer.swf?terrain=book2&breed=tackonly";
if(setSwfs.Length >= 1)
swf += "&saddle="+setSwfs[0];
if(setSwfs.Length >= 2)
swf += "&saddlepad="+setSwfs[1];
if(setSwfs.Length >= 3)
swf += "&bridle="+setSwfs[2];
swf += "&j=";
message += Messages.FormatTackSetView(set.IconId, set.SetName, swf);
// Write all peices
try
{
message += buildTackPeiceLibary(set.GetSaddle());
message += buildTackPeiceLibary(set.GetSaddlePad());
message += buildTackPeiceLibary(set.GetBridle());
}
catch(Exception e)
{
Logger.ErrorPrint(e.Message);
}
}
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildHorseReleased()
{
string message = "";

View file

@ -591,8 +591,6 @@ namespace HISP.Server
// Tack (Horse)
Messages.TackViewSetFormat = gameData.messages.meta.libary.tack.view_tack_set;
Messages.TackSetPeiceFormat = gameData.messages.meta.libary.tack.set_peice_format;
Messages.TackBonusFormat = gameData.messages.meta.libary.tack.bonus_format;
Messages.TackAndSeperator = gameData.messages.meta.libary.tack.and;
// Vet
Messages.VetServiceHorseFormat = gameData.messages.meta.vet.service_horse;

View file

@ -1338,19 +1338,10 @@ namespace HISP.Server
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAllStats(sender.LoggedinUser));
sender.SendPacket(metaPacket);
break;
case "31": // Find Ranch
break;
case "9": // View Tack
break;
case "10": // View Competitions
break;
case "12": // View Miigames
break;
case "22": // View Locations
break;
case "23": // View Awards
break;
case "38": // Read Books
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildTackLibary());
sender.SendPacket(metaPacket);
break;
case "53": // Misc Stats / Tracked Items
sender.LoggedinUser.MetaPriority = true;