Example #1
0
 public void HandleCommand(ClientConnection pConnection, string pCommand, string[] pArguments)
 {
     if (CommandHandlers.ContainsKey(pCommand))
     {
         CommandHandlers[pCommand](pConnection, pArguments);
     }
 }
Example #2
0
 public static void Initialize()
 {
     CommandHandlers.Register("InitAuction", AccessLevel.Administrator, new CommandEventHandler(OnInitAuction));
     CommandHandlers.Register("MyAuction", AccessLevel.Player, new CommandEventHandler(OnMyAuction));
     CommandHandlers.Register("Auction", AccessLevel.GameMaster, new CommandEventHandler(OnAuction));
     CommandHandlers.Register("AuctionAdmin", AccessLevel.Administrator, new CommandEventHandler(OnAuctionAdmin));
 }
Example #3
0
            protected override void OnTick()
            {
                count--;

                if (m_TournamentStone != null && m_TournamentStone.Started)
                {
                    if (count <= 0)
                    {
                        if (m_TournamentStone.Contestants.Count >= 2)
                        {
                            CommandHandlers.BroadcastMessage(AccessLevel.Player, 38, "An automated tournament has begun");
                            m_TournamentStone.AcceptingContestants = false;
                            m_TournamentStone.AddFighters(true);
                            Stop();
                        }
                        else
                        {
                            TournamentCore.SendMessage(m_TournamentStone.Contestants, "Not enough players joined, ending tournament");
                            m_TournamentStone.EndTournament(false);
                            Stop();
                        }
                    }
                    else if (count <= 10)
                    {
                        CommandHandlers.BroadcastMessage(AccessLevel.Player, 38, string.Format("An automated and supplied 1v1 tournament will start in {0} minute{1}! Type .jointour to join or .watchtour to watch", count, count == 1 ? "" : "s"));
                    }
                }
                else
                {
                    Stop();
                }
            }
Example #4
0
        public ValorRewardController()
            : base(0xEDC)
        {
            Name         = "Rewards Controller";
            Movable      = false;
            Visible      = false;
            MTitle       = new TitleCollection();
            _mValorItems = new ValorItemCollection();
            Categories   = new Dictionary <int, string>
            {
                { 0, "Titles" }
            };

            if (_mInstance != null)
            {
                // there can only be one RewardController game stone in the world
                _mInstance.Location = Location;
                CommandHandlers.BroadcastMessage(
                    AccessLevel.GameMaster, 0x489, "Existing Title Controller has been moved to this location (DON'T DELETE IT!).");
                Timer.DelayCall(TimeSpan.FromSeconds(1), UpdateInstancePosition, this);
            }
            else
            {
                _mInstance = this;
            }
        }
        public DynamicSettingsController()
            : base(0xEDC)
        {
            Name = "Dynamic Settings Controller";

            Movable = false;
            Visible = false;

            if (Instance != null && Instance != this)
            {
                // there can only be one DynamicSettingsController game stone in the world
                Instance.Location = Location;

                CommandHandlers.BroadcastMessage(
                    AccessLevel.Administrator,
                    1161,
                    "Existing DynamicSettingsController has been moved to this location.");

                Timer.DelayCall(TimeSpan.FromSeconds(1), UpdateInstancePosition, this);
            }
            else
            {
                Instance = this;
            }
        }
Example #6
0
            public CountdownTimer(TournamentStone stone) : base(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))
            {
                m_TournamentStone = stone;
                count             = m_TournamentStone.StartDelay;

                CommandHandlers.BroadcastMessage(AccessLevel.Player, 38, string.Format("An automated and supplied 1v1 tournament will start in {0} minute{1}! Type .jointour to join or .watchtour to watch", count, count == 1 ? "" : "s"));
            }
Example #7
0
        public static void Initialize()
        {
            if (Core.UOSP)
            {
                if (Core.NewEthics)
                {
                    if (Core.Factions)
                    {
                        if (Core.Ethics)
                        {
                            EventSink.Speech += new SpeechEventHandler(EventSink_Speech);
                        }
                    }
                }
                else
                {
                    // stand alone ethics
                    EventSink.Speech += new SpeechEventHandler(EventSink_Speech);
                }
            }

            // Removes the ethic alignment from the targeted player.
            CommandHandlers.Register("RemoveEthic", AccessLevel.GameMaster, new CommandEventHandler(RemoveEthic_OnCommand));
            CommandHandlers.Register("MakeHero", AccessLevel.GameMaster, new CommandEventHandler(MakeHero_OnCommand));
            CommandHandlers.Register("MakeEvil", AccessLevel.GameMaster, new CommandEventHandler(MakeEvil_OnCommand));
        }
