/// <summary>
        /// Executes this instance.
        /// </summary>
        internal override void Execute(Level Level)
        {
            if (!Level.GameObjectManager.Bunker.Locked)
            {
                BunkerComponent BunkerComponent = Level.GameObjectManager.Bunker.BunkerComponent;

                if (BunkerComponent.CanSendClanMail)
                {
                    if (!string.IsNullOrWhiteSpace(this.Message))
                    {
                        if (this.Message.Length <= 256)
                        {
                            this.Message = Resources.Regex.Replace(this.Message, " ");

                            if (this.Message.StartsWith(" "))
                            {
                                this.Message = this.Message.Remove(0, 1);
                            }

                            if (this.Message.Length > 0)
                            {
                                foreach (Player Player in Level.Player.Alliance.Members.Connected.Values.ToArray())
                                {
                                    Player.Level.GameMode.GameLogManager.Add(new AllianceMailAvatarStreamEntry(Level.Player, Level.Player.Alliance, this.Message));
                                }
                            }

                            BunkerComponent.ClanMailTimer.StartTimer(Level.GameMode.Time, Globals.ClanMailCooldown);
                        }
                    }
                }
            }
        }
        internal override void Execute()
        {
            Player Player = this.Device.GameMode.Level.Player;

            if (Player.InAlliance)
            {
                Building Bunker = this.Device.GameMode.Level.GameObjectManager.Bunker;
                if (Bunker != null)
                {
                    BunkerComponent BunkerComponent = Bunker.BunkerComponent;
                    if (BunkerComponent != null)
                    {
                        if (!BunkerComponent.CanSendUnitRequest)
                        {
                            int RemainingSeconds = BunkerComponent.UnitRequestTimer.GetRemainingSeconds(Player.LastTick);

                            if (RemainingSeconds > 0)
                            {
                                int Cost = GamePlayUtil.GetSpeedUpCost(RemainingSeconds, 0, Globals.TroopRequestSpeedUpCostMultiplier);

                                if (Cost > 0)
                                {
                                    if (Player.HasEnoughDiamonds(Cost))
                                    {
                                        Player.UseDiamonds(Cost);
                                        BunkerComponent.UnitRequestTimer = null;
                                    }
                                }
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to speed up the troop request. The player BunkerComponent.CanSendUnitRequest returned true!");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to speed up the troop request. The player BunkerComponent is null!");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to speed up the troop request. The player doesn't have a bunker!");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to speed up the troop request. The player is not in a clan!");
            }
        }
Ejemplo n.º 3
0
        internal override void Execute()
        {
            Level Level = this.Device.GameMode.Level;

            if (!Level.GameObjectManager.Bunker.Locked)
            {
                BunkerComponent BunkerComponent = Level.GameObjectManager.Bunker.BunkerComponent;
                if (BunkerComponent != null)
                {
                    if (BunkerComponent.CanSendClanMail)
                    {
                        if (!string.IsNullOrWhiteSpace(this.Message))
                        {
                            if (this.Message.Length <= 256)
                            {
                                this.Message = Resources.Regex.Replace(this.Message, " ");

                                if (this.Message.StartsWith(" "))
                                {
                                    this.Message = this.Message.Remove(0, 1);
                                }

                                if (this.Message.Length > 0)
                                {
                                    foreach (Member Member in Level.Player.Alliance.Members.Slots.Values.ToArray())
                                    {
                                        Member.Player.Inbox.Add(
                                            new AllianceMailAvatarStreamEntry(Level.Player, Level.Player.Alliance)
                                        {
                                            Message = this.Message
                                        });
                                    }
                                }

                                BunkerComponent.ClanMailTimer = new Timer();
                                BunkerComponent.ClanMailTimer.StartTimer(Level.Player.LastTick, Globals.ClanMailCooldown);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        internal override void Execute()
        {
            Level  Level  = this.Device.GameMode.Level;
            Player Target = Resources.Accounts.LoadAccount(this.HighId, this.LowId)?.Player;

            if (Level.Player.InAlliance)
            {
                Alliance Alliance = Level.Player.Alliance;
                if (Target != null)
                {
                    if (Target.InAlliance)
                    {
                        if (Target.AllianceId == Level.Player.AllianceId)
                        {
                            Role ExecutorRole = Level.Player.AllianceMember.Role;
                            if (!string.IsNullOrWhiteSpace(this.Message))
                            {
                                if (this.Message.Length <= 256)
                                {
                                    this.Message = Resources.Regex.Replace(this.Message, " ");

                                    if (this.Message.StartsWith(" "))
                                    {
                                        this.Message = this.Message.Remove(0, 1);
                                    }

                                    if (ExecutorRole == Role.Member)
                                    {
                                        Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executer have a member role!");
                                    }
                                    else if (ExecutorRole == Role.Leader || ExecutorRole == Role.CoLeader)
                                    {
                                        if (Target.AllianceMember.Role.Superior(ExecutorRole))
                                        {
                                            Member Member;
                                            if (Alliance.Members.Quit(Target, out Member))
                                            {
                                                if (Target.Connected)
                                                {
                                                    Target.Level.GameMode.CommandManager.AddCommand(
                                                        new Leaved_Alliance(Target.Level.GameMode.Device)
                                                    {
                                                        AllianceId = Alliance.AllianceId
                                                    });
                                                }
                                                else
                                                {
                                                    Target.AllianceHighId = 0;
                                                    Target.AllianceLowId  = 0;
                                                    Target.AllianceMember = null;
                                                    Target.Alliance       = null;
                                                }

                                                Target.Inbox.Add(
                                                    new AllianceKickOutStreamEntry(Level.Player, Alliance)
                                                {
                                                    Message = this.Message
                                                });

                                                Alliance.Streams.AddEntry(new EventStreamEntry(Member, Level.Player.AllianceMember, AllianceEvent.Kicked));
                                            }
                                            else
                                            {
                                                Logging.Error(this.GetType(), "Unable to kick player from the alliance. The Quit() returned false!");
                                            }
                                        }
                                        else
                                        {
                                            Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor have a lower role than the target!");
                                        }
                                    }
                                    else if (ExecutorRole == Role.Elder)
                                    {
                                        Building Bunker = Level.GameObjectManager.Bunker;
                                        if (Bunker != null)
                                        {
                                            BunkerComponent BunkerComponent = Bunker.BunkerComponent;
                                            if (BunkerComponent != null)
                                            {
                                                if (BunkerComponent.CanElderKick)
                                                {
                                                    if (Target.AllianceMember.Role.Superior(ExecutorRole))
                                                    {
                                                        Member Member;
                                                        if (Alliance.Members.Quit(Target, out Member))
                                                        {
                                                            if (Target.Connected)
                                                            {
                                                                Target.Level.GameMode.CommandManager.AddCommand(
                                                                    new Leaved_Alliance(Target.Level.GameMode.Device)
                                                                {
                                                                    AllianceId = Alliance.AllianceId
                                                                });
                                                            }
                                                            else
                                                            {
                                                                Target.AllianceHighId = 0;
                                                                Target.AllianceLowId  = 0;
                                                                Target.AllianceMember = null;
                                                                Target.Alliance       = null;
                                                            }

                                                            Target.Inbox.Add(
                                                                new AllianceKickOutStreamEntry(Level.Player, Alliance)
                                                            {
                                                                Message = this.Message
                                                            });

                                                            Alliance.Streams.AddEntry(new EventStreamEntry(Member, Level.Player.AllianceMember, AllianceEvent.Kicked));

                                                            BunkerComponent.ElderKickTimer = new Timer();
                                                            BunkerComponent.ElderKickTimer.StartTimer(Level.Player.LastTick, Globals.ElderKickCooldown);
                                                        }
                                                        else
                                                        {
                                                            Logging.Error(this.GetType(), "Unable to kick player from the alliance. The Quit() returned false!");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor have a lower role than the target!");
                                                    }
                                                }
                                                else
                                                {
                                                    Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor is still in cooldown mode!");
                                                }
                                            }
                                            else
                                            {
                                                Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor BunkerComponent is null!");
                                            }
                                        }
                                        else
                                        {
                                            Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor doesn't have bunker!");
                                        }
                                    }
                                    else
                                    {
                                        Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor doesn't have any recognisable role!");
                                    }
                                }
                                else
                                {
                                    Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor send a message that beyond the size limit!");
                                }
                            }
                            else
                            {
                                Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor send a message that is null or whitespace!");
                            }
                        }
                        else
                        {
                            Logging.Error(this.GetType(), "Unable to kick player from the alliance. The player and the executer is not in the same clan!");
                        }
                    }
                    else
                    {
                        Logging.Error(this.GetType(), "Unable to kick player from the alliance. The player is not in a clan!");
                    }
                }
                else
                {
                    Logging.Error(this.GetType(), "Unable to kick player from the alliance. The player is null!");
                }
            }
            else
            {
                Logging.Error(this.GetType(), "Unable to kick player from the alliance. The executor clan is null!");
            }
        }