diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json
index b22cd05..cfec93a 100755
--- a/DataCollection/gamedata.json
+++ b/DataCollection/gamedata.json
@@ -79,6 +79,12 @@
"awarded_you":"Mod Revenge taken upon %USERNAME%! $50 earned."
},
"events":{
+ "water_balloon_game":{
+ "event_start":"WATER BALLOON FIGHT: You have just been given 8 Water Balloons. Whoever gets hit the MOST in 5 minutes (60 game minutes) will win a prize (hits on yourself are not counted).",
+ "event_won":"You are a Water Balloon winner! Prize: $20,000",
+ "event_end":"WATER BALLOON FIGHT OVER: Here were the winners:",
+ "event_winner":"
%USERNAME% was hit %AMOUNT% times."
+ },
"real_time_riddle":{
"event_start":"CHAT RIDDLE: %RIDDLETEXT% (answer first via any chat method)",
"event_end":"TIME IS UP: No one answered the Chat Riddle in time.",
@@ -130,13 +136,6 @@
"enjoyed_service":"You enjoyed your %ITEM% for $%PRICE%.",
"fully_rested":"You are now completely rested!"
},
- "water_balloon_game":{
- "money_prize":20000,
- "starting_amount":8,
- "start_message":"WATER BALLOON FIGHT: You have just been given %AMOUNT% Water Balloons. Whoever gets hit the MOST in 5 minutes (60 game minutes) will win a prize (hits on yourself are not counted).",
- "winner_message":"You are a Water Balloon winner! Prize: $%PRIZE%",
- "end_message_winner":"WATER BALLOON FIGHT OVER: Here were the winners:
%USERNAME% was hit %AMOUNT% times."
- },
"fountain":{
"drank_your_fill":"You drank your fill from the fountain.",
"dropped_money":"Oh no!!! While drinking you accidentally dropped $%MONEY% into the fountain!! There is no way to get it back!",
diff --git a/Horse Isle Server/HorseIsleServer/Game/Events/WaterBalloonGame.cs b/Horse Isle Server/HorseIsleServer/Game/Events/WaterBalloonGame.cs
new file mode 100644
index 0000000..ca6c134
--- /dev/null
+++ b/Horse Isle Server/HorseIsleServer/Game/Events/WaterBalloonGame.cs
@@ -0,0 +1,140 @@
+using HISP.Player;
+using HISP.Server;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace HISP.Game.Events
+{
+
+ public class WaterBalloonGame
+ {
+ public WaterBalloonGame()
+ {
+ ThrownWaterBalloonMemory = new List();
+ Active = false;
+ }
+
+
+ public List ThrownWaterBalloonMemory;
+ public bool Active;
+ private Timer gameTimeout;
+ private const int WATER_BALLOON_GAME_TIMEOUT = 5;
+ public class ThrownCounter
+ {
+ public ThrownCounter(WaterBalloonGame game, User userHit, int numThrown)
+ {
+ UserHit = userHit;
+ NumThrown = numThrown;
+ baseGame = game;
+
+ game.ThrownWaterBalloonMemory.Add(this);
+ }
+ private WaterBalloonGame baseGame;
+ public User UserHit;
+ public int NumThrown;
+ }
+
+ public void StartEvent()
+ {
+ Active = true;
+ gameTimeout = new Timer(new TimerCallback(gameTimedOut), null, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000);
+
+ byte[] gameStartMessage = PacketBuilder.CreateChat(Messages.EventStartWaterBallonGame, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ foreach (GameClient client in GameServer.ConnectedClients)
+ if (client.LoggedIn)
+ client.SendPacket(gameStartMessage);
+ }
+
+ public void EndEvent()
+ {
+ ThrownCounter[] winnerCounter = getWinners();
+ resetEvent();
+ // Build event over message
+ string winMsg = Messages.EventEndWaterBalloonGame;
+ foreach(ThrownCounter winner in winnerCounter)
+ {
+ winMsg += Messages.FormatWaterBalloonGameWinner(winner.UserHit.Username, winner.NumThrown);
+ }
+
+ // Send to all online users
+ byte[] gameWinnerAnnoucement = PacketBuilder.CreateChat(winMsg, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ foreach (GameClient client in GameServer.ConnectedClients)
+ if (client.LoggedIn)
+ client.SendPacket(gameWinnerAnnoucement);
+
+ // payout / tell ppl they won.
+ foreach (ThrownCounter winner in winnerCounter)
+ {
+ byte[] youWinMsg = PacketBuilder.CreateChat(winMsg, PacketBuilder.CHAT_BOTTOM_RIGHT);
+ winner.UserHit.Money += 20000;
+ winner.UserHit.LoggedinClient.SendPacket(youWinMsg);
+ }
+
+ }
+ private void gameTimedOut(object state)
+ {
+ EndEvent();
+ }
+
+ private void resetEvent()
+ {
+ gameTimeout.Dispose();
+ gameTimeout = null;
+ ThrownWaterBalloonMemory.Clear();
+ Active = false;
+ }
+ private ThrownCounter[] getWinners()
+ {
+ int maxThrown = 0;
+ ThrownCounter[] thrownWaterBalloonMemory = ThrownWaterBalloonMemory.ToArray();
+ List winningCounter = new List();
+
+ // Find the highest throw count
+ foreach(ThrownCounter throwMemory in thrownWaterBalloonMemory)
+ {
+ if(throwMemory.NumThrown >= maxThrown)
+ {
+ maxThrown = throwMemory.NumThrown;
+ }
+ }
+
+ // Find all with that throw count and add to winner list
+ foreach (ThrownCounter throwMemory in thrownWaterBalloonMemory)
+ {
+ if (throwMemory.NumThrown == maxThrown)
+ {
+ winningCounter.Add(throwMemory);
+ }
+ }
+
+ return winningCounter.ToArray();
+ }
+
+ public void LeaveEvent(User userToLeave)
+ {
+ foreach (ThrownCounter thrownMemory in ThrownWaterBalloonMemory.ToArray())
+ {
+ if (thrownMemory.UserHit.Id == userToLeave.Id)
+ ThrownWaterBalloonMemory.Remove(thrownMemory);
+ }
+ }
+
+ private ThrownCounter getThrownCounter(User userToGet)
+ {
+ foreach(ThrownCounter thrownMemory in ThrownWaterBalloonMemory.ToArray())
+ {
+ if (thrownMemory.UserHit.Id == userToGet.Id)
+ return thrownMemory;
+ }
+
+ return new ThrownCounter(this, userToGet, 0);
+ }
+
+ public void AddWaterBallon(User throwAt)
+ {
+ ThrownCounter throwCounter = getThrownCounter(throwAt);
+ throwCounter.NumThrown++;
+ }
+
+ }
+}
diff --git a/Horse Isle Server/HorseIsleServer/Game/Messages.cs b/Horse Isle Server/HorseIsleServer/Game/Messages.cs
index d2744c4..75ea7fd 100755
--- a/Horse Isle Server/HorseIsleServer/Game/Messages.cs
+++ b/Horse Isle Server/HorseIsleServer/Game/Messages.cs
@@ -69,6 +69,12 @@ namespace HISP.Game
public static string SocialTypeFormat;
public static string SocialPlayerNoLongerNearby;
+ // Events : Water Balloon Game
+ public static string EventStartWaterBallonGame;
+ public static string EventWonWaterBallonGame;
+ public static string EventEndWaterBalloonGame;
+ public static string EventWinnerWaterBalloonGameFormat;
+
// Events : Real Time Quiz
public static string EventMetaRealTimeQuizFormat;
public static string EventStartRealTimeQuiz;
@@ -1152,6 +1158,12 @@ namespace HISP.Game
return itemFormat.Replace("%USERNAME%", username);
}
+ // Event : Water Ballon Game
+ public static string FormatWaterBalloonGameWinner(string username, int timesHit)
+ {
+ return EventWinnerWaterBalloonGameFormat.Replace("%USERNAME%", username).Replace("%AMOUNT%", timesHit.ToString("N0", CultureInfo.InvariantCulture));
+ }
+
// Event : Real Time Quiz
public static string FormatEventRealTimeQuizMeta(int questionNo, int totalMistakes, string category, string question)
{
diff --git a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs
index eb9cd58..5f9077c 100755
--- a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs
+++ b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs
@@ -958,6 +958,12 @@ namespace HISP.Server
// Message Queue
Messages.MessageQueueHeader = gameData.messages.message_queue;
+ // Events : Water Ballon Game
+ Messages.EventStartWaterBallonGame = gameData.messages.events.water_balloon_game.event_start;
+ Messages.EventWonWaterBallonGame = gameData.messages.events.water_balloon_game.event_won;
+ Messages.EventEndWaterBalloonGame = gameData.messages.events.water_balloon_game.event_end;
+ Messages.EventWinnerWaterBalloonGameFormat = gameData.messages.events.water_balloon_game.event_winner;
+
// Events : Real Time Quiz
Messages.EventMetaRealTimeQuizFormat = gameData.messages.events.real_time_quiz.event_meta;
diff --git a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs
index f3622d2..9428fa6 100755
--- a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs
+++ b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs
@@ -42,6 +42,7 @@ namespace HISP.Server
public static RealTimeRiddle RiddleEvent = RealTimeRiddle.GetRandomRiddle();
public static TackShopGiveaway TackShopGiveawayEvent = null;
public static RealTimeQuiz QuizEvent = null;
+ public static WaterBalloonGame WaterBalloonEvent = new WaterBalloonGame();
/*
* Private stuff
@@ -146,14 +147,14 @@ namespace HISP.Server
}
}
// Isle Card Trading Game
- if(totalMinutesElapsed % (60 + 55) == 0)
+ if(totalMinutesElapsed % (60 + 50) == 0)
{
}
// Water Balloon Game
if(totalMinutesElapsed % (60 * 2) == 0)
{
-
+ WaterBalloonEvent.StartEvent();
}
// Tack Shop Giveaway
if(totalMinutesElapsed % (60 * 3) == 0)