using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using Blizzard.HabboHotel.Items; using Blizzard.HabboHotel.Users; using Blizzard.HabboHotel.Wired; namespace Blizzard.HabboHotel.Rooms { class BattleBanzai { private RoomItem Item; // counter private List Items; // items on room private Habbo User; private RoomsData cRoom; private Room Room; internal BattleBanzai(RoomItem cItem, List cItems, Habbo cUser, RoomsData sRoom, Room zRoom) { Item = cItem; Items = cItems; User = cUser; cRoom = sRoom; Room = zRoom; } internal void StartGame() { cRoom.BattlePause = false; cRoom.BattleOnGame = true; foreach (RoomItem It in Items) { try { if (It.GetBaseItem().Name == "wf_trg_game_starts") { foreach(RoomItem I in Room.GetItemsForXY(It.X, It.Y)) { WiredEffects Eff = new WiredEffects(I, User); Eff.DoWiredEffects(); } } if (It.GetBaseItem().Name.Contains("bb_score")) { if (Item.ExtraData != "0") { It.ExtraData = "0"; It.UpdateState(User); } } if (It.GetBaseItem().Name.Contains("bb_apparatus")) { if (Item.ExtraData != "1") { It.ExtraData = "1"; It.UpdateState(User); } } if (It.GetBaseItem().Name.Contains("bb_patch")) { if (Item.ExtraData != "1") { It.ExtraData = "1"; It.UpdateState(User); } } } catch { continue; } } } internal void End() { cRoom.BattlePause = false; cRoom.BattleOnGame = false; List BlueTiles = new List(); List RedTiles = new List(); List GreenTiles = new List(); List YellowTiles = new List(); foreach (RoomItem I in Items) { if (I.GetBaseItem().Name.Contains("bb_patch")) { if (I.ExtraData == "5") RedTiles.Add(I); else if (I.ExtraData == "8") GreenTiles.Add(I); else if (I.ExtraData == "11") BlueTiles.Add(I); else if (I.ExtraData == "14") YellowTiles.Add(I); else continue; // Ignore } } #region Select Winner Color! int BlueCount = BlueTiles.Count; int RedCount = RedTiles.Count; int GreenCount = GreenTiles.Count; int YellowCount = YellowTiles.Count; // LOL? if (BlueCount > RedCount && BlueCount > GreenCount && BlueCount > YellowCount) { // winner Blue #region User Greet foreach (KeyValuePair Habbos in StaticGame.VirtualUser) { int id = Habbos.Key; Habbo H = Habbos.Value; if (H.CurrentEffect == 35) { ServerMessage Message = new ServerMessage("Ga"); Message.AddInt(H.VirtualId); StaticGame.SendPacketToAllRoom(User, Message); } } #endregion #region Tile Update for (int i = 0; i != 4; i++) { ServerMessage Winner = new ServerMessage("GY"); Winner.AddInt(BlueTiles.Count); foreach (RoomItem Blue in BlueTiles) { Winner.AddInt(Blue.Id); Winner.AddStringWithBreak("1"); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner); Thread.Sleep(500); ServerMessage Winner2 = new ServerMessage("GY"); Winner2.AddInt(BlueCount); foreach (RoomItem Blue in BlueTiles) { Winner2.AddInt(Blue.Id); Winner2.AddStringWithBreak(Blue.ExtraData); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner2); Thread.Sleep(500); } #endregion } else if (RedCount > BlueCount && RedCount > GreenCount && RedCount > YellowCount) { // winner Red #region User Greet foreach (KeyValuePair Habbos in StaticGame.VirtualUser) { int id = Habbos.Key; Habbo H = Habbos.Value; if (H.CurrentEffect == 33) { ServerMessage Message = new ServerMessage("Ga"); Message.AddInt(H.VirtualId); StaticGame.SendPacketToAllRoom(User, Message); } } #endregion #region Tile Update for (int i = 0; i != 4; i++) { ServerMessage Winner = new ServerMessage("GY"); Winner.AddInt(BlueTiles.Count); foreach (RoomItem Blue in RedTiles) { Winner.AddInt(Blue.Id); Winner.AddStringWithBreak("1"); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner); Thread.Sleep(500); ServerMessage Winner2 = new ServerMessage("GY"); Winner2.AddInt(BlueCount); foreach (RoomItem Blue in RedTiles) { Winner2.AddInt(Blue.Id); Winner2.AddStringWithBreak(Blue.ExtraData); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner2); Thread.Sleep(500); } #endregion } else if (GreenCount > BlueCount && GreenCount > RedCount && GreenCount > YellowCount) { // winner Green #region User Greet foreach (KeyValuePair Habbos in StaticGame.VirtualUser) { int id = Habbos.Key; Habbo H = Habbos.Value; if (H.CurrentEffect == 34) { ServerMessage Message = new ServerMessage("Ga"); Message.AddInt(H.VirtualId); StaticGame.SendPacketToAllRoom(User, Message); } } #endregion #region Tile Update for (int i = 0; i != 5; i++) { ServerMessage Winner = new ServerMessage("GY"); Winner.AddInt(BlueTiles.Count); foreach (RoomItem Blue in GreenTiles) { Winner.AddInt(Blue.Id); Winner.AddStringWithBreak("1"); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner); Thread.Sleep(500); ServerMessage Winner2 = new ServerMessage("GY"); Winner2.AddInt(BlueCount); foreach (RoomItem Blue in GreenTiles) { Winner2.AddInt(Blue.Id); Winner2.AddStringWithBreak(Blue.ExtraData); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner2); Thread.Sleep(500); } #endregion } else if (YellowCount > BlueCount && YellowCount > GreenCount && YellowCount > RedCount) { // winner Yellow #region User Greet foreach (KeyValuePair Habbos in StaticGame.VirtualUser) { int id = Habbos.Key; Habbo H = Habbos.Value; if (H.CurrentEffect == 36) { ServerMessage Message = new ServerMessage("Ga"); Message.AddInt(H.VirtualId); StaticGame.SendPacketToAllRoom(User, Message); } } #endregion #region Tile Update for (int i = 0; i != 4; i++) { ServerMessage Winner = new ServerMessage("GY"); Winner.AddInt(BlueTiles.Count); foreach (RoomItem Blue in YellowTiles) { Winner.AddInt(Blue.Id); Winner.AddStringWithBreak("1"); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner); Thread.Sleep(500); ServerMessage Winner2 = new ServerMessage("GY"); Winner2.AddInt(BlueCount); foreach (RoomItem Blue in YellowTiles) { Winner2.AddInt(Blue.Id); Winner2.AddStringWithBreak(Blue.ExtraData); } StaticGame.SSendPacketToAllRoom(cRoom.Id, Winner2); Thread.Sleep(500); } #endregion } #endregion #region Finalize Game! foreach (RoomItem CItem in cRoom.FloorItems) { if (CItem.GetBaseItem().Name == "wf_trg_game_ends") { foreach (RoomItem I in Room.GetItemsForXY(CItem.X, CItem.Y)) { WiredEffects Eff = new WiredEffects(I, User); Eff.DoWiredEffects(); } } if (CItem.GetBaseItem().Name.Contains("bb_apparatus")) { if (Item.ExtraData != "0") { CItem.ExtraData = "0"; CItem.UpdateState(User); } } } foreach(RoomItem CItem in Items) { if (CItem.GetBaseItem().Name == "bb_counter") { Thread Battle = StaticGame.CounterSystem[CItem.Id]; Battle.Abort(); Battle = null; StaticGame.CounterSystem.Remove(Item.Id); } } #endregion } internal void StartCounter() { while (true) { if (Item == null || Item.Id == 0) continue; int Time = int.Parse(Item.ExtraData); if (Time > 0) { int i = 0; foreach (RoomItem It in RoomsData.Rooms[Item.RoomId].FloorItems) { if (It.GetBaseItem().Name.Contains("bb_patch")) { if (It.ExtraData != "5" && It.ExtraData != "8" && It.ExtraData != "11" && It.ExtraData != "14") i++; } } if (i == 0) Time = 0; else Time--; Item.ExtraData = Time.ToString(); Item.UpdateState(User); Thread.Sleep(950); if (Time == 0) End(); } else { // End Game! try { End(); return; } catch (Exception e) { BlizzardSystem.WriteLine(e.ToString()); } } } } } }