Implement riddle rooms

This commit is contained in:
SilicaAndPina 2021-02-08 19:59:30 +13:00
parent 64671ef186
commit 10c1c32518
11 changed files with 1276 additions and 91 deletions

View file

@ -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.

View file

@ -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"));

View file

@ -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();

View file

@ -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.");
}
}
}

View 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];
}
}
}
}

View file

@ -48,8 +48,10 @@ namespace HISP.Player
public HorseInstance LastViewedHorse;
public HorseInstance CurrentlyRidingHorse;
public Tracking TrackedItems;
public Ranch OwnedRanch = null;
public PlayerQuests Quests;
public Highscore Highscores;
public Riddler LastRiddle;
public Award Awards;
public int CapturingHorseId;
public DateTime LoginTime;
@ -443,6 +445,19 @@ namespace HISP.Player
thirst = Database.GetPlayerThirst(UserId);
tired = Database.GetPlayerTiredness(UserId);
if(Ranch.IsRanchOwned(this.Id))
{
if (this.Subscribed)
{
OwnedRanch = Ranch.GetRanchOwnedBy(this.Id);
}
else // idk what it does here ...
{
OwnedRanch = null;
Ranch.GetRanchOwnedBy(this.Id).OwnerId = -1;
}
}
Gender = Database.GetGender(UserId);
MailBox = new Mailbox(this);
Highscores = new Highscore(this);

View file