Example #8
0
        private void Start()
        {
            Application.targetFrameRate = 60;
            InitialBalls = 80;

            SetupDebugConsole();

            // This is a static class that contains some tweaks
            BallGameGeneralCommandHandlers.Initialize();

            // Register the command handlers in this instance (i.e. non-static command handlers)
            CommandHandlers.RegisterCommandHandlers(this);

            _gameOverUI.Setup(this);
            _hud.Setup(this);

            _ballPrefab.SetActive(false);

            foreach (var ballSpawner in _ballSpawners)
            {
                ballSpawner.Setup(this, _ballPrefab);
            }

            BeginGame();
        }
Example #9
0
        public async Task RoverInstructionsCommandWithValidRoverSucceeds()
        {
            var mapGridMock = new Mock <IMapGrid>();

            mapGridMock.Setup(x => x.Width).Returns(10);
            mapGridMock.Setup(x => x.Height).Returns(10);
            var roversMgrMock = new Mock <IRoversManager>();
            var roverMock     = new Mock <IRover>();

            roverMock.Setup(x => x.X).Returns(1);
            roverMock.Setup(x => x.Y).Returns(1);
            roverMock.Setup(x => x.Orientation).Returns(OrientationEnum.N);
            roverMock.Setup(x => x.ExecuteInstruction(It.IsAny <char>())).Verifiable();
            roversMgrMock.Setup(x => x.ActiveRover).Returns(roverMock.Object);
            var cmdMock = new Mock <RoverInstructionsCommand>();

            cmdMock.Setup(x => x.Instructions).Returns(new List <char>("XX"));
            var handler       = new CommandHandlers(mapGridMock.Object, roversMgrMock.Object);
            var consoleOutput = new StringWriter();

            Console.SetOut(consoleOutput);

            await handler.Handle(cmdMock.Object, new CancellationToken());

            roverMock.Verify(x => x.ExecuteInstruction(It.IsAny <char>()), Times.Exactly(2));
            roverMock.Object.Lost.Should().BeFalse();
            consoleOutput.ToString().Should().Be("1 1 N\r\n");
        }
        public HalloweenEventController()
            : base(0xEDC)
        {
            Name = "Halloween Event Settings Controller";

            Movable = false;
            Visible = false;

            Hue = 1358;

            if (Instance != null && Instance != this)
            {
                // there can only be one seasonal event controller game stone in the world
                Instance.Location = Location;

                CommandHandlers.BroadcastMessage(
                    AccessLevel.Seer,
                    1161,
                    "Existing Halloween Event Controller has been moved to this location.");

                Timer.DelayCall(TimeSpan.FromSeconds(1), UpdateInstancePosition, this);
            }
            else
            {
                Instance = this;
            }
        }
        private static void ConfigureAutofac()
        {
            var repository = new InMemoryMovieRepository();
            var bus        = new MessageBus();

            bus.Register <CreateMovie>(x => CommandHandlers.Handle(() => bus, x));
            bus.Register <ChangeMovieTitle>(x => CommandHandlers.Handle(() => bus, x));

            bus.Register <MovieCreated>(x => EventHandlers.Handle(() => repository, x));
            bus.Register <MovieTitleChanged>(x => EventHandlers.Handle(() => repository, x));

            bus.Send(new CreateMovie(Guid.NewGuid(), "Pupl Fiction", new DateTime(1994, 1, 1), "Crime", 8.5m));

            bus.Send(new CreateMovie(Guid.NewGuid(), "From Dusk Till Dawn", new DateTime(2003, 1, 1), "Action", 8.99m));

            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            builder.RegisterType <MoviesController>()
            .WithParameter("commandSender", bus)
            .WithParameter("movieQueryFacade", repository);

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
 public TSelfInterface WithCommandHandler(
     Func <TEntityDefinition, string> topicPatternSelector,
     Func <MqttCommandContext <TEntity, TEntityDefinition>, string, Task <bool> > commandProcessor)
 {
     CommandHandlers.Add(new DelegateCommandHandler <TEntity, TEntityDefinition>(topicPatternSelector, commandProcessor));
     return((TSelf)this);
 }
        public EasterEventController()
            : base(0xEDC)
        {
            Name = "Easter Event Settings Controller";

            Movable = false;
            Visible = false;

            if (Instance != null && Instance != this)
            {
                // there can only be one seasonal event controller game stone in the world
                Instance.Location = Location;

                CommandHandlers.BroadcastMessage(
                    AccessLevel.Seer,
                    1161,
                    "Existing Easter Event Controller has been moved to this location.");

                Timer.DelayCall(TimeSpan.FromSeconds(1), UpdateInstancePosition, this);
            }
            else
            {
                Instance = this;
            }

            ParticipantList = new Dictionary <PlayerMobile, int>();
            PointList       = new Dictionary <PlayerMobile, int>();
        }
Example #14
0
        public static void Initialize()
        {
            CommandHandlers.Register("OpenEvent", AccessLevel.GameMaster, new CommandEventHandler(OpenEvent_OnCommand));
            CommandHandlers.Register("CloseEvent", AccessLevel.GameMaster, new CommandEventHandler(CloseEvent_OnCommand));

            EventSink.Login += new LoginEventHandler(EventSink_Login);
        }
Example #15
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                switch (info.ButtonID)
                {
                case 1: // RunUO
                {
                    sender.LaunchBrowser("https://github.com/runuo/");
                    break;
                }

                case 2: // List of skills
                {
                    string[] strings = Enum.GetNames(typeof(SkillName));

                    Array.Sort(strings);

                    StringBuilder sb = new StringBuilder();

                    if (strings.Length > 0)
                    {
                        sb.Append(strings[0]);
                    }

                    for (int i = 1; i < strings.Length; ++i)
                    {
                        string v = strings[i];

                        if (sb.Length + 1 + v.Length >= 256)
                        {
                            sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3,
                                                         "System", sb.ToString()));
                            sb = new StringBuilder();
                            sb.Append(v);
                        }
                        else
                        {
                            sb.Append(' ');
                            sb.Append(v);
                        }
                    }

                    if (sb.Length > 0)
                    {
                        sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, "System",
                                                     sb.ToString()));
                    }

                    break;
                }

                case 3: // Command list
                {
                    sender.Mobile.SendAsciiMessage(0x482, "The command prefix is \"{0}\"", CommandSystem.Prefix);
                    CommandHandlers.Help_OnCommand(new CommandEventArgs(sender.Mobile, "help", "", new string[0]));

                    break;
                }
                }
            }
Example #16
0
        public static void Initialize()
        {
#if RunUo2
            CommandSystem.Register("Loot", AccessLevel.Player, new CommandEventHandler(Loot_OnCommand));
#else
            CommandHandlers.Register("Loot", AccessLevel.Player, new CommandEventHandler(Loot_OnCommand));
#endif
        }
        public static void Initialize()
        {
            // alter AccessLevel to be AccessLevel.Admin if you only want admins to use.
            CommandHandlers.Register("InstallSavings", AccessLevel.GameMaster, new CommandEventHandler(InstallSavings_OnCommand));
            CommandHandlers.Register("ScaleSavings", AccessLevel.GameMaster, new CommandEventHandler(ScaleSavings_OnCommand));

            EventSink.WorldSave += new WorldSaveEventHandler(World_Save);
        }
Example #18
0
        public static void Initialize()
        {
            Instance = World.GetCore(typeof(ToolbarCore)) as ToolbarCore ?? new ToolbarCore();

            CommandHandlers.Register("Toolbar", AccessLevel.Counselor, Toolbar_OnCommand);

            EventSink.Login       += OnLogin;
            EventSink.PlayerDeath += OnPlayerDeath;
        }
Example #19
0
        public IEnumerable <IEvent> HandleCommand(ICommand <TEntity> command)
        {
            if (!CommandHandlers.ContainsKey(command.GetType()))
            {
                throw new Exception("Attempt to handle and unknown command type.");
            }

            return(CommandHandlers[command.GetType()].Invoke(command));
        }
Example #20
0
 public LMPTimer(LastManPentagram lmp, int count, String location, int ticksRequired)
     : base(TimeSpan.FromSeconds(6.0), TimeSpan.FromSeconds(6.0))
 {
     m_LMP                = lmp;
     m_Count              = count * 10;
     m_Location           = location;
     m_TimerTicksRequired = ticksRequired;
     CommandHandlers.BroadcastMessage(AccessLevel.Player, 1150, String.Format("The pentagram at {0} will be active in {1} minutes. The first one who stands on it alone for {2} seconds will receive a random reward. Hiding at this pentagram is deadly mistake.", location, count, ticksRequired * 6));
 }
Example #21
0
    private void Start()
    {
        _screenHeight = Screen.currentResolution.height;
        _screenWidth  = Screen.currentResolution.width;

        CommandHandlers.RegisterCommandHandlers(this);
        CommandHandlers.BeforeCommandExecutedHook = BeforeCommandHook;
//            ConsoleBindsListener.Instance.LoadBinds();
    }
Example #22
0
 public void Delete()
 {
     if (Owner != null)
     {
         Owner.SendMessage("Votre faction {0} viens d'être effacée");
     }
     CommandHandlers.BroadcastMessage(AccessLevel.GameMaster, 1333, String.Format("(GM)La faction de '{0}' nommée '{1}' à été effacée", (Owner == null ? "Personne" : Owner.Name), Name));
     XMLFactions.Remove(m_Name);
 }
        private void LookForCommandHandlers(ClassDeclarationSyntax node)
        {
            var handles = _cmdHandlerDeclarationVisitor.Visit(node);

            if (handles.Any())
            {
                CommandHandlers.Add(node);
            }
        }
Example #24
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Title           = "EllApp WebSocket Server";
            Console.WriteLine("Running EllApp Socket Server ...");
            Console.WriteLine("[Type \"exit\" and hit enter to stop the server]");

            if (Configuration != null)
            {
                // Start the server
                socketThread = new Thread(new ThreadStart(StartSocketServer));
                socketThread.Start();

                string content = "";
                while (content != null && content != "exit")
                {
                    if (content != "")
                    {
                        CommandHandlers cmd    = new CommandHandlers();
                        Type            type   = cmd.GetType();
                        MethodInfo      metodo = type.GetMethod(Utility.ToTitleCase(content));
                        switch (content)
                        {
                        case "fakemessage":
                        case "gsm":
                        case "online":
                            metodo.Invoke(cmd, new object[] { Server.Sessions });
                            break;

                        case "serverinfo":
                            metodo.Invoke(cmd, new object[] { Server });
                            break;

                        case "commands":
                            metodo.Invoke(cmd, null);
                            break;

                        case "createaccount":
                        case "clearconsole":
                            break;

                        default:
                            logger.Warn($"Unknown command \"{content}\".");
                            break;
                        }
                    }
                    content = Console.ReadLine();
                }
            }
            else
            {
                Console.WriteLine("No configuration file found. Exit in 5 seconds..");
                Thread.Sleep(5 * 1000);
                Environment.Exit(0);
            }
        }
        private static void StaffChat(NetState state, PacketReader pvSrc)           // 0x0B
        {
            Mobile from    = RemoteAdminHandlers.ConfirmMobile((Account)state.Account, pvSrc.ReadInt32());
            string message = pvSrc.ReadUnicodeString();

            if (from != null && message.Length > 0)
            {
                CommandHandlers.StaffChat(from, message);
            }
        }
    protected void Awake()
    {
        CommandHandlers.RegisterCommandHandlers(this);

        // Subscribe to save and load events.
        SaveGame.OnSaved                += SaveGame_OnSaved;
        SaveGame.OnLoaded               += SaveGame_OnLoaded;
        TrackerManager.OnDataUpdated    += TrackerManagerOnDataUpdated;
        TrackerManager.OnFirstDataAdded += TrackerManagerOnFirstDataAdded;
    }
Example #27
0
 /// Edit by Orbit Storm
 /// <summary>
 /// On new player login, broadcast a message.
 /// </summary>
 public static void EventSink_CharacterCreated(CharacterCreatedEventArgs e)
 {
     if (e.Mobile != null)
     {
         if (e.Mobile.AccessLevel == AccessLevel.Player)
         {
             CommandHandlers.BroadcastMessage(AccessLevel.Player, m_NewPlayerHue, String.Format(m_NewPlayerMessage, e.Mobile.Name));
         }
     }
 }
Example #28
0
        public static ToolbarInfos Infos = null;                        // DO NOT CHANGE THIS! Used for the persistance item...

        public static void Initialize()
        {
            if (Infos == null)
            {
                Infos = new ToolbarInfos();
            }

            CommandHandlers.Register("Toolbar", AccessLevel.Counselor, new CommandEventHandler(Toolbar_OnCommand));
            EventSink.Login += new LoginEventHandler(OnLogin);
        }
Example #29
0
 public override ICameraMqttEntityConfiguration Build()
 => Build(
     Entity,
     EntityDefinition,
     DiscoveryTopic,
     DiscoveryMessage,
     DeleteMessage,
     DiscoveryMessageQualityOfServiceLevel,
     RetainDiscoveryMessages,
     CommandHandlers.ToArray()
     );
Example #30
0
 void EventSink_CharacterCreated(CharacterCreatedEventArgs e)
 {
     if (e.Mobile != null)
     {
         if (e.Mobile.AccessLevel == AccessLevel.Player)
         {
             connection.Sender.PublicMessage(chatChannel, String.Format("5{0} has just arrived in Comraich!", e.Mobile.RawName));
             CommandHandlers.BroadcastMessage(AccessLevel.Player, announcementHue, String.Format("{0} has just arrived in Comraich!", e.Mobile.RawName));
         }
     }
 }
Example #31
0
 public static void SetHandlers(DependencyObject dobj, CommandHandlers value)
 {
     if (dobj != null)
      {
     dobj.SetValue (HandlersProperty, value);
      }
 }
Example #32
0
        // ----------------------------------------------------------------------
partial         static void OnChange_Handlers(DependencyObject dobj, CommandHandlers oldValue, CommandHandlers newValue, ref bool handled);