add real time quiz.

This commit is contained in:
SilicaAndPina 2021-04-16 03:18:49 +12:00
parent 4e8ad17d1c
commit 8069dd8578
7 changed files with 135 additions and 12 deletions

View file

@ -66,7 +66,7 @@
"Don't forget to stretch once in a while.", "Are you running late for school/work?!?!",
"Aren't you sleepy? It's okay to go to bed. We'll all be here tomorrow.",
"Please take a break and check on your family/pets/world. :)",
"Please take breaks once in a while."]
"Please take breaks once in a while."],
"playtime_message": "You have been playing for %TOTALHOURS% hours. "
},
"chat_errors":{

View file

@ -273,11 +273,46 @@ namespace HISP.Game
int prize = EntryCost * Entries.Count;
entry.EnteredUser.Money += prize;
byte[] youWinMessage = PacketBuilder.CreateChat(Messages.FormatArenaYouWinMessage(prize, expReward), PacketBuilder.CHAT_BOTTOM_RIGHT);
entry.EnteredUser.LoggedinClient.SendPacket(youWinMessage);
// Awards:
if (Entries.Count >= 2 && Type == "JUMPING")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(5)); // Good Jumper
if (Entries.Count >= 4 && Type == "JUMPING")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(6)); // Great Jumper
if (Entries.Count >= 2 && Type == "RACING")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(7)); // Good Racer
if (Entries.Count >= 4 && Type == "RACING")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(8)); // Great Racer
if (Entries.Count >= 2 && Type == "DRESSAGE")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(9)); // Good Dressage
if (Entries.Count >= 4 && Type == "DRESSAGE")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(10)); // Great Dressage
if (Entries.Count >= 2 && Type == "DRAFT")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(38)); // Strong Horse Award
if (Entries.Count >= 4 && Type == "DRAFT")
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(39)); // Strongest Horse Award
}
else
{
entry.EnteredUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.ArenaLoss).Count++;
if(entry.EnteredUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.ArenaLoss).Count >= 100)
entry.EnteredUser.Awards.AddAward(Award.GetAwardById(32)); // Perseverance
byte[] youDONTWinMessage = PacketBuilder.CreateChat(Messages.FormatArenaOnlyWinnerWinsMessage(expReward), PacketBuilder.CHAT_BOTTOM_RIGHT);
entry.EnteredUser.LoggedinClient.SendPacket(youDONTWinMessage);
}

View file

@ -32,11 +32,12 @@ namespace HISP.Game.Events
Quit = false;
CorrectAnswers = 0;
MistakenAnswers = 0;
NextQuestion();
}
public void NextQuestion()
{
CorrectAnswers++;
QuizCategory chosenCategory = Categories[GameServer.RandomNumberGenerator.Next(0, Categories.Length)];
OnQuestion = chosenCategory.Questions[GameServer.RandomNumberGenerator.Next(0, chosenCategory.Questions.Length)];
}
@ -50,6 +51,32 @@ namespace HISP.Game.Events
this.UserInstance.LoggedinClient.SendPacket(realTimeQuizQuestion);
}
public void CheckAnswer(string answer)
{
foreach (string correctAnswer in OnQuestion.Answers)
{
if(answer.ToLower().Trim() == correctAnswer.ToLower().Trim())
{
if(CorrectAnswers == 8)
{
GameServer.QuizEvent.WinEvent(UserInstance);
return;
}
NextQuestion();
UpdateParticipent();
return;
}
if (answer.ToLower().Trim() == "quit")
{
GameServer.QuizEvent.LeaveEvent(UserInstance);
return;
}
}
MistakenAnswers++;
UpdateParticipent();
}
public User UserInstance;
public int CorrectAnswers;
public int MistakenAnswers;
@ -136,6 +163,24 @@ namespace HISP.Game.Events
GameServer.QuizEvent = this;
}
public void WinEvent(User winner)
{
byte[] eventWinMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeQuizWin(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
foreach (GameClient client in GameServer.ConnectedClients)
if (client.LoggedIn)
client.SendPacket(eventWinMessage);
getParticipent(winner.Id).Won = true;
winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count++;
if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count >= 15)
winner.Awards.AddAward(Award.GetAwardById(54)); // Quiz Genius
if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count >= 25)
winner.Awards.AddAward(Award.GetAwardById(33)); // Quick Wit
stopEvent();
}
public void EndEvent()
{
byte[] eventEndMessage = PacketBuilder.CreateChat(Messages.EventEndRealTimeQuiz, PacketBuilder.CHAT_BOTTOM_RIGHT);
@ -156,8 +201,7 @@ namespace HISP.Game.Events
if (participent.Quit)
continue;
if (participent.UserInstance.InRealTimeQuiz)
GameServer.UpdateArea(participent.UserInstance.LoggedinClient);
GameServer.UpdateArea(participent.UserInstance.LoggedinClient);
participent.UserInstance.InRealTimeQuiz = false;

View file

@ -128,6 +128,7 @@ namespace HISP.Game.Events
User winner = usersHere[winIndx];
winner.HorseInventory.AddHorse(HorseGiveaway);
winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.TackShopGiveaway).Count++;
byte[] horseWonMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayWon(winner.Username, HorseGiveaway.Breed.Name, ShopName, Town.Name, usersHere.Length), PacketBuilder.CHAT_BOTTOM_RIGHT);
foreach (GameClient client in GameServer.ConnectedClients)