@ -46,8 +46,22 @@ namespace HISP.Server
string Treasure = "CREATE TABLE Treasure(randomId INT, x INT, y INT, value INT, type TEXT(128))";
string Ranches = "CREATE TABLE Ranches(ranchId INT, playerId INT, title TEXT(1028), description TEXT(1028), upgradeLevel INT, building1 INT, building2 INT, building3 INT, building4 INT, building5 INT, building6 INT, building7 INT, building8 INT, building9 INT, building10 INT, building11 INT, building12 INT, building13 INT, building14 INT, building15 INT, building16 INT, investedMoney INT)";
string BannedPlayers = "CREATE TABLE BannedPlayers(playerId INT, ipAddress TEXT(1028), reason TEXT(1028))";
string RiddlesComplete = "CREATE TABLE RiddlesComplete(playerId INT, riddleId INT, solved TEXT(1028))";
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
try
{
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = RiddlesComplete;
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
catch (Exception e)
{
Logger.WarnPrint(e.Message);
};
try
{
@ -426,6 +440,667 @@ namespace HISP.Server
}
public static void DeleteRanchOwner(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "DELETE FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static bool IsRanchOwned(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT COUNT(1) FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return count >= 1;
}
}
public static int GetRanchInvestment(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT investedMoney FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int invested = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return invested;
}
}
public static void SetRanchUpgradeLevel(int ranchId, int upgradeLevel)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET upgradeLevel=@upgradeLevel";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@upgradeLevel", upgradeLevel);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchInvestment(int ranchId, int investedMoney)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET investedMoney=@investedMoney";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@investedMoney", investedMoney);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchOwner(int ranchId, int ownerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET playerId=@ownerId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@ownerId", ownerId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchDescription(int ranchId, string description)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET description=@description";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@description", description);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchTitle(int ranchId, string title)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET title=@title";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@title", title);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding16(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building16=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding15(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building15=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding14(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building14=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding13(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building13=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding12(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building12=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding11(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building11=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding10(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building10=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding9(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building9=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding8(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building8=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding7(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building7=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding6(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building6=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding5(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building5=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding4(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building4=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding3(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building3=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding2(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building2=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void SetRanchBuilding1(int ranchId, int buildingId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "UPDATE Ranches SET building1=@buildingId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Parameters.AddWithValue("@buildingId", buildingId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static int GetRanchBuilding16(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building16 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding15(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building15 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding14(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building14 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding13(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building13 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding12(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building12 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding11(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building11 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding10(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building10 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding9(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building9 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding8(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building8 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding7(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building7 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding6(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building6 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding5(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building5 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding4(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building4 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding3(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building3 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding2(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building2 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchBuilding1(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT building1 FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int building = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return building;
}
}
public static int GetRanchUpgradeLevel(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT upgradeLevel FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int upgradeLevel = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return upgradeLevel;
}
}
public static string GetRanchDescription(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT description FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
string description = sqlCommand.ExecuteScalar().ToString();
sqlCommand.Dispose();
return description;
}
}
public static string GetRanchTitle(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT title FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
string title = sqlCommand.ExecuteScalar().ToString();
sqlCommand.Dispose();
return title;
}
}
public static int GetRanchOwner(int ranchId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT playerId FROM Ranches WHERE ranchId=@ranchId";
sqlCommand.Parameters.AddWithValue("@ranchId", ranchId);
sqlCommand.Prepare();
int playerId = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return playerId;
}
}
public static int TotalRiddlesCompletedByPlayer(int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT COUNT(*) FROM RiddlesComplete WHERE playerId=@playerId AND solved=\"YES\"";
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return count;
}
}
public static bool HasPlayerCompletedRiddle(int riddleId, int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT COUNT(*) FROM RiddlesComplete WHERE riddleId=@riddleId AND playerId=@playerId AND solved=\"YES\"";
sqlCommand.Parameters.AddWithValue("@riddleId", riddleId);
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
int count = Convert.ToInt32(sqlCommand.ExecuteScalar());
sqlCommand.Dispose();
return count >= 1;
}
}
public static void CompleteRiddle(int riddleId, int playerId)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))
{
db.Open();
MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "INSERT INTO RiddlesComplete VALUES(@riddleId, @playerId, \"YES\")";
sqlCommand.Parameters.AddWithValue("@riddleId", riddleId);
sqlCommand.Parameters.AddWithValue("@playerId", playerId);
sqlCommand.Prepare();
sqlCommand.ExecuteNonQuery();
sqlCommand.Dispose();
}
}
public static void AddRanch(int ranchId, int playerId, string title, string description, int upgradeLevel, int building1, int building2, int building3, int building4, int building5, int building6, int building7, int building8, int building9, int building10, int building11, int building12, int building13, int building14, int building15, int building16, int investedMoney)
{
using (MySqlConnection db = new MySqlConnection(ConnectionString))

View file

@ -609,6 +609,17 @@ namespace HISP.Server
Ranch.RanchBuilding.RanchBuildings.Add(building);
Logger.DebugPrint("Registered Ranch Building: "+building.Title);
}
int totalRiddles = gameData.riddle_room.Count;
for (int i = 0; i < totalRiddles; i++)
{
int id = gameData.riddle_room[i].id;
string riddle = gameData.riddle_room[i].riddle;
string[] answers = gameData.riddle_room[i].answers.ToObject<string[]>();
string reason = gameData.riddle_room[i].reason;
Riddler riddlerRiddle = new Riddler(id, riddle, answers, reason);
Logger.DebugPrint("Registered Riddler Riddle: " + riddlerRiddle.Riddle);
}
HorseInfo.HorseNames = gameData.horses.names.ToObject<string[]>();
@ -801,6 +812,12 @@ namespace HISP.Server
Messages.BankDepositedMoneyFormat = gameData.messages.bank.deposit_format;
Messages.BankWithdrewMoneyFormat = gameData.messages.bank.withdraw_format;
// Riddler
Messages.RiddlerAnsweredAll = gameData.messages.meta.riddler.riddle_all_complete;
Messages.RiddlerIncorrectAnswer = gameData.messages.meta.riddler.riddle_incorrect;
Messages.RiddlerCorrectAnswerFormat = gameData.messages.meta.riddler.riddle_correct;
Messages.RiddlerEnterAnswerFormat = gameData.messages.meta.riddler.riddle_format;
// Workshop
Messages.WorkshopCraftEntryFormat = gameData.messages.meta.workshop.craft_entry;
Messages.WorkshopRequiresFormat = gameData.messages.meta.workshop.requires;

View file

@ -1067,6 +1067,23 @@ namespace HISP.Server
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
break;
}
case 6: // Riddle Room
if (dynamicInput.Length >= 2)
{
if (sender.LoggedinUser.LastRiddle != null)
{
string answer = dynamicInput[1];
if(sender.LoggedinUser.LastRiddle.CheckAnswer(sender.LoggedinUser, answer))
sender.LoggedinUser.LastRiddle = null;
UpdateArea(sender);
}
break;
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (LastRiddle, wrong size)");
break;
}
case 5: // Horse Description
if (dynamicInput.Length >= 3)
{
@ -2498,7 +2515,7 @@ namespace HISP.Server
{
if(loggedInUser.CurrentlyRidingHorse.BasicStats.Experience < 25)
{
if(GameServer.RandomNumberGenerator.Next(0,10) == 7 || sender.LoggedinUser.Username.ToLower() == "dream")
if(GameServer.RandomNumberGenerator.Next(0,50) == 25 || sender.LoggedinUser.Username.ToLower() == "dream")
{
loggedInUser.CurrentlyRidingHorse.BasicStats.Experience++;
sender.LoggedinUser.CurrentlyRidingHorse = null;