Implement password tiles & venus fly trap in jungle isle.

This commit is contained in:
SilicaAndPina 2021-01-02 12:40:57 +13:00
parent b939c9e142
commit 4c7a9c8ed1
7 changed files with 181 additions and 89 deletions

View file

@ -1 +1,4 @@
bank total @ 1/01/2021 : 14,961 bank total @ 1/01/2021 : 14,961
bank total @ 1/01/2021 : 15,070
You made $108 in interest since your last visit.

View file

@ -127,6 +127,8 @@
"back_to_map":"^M", "back_to_map":"^M",
"long_full_line":"^L", "long_full_line":"^L",
"fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z", "fountain":"Although it's not recommended, you could drink from this fountain if you are thirsty...^T6Drink from the public fountain. ^B1D^R1^X^Z",
"venus_flytrap_format":"The Giant Venus Flytrap chomped at you!<BR><B>OUCH!!</B><BR>It chomped your pocket, taking $%MONEY% with it!!",
"password_input":"<BR>^PLReply:|^PS14|ANSWER^R1",
"bank":{ "bank":{
"made_interest":"^LYou made $%MONEY% in interest since your last visit.^R1", "made_interest":"^LYou made $%MONEY% in interest since your last visit.^R1",
"carrying_message":"^L(You are carrying $%MONEY% and have $%BANKMONEY% in the bank.)^R1", "carrying_message":"^L(You are carrying $%MONEY% and have $%BANKMONEY% in the bank.)^R1",

View file

@ -296,6 +296,8 @@ namespace HISP.Game
public static string TileFormat; public static string TileFormat;
public static string Seperator; public static string Seperator;
public static string VenusFlyTrapFormat;
public static string PasswordEntry;
public static string ExitThisPlace; public static string ExitThisPlace;
public static string BackToMap; public static string BackToMap;
@ -329,6 +331,10 @@ namespace HISP.Game
// Click // Click
public static string NothingInterestingHere; public static string NothingInterestingHere;
public static string FormatVenusFlyTrapMeta(int money)
{
return VenusFlyTrapFormat.Replace("%MONEY%", money.ToString("N0"));
}
public static string FormatBankIntrestMadeMeta(UInt64 intrestMade) public static string FormatBankIntrestMadeMeta(UInt64 intrestMade)
{ {
return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0")); return BankMadeInIntrestFormat.Replace("%MONEY%", intrestMade.ToString("N0"));

View file

@ -252,7 +252,14 @@ namespace HISP.Game
} }
return message; return message;
} }
public static string buildVenusFlyTrap(User user)
{
int moneyLost = GameServer.RandomNumberGenerator.Next(0, 100);
if (moneyLost > user.Money)
moneyLost = user.Money;
user.Money -= moneyLost;
return Messages.FormatVenusFlyTrapMeta(moneyLost);
}
public static string buildInn(Inn inn) public static string buildInn(Inn inn)
{ {
string message = Messages.InnBuyMeal; string message = Messages.InnBuyMeal;
@ -593,7 +600,10 @@ namespace HISP.Game
{ {
return Messages.FountainMeta; return Messages.FountainMeta;
} }
private static string buildPassword()
{
return Messages.PasswordEntry + Messages.ExitThisPlace + Messages.MetaTerminator;
}
private static string buildBank(User user) private static string buildBank(User user)
{ {
double moneyMade = 0; double moneyMade = 0;
@ -686,6 +696,14 @@ namespace HISP.Game
{ {
message += buildWishingWell(user); message += buildWishingWell(user);
} }
if(TileCode == "VENUSFLYTRAP")
{
message += buildVenusFlyTrap(user);
}
if(TileCode == "PASSWORD")
{
message += buildPassword();
}
if(TileCode == "INN") if(TileCode == "INN")
{ {
int InnID = int.Parse(TileArg); int InnID = int.Parse(TileArg);

View file

@ -151,10 +151,7 @@ namespace HISP.Game
return true; return true;
} }
public static bool ActivateQuest(User user, QuestEntry quest, bool npcActivation = false) public static bool CompleteQuest(User user, QuestEntry quest, bool npcActivation = false)
{
if(CanComplete(user, quest))
{ {
// Take Items // Take Items
foreach (QuestItemInfo itemInfo in quest.ItemsRequired) foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
@ -188,6 +185,13 @@ namespace HISP.Game
if (quest.Tracked) if (quest.Tracked)
user.Quests.TrackQuest(quest.Id); user.Quests.TrackQuest(quest.Id);
if (quest.SuccessMessage != null)
{
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(ChatPacket);
}
if (quest.SuccessNpcChat != null) if (quest.SuccessNpcChat != null)
{ {
if (!npcActivation) if (!npcActivation)
@ -197,11 +201,6 @@ namespace HISP.Game
} }
} }
if (quest.SuccessMessage != null)
{
byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(ChatPacket);
}
// Check if award unlocked // Check if award unlocked
@ -224,7 +223,8 @@ namespace HISP.Game
return true; return true;
} }
else { public static bool FailQuest(User user, QuestEntry quest, bool npcActivation = false)
{
if (quest.FailNpcChat != null) if (quest.FailNpcChat != null)
{ {
if (!npcActivation) if (!npcActivation)
@ -234,7 +234,18 @@ namespace HISP.Game
} }
} }
return false; return false;
}; }
public static bool ActivateQuest(User user, QuestEntry quest, bool npcActivation = false)
{
if (CanComplete(user, quest))
{
return CompleteQuest(user, quest, npcActivation);
}
else
{
return FailQuest(user, quest, npcActivation);
}
} }
public static bool DoesQuestExist(int id) public static bool DoesQuestExist(int id)

View file

@ -674,6 +674,9 @@ namespace HISP.Server
Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork; Messages.NoPitchforkMeta = gameData.messages.meta.hay_pile.no_pitchfork;
Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork; Messages.HasPitchforkMeta = gameData.messages.meta.hay_pile.pitchfork;
Messages.PasswordEntry = gameData.messages.meta.password_input;
Messages.VenusFlyTrapFormat = gameData.messages.meta.venus_flytrap_format;
// Inn // Inn
Messages.InnBuyMeal = gameData.messages.meta.inn.buy_meal; Messages.InnBuyMeal = gameData.messages.meta.inn.buy_meal;
Messages.InnBuyRest = gameData.messages.meta.inn.buy_rest; Messages.InnBuyRest = gameData.messages.meta.inn.buy_rest;

View file

@ -193,6 +193,55 @@ namespace HISP.Server
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)"); Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
break; break;
} }
case 14:
if(dynamicInput.Length >= 1)
{
string password = dynamicInput[1];
// Get current tile
if(World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
{
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
if(tile.Code.StartsWith("PASSWORD-"))
{
string[] args = tile.Code.Replace("!","-").Split('-');
if(args.Length >= 3)
{
string expectedPassword = args[1];
int questId = int.Parse(args[2]);
if(password.ToLower() == expectedPassword.ToLower())
{
Quest.CompleteQuest(sender.LoggedinUser, Quest.GetQuestById(questId), false);
}
else
{
Quest.FailQuest(sender.LoggedinUser, Quest.GetQuestById(questId), false);
}
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Send invalid password input request. (Too few arguments!)");
break;
}
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Send password input request. (Not on password tile!)");
break;
}
}
else
{
Logger.HackerPrint(sender.LoggedinUser.Username + " Sent a password while not in a special tile.");
break;
}
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid password request, (wrong size)");
break;
}
break;
default: default:
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " ")); Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
break; break;