namespace Supercell.Laser.Logic.Command.Home { using Supercell.Laser.Logic.Data; using Supercell.Laser.Logic.Data.Helper; using Supercell.Laser.Logic.Home; using Supercell.Laser.Logic.Home.Gatcha; using Supercell.Laser.Logic.Home.Items; using Supercell.Laser.Logic.Message.Home; using Supercell.Laser.Titan.DataStream; public class LogicViewInboxNotificationCommand : Command { public int NotificationIndex; public override void Decode(ByteStream stream) { base.Decode(stream); NotificationIndex = stream.ReadVInt(); } public override int Execute(HomeMode homeMode) { if (NotificationIndex < 0) { return 0; } NotificationFactory factory = homeMode.Home.NotificationFactory; if (factory == null || NotificationIndex >= factory.NotificationList.Count) { return 0; } Notification notification = factory.NotificationList[NotificationIndex]; if (notification.IsViewed) { return 0; } if (notification.Id == 79) { if (!notification.RewardClaimed) { foreach (int amount in notification.StarpointsAwarded) { homeMode.Avatar.StarPoints += amount; } notification.RewardClaimed = true; } } else if (notification.Id == 85) { SendDelivery(homeMode, BuildSimpleDrop(100, 7, notification.DonationCount)); } else if (notification.Id == 88) { SendDelivery(homeMode, BuildSimpleDrop(100, 2, notification.DonationCount)); } else if (notification.Id == 89 || notification.Id == 95) { SendDelivery(homeMode, BuildSimpleDrop(100, 8, notification.DonationCount)); } else if (notification.Id == 91) { SendDelivery(homeMode, BuildSimpleDrop(100, 12, notification.DonationCount)); } else if (notification.Id == 90) { LogicGiveDeliveryItemsCommand delivery = new LogicGiveDeliveryItemsCommand(); DeliveryUnit unit = new DeliveryUnit(100); if (notification.SkinID < 29000000) { GatchaDrop reward = new GatchaDrop(7); reward.Count = notification.DonationCount; unit.AddDrop(reward); } else { GatchaDrop reward = new GatchaDrop(9); reward.Count = notification.DonationCount; reward.DataGlobalId = 29000000; reward.PinGlobalId = notification.SkinID - 29000000; unit.AddDrop(reward); } delivery.DeliveryUnits.Add(unit); SendDelivery(homeMode, delivery); } else if (notification.Id == 93) { CharacterData character = DataTables.Get(DataType.Character) .GetDataByGlobalId(GlobalId.CreateGlobalId(16, notification.brawlerId)); if (character != null) { LogicGiveDeliveryItemsCommand delivery = new LogicGiveDeliveryItemsCommand(); DeliveryUnit unit = new DeliveryUnit(100); GatchaDrop reward = new GatchaDrop(1); reward.DataGlobalId = character.GetGlobalId(); reward.Count = 1; unit.AddDrop(reward); delivery.DeliveryUnits.Add(unit); SendDelivery(homeMode, delivery); } } else if (notification.Id == 94) { LogicGiveDeliveryItemsCommand delivery = new LogicGiveDeliveryItemsCommand(); DeliveryUnit unit = new DeliveryUnit(100); GatchaDrop reward = new GatchaDrop(9); reward.DataGlobalId = 29000000; reward.PinGlobalId = notification.SkinID; reward.Count = 1; unit.AddDrop(reward); delivery.DeliveryUnits.Add(unit); SendDelivery(homeMode, delivery); } notification.IsViewed = true; return 0; } private static LogicGiveDeliveryItemsCommand BuildSimpleDrop(int deliveryType, int rewardType, int count) { LogicGiveDeliveryItemsCommand delivery = new LogicGiveDeliveryItemsCommand(); DeliveryUnit unit = new DeliveryUnit(deliveryType); GatchaDrop reward = new GatchaDrop(rewardType); reward.Count = count; unit.AddDrop(reward); delivery.DeliveryUnits.Add(unit); return delivery; } private static void SendDelivery(HomeMode homeMode, LogicGiveDeliveryItemsCommand delivery) { delivery.Execute(homeMode); AvailableServerCommandMessage message = new AvailableServerCommandMessage(); message.Command = delivery; homeMode.GameListener.SendMessage(message); } public override int GetCommandType() { return 528; } } }