View file

@ -1,9 +1,6 @@
using HISP.Game.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HISP.Game.Horse
{

View file

@ -1144,7 +1144,7 @@ namespace HISP.Game
// Event : Real Time Quiz
public static string FormatEventRealTimeQuizMeta(int questionNo, int totalMistakes, string category, string question)
{
return EventMetaRealTimeQuizFormat.Replace("%QUESTIONNUMBER%", questionNo.ToString()).Replace("%MISTAKES%", questionNo.ToString()).Replace("%CATEGORY%", category).Replace("%QUESTIONTEXT%", question);
return EventMetaRealTimeQuizFormat.Replace("%QUESTIONNUMBER%", questionNo.ToString()).Replace("%MISTAKES%", totalMistakes.ToString()).Replace("%CATEGORY%", category).Replace("%QUESTIONTEXT%", question);
}
public static string FormatEventRealTimeQuizBonus(int bonusMoney)
{

View file

@ -169,7 +169,7 @@ namespace HISP.Server
QuizEvent.StartEvent();
}
if (totalMinutesElapsed % 60 == 0)
if (totalMinutesElapsed % 60 == 0) // Do spoils
{
foreach (HorseInstance horse in Database.GetMostSpoiledHorses())
{
@ -2542,6 +2542,25 @@ namespace HISP.Server
}
break;
case 15: // Real Time Quiz
if (dynamicInput.Length >= 2)
{
if(QuizEvent != null)
{
if (sender.LoggedinUser.InRealTimeQuiz)
{
RealTimeQuiz.Participent participent = QuizEvent.JoinEvent(sender.LoggedinUser);
string answer = dynamicInput[1];
participent.CheckAnswer(answer);
}
}
break;
}
else
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (RealTimeQuiz, wrong size)");
break;
}
default:
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
break;
@ -3315,8 +3334,29 @@ namespace HISP.Server
{
sender.LoggedinUser.MetaPriority = true;
sender.LoggedinUser.Money -= horseLeaser.Price;
HorseInstance leaseHorse = horseLeaser.GenerateLeaseHorse();
if(leaseHorse.Breed.Id == 170) // UniPeg
{
sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.UnipegTeamup).Count++;
if(sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.UnipegTeamup).Count >= 5)
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(55)); // UniPeg Friend
}
else if(leaseHorse.Breed.Type == "unicorn")
{
sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.UnicornTeamup).Count++;
if (sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.UnicornTeamup).Count >= 5)
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(42)); // Unicorn Friend
}
else if(leaseHorse.Breed.Type == "pegasus")
{
sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PegasusTeamup).Count++;
if (sender.LoggedinUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PegasusTeamup).Count >= 5)
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(43)); // Pegasus Friend
}
sender.LoggedinUser.HorseInventory.AddHorse(horseLeaser.GenerateLeaseHorse());
sender.LoggedinUser.HorseInventory.AddHorse(leaseHorse);
byte[] addedHorseMeta = PacketBuilder.CreateMetaPacket(Meta.BuildLeaserOnLeaseInfo(horseLeaser));
sender.SendPacket(addedHorseMeta);
@ -7376,8 +7416,10 @@ namespace HISP.Server
forClient.LoggedinUser.ListingAuction = false;
string LocationStr = "";
if (!World.InSpecialTile(forClient.LoggedinUser.X, forClient.LoggedinUser.Y) && !forClient.LoggedinUser.InRealTimeQuiz)
if (!World.InSpecialTile(forClient.LoggedinUser.X, forClient.LoggedinUser.Y))
{
if (forClient.LoggedinUser.InRealTimeQuiz)
return;
LocationStr = Meta.BuildMetaInfo(forClient.LoggedinUser, forClient.LoggedinUser.X, forClient.LoggedinUser.Y);
}
else
@ -7488,10 +7530,14 @@ namespace HISP.Server
}
if (horseMountInst.Breed.Type == "camel")
{
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(40)); // Camel Rider
incBy = 13;
}
if(horseMountInst.Breed.Type == "llama")
{
sender.LoggedinUser.Awards.AddAward(Award.GetAwardById(41)); // Llama Rider
incBy = 14;
}
if (horseMountInst.Breed.Type == "unicorn")