public override void Process(Level level) { var alliance = ObjectManager.GetAlliance(m_vAllianceId); if (alliance != null) { if (!alliance.IsAllianceFull()) { level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(1); alliance.AddAllianceMember(member); var joinAllianceCommand = new JoinAllianceCommand(); joinAllianceCommand.SetAlliance(alliance); var availableServerCommandMessage = new AvailableServerCommandMessage(Client); availableServerCommandMessage.SetCommandId(8); availableServerCommandMessage.SetCommand(joinAllianceCommand); PacketManager.ProcessOutgoingPacket(availableServerCommandMessage); PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(Client, level)); PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance)); PacketManager.ProcessOutgoingPacket(new AllianceFullEntryMessage(Client, alliance)); } } }
public override void Process(Level level) { var alliance = ObjectManager.CreateAlliance(0); alliance.SetAllianceName(m_vAllianceName); alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetWarPublicStatus(m_vWarLogPublic); level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(2); alliance.AddAllianceMember(member); var b = new JoinAllianceCommand(); b.SetAlliance(alliance); var a = new AvailableServerCommandMessage(Client); a.SetCommandId(1); a.SetCommand(b); PacketManager.ProcessOutgoingPacket(a); PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(Client, level)); PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance)); PacketManager.ProcessOutgoingPacket(new AllianceFullEntryMessage(Client, alliance)); }
public override void Process(Level level) { //Clan creation var alliance = ObjectManager.CreateAlliance(0); alliance.SetAllianceName(m_vAllianceName); alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarFrequency(m_vWarFrequency); //Set player clan //ObjectManager.OnlinePlayers.TryGetValue(p.Client, out player); level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(2); alliance.AddAllianceMember(member); var joinAllianceCommand = new JoinAllianceCommand(); joinAllianceCommand.SetAlliance(alliance); var availableServerCommandMessage = new AvailableServerCommandMessage(Client); availableServerCommandMessage.SetCommandId(1); availableServerCommandMessage.SetCommand(joinAllianceCommand); PacketManager.ProcessOutgoingPacket(availableServerCommandMessage); PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance)); //PacketManager.ProcessOutgoingPacket(new OutOfSyncMessage(level.GetClient())); // Necessary to display the "Customize" Button. }
public void AddServerCommand(LogicServerCommand serverCommand) { if (this.m_logicGameMode.GetState() != 1) { throw new Exception("GameMode.addServerCommand: Method called in invalid game state."); } this.m_serverCommandStorage.AddServerCommand(serverCommand); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(serverCommand); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); }
public override void Process(Level level) { var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (alliance != null) { alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus); var avatar = level.GetPlayerAvatar(); var allianceId = avatar.GetAllianceId(); var eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(10); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); eventStreamEntry.SetSenderId(avatar.GetId()); eventStreamEntry.SetSenderName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); var edit = new AllianceSettingChangedCommand(); edit.SetAlliance(alliance); edit.SetPlayer(level); var availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient()); availableServerCommandMessage.SetCommandId(6); availableServerCommandMessage.SetCommand(edit); availableServerCommandMessage.Send(); Parallel.ForEach(alliance.GetAllianceMembers(), op => { var user = ResourcesManager.GetPlayer(op.GetAvatarId()); if (ResourcesManager.IsPlayerOnline(user)) { var p = new AllianceStreamEntryMessage(user.GetClient()); p.SetStreamEntry(eventStreamEntry); p.Send(); } }); var clan = DatabaseManager.Single().Save(alliance); clan.Wait(); } }
public override void Process(Level level) { if (m_vAllianceName == null) { m_vAllianceName = "Clan"; } var alliance = ObjectManager.CreateAlliance(0); alliance.SetAllianceName(m_vAllianceName); alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus); level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(2); alliance.AddAllianceMember(member); var b = new JoinedAllianceCommand(); b.SetAlliance(alliance); var d = new AllianceRoleUpdateCommand(); d.SetAlliance(alliance); d.SetRole(2); d.Tick(level); var a = new AvailableServerCommandMessage(Client); a.SetCommandId(1); a.SetCommand(b); var c = new AvailableServerCommandMessage(Client); c.SetCommandId(8); c.SetCommand(d); a.Send(); c.Send(); }
public override void Process(Level level) { var alliance = ObjectManager.GetAlliance(m_vAllianceId); if (alliance == null || alliance.IsAllianceFull()) { return; } level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var entry = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); entry.SetRole(1); alliance.AddAllianceMember(entry); var jaCommand = new JoinedAllianceCommand(); jaCommand.SetAlliance(alliance); var aruCommand = new AllianceRoleUpdateCommand(); aruCommand.SetAlliance(alliance); aruCommand.SetRole(1); aruCommand.Tick(level); var asCommand1 = new AvailableServerCommandMessage(Client); asCommand1.SetCommandId(1); asCommand1.SetCommand(jaCommand); var asCommand2 = new AvailableServerCommandMessage(Client); asCommand2.SetCommandId(8); asCommand2.SetCommand(aruCommand); asCommand1.Send(); asCommand2.Send(); new AllianceStreamMessage(Client, alliance).Send(); }
private async Task HandleChangeAvatarRequestName(IClient client, Message message, CancellationToken cancellationToken) { var careqMessage = (ChangeAvatarNameRequestMessage)message; var level = client.Session.Level; var avatar = level.Avatar; avatar.Name = careqMessage.NewName; avatar.IsNamed = true; // Update the TutorialProgress slots to skip the // "Get a name" stuff. var tutorialProgress = avatar.TutorialProgess; var count = tutorialProgress.Count; for (int i = count; i < count + 3; i++) { tutorialProgress.Add(new TutorialProgressSlot(21000000 + i)); } // 900 Gold and 400 Elixir is given after the tutorial ends. avatar.UseResource("Gold", -900); avatar.UseResource("Elixir", -400); var ascMessage = new AvailableServerCommandMessage { Command = new AvatarNameChangedCommand { NewName = careqMessage.NewName, Unknown1 = 1, Unknown2 = -1 // -> Tick? } }; client.SendMessage(ascMessage); // Save the client. var save = client.Save; await Server.Db.SaveLevelAsync(save, cancellationToken); }
public override async void Process(Level level) { try { Alliance alliance = await ObjectManager.GetAlliance(m_vAllianceId); if (alliance != null) { if (!alliance.IsAllianceFull()) { level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); AllianceMemberEntry member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(1); alliance.AddAllianceMember(member); JoinedAllianceCommand b = new JoinedAllianceCommand(); b.SetAlliance(alliance); AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand(); c.SetAlliance(alliance); c.SetRole(1); c.Tick(level); AvailableServerCommandMessage a = new AvailableServerCommandMessage(Client); a.SetCommandId(1); a.SetCommand(b); AvailableServerCommandMessage d = new AvailableServerCommandMessage(Client); d.SetCommandId(8); d.SetCommand(c); PacketProcessor.Send(a); PacketProcessor.Send(d); PacketProcessor.Send(new AllianceStreamMessage(Client, alliance)); } } } catch (Exception) { } }
public override void Process(Level level) { var alliance = ObjectManager.GetAlliance(m_vAllianceId); if (alliance != null) { if (!alliance.IsAllianceFull()) { level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); var member = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); member.SetRole(1); alliance.AddAllianceMember(member); var b = new JoinedAllianceCommand(); b.SetAlliance(alliance); var c = new AllianceRoleUpdateCommand(); c.SetAlliance(alliance); c.SetRole(1); c.Tick(level); var a = new AvailableServerCommandMessage(Client); a.SetCommandId(1); a.SetCommand(b); var d = new AvailableServerCommandMessage(Client); d.SetCommandId(8); d.SetCommand(c); a.Send(); d.Send(); new AllianceStreamMessage(Client, alliance).Send(); } } }
private async Task HandleCreateAlliance(IClient client, Message message, CancellationToken cancellationToken) { var caMessage = (CreateAllianceMessage)message; var level = client.Session.Level; // Look up what it is gonna cost and how its gonna cost // from the /logic/globals.csv table. var globals = Server.Assets.DataTables.GetTable <GlobalData>(); var resource = globals.Rows["ALLIANCE_CREATE_RESOURCE"][0].TextValue; var cost = globals.Rows["ALLIANCE_CREATE_COST"][0].NumberValue; level.Avatar.UseResource(resource, cost); // Request the db for a new clan. var clanSave = await Server.Db.NewClanAsync(cancellationToken); var clan = clanSave.ToClan(); // Set the values as specified in the message. clan.Name = caMessage.Name; clan.Description = caMessage.Description; clan.Badge = caMessage.Badge; clan.InviteType = caMessage.InviteType; clan.RequiredTrophies = caMessage.RequiredTrophy; clan.WarFrequency = caMessage.WarFrequency; clan.Location = caMessage.Origin; clan.RequiredTrophies = caMessage.RequiredTrophy; // Add client that created the clan as a member of the clan // with role as the leader. var member = new ClanMember(client.Session.Level) { Role = ClanMemberRole.Leader, Rank = 1, PreviousRank = 1, }; clan.Members.Add(member); // Set the clan of the creator to the created clan. level.Avatar.Alliance = clan; // Save the level which contains a ref to the ID of the clan. var levelSave = client.Save; await Server.Db.SaveLevelAsync(levelSave, cancellationToken); clanSave.FromClan(clan); // Save the clan to the db. await Server.Db.SaveClanAsync(clanSave, cancellationToken); // Let the client know he was added to the clan. var ascCommand1 = new AvailableServerCommandMessage { Command = new AllianceJoinedCommand { ClanId = clan.Id, Name = clan.Name, Badge = clan.Badge, ExpLevels = clan.ExpLevels, Tick = -1, } }; // Let the client know he is the leader of the clan. var ascCommand2 = new AvailableServerCommandMessage { Command = new AllianceRoleUpdatedCommand { ClanId = clan.Id, Role = member.Role, Tick = -1 } }; client.SendMessage(ascCommand1); client.SendMessage(ascCommand2); }
private async Task HandleLeaveAlliance(IClient client, Message message, CancellationToken cancellationToken) { var level = client.Session.Level; var clan = level.Avatar.Alliance; if (clan == null) { Server.Logs.Warn("A client tried to leave a clan, but himself is not in a clan."); } else { //TODO: Look for new leader in case leader leaves. var member = clan.Get(level.Avatar.Id); var jolStreamEntry = clan.Leave(level.Avatar.Id); if (jolStreamEntry == null) { Server.Logs.Warn("A client tried to leave a clan, but wasn't not in the clan."); } else { // Set avatar to null so that when it saves with ClanId = 0. level.Avatar.Alliance = null; var ascCommand = new AvailableServerCommandMessage { Command = new AllianceLeftCommand { ClanId = clan.Id, Reason = 1, Tick = -1 } }; client.SendMessage(ascCommand); // Set clan_id to NULL so that the FOREIGN KEY constraint does not fail. var levelSave = client.Save; await Server.Db.SaveLevelAsync(levelSave, cancellationToken); var clanSave = Server.Factories.GetFactory <ClanSaveFactory>().Create(); clanSave.FromClan(clan); await Server.Db.SaveClanAsync(clanSave, cancellationToken); // Send this message to all the clients online who are in the clans. foreach (var c in Server.Clients) { // Send an alliance stream event to client. var aseMessage = new AllianceStreamEventMessage { Entry = jolStreamEntry }; if (c?.Session.Level?.Avatar?.Alliance != null) { var cclan = c.Session.Level.Avatar.Alliance; if (cclan.Id == clan.Id) { c.SendMessage(aseMessage); } } } } } }
private async Task HandleJoinAlliance(IClient client, Message message, CancellationToken cancellationToken) { var jaMessage = (JoinAllianceMessage)message; var clan = await Server.Clans.GetClanAsync(jaMessage.ClanId, cancellationToken); var level = client.Session.Level; if (clan == null) { Server.Logs.Warn("Client tried to join a clan that does not exists."); } else { var jolStreamEntry = clan.Join(level.Avatar); if (jolStreamEntry == null) { Server.Logs.Warn("Client tried to join his own clan"); } else { client.Session.Level.Avatar.Alliance = clan; var asMessage = clan.AllianceStream; var ascMessage = new AvailableServerCommandMessage { Command = new AllianceJoinedCommand { ClanId = clan.Id, Name = clan.Name, Badge = clan.Badge, ExpLevels = clan.ExpLevels, Tick = -1 } }; client.SendMessage(ascMessage); client.SendMessage(asMessage); await Server.Db.SaveLevelAsync(client.Save, cancellationToken); // Send this message to all the clients online who are in the clans. foreach (var c in Server.Clients) { // Send an alliance stream event to client. var aseMessage = new AllianceStreamEventMessage { Entry = jolStreamEntry }; if (c?.Session.Level?.Avatar?.Alliance != null) { var cclan = c.Session.Level.Avatar.Alliance; if (cclan.Id == clan.Id) { c.SendMessage(aseMessage); } } } } } }
public override void Execute(Level level) { var targetAccount = ResourcesManager.GetPlayer(m_vAvatarId, true); if (targetAccount != null) { var targetAvatar = targetAccount.GetPlayerAvatar(); var targetAllianceId = targetAvatar.GetAllianceId(); var requesterAvatar = level.GetPlayerAvatar(); var requesterAllianceId = requesterAvatar.GetAllianceId(); if (requesterAllianceId > 0 && targetAllianceId == requesterAllianceId) { var alliance = ObjectManager.GetAlliance(requesterAllianceId); var requesterMember = alliance.GetAllianceMember(requesterAvatar.GetId()); var targetMember = alliance.GetAllianceMember(m_vAvatarId); if (targetMember.HasLowerRoleThan(requesterMember.GetRole())) { targetAvatar.SetAllianceId(0); alliance.RemoveMember(m_vAvatarId); if (ResourcesManager.IsPlayerOnline(targetAccount)) { var leaveAllianceCommand = new LeaveAllianceCommand(); leaveAllianceCommand.SetAlliance(alliance); leaveAllianceCommand.SetReason(2); //Kick var availableServerCommandMessage = new AvailableServerCommandMessage(targetAccount.GetClient()); availableServerCommandMessage.SetCommandId(2); availableServerCommandMessage.SetCommand(leaveAllianceCommand); PacketManager.ProcessOutgoingPacket(availableServerCommandMessage); var kickOutStreamEntry = new AllianceKickOutStreamEntry(); kickOutStreamEntry.SetId( (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); kickOutStreamEntry.SetAvatar(requesterAvatar); kickOutStreamEntry.SetIsNew(0); kickOutStreamEntry.SetAllianceId(alliance.GetAllianceId()); kickOutStreamEntry.SetAllianceBadgeData(alliance.GetAllianceBadgeData()); kickOutStreamEntry.SetAllianceName(alliance.GetAllianceName()); kickOutStreamEntry.SetMessage(m_vMessage); var p = new AvatarStreamEntryMessage(targetAccount.GetClient()); p.SetAvatarStreamEntry(kickOutStreamEntry); PacketManager.ProcessOutgoingPacket(p); } var eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetAvatar(targetAvatar); eventStreamEntry.SetEventType(1); eventStreamEntry.SetAvatarId(requesterAvatar.GetId()); eventStreamEntry.SetAvatarName(requesterAvatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == requesterAllianceId) { var p = new AllianceStreamEntryMessage(onlinePlayer.GetClient()); p.SetStreamEntry(eventStreamEntry); PacketManager.ProcessOutgoingPacket(p); } } } } } }
internal override async void Process() { try { Level target = await ResourcesManager.GetPlayer(m_vId); ClientAvatar player = this.Device.Player.Avatar; Alliance alliance = ObjectManager.GetAlliance(player.AllianceId); if (await player.GetAllianceRole() == 2 || await player.GetAllianceRole() == 4) { if (player.AllianceId == target.Avatar.AllianceId) { int oldrole = await target.Avatar.GetAllianceRole(); target.Avatar.SetAllianceRole(m_vRole); if (m_vRole == 2) { player.SetAllianceRole(4); AllianceEventStreamEntry demote = new AllianceEventStreamEntry(); demote.ID = alliance.m_vChatMessages.Count + 1; demote.SetSender(player); demote.EventType = 6; alliance.AddChatMessage(demote); AllianceEventStreamEntry promote = new AllianceEventStreamEntry(); promote.ID = alliance.m_vChatMessages.Count + 1; promote.SetSender(target.Avatar); promote.EventType = 5; alliance.AddChatMessage(promote); AllianceRoleUpdateCommand p = new AllianceRoleUpdateCommand(this.Device); AvailableServerCommandMessage pa = new AvailableServerCommandMessage(Device, p.Handle()); AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(target.Client); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.Client, t.Handle()); PromoteAllianceMemberOkMessage rup = new PromoteAllianceMemberOkMessage(Device) { Id = this.Device.Player.Avatar.UserId, Role = 4 }; PromoteAllianceMemberOkMessage rub = new PromoteAllianceMemberOkMessage(target.Client) { Id = target.Avatar.UserId, Role = 2 }; t.SetAlliance(alliance); p.SetAlliance(alliance); t.SetRole(2); p.SetRole(4); t.Tick(target); p.Tick(this.Device.Player); if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); rub.Send(); } rup.Send(); pa.Send(); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.AvatarId); if (aplayer.Client != null) { new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = demote }.Send(); new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = promote }.Send(); } } } else { AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(target.Client); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.Client, t.Handle()); t.SetAlliance(alliance); t.SetRole(m_vRole); t.Tick(target); PromoteAllianceMemberOkMessage ru = new PromoteAllianceMemberOkMessage(target.Client) { Id = target.Avatar.UserId, Role = m_vRole }; if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); ru.Send(); } AllianceEventStreamEntry stream = new AllianceEventStreamEntry(); stream.ID = alliance.m_vChatMessages.Count + 1; stream.SetSender(target.Avatar); stream.EventType = m_vRole > oldrole ? 5 : 6; alliance.AddChatMessage(stream); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = await ResourcesManager.GetPlayer(op.AvatarId); if (aplayer.Client != null) { new AllianceStreamEntryMessage(aplayer.Client) { StreamEntry = stream }.Send(); } } } } } } catch (Exception) { } }
public override void Process(Level level) { if (m_vAllianceName == null) { m_vAllianceName = "Clan"; } if (m_vAllianceName.Length < 16 || m_vAllianceName.Length < 1) { if (m_vAllianceDescription.Length < 259 || m_vAllianceDescription.Length < 0) { if (m_vAllianceBadgeData < 1 || (long)m_vAllianceBadgeData < 10000000000L) { if (m_vAllianceType < 0 || m_vAllianceType < 10) { if (m_vRequiredScore < 0 || m_vRequiredScore < 4201) { if (m_vWarFrequency < 0 || m_vWarFrequency < 10) { if (m_vAllianceOrigin < 0 || m_vAllianceOrigin < 42000000) { if ((int)m_vWarAndFriendlyStatus < 0 || (int)m_vWarAndFriendlyStatus < 5) { Alliance alliance = ObjectManager.CreateAlliance(); alliance.SetAllianceName(m_vAllianceName); alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus); level.GetPlayerAvatar().SetAllianceId(alliance.GetAllianceId()); AllianceMemberEntry entry = new AllianceMemberEntry(level.GetPlayerAvatar().GetId()); entry.SetRole(2); alliance.AddAllianceMember(entry); JoinedAllianceCommand Command1 = new JoinedAllianceCommand(); Command1.SetAlliance(alliance); AllianceRoleUpdateCommand Command2 = new AllianceRoleUpdateCommand(); Command2.SetAlliance(alliance); Command2.SetRole(2); Command2.Tick(level); var a = new AvailableServerCommandMessage(Client); a.SetCommandId(1); a.SetCommand(Command1); var c = new AvailableServerCommandMessage(Client); c.SetCommandId(8); c.SetCommand(Command2); a.Send(); c.Send(); } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } }
public override void Process(Level level) { var target = ResourcesManager.GetPlayer(m_vId); var player = level.GetPlayerAvatar(); var alliance = ObjectManager.GetAlliance(player.GetAllianceId()); if (player.GetAllianceRole() == 2 || player.GetAllianceRole() == 4) { if (player.GetAllianceId() == target.GetPlayerAvatar().GetAllianceId()) { int oldrole = target.GetPlayerAvatar().GetAllianceRole(); target.GetPlayerAvatar().SetAllianceRole(m_vRole); if (m_vRole == 2) { player.SetAllianceRole(4); AllianceEventStreamEntry demote = new AllianceEventStreamEntry(); demote.SetId(alliance.GetChatMessages().Count + 1); demote.SetSender(player); demote.SetEventType(6); demote.SetAvatarId(player.GetId()); demote.SetAvatarName(player.GetAvatarName()); alliance.AddChatMessage(demote); AllianceEventStreamEntry promote = new AllianceEventStreamEntry(); promote.SetId(alliance.GetChatMessages().Count + 1); promote.SetSender(target.GetPlayerAvatar()); promote.SetEventType(5); promote.SetAvatarId(player.GetId()); promote.SetAvatarName(player.GetAvatarName()); alliance.AddChatMessage(promote); PromoteAllianceMemberOkMessage rup = new PromoteAllianceMemberOkMessage(Client); PromoteAllianceMemberOkMessage rub = new PromoteAllianceMemberOkMessage(target.GetClient()); AllianceRoleUpdateCommand p = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage pa = new AvailableServerCommandMessage(Client); AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.GetClient()); rup.SetID(level.GetPlayerAvatar().GetId()); rup.SetRole(4); rub.SetID(target.GetPlayerAvatar().GetId()); rub.SetRole(2); t.SetAlliance(alliance); p.SetAlliance(alliance); t.SetRole(2); p.SetRole(4); t.Tick(target); p.Tick(level); ta.SetCommandId(8); pa.SetCommandId(8); ta.SetCommand(t); pa.SetCommand(p); if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); rub.Send(); } rup.Send(); pa.Send(); // New function for send a message foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { AllianceStreamEntryMessage a = new AllianceStreamEntryMessage(aplayer.GetClient()); AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient()); a.SetStreamEntry(demote); b.SetStreamEntry(promote); a.Send(); b.Send(); } } } else { AllianceRoleUpdateCommand t = new AllianceRoleUpdateCommand(); AvailableServerCommandMessage ta = new AvailableServerCommandMessage(target.GetClient()); PromoteAllianceMemberOkMessage ru = new PromoteAllianceMemberOkMessage(target.GetClient()); AllianceEventStreamEntry stream = new AllianceEventStreamEntry(); stream.SetId(alliance.GetChatMessages().Count + 1); stream.SetSender(target.GetPlayerAvatar()); stream.SetAvatarId(player.GetId()); stream.SetAvatarName(player.GetAvatarName()); if (m_vRole > oldrole) { stream.SetEventType(5); } else { stream.SetEventType(6); } t.SetAlliance(alliance); t.SetRole(m_vRole); t.Tick(target); ta.SetCommandId(8); ta.SetCommand(t); ru.SetID(target.GetPlayerAvatar().GetId()); ru.SetRole(m_vRole); alliance.AddChatMessage(stream); if (ResourcesManager.IsPlayerOnline(target)) { ta.Send(); ru.Send(); } // New function for send a message foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level aplayer = ResourcesManager.GetPlayer(op.GetAvatarId()); if (aplayer.GetClient() != null) { AllianceStreamEntryMessage b = new AllianceStreamEntryMessage(aplayer.GetClient()); b.SetStreamEntry(stream); PacketManager.Send(b); } } } } } }
private static void OnGameStartFakeAttackMessageReceived(GameStartFakeAttackMessage message) { if (GameSessionManager.TryGet(message.SessionId, out GameSession session)) { if (message.AccountId != null) { ServerRequestManager.Create(new GameAvatarRequestMessage { AccountId = message.AccountId }, ServerManager.GetDocumentSocket(9, message.AccountId)).OnComplete = args => { if (session.IsDestructed()) { return; } if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success) { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { GameAvatarResponseMessage gameAvatarResponseMessage = (GameAvatarResponseMessage)args.ResponseMessage; GameDocument document = gameAvatarResponseMessage.Document; AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = document.LogicClientHome, HomeOwnerAvatar = document.LogicClientAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = document.SaveTime, MaintenanceTime = document.MaintenanceTime }; } } else { AttackHomeFailedMessage attackHomeFailedMessage = new AttackHomeFailedMessage(); attackHomeFailedMessage.SetReason(AttackHomeFailedMessage.Reason.GENERIC); session.SendPiranhaMessage(attackHomeFailedMessage, 1); } }; } else { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = GameBaseGenerator.GenerateBase((LogicGameObjectData)message.ArgData), HomeOwnerAvatar = GameBaseGenerator.HomeOwnerAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = TimeUtil.GetTimestamp(), MaintenanceTime = -1 }; } } } }
public override void Process(Level level) { EditClanSettingsMessage clanSettingsMessage = this; try { Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (alliance != null) { if (clanSettingsMessage.m_vAllianceDescription.Length < 259 || clanSettingsMessage.m_vAllianceDescription.Length < 0) { if (clanSettingsMessage.m_vAllianceBadgeData < 1 || (long)clanSettingsMessage.m_vAllianceBadgeData < 10000000000L) { if (clanSettingsMessage.m_vAllianceType < 0 || clanSettingsMessage.m_vAllianceType < 10) { if (clanSettingsMessage.m_vRequiredScore < 0 || clanSettingsMessage.m_vRequiredScore < 4201) { if (clanSettingsMessage.m_vWarFrequency < 0 || clanSettingsMessage.m_vWarFrequency < 10) { if (clanSettingsMessage.m_vAllianceOrigin < 0 || clanSettingsMessage.m_vAllianceOrigin < 42000000) { if ((int)clanSettingsMessage.m_vWarAndFriendlyStatus < 0 || (int)clanSettingsMessage.m_vWarAndFriendlyStatus < 5) { alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus); ClientAvatar avatar = level.GetPlayerAvatar(); avatar.GetAllianceId(); AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(10); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); eventStreamEntry.SetSenderId(avatar.GetId()); eventStreamEntry.SetSenderName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); AllianceSettingChangedCommand Command = new AllianceSettingChangedCommand(); Command.SetAlliance(alliance); Command.SetPlayer(level); var availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient()); availableServerCommandMessage.SetCommandId(6); availableServerCommandMessage.SetCommand(Command); availableServerCommandMessage.Send(); foreach (AllianceMemberEntry allianceMember in alliance.GetAllianceMembers()) { Level player = ResourcesManager.GetPlayer(allianceMember.GetAvatarId(), false); if (ResourcesManager.IsPlayerOnline(player)) { var p = new AllianceStreamEntryMessage(player.GetClient()); AllianceEventStreamEntry eventStreamEntry1 = eventStreamEntry; p.SetStreamEntry(eventStreamEntry1); p.Send(); } } List <AllianceMemberEntry> .Enumerator enumerator = new List <AllianceMemberEntry> .Enumerator(); DatabaseManager.Instance.Save(alliance); eventStreamEntry = (AllianceEventStreamEntry)null; } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } else { ResourcesManager.DisconnectClient(clanSettingsMessage.Client); } } alliance = (Alliance)null; } catch (Exception ex) { } }
public override PiranhaMessage CreateMessageByType(int type) { PiranhaMessage message = null; if (type < 20000) { switch (type) { case ClientCryptoErrorMessage.MESSAGE_TYPE: { message = new ClientCryptoErrorMessage(); break; } case ClientHelloMessage.MESSAGE_TYPE: { message = new ClientHelloMessage(); break; } case LoginMessage.MESSAGE_TYPE: { message = new LoginMessage(); break; } case KeepAliveMessage.MESSAGE_TYPE: { message = new KeepAliveMessage(); break; } case SetDeviceTokenMessage.MESSAGE_TYPE: { message = new SetDeviceTokenMessage(); break; } case ResetAccountMessage.MESSAGE_TYPE: { message = new ResetAccountMessage(); break; } case ReportUserMessage.MESSAGE_TYPE: { message = new ReportUserMessage(); break; } case AccountSwitchedMessage.MESSAGE_TYPE: { message = new AccountSwitchedMessage(); break; } case UnlockAccountMessage.MESSAGE_TYPE: { message = new UnlockAccountMessage(); break; } case AppleBillingRequestMessage.MESSAGE_TYPE: { message = new AppleBillingRequestMessage(); break; } case ChangeAvatarNameMessage.MESSAGE_TYPE: { message = new ChangeAvatarNameMessage(); break; } case AcceptFriendMessage.MESSAGE_TYPE: { message = new AcceptFriendMessage(); break; } case AddFriendMessage.MESSAGE_TYPE: { message = new AddFriendMessage(); break; } case AskForFriendListMessage.MESSAGE_TYPE: { message = new AskForFriendListMessage(); break; } case RemoveFriendMessage.MESSAGE_TYPE: { message = new RemoveFriendMessage(); break; } case StartFriendLiveSpectateMessage.MESSAGE_TYPE: { message = new StartFriendLiveSpectateMessage(); break; } case InboxOpenedMessage.MESSAGE_TYPE: { message = new InboxOpenedMessage(); break; } case GoHomeMessage.MESSAGE_TYPE: { message = new GoHomeMessage(); break; } case EndClientTurnMessage.MESSAGE_TYPE: { message = new EndClientTurnMessage(); break; } case CancelMatchmakingMessage.MESSAGE_TYPE: { message = new CancelMatchmakingMessage(); break; } case AttackHomeMessage.MESSAGE_TYPE: { message = new AttackHomeMessage(); break; } case StartFriendlyChallengeSpectateMessage.MESSAGE_TYPE: { message = new StartFriendlyChallengeSpectateMessage(); break; } case ScoutFriendlyBattleMessage.MESSAGE_TYPE: { message = new ScoutFriendlyBattleMessage(); break; } case VisitHomeMessage.MESSAGE_TYPE: { message = new VisitHomeMessage(); break; } case HomeBattleReplayMessage.MESSAGE_TYPE: { message = new HomeBattleReplayMessage(); break; } case AttackMatchedHomeMessage.MESSAGE_TYPE: { message = new AttackMatchedHomeMessage(); break; } case AcceptFriendlyBattleMessage.MESSAGE_TYPE: { message = new AcceptFriendlyBattleMessage(); break; } case CancelChallengeMessage.MESSAGE_TYPE: { message = new CancelChallengeMessage(); break; } case AttackNpcMessage.MESSAGE_TYPE: { message = new AttackNpcMessage(); break; } case DuelNpcMessage.MESSAGE_TYPE: { message = new DuelNpcMessage(); break; } case BindGoogleServiceAccountMessage.MESSAGE_TYPE: { message = new BindGoogleServiceAccountMessage(); break; } case BindFacebookAccountMessage.MESSAGE_TYPE: { message = new BindFacebookAccountMessage(); break; } case CreateAllianceMessage.MESSAGE_TYPE: { message = new CreateAllianceMessage(); break; } case AskForAllianceDataMessage.MESSAGE_TYPE: { message = new AskForAllianceDataMessage(); break; } case AskForJoinableAlliancesListMessage.MESSAGE_TYPE: { message = new AskForJoinableAlliancesListMessage(); break; } case JoinAllianceMessage.MESSAGE_TYPE: { message = new JoinAllianceMessage(); break; } case ChangeAllianceMemberRoleMessage.MESSAGE_TYPE: { message = new ChangeAllianceMemberRoleMessage(); break; } case LeaveAllianceMessage.MESSAGE_TYPE: { message = new LeaveAllianceMessage(); break; } case DonateAllianceUnitMessage.MESSAGE_TYPE: { message = new DonateAllianceUnitMessage(); break; } case ChatToAllianceStreamMessage.MESSAGE_TYPE: { message = new ChatToAllianceStreamMessage(); break; } case ChangeAllianceSettingsMessage.MESSAGE_TYPE: { message = new ChangeAllianceSettingsMessage(); break; } case RequestJoinAllianceMessage.MESSAGE_TYPE: { message = new RequestJoinAllianceMessage(); break; } case RespondToAllianceJoinRequestMessage.MESSAGE_TYPE: { message = new RespondToAllianceJoinRequestMessage(); break; } case SendAllianceInvitationMessage.MESSAGE_TYPE: { message = new SendAllianceInvitationMessage(); break; } case JoinAllianceUsingInvitationMessage.MESSAGE_TYPE: { message = new JoinAllianceUsingInvitationMessage(); break; } case SearchAlliancesMessage.MESSAGE_TYPE: { message = new SearchAlliancesMessage(); break; } case AskForAvatarProfileMessage.MESSAGE_TYPE: { message = new AskForAvatarProfileMessage(); break; } case AskForAllianceBookmarksFullDataMessage.MESSAGE_TYPE: { message = new AskForAllianceBookmarksFullDataMessage(); break; } case AddAllianceBookmarkMessage.MESSAGE_TYPE: { message = new AddAllianceBookmarkMessage(); break; } case RemoveAllianceBookmarkMessage.MESSAGE_TYPE: { message = new RemoveAllianceBookmarkMessage(); break; } case AskForAllianceRankingListMessage.MESSAGE_TYPE: { message = new AskForAllianceRankingListMessage(); break; } case AskForAvatarRankingListMessage.MESSAGE_TYPE: { message = new AskForAvatarRankingListMessage(); break; } case AskForAvatarLocalRankingListMessage.MESSAGE_TYPE: { message = new AskForAvatarLocalRankingListMessage(); break; } case AskForAvatarLastSeasonRankingListMessage.MESSAGE_TYPE: { message = new AskForAvatarLastSeasonRankingListMessage(); break; } case AskForAvatarDuelLastSeasonRankingListMessage.MESSAGE_TYPE: { message = new AskForAvatarDuelLastSeasonRankingListMessage(); break; } case RemoveAvatarStreamEntryMessage.MESSAGE_TYPE: { message = new RemoveAvatarStreamEntryMessage(); break; } case AskForLeagueMemberListMessage.MESSAGE_TYPE: { message = new AskForLeagueMemberListMessage(); break; } case BattleEndClientTurnMessage.MESSAGE_TYPE: { message = new BattleEndClientTurnMessage(); break; } case AvatarNameCheckRequestMessage.MESSAGE_TYPE: { message = new AvatarNameCheckRequestMessage(); break; } case SendGlobalChatLineMessage.MESSAGE_TYPE: { message = new SendGlobalChatLineMessage(); break; } case Village2AttackStartSpectateMessage.MESSAGE_TYPE: { message = new Village2AttackStartSpectateMessage(); break; } } } else { switch (type) { case SetEncryptionMessage.MESSAGE_TYPE: { message = new ExtendedSetEncryptionMessage(); break; } case ServerHelloMessage.MESSAGE_TYPE: { message = new ServerHelloMessage(); break; } case LoginFailedMessage.MESSAGE_TYPE: { message = new LoginFailedMessage(); break; } case LoginOkMessage.MESSAGE_TYPE: { message = new LoginOkMessage(); break; } case FriendListMessage.MESSAGE_TYPE: { message = new FriendListMessage(); break; } case FriendListUpdateMessage.MESSAGE_TYPE: { message = new FriendListUpdateMessage(); break; } case KeepAliveServerMessage.MESSAGE_TYPE: { message = new KeepAliveServerMessage(); break; } case AddFriendErrorMessage.MESSAGE_TYPE: { message = new AddFriendErrorMessage(); break; } case ReportUserStatusMessage.MESSAGE_TYPE: { message = new ReportUserStatusMessage(); break; } case UnlockAccountOkMessage.MESSAGE_TYPE: { message = new UnlockAccountOkMessage(); break; } case UnlockAccountFailedMessage.MESSAGE_TYPE: { message = new UnlockAccountFailedMessage(); break; } case AppleBillingProcessedByServerMessage.MESSAGE_TYPE: { message = new AppleBillingProcessedByServerMessage(); break; } case ShutdownStartedMessage.MESSAGE_TYPE: { message = new ShutdownStartedMessage(); break; } case PersonalBreakStartedMessage.MESSAGE_TYPE: { message = new PersonalBreakStartedMessage(); break; } case FacebookAccountBoundMessage.MESSAGE_TYPE: { message = new FacebookAccountBoundMessage(); break; } case AvatarNameChangeFailedMessage.MESSAGE_TYPE: { message = new AvatarNameChangeFailedMessage(); break; } case AvatarOnlineStatusUpdated.MESSAGE_TYPE: { message = new AvatarOnlineStatusUpdated(); break; } case AvatarOnlineStatusListMessage.MESSAGE_TYPE: { message = new AvatarOnlineStatusListMessage(); break; } case AllianceOnlineStatusUpdatedMessage.MESSAGE_TYPE: { message = new AllianceOnlineStatusUpdatedMessage(); break; } case GoogleServiceAccountBoundMessage.MESSAGE_TYPE: { message = new GoogleServiceAccountBoundMessage(); break; } case GoogleServiceAccountAlreadyBoundMessage.MESSAGE_TYPE: { message = new GoogleServiceAccountAlreadyBoundMessage(); break; } case AvatarNameCheckResponseMessage.MESSAGE_TYPE: { message = new AvatarNameCheckResponseMessage(); break; } case AcceptFriendErrorMessage.MESSAGE_TYPE: { message = new AcceptFriendErrorMessage(); break; } case OwnHomeDataMessage.MESSAGE_TYPE: { message = new OwnHomeDataMessage(); break; } case AttackHomeFailedMessage.MESSAGE_TYPE: { message = new AttackHomeFailedMessage(); break; } case OutOfSyncMessage.MESSAGE_TYPE: { message = new OutOfSyncMessage(); break; } case EnemyHomeDataMessage.MESSAGE_TYPE: { message = new EnemyHomeDataMessage(); break; } case AvailableServerCommandMessage.MESSAGE_TYPE: { message = new AvailableServerCommandMessage(); break; } case WaitingToGoHomeMessage.MESSAGE_TYPE: { message = new WaitingToGoHomeMessage(); break; } case VisitedHomeDataMessage.MESSAGE_TYPE: { message = new VisitedHomeDataMessage(); break; } case HomeBattleReplayDataMessage.MESSAGE_TYPE: { message = new HomeBattleReplayDataMessage(); break; } case ServerErrorMessage.MESSAGE_TYPE: { message = new ServerErrorMessage(); break; } case HomeBattleReplayFailedMessage.MESSAGE_TYPE: { message = new HomeBattleReplayFailedMessage(); break; } case LiveReplayHeaderMessage.MESSAGE_TYPE: { message = new LiveReplayHeaderMessage(); break; } case LiveReplayDataMessage.MESSAGE_TYPE: { message = new LiveReplayDataMessage(); break; } case ChallengeFailedMessage.MESSAGE_TYPE: { message = new ChallengeFailedMessage(); break; } case VisitFailedMessage.MESSAGE_TYPE: { message = new VisitFailedMessage(); break; } case AttackSpectatorCountMessage.MESSAGE_TYPE: { message = new AttackSpectatorCountMessage(); break; } case LiveReplayEndMessage.MESSAGE_TYPE: { message = new LiveReplayEndMessage(); break; } case LiveReplayFailedMessage.MESSAGE_TYPE: { message = new LiveReplayFailedMessage(); break; } case NpcDataMessage.MESSAGE_TYPE: { message = new NpcDataMessage(); break; } case AllianceDataMessage.MESSAGE_TYPE: { message = new AllianceDataMessage(); break; } case AllianceJoinFailedMessage.MESSAGE_TYPE: { message = new AllianceJoinFailedMessage(); break; } case JoinableAllianceListMessage.MESSAGE_TYPE: { message = new JoinableAllianceListMessage(); break; } case AllianceListMessage.MESSAGE_TYPE: { message = new AllianceListMessage(); break; } case AllianceStreamMessage.MESSAGE_TYPE: { message = new AllianceStreamMessage(); break; } case AllianceStreamEntryMessage.MESSAGE_TYPE: { message = new AllianceStreamEntryMessage(); break; } case AllianceStreamEntryRemovedMessage.MESSAGE_TYPE: { message = new AllianceStreamEntryRemovedMessage(); break; } case AllianceJoinRequestOkMessage.MESSAGE_TYPE: { message = new AllianceJoinRequestOkMessage(); break; } case AllianceJoinRequestFailedMessage.MESSAGE_TYPE: { message = new AllianceJoinRequestFailedMessage(); break; } case AllianceInvitationSendFailedMessage.MESSAGE_TYPE: { message = new AllianceInvitationSendFailedMessage(); break; } case AllianceInvitationSentOkMessage.MESSAGE_TYPE: { message = new AllianceInvitationSentOkMessage(); break; } case AllianceFullEntryUpdateMessage.MESSAGE_TYPE: { message = new AllianceFullEntryUpdateMessage(); break; } case AllianceWarSearchDataMessage.MESSAGE_TYPE: { message = new AllianceWarSearchDataMessage(); break; } case AllianceWarDataMessage.MESSAGE_TYPE: { message = new AllianceWarDataMessage(); break; } case AllianceCreateFailedMessage.MESSAGE_TYPE: { message = new AllianceCreateFailedMessage(); break; } case AvatarProfileMessage.MESSAGE_TYPE: { message = new AvatarProfileMessage(); break; } case AllianceWarFullEntryMessage.MESSAGE_TYPE: { message = new AllianceWarFullEntryMessage(); break; } case AllianceWarDataFailedMessage.MESSAGE_TYPE: { message = new AllianceWarDataFailedMessage(); break; } case AllianceWarHistoryMessage.MESSAGE_TYPE: { message = new AllianceWarHistoryMessage(); break; } case AvatarProfileFailedMessage.MESSAGE_TYPE: { message = new AvatarProfileFailedMessage(); break; } case BookmarksListMessage.MESSAGE_TYPE: { message = new BookmarksListMessage(); break; } case AllianceBookmarksFullDataMessage.MESSAGE_TYPE: { message = new AllianceBookmarksFullDataMessage(); break; } case Village2AttackEntryListMessage.MESSAGE_TYPE: { message = new Village2AttackEntryListMessage(); break; } case Village2AttackEntryUpdateMessage.MESSAGE_TYPE: { message = new Village2AttackEntryUpdateMessage(); break; } case Village2AttackEntryAddedMessage.MESSAGE_TYPE: { message = new Village2AttackEntryAddedMessage(); break; } case Village2AttackEntryRemovedMessage.MESSAGE_TYPE: { message = new Village2AttackEntryRemovedMessage(); break; } case AllianceRankingListMessage.MESSAGE_TYPE: { message = new AllianceRankingListMessage(); break; } case AllianceLocalRankingListMessage.MESSAGE_TYPE: { message = new AllianceLocalRankingListMessage(); break; } case AvatarRankingListMessage.MESSAGE_TYPE: { message = new AvatarRankingListMessage(); break; } case AvatarLocalRankingListMessage.MESSAGE_TYPE: { message = new AvatarLocalRankingListMessage(); break; } case AvatarLastSeasonRankingListMessage.MESSAGE_TYPE: { message = new AvatarLastSeasonRankingListMessage(); break; } case AvatarDuelLocalRankingListMessage.MESSAGE_TYPE: { message = new AvatarDuelLocalRankingListMessage(); break; } case AvatarDuelLastSeasonRankingListMessage.MESSAGE_TYPE: { message = new AvatarDuelLastSeasonRankingListMessage(); break; } case AvatarDuelRankingListMessage.MESSAGE_TYPE: { message = new AvatarDuelRankingListMessage(); break; } case AvatarStreamMessage.MESSAGE_TYPE: { message = new AvatarStreamMessage(); break; } case AvatarStreamEntryMessage.MESSAGE_TYPE: { message = new AvatarStreamEntryMessage(); break; } case AvatarStreamEntryRemovedMessage.MESSAGE_TYPE: { message = new AvatarStreamEntryRemovedMessage(); break; } case LeagueMemberListMessage.MESSAGE_TYPE: { message = new LeagueMemberListMessage(); break; } case GlobalChatLineMessage.MESSAGE_TYPE: { message = new GlobalChatLineMessage(); break; } case AllianceWarEventMessage.MESSAGE_TYPE: { message = new AllianceWarEventMessage(); break; } case FriendlyScoutHomeDataMessage.MESSAGE_TYPE: { message = new FriendlyScoutHomeDataMessage(); break; } case Village2AttackAvatarDataMessage.MESSAGE_TYPE: { message = new Village2AttackAvatarDataMessage(); break; } case AttackEventMessage.MESSAGE_TYPE: { message = new AttackEventMessage(); break; } case TitanDisconnectedMessage.MESSAGE_TYPE: { message = new DisconnectedMessage(); break; } case CryptoErrorMessage.MESSAGE_TYPE: { message = new CryptoErrorMessage(); break; } } } return(message); }
public override void Process(Level level) { var avatar = level.GetPlayerAvatar(); var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (avatar.GetAllianceRole() == 2 && alliance.GetAllianceMembers().Count > 1) { var members = alliance.GetAllianceMembers(); foreach (AllianceMemberEntry player in members.Where(player => player.GetRole() >= 3)) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(ResourcesManager.GetPlayer(player.GetAvatarId()))) { var c = new AllianceRoleUpdateCommand(); c.SetAlliance(alliance); c.SetRole(2); c.Tick(level); var d = new AvailableServerCommandMessage(ResourcesManager.GetPlayer(player.GetAvatarId()).GetClient()); d.SetCommandId(8); d.SetCommand(c); d.Send(); } done = true; break; } if (!done) { var count = alliance.GetAllianceMembers().Count; var rnd = new Random(); var id = rnd.Next(1, count); while (id != level.GetPlayerAvatar().GetId()) { id = rnd.Next(1, count); } var loop = 0; foreach (AllianceMemberEntry player in members) { loop++; if (loop == id) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(ResourcesManager.GetPlayer(player.GetAvatarId()))) { var e = new AllianceRoleUpdateCommand(); e.SetAlliance(alliance); e.SetRole(2); e.Tick(level); var f = new AvailableServerCommandMessage(ResourcesManager.GetPlayer(player.GetAvatarId()).GetClient()); f.SetCommandId(8); f.SetCommand(e); f.Send(); } break; } } } } var a = new LeavedAllianceCommand(); a.SetAlliance(alliance); a.SetReason(1); var b = new AvailableServerCommandMessage(Client); b.SetCommandId(2); b.SetCommand(a); b.Send(); alliance.RemoveMember(avatar.GetId()); avatar.SetAllianceId(0); if (alliance.GetAllianceMembers().Count > 0) { var eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(4); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers()) { if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == alliance.GetAllianceId()) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(onlinePlayer.GetClient()); p.SetStreamEntry(eventStreamEntry); p.Send(); } } } else { DatabaseManager.Single().RemoveAlliance(alliance); } new LeaveAllianceOkMessage(Client, alliance).Send(); }
public override async void Process(Level level) { try { Alliance a = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); StreamEntry message = a.GetChatMessages().Find(c => c.GetId() == MessageID); Level requester = await ResourcesManager.GetPlayer(message.GetSenderId()); if (Choice == 1) { if (!a.IsAllianceFull()) { requester.GetPlayerAvatar().SetAllianceId(a.GetAllianceId()); AllianceMemberEntry member = new AllianceMemberEntry(requester.GetPlayerAvatar().GetId()); member.SetRole(1); a.AddAllianceMember(member); StreamEntry e = a.GetChatMessages().Find(c => c.GetId() == MessageID); e.SetJudgeName(level.GetPlayerAvatar().GetAvatarName()); e.SetState(2); AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId(a.GetChatMessages().Count + 1); eventStreamEntry.SetSender(requester.GetPlayerAvatar()); eventStreamEntry.SetAvatarName(level.GetPlayerAvatar().GetAvatarName()); eventStreamEntry.SetAvatarId(level.GetPlayerAvatar().GetId()); eventStreamEntry.SetEventType(2); a.AddChatMessage(eventStreamEntry); foreach (AllianceMemberEntry op in a.GetAllianceMembers()) { Level player = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (player.GetClient() != null) { AllianceStreamEntryMessage c = new AllianceStreamEntryMessage(player.GetClient()); AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(player.GetClient()); p.SetStreamEntry(eventStreamEntry); c.SetStreamEntry(e); PacketProcessor.Send(p); PacketProcessor.Send(c); } } if (ResourcesManager.IsPlayerOnline(requester)) { JoinedAllianceCommand joinAllianceCommand = new JoinedAllianceCommand(); joinAllianceCommand.SetAlliance(a); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(requester.GetClient()); availableServerCommandMessage.SetCommandId(1); availableServerCommandMessage.SetCommand(joinAllianceCommand); AllianceRoleUpdateCommand d = new AllianceRoleUpdateCommand(); d.SetAlliance(a); d.SetRole(4); d.Tick(level); AvailableServerCommandMessage c = new AvailableServerCommandMessage(Client); c.SetCommandId(8); c.SetCommand(d); PacketProcessor.Send(new AnswerJoinRequestAllianceMessage(Client)); PacketProcessor.Send(availableServerCommandMessage); PacketProcessor.Send(c); PacketProcessor.Send(new AllianceStreamMessage(requester.GetClient(), a)); } } } else { StreamEntry e = a.GetChatMessages().Find(c => c.GetId() == MessageID); e.SetJudgeName(level.GetPlayerAvatar().GetAvatarName()); e.SetState(3); foreach (AllianceMemberEntry op in a.GetAllianceMembers()) { Level player = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (player.GetClient() != null) { AllianceStreamEntryMessage c = new AllianceStreamEntryMessage(player.GetClient()); c.SetStreamEntry(e); PacketProcessor.Send(c); } } } } catch (Exception) { } }
public override async void Process(Level level) { try { Alliance alliance = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (alliance != null) { if (m_vAllianceDescription.Length < 259 || m_vAllianceDescription.Length < 0) { if (m_vAllianceBadgeData < 1 || m_vAllianceBadgeData < 10000000000) { if (m_vAllianceType < 0 || m_vAllianceType < 10) { if (m_vRequiredScore < 0 || m_vRequiredScore < 4201) { if (m_vWarFrequency < 0 || m_vWarFrequency < 10) { if (m_vAllianceOrigin < 0 || m_vAllianceOrigin < 42000000) { if (m_vWarAndFriendlyStatus < 0 || m_vWarAndFriendlyStatus < 5) { alliance.SetAllianceDescription(m_vAllianceDescription); alliance.SetAllianceBadgeData(m_vAllianceBadgeData); alliance.SetAllianceType(m_vAllianceType); alliance.SetRequiredScore(m_vRequiredScore); alliance.SetWarFrequency(m_vWarFrequency); alliance.SetAllianceOrigin(m_vAllianceOrigin); alliance.SetWarAndFriendlytStatus(m_vWarAndFriendlyStatus); ClientAvatar avatar = level.GetPlayerAvatar(); long allianceId = avatar.GetAllianceId(); AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(10); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); eventStreamEntry.SetSenderId(avatar.GetId()); eventStreamEntry.SetSenderName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); AllianceSettingChangedCommand edit = new AllianceSettingChangedCommand(); edit.SetAlliance(alliance); edit.SetPlayer(level); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient()); availableServerCommandMessage.SetCommandId(6); availableServerCommandMessage.SetCommand(edit); PacketProcessor.Send(availableServerCommandMessage); foreach (AllianceMemberEntry op in alliance.GetAllianceMembers()) { Level user = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (ResourcesManager.IsPlayerOnline(user)) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(user.GetClient()); p.SetStreamEntry(eventStreamEntry); PacketProcessor.Send(p); } } DatabaseManager.Single().Save(alliance); } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } else { ResourcesManager.DisconnectClient(Client); } } } catch (Exception) { } }
public override async void Process(Level level) { try { ClientAvatar avatar = level.GetPlayerAvatar(); Alliance alliance = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (await avatar.GetAllianceRole() == 2 && alliance.GetAllianceMembers().Count > 1) { List<AllianceMemberEntry> members = alliance.GetAllianceMembers(); foreach (AllianceMemberEntry player in members.Where(player => player.GetRole() >= 3)) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.GetAvatarId()))) { AllianceRoleUpdateCommand c = new AllianceRoleUpdateCommand(); c.SetAlliance(alliance); c.SetRole(2); c.Tick(level); Level l = await ResourcesManager.GetPlayer(player.GetAvatarId()); AvailableServerCommandMessage d = new AvailableServerCommandMessage(l.GetClient()); d.SetCommandId(8); d.SetCommand(c); PacketProcessor.Send(d); } done = true; break; } if (!done) { int count = alliance.GetAllianceMembers().Count; Random rnd = new Random(); int id = rnd.Next(1, count); while (id != level.GetPlayerAvatar().GetId()) id = rnd.Next(1, count); int loop = 0; foreach (AllianceMemberEntry player in members) { loop++; if (loop == id) { player.SetRole(2); if (ResourcesManager.IsPlayerOnline(await ResourcesManager.GetPlayer(player.GetAvatarId()))) { AllianceRoleUpdateCommand e = new AllianceRoleUpdateCommand(); e.SetAlliance(alliance); e.SetRole(2); e.Tick(level); Level l2 = await ResourcesManager.GetPlayer(player.GetAvatarId()); AvailableServerCommandMessage f = new AvailableServerCommandMessage(l2.GetClient()); f.SetCommandId(8); f.SetCommand(e); PacketProcessor.Send(f); } break; } } } } LeavedAllianceCommand a = new LeavedAllianceCommand(); a.SetAlliance(alliance); a.SetReason(1); AvailableServerCommandMessage b = new AvailableServerCommandMessage(Client); b.SetCommandId(2); b.SetCommand(a); PacketProcessor.Send(b); alliance.RemoveMember(avatar.GetId()); avatar.SetAllianceId(0); if (alliance.GetAllianceMembers().Count > 0) { AllianceEventStreamEntry eventStreamEntry = new AllianceEventStreamEntry(); eventStreamEntry.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); eventStreamEntry.SetSender(avatar); eventStreamEntry.SetEventType(4); eventStreamEntry.SetAvatarId(avatar.GetId()); eventStreamEntry.SetAvatarName(avatar.GetAvatarName()); alliance.AddChatMessage(eventStreamEntry); foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers()) if (onlinePlayer.GetPlayerAvatar().GetAllianceId() == alliance.GetAllianceId()) { AllianceStreamEntryMessage p = new AllianceStreamEntryMessage(onlinePlayer.GetClient()); p.SetStreamEntry(eventStreamEntry); PacketProcessor.Send(p); } } else { DatabaseManager.Single().RemoveAlliance(alliance); } PacketProcessor.Send(new LeaveAllianceOkMessage(Client, alliance)); } catch (Exception) { } }
public override async void Process(Level level) { try { Alliance a = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); StreamEntry stream = a.GetChatMessages().Find(c => c.GetId() == MessageID); Level _Sender = await ResourcesManager.GetPlayer(stream.GetSenderId()); int upcomingspace = stream.m_vDonatedTroop + Troop.GetHousingSpace(); if (upcomingspace <= stream.m_vMaxTroop) { DonateAllianceUnitCommand _Donate = new DonateAllianceUnitCommand(); _Donate.SetMessageID(MessageID); _Donate.Tick(level); _Donate.SetUnit(Troop); DonatedAllianceUnitCommand _Donated = new DonatedAllianceUnitCommand(); _Donated.Tick(_Sender); _Donated.SetDonator(level.GetPlayerAvatar().GetAvatarName()); _Donated.SetUnitID(Troop.GetGlobalID()); _Donated.SetUnitLevel(level.GetPlayerAvatar().GetUnitUpgradeLevel(Troop)); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(level.GetClient()); availableServerCommandMessage.SetCommandId(4); availableServerCommandMessage.SetCommand(_Donate); AvailableServerCommandMessage ravailableServerCommandMessage = new AvailableServerCommandMessage(_Sender.GetClient()); ravailableServerCommandMessage.SetCommandId(5); ravailableServerCommandMessage.SetCommand(_Donated); StreamEntry _Stream = a.GetChatMessages().Find(c => c.GetId() == MessageID); Level _PreviousPlayer = await ResourcesManager.GetPlayer(_Stream.GetSenderId()); ClientAvatar _PreviousPlayerAvatar = _PreviousPlayer.GetPlayerAvatar(); _Stream.AddDonatedTroop(level.GetPlayerAvatar().GetId(), Troop.GetGlobalID(), 1, level.GetPlayerAvatar().GetUnitUpgradeLevel(Troop)); int _Capicity = Troop.GetHousingSpace(); _Stream.AddUsedCapicity(_Capicity); _PreviousPlayerAvatar.SetAllianceCastleUsedCapacity(_PreviousPlayerAvatar.GetAllianceCastleUsedCapacity() + _Capicity); _PreviousPlayerAvatar.AddAllianceTroop(level.GetPlayerAvatar().GetId(), Troop.GetGlobalID(), 1, level.GetPlayerAvatar().GetUnitUpgradeLevel(Troop)); //PacketProcessor.Send(availableServerCommandMessage); if (ResourcesManager.IsPlayerOnline(_Sender)) { PacketProcessor.Send(ravailableServerCommandMessage); } foreach (AllianceMemberEntry op in a.GetAllianceMembers()) { Level player = await ResourcesManager.GetPlayer(op.GetAvatarId()); if (player.GetClient() != null) { AllianceStreamEntryMessage c = new AllianceStreamEntryMessage(player.GetClient()); c.SetStreamEntry(_Stream); PacketProcessor.Send(c); } } } } catch (Exception) { } }
public async Task <JObject> ExecuteDebugCommand(int id, [FromQuery(Name = "userId")] long accountId, [FromQuery(Name = "pass")] string passToken) { AccountDocument accountDocument = await UserManager.GetAccount(accountId); if (accountDocument == null) { return(this.BuildResponse(HttpStatusCode.InternalServerError)); } if (this.GetUserRole() <= UserRole.NULL && passToken != accountDocument.PassToken) { return(this.BuildResponse(HttpStatusCode.Forbidden)); } RedisValue currentSession = await ServerAdmin.SessionDatabase.Get(accountDocument.Id); if (currentSession.IsNull) { return(this.BuildResponse(HttpStatusCode.Forbidden).AddAttribute("reason", "No client connected.")); } LogicDebugCommand logicDebugCommand = null; switch ((DebugCommandType)id) { case DebugCommandType.FAST_FORWARD_1_HOUR: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_1_HOUR); break; case DebugCommandType.FAST_FORWARD_24_HOUR: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_24_HOUR); break; case DebugCommandType.ADD_UNITS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_UNITS); break; case DebugCommandType.ADD_RESOURCES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_RESOURCES); break; case DebugCommandType.INCREASE_XP_LEVEL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_XP_LEVEL); break; case DebugCommandType.UPGRADE_ALL_BUILDINGS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_ALL_BUILDINGS); break; case DebugCommandType.COMPLETE_TUTORIAL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_TUTORIAL); break; case DebugCommandType.UNLOCK_MAP: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UNLOCK_MAP); break; case DebugCommandType.SHIELD_TO_HALF: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SHIELD_TO_HALF); break; case DebugCommandType.FAST_FORWARD_1_MIN: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.FAST_FORWARD_1_MIN); break; case DebugCommandType.INCREASE_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_TROPHIES); break; case DebugCommandType.DECREASE_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DECREASE_TROPHIES); break; case DebugCommandType.ADD_ALLIANCE_UNITS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_ALLIANCE_UNITS); break; case DebugCommandType.INCREASE_HERO_LEVELS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.INCREASE_HERO_LEVELS); break; case DebugCommandType.REMOVE_RESOURCES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_RESOURCES); break; case DebugCommandType.RESET_MAP_PROGRESS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_MAP_PROGRESS); break; case DebugCommandType.DEPLOY_ALL_TROOPS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DEPLOY_ALL_TROOPS); break; case DebugCommandType.ADD_100_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_100_TROPHIES); break; case DebugCommandType.REMOVE_100_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_100_TROPHIES); break; case DebugCommandType.UPGRADE_TO_MAX_FOR_TH: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_TO_MAX_FOR_TH); break; case DebugCommandType.REMOVE_UNITS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_UNITS); break; case DebugCommandType.DISARM_TRAPS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.DISARM_TRAPS); break; case DebugCommandType.REMOVE_OBSTACLES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_OBSTACLES); break; case DebugCommandType.RESET_HERO_LEVELS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_HERO_LEVELS); break; case DebugCommandType.COLLECT_WAR_RESOURCES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COLLECT_WAR_RESOURCES); break; case DebugCommandType.SET_RANDOM_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_RANDOM_TROPHIES); break; case DebugCommandType.COMPLETE_WAR_TUTORIAL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_WAR_TUTORIAL); break; case DebugCommandType.ADD_WAR_RESOURCES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_WAR_RESOURCES); break; case DebugCommandType.REMOVE_WAR_RESOURCES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_WAR_RESOURCES); break; case DebugCommandType.RESET_WAR_TUTORIAL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_WAR_TUTORIAL); break; case DebugCommandType.ADD_UNIT: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_UNIT); break; case DebugCommandType.SET_MAX_UNIT_SPELL_LEVELS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_MAX_UNIT_SPELL_LEVELS); break; case DebugCommandType.REMOVE_ALL_AMMO: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_ALL_AMMO); break; case DebugCommandType.RESET_ALL_LAYOUTS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_ALL_LAYOUTS); break; case DebugCommandType.LOCK_CLAN_CASTLE: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.LOCK_CLAN_CASTLE); break; case DebugCommandType.RANDOM_RESOURCES_TROPHY_XP: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RANDOM_RESOURCES_TROPHY_XP); break; case DebugCommandType.LOAD_LEVEL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.LOAD_LEVEL); logicDebugCommand.SetDebugString(UserManager.GetPresetLevel()); break; case DebugCommandType.UPGRADE_BUILDING: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_BUILDING); break; case DebugCommandType.UPGRADE_BUILDINGS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UPGRADE_BUILDINGS); break; case DebugCommandType.ADD_1000_CLAN_XP: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_1000_CLAN_XP); break; case DebugCommandType.RESET_ALL_TUTORIALS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RESET_ALL_TUTORIALS); break; case DebugCommandType.ADD_1000_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_1000_TROPHIES); break; case DebugCommandType.REMOVE_1000_TROPHIES: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.REMOVE_1000_TROPHIES); break; case DebugCommandType.CAUSE_DAMAGE: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.CAUSE_DAMAGE); break; case DebugCommandType.SET_MAX_HERO_LEVELS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.SET_MAX_HERO_LEVELS); break; case DebugCommandType.ADD_PRESET_TROOPS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_PRESET_TROOPS); break; case DebugCommandType.TOGGLE_INVULNERABILITY: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TOGGLE_INVULNERABILITY); break; case DebugCommandType.ADD_GEMS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_GEMS); break; case DebugCommandType.PAUSE_ALL_BOOSTS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.PAUSE_ALL_BOOSTS); break; case DebugCommandType.TRAVEL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TRAVEL); break; case DebugCommandType.TOGGLE_RED: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.TOGGLE_RED); break; case DebugCommandType.COMPLETE_HOME_TUTORIALS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.COMPLETE_HOME_TUTORIALS); break; case DebugCommandType.UNLOCK_SHIPYARD: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.UNLOCK_SHIPYARD); break; case DebugCommandType.GIVE_REENGAGEMENT_LOOT_FOR_30_DAYS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.GIVE_REENGAGEMENT_LOOT_FOR_30_DAYS); break; case DebugCommandType.ADD_FREE_UNITS: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.ADD_FREE_UNITS); break; case DebugCommandType.RANDOM_ALLIANCE_EXP_LEVEL: logicDebugCommand = new LogicDebugCommand(LogicDebugActionType.RANDOM_ALLIANCE_EXP_LEVEL); break; } if (logicDebugCommand == null) { return(this.BuildResponse(HttpStatusCode.InternalServerError)); } long sessionId = long.Parse(currentSession); AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(logicDebugCommand); availableServerCommandMessage.Encode(); ServerMessageManager.SendMessage(new ForwardLogicMessage { MessageType = availableServerCommandMessage.GetMessageType(), MessageLength = availableServerCommandMessage.GetEncodingLength(), MessageVersion = (short)availableServerCommandMessage.GetMessageVersion(), MessageBytes = availableServerCommandMessage.GetByteStream().GetByteArray(), SessionId = sessionId }, ServerManager.GetProxySocket(sessionId)); return(this.BuildResponse(HttpStatusCode.OK)); }
private void OnSendGlobalChatLineMessageReceived(SendGlobalChatLineMessage message) { if (!this.CanSendGlobalChatMessage()) { return; } string chatMessage = StringUtil.RemoveMultipleSpaces(message.RemoveMessage()); if (chatMessage.Length > 0) { if (chatMessage.Length > 128) { chatMessage = chatMessage.Substring(0, 128); } if (chatMessage.StartsWith("/op ")) { string[] args = chatMessage.Trim().Split(' '); if (args.Length < 3) { return; } string commandType = args[1]; string commandName = args[2]; switch (commandType) { case "attack": { if (string.Equals(commandName, "me", StringComparison.InvariantCultureIgnoreCase)) { this.m_session.SendMessage(new GameStartFakeAttackMessage { AccountId = this.m_session.AccountId, ArgData = null }, 9); } else if (commandName.StartsWith("#")) { LogicLong accountId = HashTagCodeGenerator.m_instance.ToId(commandName.ToUpperInvariant()); if (accountId != null) { this.m_session.SendMessage(new GameStartFakeAttackMessage { AccountId = accountId, ArgData = null }, 9); } } else if (string.Equals(commandName, "generate", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length >= 4) { if (int.TryParse(args[3], out int id)) { LogicGameObjectData gameObjectData = null; switch (id / 100) { case 0: LogicBuildingData buildingData = (LogicBuildingData)LogicDataTables.GetDataById(GlobalID.CreateGlobalID((int)LogicDataType.BUILDING + 1, id), LogicDataType.BUILDING); if (buildingData.IsTownHall() || buildingData.IsTownHallVillage2()) { return; } if (!buildingData.IsEnabledInVillageType(0)) { return; } if (buildingData.IsLocked() && !buildingData.IsAllianceCastle()) { return; } gameObjectData = buildingData; break; case 1: gameObjectData = (LogicGameObjectData)LogicDataTables.GetDataById(GlobalID.CreateGlobalID((int)LogicDataType.TRAP + 1, id), LogicDataType.TRAP); break; } if (gameObjectData != null) { this.m_session.SendMessage(new GameStartFakeAttackMessage { AccountId = null, ArgData = gameObjectData }, 9); } } } else { this.m_session.SendMessage(new GameStartFakeAttackMessage { AccountId = null, ArgData = null }, 9); } } break; } case "village": switch (commandName) { case "upgrade": { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicDebugCommand(LogicDebugActionType.UPGRADE_ALL_BUILDINGS)); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); break; } case "obstacle": { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicDebugCommand(LogicDebugActionType.REMOVE_OBSTACLES)); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); break; } case "preset": // TODO: Implement this. break; } break; case "hero": switch (commandName) { case "max": { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicDebugCommand(LogicDebugActionType.SET_MAX_HERO_LEVELS)); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); return; } case "reset": { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicDebugCommand(LogicDebugActionType.RESET_HERO_LEVELS)); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); return; } } break; case "unit": switch (commandName) { case "max": { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicDebugCommand(LogicDebugActionType.SET_MAX_UNIT_SPELL_LEVELS)); this.m_session.SendPiranhaMessage(availableServerCommandMessage, 1); return; } } break; } } else { ServerRequestManager.Create(new AvatarRequestMessage { AccountId = this.m_session.AccountId }, ServerManager.GetDocumentSocket(9, this.m_session.AccountId)).OnComplete = args => { if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success) { this.m_session.ChatInstance.PublishMessage(((AvatarResponseMessage)args.ResponseMessage).LogicClientAvatar, WordCensorUtil.FilterMessage(chatMessage)); this.m_previousGlobalChatMessageTime = DateTime.UtcNow; } }; } } }