mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
Implement riddle rooms
This commit is contained in:
parent
64671ef186
commit
10c1c32518
11 changed files with 1276 additions and 91 deletions
|
@ -31,18 +31,14 @@ namespace HISP.Game
|
|||
|
||||
if (pos >= oMapData.Length && overlay)
|
||||
return 1;
|
||||
else if (pos >= MapData.Length && !overlay)
|
||||
return 1;
|
||||
else if (overlay && oMapData[pos] != 1)
|
||||
return oMapData[pos];
|
||||
else if (overlay && Treasure.IsTileBuiredTreasure(x, y))
|
||||
return 193; // Burried Treasure tile.
|
||||
else if (overlay && Treasure.IsTilePotOfGold(x, y))
|
||||
return 186; // Pot of Gold tile.
|
||||
else if (overlay && Ranch.IsRanchHere(x, y))
|
||||
return 170 + Ranch.GetRanchAt(x, y).Upgraded; // Ranch Tile + Upgraded amount
|
||||
return 170 + Ranch.GetRanchAt(x, y).UpgradedLevel; // Ranch Tile + Upgraded amount
|
||||
else if (overlay)
|
||||
return 1;
|
||||
return oMapData[pos];
|
||||
else if (!overlay)
|
||||
return MapData[pos];
|
||||
else // Not sure how you could even get here.
|
||||
|
|
|
@ -580,6 +580,12 @@ namespace HISP.Game
|
|||
public static string KickReasonIdleFormat;
|
||||
public static string KickReasonNoTime;
|
||||
|
||||
// Riddler
|
||||
public static string RiddlerEnterAnswerFormat;
|
||||
public static string RiddlerCorrectAnswerFormat;
|
||||
public static string RiddlerIncorrectAnswer;
|
||||
public static string RiddlerAnsweredAll;
|
||||
|
||||
// Password
|
||||
public static string IncorrectPasswordMessage;
|
||||
|
||||
|
@ -591,6 +597,15 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatRiddlerRiddle(string riddle)
|
||||
{
|
||||
return RiddlerEnterAnswerFormat.Replace("%RIDDLE%", riddle);
|
||||
}
|
||||
public static string FormatRiddlerAnswerCorrect(string reason)
|
||||
{
|
||||
return RiddlerCorrectAnswerFormat.Replace("%REASON%", reason);
|
||||
}
|
||||
|
||||
public static string FormatPirateTreasure(int prize)
|
||||
{
|
||||
return PirateTreasureFormat.Replace("%PRIZE%", prize.ToString("N0"));
|
||||
|
|
|
@ -121,10 +121,10 @@ namespace HISP.Game
|
|||
message += "^R1" + Messages.ThingsYouSellMe;
|
||||
InventoryItem[] shopperItemList = shopperInventory.GetItemList();
|
||||
|
||||
foreach(InventoryItem shopperitem in shopperItemList)
|
||||
foreach (InventoryItem shopperitem in shopperItemList)
|
||||
{
|
||||
Item.ItemInformation itemInfo = Item.GetItemById(shopperitem.ItemId);
|
||||
|
||||
|
||||
// Prevent items that cannot be sold to this shopkeeper.
|
||||
if (!shop.CanSell(itemInfo))
|
||||
continue;
|
||||
|
@ -150,7 +150,7 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
bool hasCoins = user.Inventory.HasItemId(Item.WishingCoin);
|
||||
if(!hasCoins)
|
||||
if (!hasCoins)
|
||||
{
|
||||
message += Messages.NoWishingCoins;
|
||||
}
|
||||
|
@ -181,12 +181,12 @@ namespace HISP.Game
|
|||
else
|
||||
{
|
||||
message += Messages.ItemsOnGroundMessage;
|
||||
foreach(DroppedItems.DroppedItem item in Items)
|
||||
foreach (DroppedItems.DroppedItem item in Items)
|
||||
{
|
||||
Item.ItemInformation itemInfo = item.Instance.GetItemInfo();
|
||||
message += Messages.FormatGrabItemMessage(itemInfo.Name, item.Instance.RandomId, itemInfo.IconId);
|
||||
}
|
||||
if(Items.Length > 1)
|
||||
if (Items.Length > 1)
|
||||
message += Messages.GrabAllItemsButton;
|
||||
}
|
||||
return message;
|
||||
|
@ -212,23 +212,23 @@ namespace HISP.Game
|
|||
|
||||
private static string buildMultiroom(string id, User user)
|
||||
{
|
||||
string message = Messages.MultiroomPlayersParticipating;
|
||||
foreach(User userOnTile in GameServer.GetUsersOnSpecialTileCode("MULTIROOM-"+id))
|
||||
string message = Messages.MultiroomPlayersParticipating;
|
||||
foreach (User userOnTile in GameServer.GetUsersOnSpecialTileCode("MULTIROOM-" + id))
|
||||
{
|
||||
if (userOnTile.Id == user.Id)
|
||||
continue;
|
||||
message += Messages.FormatMultiroomParticipent(userOnTile.Username);
|
||||
}
|
||||
if(id[0] == 'P') // Poet
|
||||
if (id[0] == 'P') // Poet
|
||||
{
|
||||
int lastPoet = Database.GetLastPlayer(id);
|
||||
string username = "";
|
||||
if(lastPoet != -1)
|
||||
if (lastPoet != -1)
|
||||
username = Database.GetUsername(lastPoet);
|
||||
|
||||
message += Messages.FormatLastPoet(username);
|
||||
}
|
||||
if(id[0] == 'D') // Drawning room
|
||||
if (id[0] == 'D') // Drawning room
|
||||
{
|
||||
int lastDraw = Database.GetLastPlayer(id);
|
||||
string username = "";
|
||||
|
@ -300,7 +300,7 @@ namespace HISP.Game
|
|||
public static string buildInn(Inn inn)
|
||||
{
|
||||
string message = Messages.InnBuyMeal;
|
||||
foreach(Item.ItemInformation item in inn.MealsOffered)
|
||||
foreach (Item.ItemInformation item in inn.MealsOffered)
|
||||
{
|
||||
message += Messages.FormatInnItemEntry(item.IconId, item.Name, inn.CalculateBuyCost(item), item.Id);
|
||||
}
|
||||
|
@ -340,16 +340,16 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
|
||||
foreach(Tack.TackSet set in Tack.TackSets.OrderBy(o => o.SortPosition()).ToArray())
|
||||
foreach (Tack.TackSet set in Tack.TackSets.OrderBy(o => o.SortPosition()).ToArray())
|
||||
{
|
||||
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];
|
||||
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);
|
||||
|
@ -361,7 +361,7 @@ namespace HISP.Game
|
|||
message += buildTackPeiceLibary(set.GetSaddlePad());
|
||||
message += buildTackPeiceLibary(set.GetBridle());
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorPrint(e.Message);
|
||||
}
|
||||
|
@ -374,36 +374,36 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
message += Messages.MinigameSingleplayer;
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
foreach (World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
{
|
||||
if(tile.TypeFlag == "1PLAYER")
|
||||
if (tile.TypeFlag == "1PLAYER")
|
||||
{
|
||||
string mapXy = Messages.FormatMapLocation(tile.X, tile.Y);
|
||||
message += Messages.FormatMinigameEntry(tile.Title, mapXy);
|
||||
}
|
||||
}
|
||||
message += Messages.MinigameTwoplayer;
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
foreach (World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
{
|
||||
if(tile.TypeFlag == "2PLAYER")
|
||||
if (tile.TypeFlag == "2PLAYER")
|
||||
{
|
||||
string mapXy = Messages.FormatMapLocation(tile.X, tile.Y);
|
||||
message += Messages.FormatMinigameEntry(tile.Title, mapXy);
|
||||
}
|
||||
}
|
||||
message += Messages.MinigameMultiplayer;
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
foreach (World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
{
|
||||
if(tile.TypeFlag == "MULTIPLAYER")
|
||||
if (tile.TypeFlag == "MULTIPLAYER")
|
||||
{
|
||||
string mapXy = Messages.FormatMapLocation(tile.X, tile.Y);
|
||||
message += Messages.FormatMinigameEntry(tile.Title, mapXy);
|
||||
}
|
||||
}
|
||||
message += Messages.MinigameCompetitions;
|
||||
foreach(World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
foreach (World.SpecialTile tile in World.SpecialTiles.OrderBy(o => o.Title))
|
||||
{
|
||||
if(tile.TypeFlag == "ARENA")
|
||||
if (tile.TypeFlag == "ARENA")
|
||||
{
|
||||
string mapXy = Messages.FormatMapLocation(tile.X, tile.Y);
|
||||
message += Messages.FormatMinigameEntry(tile.Title, mapXy);
|
||||
|
@ -416,11 +416,11 @@ namespace HISP.Game
|
|||
public static string BuildCompanionLibary()
|
||||
{
|
||||
string message = "";
|
||||
foreach(Item.ItemInformation itm in Item.Items.OrderBy(o => o.GetMiscFlag(0)).ToArray())
|
||||
foreach (Item.ItemInformation itm in Item.Items.OrderBy(o => o.GetMiscFlag(0)).ToArray())
|
||||
{
|
||||
if(itm.Type == "COMPANION" && itm.EmbedSwf != null)
|
||||
if (itm.Type == "COMPANION" && itm.EmbedSwf != null)
|
||||
{
|
||||
string swf = "breedviewer.swf?terrain=book2&breed=tackonly&companion="+itm.EmbedSwf+"&j=";
|
||||
string swf = "breedviewer.swf?terrain=book2&breed=tackonly&companion=" + itm.EmbedSwf + "&j=";
|
||||
message += Messages.FormatCompanionViewButton(itm.IconId, itm.Name, swf);
|
||||
message += Messages.FormatCompanionEntry(itm.Description);
|
||||
}
|
||||
|
@ -433,9 +433,9 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
message += Messages.LocationKnownIslands;
|
||||
foreach(World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
|
||||
foreach (World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
|
||||
{
|
||||
if(waypoint.Type == "ISLE")
|
||||
if (waypoint.Type == "ISLE")
|
||||
{
|
||||
string mapxy = Messages.FormatMapLocation(waypoint.PosX, waypoint.PosY);
|
||||
message += Messages.FormatIslandLocation(waypoint.Name, mapxy);
|
||||
|
@ -443,9 +443,9 @@ namespace HISP.Game
|
|||
}
|
||||
}
|
||||
message += Messages.LocationKnownTowns;
|
||||
foreach(World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
|
||||
foreach (World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
|
||||
{
|
||||
if(waypoint.Type == "TOWN")
|
||||
if (waypoint.Type == "TOWN")
|
||||
{
|
||||
string mapxy = Messages.FormatMapLocation(waypoint.PosX, waypoint.PosY);
|
||||
message += Messages.FormatTownLocation(waypoint.Name, mapxy);
|
||||
|
@ -460,7 +460,7 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
message += Messages.AwardsAvalible;
|
||||
foreach(Award.AwardEntry award in Award.GlobalAwardList.OrderBy(o => o.Sort).ToArray())
|
||||
foreach (Award.AwardEntry award in Award.GlobalAwardList.OrderBy(o => o.Sort).ToArray())
|
||||
{
|
||||
message += Messages.FormatAwardEntry(award.IconId, award.Title, award.MoneyBonus, award.Description);
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
message += Messages.BooksOfHorseIsle;
|
||||
foreach(Book libaryBook in Book.LibaryBooks.OrderBy(o => o.Title).ToArray())
|
||||
foreach (Book libaryBook in Book.LibaryBooks.OrderBy(o => o.Title).ToArray())
|
||||
{
|
||||
message += Messages.FormatBookEntry(libaryBook.Title, libaryBook.Author, libaryBook.Id);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ namespace HISP.Game
|
|||
|
||||
for (int i = 0; i < scores.Length; i++)
|
||||
{
|
||||
message += Messages.FormatHighscoreListEntry(i+1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
message += Messages.FormatHighscoreListEntry(i + 1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
@ -522,12 +522,12 @@ namespace HISP.Game
|
|||
if (scores.Length <= 0)
|
||||
return "No times recorded.";
|
||||
string message = "";
|
||||
|
||||
|
||||
message += Messages.FormatBestTimeHeader(gameName);
|
||||
|
||||
for (int i = 0; i < scores.Length; i++)
|
||||
{
|
||||
message += Messages.FormatBestTimeListEntry(i+1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
message += Messages.FormatBestTimeListEntry(i + 1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
@ -536,11 +536,11 @@ namespace HISP.Game
|
|||
public static string BuildMinigameRankingsForUser(User user)
|
||||
{
|
||||
string message = Messages.HighscoreHeaderMeta;
|
||||
foreach(Highscore.HighscoreTableEntry highscore in user.Highscores.HighscoreList)
|
||||
foreach (Highscore.HighscoreTableEntry highscore in user.Highscores.HighscoreList)
|
||||
{
|
||||
if (highscore.Type == "SCORE")
|
||||
message += Messages.FormatHighscoreStat(highscore.GameName, Database.GetRanking(highscore.Score, highscore.GameName), highscore.Score, highscore.TimesPlayed);
|
||||
else if(highscore.Type == "TIME")
|
||||
else if (highscore.Type == "TIME")
|
||||
message += Messages.FormatBestTimeStat(highscore.GameName, Database.GetRanking(highscore.Score, highscore.GameName), highscore.Score, highscore.TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
|
@ -594,7 +594,7 @@ namespace HISP.Game
|
|||
if (areaString != "")
|
||||
message += Messages.FormatStatsArea(areaString);
|
||||
message += Messages.FormatMoneyStat(user.Money);
|
||||
if(!user.Subscribed)
|
||||
if (!user.Subscribed)
|
||||
message += Messages.FormatFreeTime(user.FreeMinutes);
|
||||
message += Messages.FormatPlayerDescriptionForStatsMenu(user.ProfilePage);
|
||||
message += Messages.FormatExperience(user.Experience);
|
||||
|
@ -620,10 +620,10 @@ namespace HISP.Game
|
|||
{
|
||||
string message = "";
|
||||
WildHorse[] horses = WildHorse.GetHorsesAt(user.X, user.Y);
|
||||
if(horses.Length > 0)
|
||||
if (horses.Length > 0)
|
||||
{
|
||||
message = Messages.HorsesHere;
|
||||
foreach(WildHorse horse in horses)
|
||||
foreach (WildHorse horse in horses)
|
||||
{
|
||||
message += Messages.FormatWildHorse(horse.Instance.Name, horse.Instance.Breed.Name, horse.Instance.RandomId);
|
||||
}
|
||||
|
@ -636,10 +636,10 @@ namespace HISP.Game
|
|||
if (user.Awards.AwardsEarned.Length <= 0)
|
||||
message += Messages.NoAwards;
|
||||
else
|
||||
foreach(Award.AwardEntry award in user.Awards.AwardsEarned)
|
||||
foreach (Award.AwardEntry award in user.Awards.AwardsEarned)
|
||||
message += Messages.FormatAwardEntry(award.IconId, award.Title, award.MoneyBonus);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
message += Messages.BackToMap;
|
||||
|
@ -659,7 +659,7 @@ namespace HISP.Game
|
|||
else
|
||||
fmsg = Messages.QuestNotCompleted;
|
||||
|
||||
foreach(int questId in quest.RequiresQuestIdCompleteStatsMenu)
|
||||
foreach (int questId in quest.RequiresQuestIdCompleteStatsMenu)
|
||||
{
|
||||
if (user.Quests.GetTrackedQuestAmount(questId) > 0)
|
||||
continue;
|
||||
|
@ -750,9 +750,9 @@ namespace HISP.Game
|
|||
{
|
||||
string message = Messages.PlayerListAllHeader;
|
||||
GameClient[] clients = GameServer.ConnectedClients;
|
||||
foreach(GameClient client in clients)
|
||||
foreach (GameClient client in clients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Stealth)
|
||||
continue;
|
||||
|
@ -776,7 +776,7 @@ namespace HISP.Game
|
|||
public static string BuildBuddyList(User user)
|
||||
{
|
||||
string message = Messages.BuddyListHeader;
|
||||
foreach(int id in user.Friends.List.ToArray())
|
||||
foreach (int id in user.Friends.List.ToArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -797,7 +797,7 @@ namespace HISP.Game
|
|||
}
|
||||
message += Messages.BuddyListOfflineBuddys;
|
||||
|
||||
foreach(int id in user.Friends.List.ToArray())
|
||||
foreach (int id in user.Friends.List.ToArray())
|
||||
{
|
||||
if (GameServer.IsUserOnline(id))
|
||||
continue;
|
||||
|
@ -831,11 +831,11 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public static string BuildHorseList()
|
||||
{
|
||||
string message = "";
|
||||
foreach(HorseInfo.Breed breed in HorseInfo.Breeds.OrderBy(o => o.Name).ToList())
|
||||
foreach (HorseInfo.Breed breed in HorseInfo.Breeds.OrderBy(o => o.Name).ToList())
|
||||
{
|
||||
if (breed.Swf == "")
|
||||
continue;
|
||||
|
@ -851,11 +851,11 @@ namespace HISP.Game
|
|||
public static string BuildNpcSearch(string search)
|
||||
{
|
||||
List<Npc.NpcEntry> foundNpcs = new List<Npc.NpcEntry>();
|
||||
foreach(Npc.NpcEntry npc in Npc.NpcList)
|
||||
foreach (Npc.NpcEntry npc in Npc.NpcList)
|
||||
{
|
||||
if(npc.Name.ToLower().Contains(search.ToLower()))
|
||||
if (npc.Name.ToLower().Contains(search.ToLower()))
|
||||
{
|
||||
if(npc.LibarySearchable)
|
||||
if (npc.LibarySearchable)
|
||||
{
|
||||
if (foundNpcs.Count >= 5)
|
||||
break;
|
||||
|
@ -872,17 +872,17 @@ namespace HISP.Game
|
|||
}
|
||||
}
|
||||
string message = Messages.LibaryFindNpcSearchNoResults;
|
||||
if(foundNpcs.Count >= 1)
|
||||
if (foundNpcs.Count >= 1)
|
||||
{
|
||||
message = Messages.LibaryFindNpcSearchResultsHeader;
|
||||
foreach(Npc.NpcEntry npc in foundNpcs)
|
||||
foreach (Npc.NpcEntry npc in foundNpcs)
|
||||
{
|
||||
string searchResult = Messages.FormatNpcSearchResult(npc.Name, npc.ShortDescription, npc.X, npc.Y);
|
||||
Logger.DebugPrint(searchResult);
|
||||
message += searchResult;
|
||||
}
|
||||
}
|
||||
if(foundNpcs.Count >= 5)
|
||||
if (foundNpcs.Count >= 5)
|
||||
{
|
||||
message += Messages.LibaryFindNpcLimit5;
|
||||
}
|
||||
|
@ -903,14 +903,14 @@ namespace HISP.Game
|
|||
public static string BuildWhisperSearchResults(WildHorse[] results)
|
||||
{
|
||||
string message = Messages.WhispererSearchingAmoungHorses;
|
||||
if(results.Length <= 0)
|
||||
if (results.Length <= 0)
|
||||
{
|
||||
message = Messages.WhispererNoneFound;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Point> locations = new List<Point>();
|
||||
foreach(WildHorse result in results)
|
||||
foreach (WildHorse result in results)
|
||||
{
|
||||
Point location = new Point();
|
||||
location.X = result.X;
|
||||
|
@ -932,11 +932,11 @@ namespace HISP.Game
|
|||
private static string buildPond(User user)
|
||||
{
|
||||
string message = Messages.PondHeader;
|
||||
if(!user.Inventory.HasItemId(Item.FishingPole))
|
||||
if (!user.Inventory.HasItemId(Item.FishingPole))
|
||||
{
|
||||
message += Messages.PondNoFishingPole;
|
||||
}
|
||||
else if(!user.Inventory.HasItemId(Item.Earthworm))
|
||||
else if (!user.Inventory.HasItemId(Item.Earthworm))
|
||||
{
|
||||
message += Messages.PondNoEarthWorms;
|
||||
}
|
||||
|
@ -945,7 +945,7 @@ namespace HISP.Game
|
|||
message += Messages.PondGoFishing;
|
||||
}
|
||||
message += Messages.PondDrinkHereIfSafe;
|
||||
foreach(HorseInstance horse in user.HorseInventory.HorseList)
|
||||
foreach (HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
message += Messages.FormatPondDrinkHorseFormat(horse.Name, horse.BasicStats.Thirst, 1000, horse.RandomId);
|
||||
}
|
||||
|
@ -956,7 +956,7 @@ namespace HISP.Game
|
|||
private static string buildMudHole(User user)
|
||||
{
|
||||
string message = "";
|
||||
if(user.HorseInventory.HorseList.Length > 0)
|
||||
if (user.HorseInventory.HorseList.Length > 0)
|
||||
{
|
||||
int rngHorseIndex = GameServer.RandomNumberGenerator.Next(0, user.HorseInventory.HorseList.Length);
|
||||
HorseInstance horse = user.HorseInventory.HorseList[rngHorseIndex];
|
||||
|
@ -979,11 +979,11 @@ namespace HISP.Game
|
|||
private static string buildHorseWhisperer()
|
||||
{
|
||||
string message = "";
|
||||
foreach(HorseInfo.Breed breed in HorseInfo.Breeds.OrderBy(o => o.Name).ToList())
|
||||
foreach (HorseInfo.Breed breed in HorseInfo.Breeds.OrderBy(o => o.Name).ToList())
|
||||
{
|
||||
if (breed.Swf == "")
|
||||
continue;
|
||||
if(breed.SpawnInArea == "none")
|
||||
if (breed.SpawnInArea == "none")
|
||||
continue;
|
||||
message += Messages.FormatWhispererHorseBreedButton(breed.Name, breed.Id);
|
||||
}
|
||||
|
@ -1022,13 +1022,13 @@ namespace HISP.Game
|
|||
{
|
||||
Workshop shop = Workshop.GetWorkshopAt(user.X, user.Y);
|
||||
string message = "";
|
||||
foreach(Workshop.CraftableItem craft in shop.CraftableItems)
|
||||
foreach (Workshop.CraftableItem craft in shop.CraftableItems)
|
||||
{
|
||||
Item.ItemInformation itmInfo = Item.GetItemById(craft.GiveItemId);
|
||||
message += Messages.FormatWorkshopCraftEntry(itmInfo.IconId, itmInfo.Name, craft.MoneyCost, itmInfo.Id, craft.Id);
|
||||
// Get requirements
|
||||
List<string> Requirements = new List<string>();
|
||||
foreach(Workshop.RequiredItem reqItem in craft.RequiredItems)
|
||||
foreach (Workshop.RequiredItem reqItem in craft.RequiredItems)
|
||||
{
|
||||
|
||||
Item.ItemInformation requiredItemInfo = Item.GetItemById(reqItem.RequiredItemId);
|
||||
|
@ -1052,7 +1052,7 @@ namespace HISP.Game
|
|||
foreach (HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
message += Messages.FormatVetServiceHorseMeta(horse.Name, horse.BasicStats.Health, 1000);
|
||||
|
||||
|
||||
if (horse.BasicStats.Health >= 1000)
|
||||
message += Messages.VetSerivcesNotNeeded;
|
||||
else
|
||||
|
@ -1062,13 +1062,23 @@ namespace HISP.Game
|
|||
|
||||
message += Messages.FormatVetApplyServiceMeta(price, horse.RandomId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
message += Messages.FormatVetApplyAllServiceMeta(totalPrice);
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildRiddlerRiddle(User user)
|
||||
{
|
||||
Riddler riddle = Riddler.GetRandomRiddle(user);
|
||||
user.LastRiddle = riddle;
|
||||
string message = "";
|
||||
message += Messages.FormatRiddlerRiddle(riddle.Riddle);
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile)
|
||||
{
|
||||
|
@ -1146,6 +1156,10 @@ namespace HISP.Game
|
|||
{
|
||||
message += buildVenusFlyTrap(user);
|
||||
}
|
||||
if(TileCode == "RIDDLER")
|
||||
{
|
||||
message += buildRiddlerRiddle(user);
|
||||
}
|
||||
if(TileCode == "LIBRARY")
|
||||
{
|
||||
message += buildLibary();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -17,6 +14,25 @@ namespace HISP.Game
|
|||
public string Title;
|
||||
public string Description;
|
||||
public int Limit;
|
||||
|
||||
public static bool RanchBuildingExists(int id)
|
||||
{
|
||||
foreach (RanchBuilding ranchBuilding in RanchBuildings)
|
||||
{
|
||||
if (ranchBuilding.Id == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static RanchBuilding GetRanchBuildingById(int id)
|
||||
{
|
||||
foreach(RanchBuilding ranchBuilding in RanchBuildings)
|
||||
{
|
||||
if (ranchBuilding.Id == id)
|
||||
return ranchBuilding;
|
||||
}
|
||||
throw new KeyNotFoundException("No ranch found.");
|
||||
}
|
||||
}
|
||||
public static List<Ranch> Ranches = new List<Ranch>();
|
||||
|
||||
|
@ -25,21 +41,250 @@ namespace HISP.Game
|
|||
public int Id;
|
||||
public int Value;
|
||||
|
||||
public int OwnerId;
|
||||
public int UpgradedLevel;
|
||||
public int InvestedMoney;
|
||||
public string Title;
|
||||
public string Description;
|
||||
private int ownerId;
|
||||
private int upgradedLevel;
|
||||
private int investedMoney;
|
||||
private string title;
|
||||
private string description;
|
||||
|
||||
public int OwnerId
|
||||
{
|
||||
get
|
||||
{
|
||||
return ownerId;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
ownerId = value;
|
||||
|
||||
if (value == -1)
|
||||
{
|
||||
Database.DeleteRanchOwner(this.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Database.IsRanchOwned(this.Id))
|
||||
{
|
||||
Database.SetRanchOwner(this.Id, ownerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
title = "";
|
||||
description = "";
|
||||
investedMoney = 0;
|
||||
upgradedLevel = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
buildings[i] = null;
|
||||
|
||||
Database.AddRanch(this.Id, OwnerId, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int UpgradedLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
return upgradedLevel;
|
||||
}
|
||||
set
|
||||
{
|
||||
upgradedLevel = value;
|
||||
Database.SetRanchUpgradeLevel(Id, value);
|
||||
}
|
||||
}
|
||||
public int InvestedMoney
|
||||
{
|
||||
get
|
||||
{
|
||||
return investedMoney;
|
||||
}
|
||||
set
|
||||
{
|
||||
investedMoney = 0;
|
||||
Database.SetRanchUpgradeLevel(Id, value);
|
||||
}
|
||||
}
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
Database.SetRanchTitle(Id, value);
|
||||
}
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return description;
|
||||
}
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
Database.SetRanchDescription(Id, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private RanchBuilding[] buildings = new RanchBuilding[16];
|
||||
|
||||
public RanchBuilding[] Buildings
|
||||
{
|
||||
get
|
||||
{
|
||||
return buildings;
|
||||
}
|
||||
set
|
||||
{
|
||||
buildings = value;
|
||||
if (buildings[0] != null)
|
||||
Database.SetRanchBuilding1(this.Id, buildings[0].Id);
|
||||
else
|
||||
Database.SetRanchBuilding1(this.Id, 0);
|
||||
if (buildings[1] != null)
|
||||
Database.SetRanchBuilding2(this.Id, buildings[1].Id);
|
||||
else
|
||||
Database.SetRanchBuilding2(this.Id, 0);
|
||||
if (buildings[2] != null)
|
||||
Database.SetRanchBuilding3(this.Id, buildings[2].Id);
|
||||
else
|
||||
Database.SetRanchBuilding3(this.Id, 0);
|
||||
if (buildings[3] != null)
|
||||
Database.SetRanchBuilding4(this.Id, buildings[3].Id);
|
||||
else
|
||||
Database.SetRanchBuilding4(this.Id, 0);
|
||||
if (buildings[4] != null)
|
||||
Database.SetRanchBuilding5(this.Id, buildings[4].Id);
|
||||
else
|
||||
Database.SetRanchBuilding5(this.Id, 0);
|
||||
if (buildings[5] != null)
|
||||
Database.SetRanchBuilding6(this.Id, buildings[5].Id);
|
||||
else
|
||||
Database.SetRanchBuilding6(this.Id, 0);
|
||||
if (buildings[6] != null)
|
||||
Database.SetRanchBuilding7(this.Id, buildings[6].Id);
|
||||
else
|
||||
Database.SetRanchBuilding7(this.Id, 0);
|
||||
if (buildings[7] != null)
|
||||
Database.SetRanchBuilding8(this.Id, buildings[7].Id);
|
||||
else
|
||||
Database.SetRanchBuilding8(this.Id, 0);
|
||||
if (buildings[8] != null)
|
||||
Database.SetRanchBuilding9(this.Id, buildings[8].Id);
|
||||
else
|
||||
Database.SetRanchBuilding9(this.Id, 0);
|
||||
if (buildings[9] != null)
|
||||
Database.SetRanchBuilding10(this.Id, buildings[9].Id);
|
||||
else
|
||||
Database.SetRanchBuilding10(this.Id, 0);
|
||||
if (buildings[10] != null)
|
||||
Database.SetRanchBuilding11(this.Id, buildings[10].Id);
|
||||
else
|
||||
Database.SetRanchBuilding11(this.Id, 0);
|
||||
if (buildings[11] != null)
|
||||
Database.SetRanchBuilding12(this.Id, buildings[11].Id);
|
||||
else
|
||||
Database.SetRanchBuilding12(this.Id, 0);
|
||||
if (buildings[12] != null)
|
||||
Database.SetRanchBuilding13(this.Id, buildings[12].Id);
|
||||
else
|
||||
Database.SetRanchBuilding13(this.Id, 0);
|
||||
if (buildings[13] != null)
|
||||
Database.SetRanchBuilding14(this.Id, buildings[13].Id);
|
||||
else
|
||||
Database.SetRanchBuilding14(this.Id, 0);
|
||||
if (buildings[14] != null)
|
||||
Database.SetRanchBuilding15(this.Id, buildings[14].Id);
|
||||
else
|
||||
Database.SetRanchBuilding15(this.Id, 0);
|
||||
if (buildings[15] != null)
|
||||
Database.SetRanchBuilding16(this.Id, buildings[15].Id);
|
||||
else
|
||||
Database.SetRanchBuilding16(this.Id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RanchBuilding[] Buildings = new RanchBuilding[16];
|
||||
public Ranch(int x, int y, int id, int value)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Id = id;
|
||||
Value = value;
|
||||
Title = "";
|
||||
Description = "";
|
||||
UpgradedLevel = 0;
|
||||
OwnerId = -1;
|
||||
InvestedMoney = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
buildings[i] = null;
|
||||
|
||||
if (Database.IsRanchOwned(id))
|
||||
{
|
||||
UpgradedLevel = Database.GetRanchUpgradeLevel(id);
|
||||
Title = Database.GetRanchTitle(id);
|
||||
Description = Database.GetRanchDescription(id);
|
||||
OwnerId = Database.GetRanchOwner(id);
|
||||
int b1 = Database.GetRanchBuilding1(id);
|
||||
int b2 = Database.GetRanchBuilding2(id);
|
||||
int b3 = Database.GetRanchBuilding3(id);
|
||||
int b4 = Database.GetRanchBuilding4(id);
|
||||
int b5 = Database.GetRanchBuilding5(id);
|
||||
int b6 = Database.GetRanchBuilding6(id);
|
||||
int b7 = Database.GetRanchBuilding7(id);
|
||||
int b8 = Database.GetRanchBuilding8(id);
|
||||
int b9 = Database.GetRanchBuilding9(id);
|
||||
int b10 = Database.GetRanchBuilding10(id);
|
||||
int b11 = Database.GetRanchBuilding11(id);
|
||||
int b12 = Database.GetRanchBuilding12(id);
|
||||
int b13 = Database.GetRanchBuilding13(id);
|
||||
int b14 = Database.GetRanchBuilding14(id);
|
||||
int b15 = Database.GetRanchBuilding15(id);
|
||||
int b16 = Database.GetRanchBuilding16(id);
|
||||
|
||||
if (RanchBuilding.RanchBuildingExists(b1))
|
||||
buildings[0] = RanchBuilding.GetRanchBuildingById(b1);
|
||||
if (RanchBuilding.RanchBuildingExists(b2))
|
||||
buildings[1] = RanchBuilding.GetRanchBuildingById(b2);
|
||||
if (RanchBuilding.RanchBuildingExists(b3))
|
||||
buildings[2] = RanchBuilding.GetRanchBuildingById(b3);
|
||||
if (RanchBuilding.RanchBuildingExists(b4))
|
||||
buildings[3] = RanchBuilding.GetRanchBuildingById(b4);
|
||||
if (RanchBuilding.RanchBuildingExists(b5))
|
||||
buildings[4] = RanchBuilding.GetRanchBuildingById(b5);
|
||||
if (RanchBuilding.RanchBuildingExists(b6))
|
||||
buildings[5] = RanchBuilding.GetRanchBuildingById(b6);
|
||||
if (RanchBuilding.RanchBuildingExists(b7))
|
||||
buildings[6] = RanchBuilding.GetRanchBuildingById(b7);
|
||||
if (RanchBuilding.RanchBuildingExists(b8))
|
||||
buildings[7] = RanchBuilding.GetRanchBuildingById(b8);
|
||||
if (RanchBuilding.RanchBuildingExists(b9))
|
||||
buildings[8] = RanchBuilding.GetRanchBuildingById(b9);
|
||||
if (RanchBuilding.RanchBuildingExists(b10))
|
||||
buildings[9] = RanchBuilding.GetRanchBuildingById(b10);
|
||||
if (RanchBuilding.RanchBuildingExists(b11))
|
||||
buildings[10] = RanchBuilding.GetRanchBuildingById(b11);
|
||||
if (RanchBuilding.RanchBuildingExists(b12))
|
||||
buildings[11] = RanchBuilding.GetRanchBuildingById(b12);
|
||||
if (RanchBuilding.RanchBuildingExists(b13))
|
||||
buildings[12] = RanchBuilding.GetRanchBuildingById(b13);
|
||||
if (RanchBuilding.RanchBuildingExists(b14))
|
||||
buildings[13] = RanchBuilding.GetRanchBuildingById(b14);
|
||||
if (RanchBuilding.RanchBuildingExists(b15))
|
||||
buildings[14] = RanchBuilding.GetRanchBuildingById(b15);
|
||||
if (RanchBuilding.RanchBuildingExists(b16))
|
||||
buildings[15] = RanchBuilding.GetRanchBuildingById(b16);
|
||||
|
||||
|
||||
InvestedMoney = Database.GetRanchInvestment(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsRanchHere(int x, int y)
|
||||
|
@ -60,5 +305,28 @@ namespace HISP.Game
|
|||
}
|
||||
throw new KeyNotFoundException("No Ranch found at x" + x + " y" + y);
|
||||
}
|
||||
|
||||
public static bool IsRanchOwned(int playerId)
|
||||
{
|
||||
foreach (Ranch ranch in Ranches)
|
||||
{
|
||||
if (ranch.OwnerId == playerId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static Ranch GetRanchOwnedBy(int playerId)
|
||||
{
|
||||
foreach(Ranch ranch in Ranches)
|
||||
{
|
||||
if(ranch.OwnerId == playerId)
|
||||
{
|
||||
return ranch;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Player " + playerId + " does not own a ranch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
81
Horse Isle Server/HorseIsleServer/Game/Riddler.cs
Normal file
81
Horse Isle Server/HorseIsleServer/Game/Riddler.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
public class Riddler
|
||||
{
|
||||
private static List<Riddler> riddlerRiddles = new List<Riddler>();
|
||||
public static Riddler[] Riddles
|
||||
{
|
||||
get
|
||||
{
|
||||
return riddlerRiddles.ToArray();
|
||||
}
|
||||
}
|
||||
public Riddler(int id, string riddle, string[] answers, string reason)
|
||||
{
|
||||
Id = id;
|
||||
Riddle = riddle;
|
||||
Answers = answers;
|
||||
Reason = reason;
|
||||
riddlerRiddles.Add(this);
|
||||
}
|
||||
public int Id;
|
||||
public string Riddle;
|
||||
public string[] Answers;
|
||||
public string Reason;
|
||||
public void AnswerSuccess(User user)
|
||||
{
|
||||
if (!Database.HasPlayerCompletedRiddle(this.Id, user.Id))
|
||||
Database.CompleteRiddle(this.Id, user.Id);
|
||||
|
||||
byte[] riddleAnswerCorrectPacket = PacketBuilder.CreateChat(Messages.FormatRiddlerAnswerCorrect(this.Reason), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(riddleAnswerCorrectPacket);
|
||||
user.Money += 10000;
|
||||
|
||||
if(Database.TotalRiddlesCompletedByPlayer(user.Id) >= riddlerRiddles.Count)
|
||||
user.Awards.AddAward(Award.GetAwardById(11)); // Riddlers Riddles
|
||||
}
|
||||
|
||||
public void AnswerFail(User user)
|
||||
{
|
||||
byte[] riddleIncorrect = PacketBuilder.CreateChat(Messages.RiddlerIncorrectAnswer, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
user.LoggedinClient.SendPacket(riddleIncorrect);
|
||||
}
|
||||
|
||||
public bool CheckAnswer(User user, string txt)
|
||||
{
|
||||
foreach(string Answer in Answers)
|
||||
{
|
||||
if(Answer.ToLower() == txt.ToLower())
|
||||
{
|
||||
AnswerSuccess(user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
AnswerFail(user);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasCompletedAllRiddles(User user)
|
||||
{
|
||||
if (Database.TotalRiddlesCompletedByPlayer(user.Id) > Riddles.Length)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Riddler GetRandomRiddle(User user)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
|
||||
int rng = GameServer.RandomNumberGenerator.Next(0, Riddles.Length);
|
||||
if (Database.HasPlayerCompletedRiddle(rng, user.Id))
|
||||
continue;
|
||||
return Riddles[rng];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue