コード例 #1
0
ファイル: DrawOpWithBrush.cs プロジェクト: fragmer/fCraft
 IBrushInstance IBrush.MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
     if( ReadParams( cmd ) ) {
         return this;
     } else {
         return null;
     }
 }
コード例 #2
0
ファイル: ReplaceNotBrush.cs プロジェクト: Magi1053/ProCraft
        public IBrush MakeBrush(Player player, CommandReader cmd) {
            if (player == null)
                throw new ArgumentNullException("player");
            if (cmd == null)
                throw new ArgumentNullException("cmd");

            Stack<Block> blocks = new Stack<Block>();
            while (cmd.HasNext) {
                Block block;
                if (!cmd.NextBlock(player, false, out block))
                    return null;
                blocks.Push(block);
            }
            switch (blocks.Count) {
                case 0:
                    player.Message("{0} brush: Please specify the replacement block type.", Name);
                    return null;
                case 1:
                    return new ReplaceNotBrush(blocks.ToArray(), Block.None);
                default: {
                        Block replacement = blocks.Pop();
                        return new ReplaceNotBrush(blocks.ToArray(), replacement);
                    }
            }
        }
コード例 #3
0
ファイル: PasteBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush(Player player, CommandReader cmd) {
            if (player == null) throw new ArgumentNullException("player");
            if (cmd == null) throw new ArgumentNullException("cmd");

            // read the block filter list
            HashSet<Block> blocks = new HashSet<Block>();
            while (cmd.HasNext) {
                Block block;
                if (!cmd.NextBlock(player, false, out block)) {
                    return null;
                }
                if (!blocks.Add(block)) {
                    // just a warning -- don't abort
                    player.Message("{0}: {1} was specified twice!", Name, block);
                }
            }

            // create a brush
            if (blocks.Count > 0) {
                return new PasteBrush(blocks.ToArray(), Not);
            } else if (Not) {
                player.Message("PasteNot brush requires at least 1 block.");
                return null;
            } else {
                return new PasteBrush();
            }
        }
コード例 #4
0
ファイル: RandomBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush( Player player, CommandReader cmd ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );

            List<Block> blocks = new List<Block>();
            List<int> blockRatios = new List<int>();
            while( cmd.HasNext ) {
                int ratio;
                Block block;
                if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
                if( block == Block.None ) return null;
                if( ratio < 0 || ratio > 1000 ) {
                    player.Message( "{0} brush: Invalid block ratio ({1}). Must be between 1 and 1000.",
                                    Name, ratio );
                    return null;
                }
                blocks.Add( block );
                blockRatios.Add( ratio );
            }

            switch( blocks.Count ) {
                case 0:
                    return new RandomBrush();
                case 1:
                    return new RandomBrush( blocks[0], blockRatios[0] );
                default:
                    return new RandomBrush( blocks.ToArray(), blockRatios.ToArray() );
            }
        }
コード例 #5
0
ファイル: RandomBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush( Player player, CommandReader cmd ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );

            List<Block> blocks = new List<Block>();
            List<int> blockRatios = new List<int>();
            while( cmd.HasNext ) {
                int ratio;
                Block block;
                if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
                if( ratio < 1 || ratio > RandomBrush.MaxRatio ) {
                    player.Message( "Random brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
                                    ratio, RandomBrush.MaxRatio );
                    return null;
                }
                blocks.Add( block );
                blockRatios.Add( ratio );
            }

            if( blocks.Count == 0 ) {
                return new RandomBrush();
            } else if( blocks.Count == 1 ) {
                return new RandomBrush( blocks[0], blockRatios[0] );
            } else {
                return new RandomBrush( blocks.ToArray(), blockRatios.ToArray() );
            }
        }
コード例 #6
0
ファイル: ReplaceBrushBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush( Player player, CommandReader cmd ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );

            if( !cmd.HasNext ) {
                player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
                return null;
            }

            Block block;
            if( !cmd.NextBlock( player, false, out block ) ) return null;

            string brushName = cmd.Next();
            if( brushName == null || !CommandManager.IsValidCommandName( brushName ) ) {
                player.Message( "ReplaceBrush usage: &H/Brush rb <Block> <BrushName>" );
                return null;
            }
            IBrushFactory brushFactory = BrushManager.GetBrushFactory( brushName );

            if( brushFactory == null ) {
                player.Message( "Unrecognized brush \"{0}\"", brushName );
                return null;
            }

            IBrush newBrush = brushFactory.MakeBrush( player, cmd );
            if( newBrush == null ) {
                return null;
            }

            return new ReplaceBrushBrush( block, newBrush );
        }
コード例 #7
0
ファイル: CheckeredBrush.cs プロジェクト: fragmer/fCraft
 public IBrush MakeBrush( Player player, CommandReader cmd ) {
     if( player == null ) throw new ArgumentNullException( "player" );
     if( cmd == null ) throw new ArgumentNullException( "cmd" );
     Block block, altBlock;
     cmd.NextBlock( player, true, out block );
     cmd.NextBlock( player, true, out altBlock );
     return new CheckeredBrush( block, altBlock );
 }
コード例 #8
0
        public override bool ReadParams(CommandReader cmd) {
            // get image URL
            string urlString = cmd.Next();
            if (string.IsNullOrWhiteSpace(urlString)) {
                return false;
            }

            if (urlString.StartsWith("http://imgur.com/")) {
                urlString = "http://i.imgur.com/" + urlString.Substring("http://imgur.com/".Length) + ".png";
            }
            // if string starts with "++", load image from imgur
            if (urlString.StartsWith("++")) {
                urlString = "http://i.imgur.com/" + urlString.Substring(2) + ".png";
            }
            // prepend the protocol, if needed (assume http)
            if (!urlString.ToLower().StartsWith("http://") && !urlString.ToLower().StartsWith("https://")) {
                urlString = "http://" + urlString;
            }
            if (!urlString.ToLower().StartsWith("http://i.imgur.com")) {
                Player.Message("For safety reasons we only accept images uploaded to &9http://imgur.com/ &sSorry for this inconvenience.");
                return false;
            }
            if (!urlString.ToLower().EndsWith(".png") && !urlString.ToLower().EndsWith(".jpg") && !urlString.ToLower().EndsWith(".gif")) {
                Player.Message("URL must be a link to an image");
                return false;
            }

            // validate the image URL
            Uri url;
            if (!Uri.TryCreate(urlString, UriKind.Absolute, out url)) {
                Player.Message("DrawImage: Invalid URL given.");
                return false;
            } else if (!url.Scheme.Equals(Uri.UriSchemeHttp) && !url.Scheme.Equals(Uri.UriSchemeHttps)) {
                Player.Message("DrawImage: Invalid URL given. Only HTTP and HTTPS links are allowed.");
                return false;
            }
            ImageUrl = url;

            // Check if player gave optional second argument (palette name)
            string paletteName = cmd.Next();
            if (paletteName != null) {
                StandardBlockPalette paletteType;
                if (EnumUtil.TryParse(paletteName, out paletteType, true)) {
                    Palette = BlockPalette.GetPalette(paletteType);
                } else {
                    Player.Message("DrawImage: Unrecognized palette \"{0}\". Available palettes are: \"{1}\"",
                                   paletteName,
                                   Enum.GetNames(typeof(StandardBlockPalette)).JoinToString());
                    return false;
                }
            } else {
                // default to "Light" (lit single-layer) palette
                Palette = BlockPalette.Light;
            }

            // All set
            return true;
        }
コード例 #9
0
ファイル: EntriesTest.cs プロジェクト: tcoelho80/RobotCleaner
        public void TestCoordinatesOK()
        {
            CommandReader test = new CommandReader(_mockView.Object, _mockRobotCleanerServices.Object);

            _mockView.Setup(x => x.ReadLine()).Returns("10 22");
            Coordinate result = test.ReadStartingCoordinate();

            Assert.AreEqual(10, result.X);
            Assert.AreEqual(22, result.Y);
        }
コード例 #10
0
 public static bool OpenYS_Command_Weather_Night_Method(Client ThisClient, CommandReader Command)
 {
     OpenYS.SetServerTimeTicks(0);
     Settings.Weather.Time = 0000;
     SettingsHandler.SaveAll();
     //OpenYS.AdvancedWeatherOptions._LastDayNightCycleRestart = DateTime.Now;
     ThisClient.SendMessage("&aServer time set to NIGHT.");
     Clients.AllClients.Exclude(ThisClient).SendMessage("&a" + ThisClient.Username + " set the time to NIGHT.");
     return(true);
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: AkselSLarsen/BigMammaUML3
        public static void Main()
        {
            MenuCatalog   menu          = new MenuCatalog();
            CommandReader commandReader = new CommandReader("data\\menu.txt");

            menu.ReadFromFile(commandReader);
            menu.PrintPizzasMenu();
            menu.PrintPastaMenu();
            read();
        }
コード例 #12
0
        public override MapGeneratorParameters CreateParameters(Player player, CommandReader cmd)
        {
            string themeName = cmd.Next();

            if (themeName == null)
            {
                return(CreateDefaultParameters());
            }

            MapGenTheme theme;
            RealisticMapGenTerrainType terrainType;

            string templateName = cmd.Next();

            if (templateName == null)
            {
                player.Message("SetGen: Realistic MapGen requires both a theme and a terrainType. " +
                               "See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details");
                return(null);
            }

            // parse theme
            bool swapThemeAndTemplate;

            if (EnumUtil.TryParse(themeName, out theme, true))
            {
                swapThemeAndTemplate = false;
            }
            else if (EnumUtil.TryParse(templateName, out theme, true))
            {
                swapThemeAndTemplate = true;
            }
            else
            {
                player.Message("SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
                               themeName,
                               Enum.GetNames(typeof(MapGenTheme)).JoinToString());
                return(null);
            }

            // parse terrainType
            if (swapThemeAndTemplate && !EnumUtil.TryParse(themeName, out terrainType, true))
            {
                MessageTemplateList(themeName, player);
                return(null);
            }
            else if (!EnumUtil.TryParse(templateName, out terrainType, true))
            {
                MessageTemplateList(templateName, player);
                return(null);
            }

            // TODO: optional parameters for preset customization
            return(CreateParameters(terrainType, theme));
        }
コード例 #13
0
ファイル: ReplaceBrushBrush.cs プロジェクト: mstefarov/fCraft
        public IBrushInstance MakeInstance(Player player, CommandReader cmd, DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            if (cmd.HasNext)
            {
                Block block;
                if (!cmd.NextBlock(player, false, out block))
                {
                    return(null);
                }

                string brushName = cmd.Next();
                if (brushName == null || !CommandManager.IsValidCommandName(brushName))
                {
                    player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                    return(null);
                }
                IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName);

                if (brushFactory == null)
                {
                    player.Message("Unrecognized brush \"{0}\"", brushName);
                    return(null);
                }

                IBrush replacement = brushFactory.MakeBrush(player, cmd);
                if (replacement == null)
                {
                    return(null);
                }
                Block       = block;
                Replacement = replacement;
            }

            ReplacementInstance = Replacement.MakeInstance(player, cmd, op);
            if (ReplacementInstance == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(this));
        }
コード例 #14
0
        public void SetFileTest()
        {
            CommandReader target   = new CommandReader();
            string        filename = "testfilename";

            target.AddFile(filename);
            string expected = "testfilename";
            string actual   = target.Accessor();

            Assert.AreEqual(expected, actual);
        }
コード例 #15
0
ファイル: CommandReaderTests.cs プロジェクト: ajlopez/AjKeyvs
        public void ParseGetCommand()
        {
            CommandReader reader = new CommandReader("get users:1:name");

            CommandInfo command = reader.NextCommand();

            Assert.IsNotNull(command);
            Assert.AreEqual("get", command.Verb);
            Assert.AreEqual("users:1:name", command.Key);
            Assert.IsNull(command.Parameters);
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: Antash/EmptedKiller
        static void Main(string[] args)
        {
            using (var commandLog = new StreamWriter(@"log.txt"))
            {
                commandLog.WriteLine($"New game: {DateTime.Now}");
            }
            var inputReader = new CommandReader();

            inputReader.CommandRecieved += InputReader_CommandRecieved;
            inputReader.Run();
        }
コード例 #17
0
        public void StandardPicRequestWithoutEndMssg()
        {
            byte[] request    = new CommandBuilder().Request(CameraRequest.SendFullResImage).AddParam("thing", "xtbb").Build();
            byte[] rawRequest = new byte[request.Length - Constants.EndOfMessage.Length];
            Array.Copy(request, rawRequest, rawRequest.Length);

            CommandReader result = new CommandReader(rawRequest);

            Assert.True(result.Request == CameraRequest.SendFullResImage);
            Assert.True(result.Parameters.Count == 1);
        }
コード例 #18
0
 IBrushInstance IBrush.MakeInstance(Player player, CommandReader cmd, DrawOperation op)
 {
     if (ReadParams(cmd))
     {
         return(this);
     }
     else
     {
         return(null);
     }
 }
コード例 #19
0
        public void StandardPicRequestWithEmpty()
        {
            byte[] request    = new CommandBuilder().Request(CameraRequest.SendFullResImage).Build();
            byte[] rawRequest = new byte[request.Length + 12];
            request.CopyTo(rawRequest, 0);

            CommandReader result = new CommandReader(rawRequest);

            Assert.True(result.Request == CameraRequest.SendFullResImage);
            Assert.True(result.Parameters.Count == 0);
        }
コード例 #20
0
 public IBrush MakeBrush(Player player, CommandReader cmd)
 {
     if (player == null)
     {
         throw new ArgumentNullException("player");
     }
     if (cmd == null)
     {
         throw new ArgumentNullException("cmd");
     }
     return(this);
 }
コード例 #21
0
 private void QueueReadCommand(NamedConnection connection)
 {
     lock (_lock)
     {
         _runningCommands.Add(Task.Factory.StartNew <CommandRead>(() =>
         {
             ICommandReader reader = new CommandReader();
             MqttCommand cmd       = reader.Read(connection.Connection);
             return(new CommandRead(cmd, connection));
         }, TaskCreationOptions.LongRunning));
     }
 }
コード例 #22
0
 static void Main()
 {
     while (true)
     {
         string[] command = ConsoleRead.CommandInput();
         object   value   = CommandReader.FunctionCall(command[0], command);
         if (value != null)
         {
             Console.WriteLine($"Got -> {value}");
         }
     }
 }
コード例 #23
0
ファイル: Fill2DDrawOperation.cs プロジェクト: fragmer/fCraft
 public override bool ReadParams( CommandReader cmd ) {
     if( cmd.HasNext ) {
         Block replacement;
         if( cmd.NextBlock( Player, false, out replacement ) ) {
             ReplacementBlock = replacement;
         } else {
             return false;
         }
     }
     Brush = this;
     return true;
 }
コード例 #24
0
 internal CommandCalledEventArgs([NotNull] CommandReader command, [NotNull] Player player)
 {
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     if (player == null)
     {
         throw new ArgumentNullException("player");
     }
     Command = command;
     Player  = player;
 }
コード例 #25
0
ファイル: CommandReaderTests.cs プロジェクト: ajlopez/AjKeyvs
        public void ParseSetCommand()
        {
            CommandReader reader = new CommandReader("set users:1:name \"Adam\"");

            CommandInfo command = reader.NextCommand();

            Assert.IsNotNull(command);
            Assert.AreEqual("set", command.Verb);
            Assert.AreEqual("users:1:name", command.Key);
            Assert.IsNotNull(command.Parameters);
            Assert.AreEqual(1, command.Parameters.Count);
            Assert.AreEqual("Adam", command.Parameters[0]);
        }
コード例 #26
0
ファイル: Program.cs プロジェクト: V3ronique/Labyrinth-2
        private static void Main()
        {
            ICommandInputProvider commandInput  = new CommandReader();
            IInfoInputProvider    menuInput     = new Menu();
            IInputProvider        inputProvider = new ConsoleInputProvider(commandInput, menuInput);

            IInfoRenderer      infoPanel       = new InfoPanel();
            IPlayFieldRenderer playFieldPanel  = new PlayFieldPanel();
            ILadderRenderer    topScoresPanel  = new TopScoresPanel();
            IRenderer          consoleRenderer = new ConsoleRender(infoPanel, playFieldPanel, topScoresPanel);

            LabyrinthFacade.Start(consoleRenderer, inputProvider, FileLogger.Instance());
        }
コード例 #27
0
 public void Execute( string text )
 {
     CommandReader reader = new CommandReader( text );
     if( reader.TotalArgs == 0 ) {
         game.Chat.Add( "&e/client: No command name specified. See /client commands for a list of commands." );
         return;
     }
     string commandName = reader.Next();
     Command cmd = GetMatchingCommand( commandName );
     if( cmd != null ) {
         cmd.Execute( reader );
     }
 }
コード例 #28
0
    private bool GlobalizationMenuState()
    {
        int val = -CommandReader.GetIntTriggerDown("vertical", Controlador.teclado);

        globalMenu.ChangeOption(val);

        if (Input.GetKeyDown(KeyCode.Return))
        {
            OpcoesDoGlobalizationMenu(globalMenu.SelectedOption);
        }

        return(false);
    }
コード例 #29
0
        public void ReadFromFileTest()
        {
            string[]      args               = { "read test" };
            CommandReader target             = new CommandReader(args);
            string        ResultLine         = string.Empty;
            string        ResultLineExpected = "";
            string        expected           = null;
            string        actual             = null;

            //actual = target.ReadFromFile(ref ResultLine);
            Assert.AreEqual(ResultLineExpected, ResultLine);
            Assert.AreEqual(expected, actual);
        }
コード例 #30
0
    // Update is called once per frame
    void Update()
    {
        if (podeMudar)
        {
            float quanto = CommandReader.GetAxis("horizontal", GlobalController.g.Control)
                           + CommandReader.GetAxis("HDpad", GlobalController.g.Control);

            if (quanto > 0)
            {
                VerificaModificacao(true);
            }
            else if (quanto < 0)
            {
                VerificaModificacao(false);
            }
            else
            {
                quanto = UiDeOpcoes.VerificaMudarOpcao(true);

                if (quanto > 0)
                {
                    opcaoSelecionada = ContadorCiclico.AlteraContador(1, opcaoSelecionada, destaques.Length);
                }
                else if (quanto < 0)
                {
                    opcaoSelecionada = ContadorCiclico.AlteraContador(-1, opcaoSelecionada, destaques.Length);
                }

                if (quanto != 0)
                {
                    ColocarDestaqueSelecionado();
                }
            }

            bool foi = ActionManager.ButtonUp(0, GlobalController.g.Control);

            if (CommandReader.ButtonDown(2, GlobalController.g.Control)
                ||
                (foi && opcaoSelecionada == destaques.Length - 1))
            {
                BotaoVoltar();
            }
            else

            if (foi && opcaoSelecionada == 2)
            {
                BotaoTodasHabilidades();
            }
        }
    }
コード例 #31
0
    public static bool ButtonUp(int n, Controlador c)
    {
        bool press = CommandReader.ButtonUp(n, c);

        if (!esteQuadro && press)
        {
            AgendaEsseQuadro();
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #32
0
        public static bool OpenYS_Command_Racing_CreateTT_Method(Client ThisClient, CommandReader Command)
        {
            #region Didn't Specify Path
            if (Command._CmdArguments.Count() < 1)
            {
                ThisClient.SendMessage("&eYou need to specify a path to race on!");
                return(false);
            }
            #endregion
            #region Don't Have the Path
            if (!World.Objects.PathList
                .Where(y => y.Type == 15)
                .Select(x => x.Identify.ToUpperInvariant())
                .Contains(Command._CmdArguments[0]
                          .ToUpperInvariant()))
            {
                ThisClient.SendMessage("Path not found - use /ListPaths to see compatible racing paths!");
                return(false);
            }
            #endregion
            #region Specified Duration
            TimeSpan RaceDuration = new TimeSpan(0, 0, 0);
            if (Command._CmdArguments.Count() > 1)
            {
                double Duration = 0;
                bool   Failed   = !Double.TryParse(Command._CmdArguments[1], out Duration);
                if (Failed)
                {
                    ThisClient.SendMessage("Duration in Minutes given was not an integer! Durations must be in numeric format!");
                    return(false);
                }
                RaceDuration = new TimeSpan(0, 0, 0, 0, (int)(Duration * 60 * 1000));
            }
            #endregion

            Games.Racing2.Race NewTT = new Games.Racing2.Race();
            NewTT.Path = World.Objects.PathList
                         .Where(y => y.Identify.ToUpperInvariant() == Command._CmdArguments[0].ToUpperInvariant()).ToArray()[0];
            NewTT.Owner             = ThisClient;
            NewTT.FastestSectors    = new float[NewTT.Path.Points.Count];
            NewTT.CumulativeSectors = new float[NewTT.Path.Points.Count];

            NewTT.RaceTypeSetTimeTrial();
            NewTT.RaceEnds = DateTime.Now + RaceDuration;

            ThisClient.SendMessage("&eTimeTrial Created on Path: \"" + NewTT.Path.Identify + "\". To join in, type \"&c/JoinRace " + NewTT.ID + "&e\".");
            Clients.AllClients.Exclude(ThisClient).SendMessage("&e" + ThisClient.Username + " created a TimeTrial at " + NewTT.Path.Identify + ". To join in, type \"&c/JoinRace " + NewTT.ID + "&e\".");
            Games.Racing2.Races.Add(NewTT);
            return(true);
        }
コード例 #33
0
ファイル: Commands.cs プロジェクト: boqnd/DataBaseApp
        /// <addBuyer>
        ///  This method takes from the console information for a new buyer.
        ///  (nickname, the nickname of an existing dealer)
        ///  It adds the new dealer to the database,
        ///  and assigns the new buyer to the dealer.
        /// </addBuyer>
        public void AddBuyer()
        {
            string nickname;
            string dNickname;
            int    dealerID;
            Dealer dealer;

            try
            {
                Dictionary <string, string> dict = CommandReader.AddBuyer();
                nickname  = dict["nickname"];
                dNickname = dict["dealerNickname"];

                if (nickname == "" || dNickname == "")
                {
                    throw new InvalidOperationException(ConstantStrings.Blank);
                }
                OutputPrinter.Connecting();

                List <string> nicknames = c.Buyers.Select(e => e.Nickname).ToList();

                if (nicknames.Contains(nickname))
                {
                    throw new InvalidOperationException(ConstantStrings.Buyer + $" with nickname '{nickname}' " + ConstantStrings.AlreadyExists);
                }

                try
                {
                    dealer   = c.Dealers.Single(e => e.Nickname == dNickname);
                    dealerID = dealer.Id;
                }
                catch (Exception)
                {
                    throw new InvalidOperationException(ConstantStrings.Dealer + $" with nickname '{nickname}' " + ConstantStrings.NotFound);
                }

                var buyer = new Buyer()
                {
                    Nickname = nickname,
                    DealerId = dealerID
                };
                Add(buyer);
                OutputPrinter.Done();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                OutputPrinter.InvalidCommand();
            }
        }
コード例 #34
0
    private bool ColorCircleState()
    {
        bool foi       = false;
        bool effective = false;

        Vector2 V = new Vector2(
            CommandReader.GetAxis("horizontal", Controlador.teclado),
            CommandReader.GetAxis("vertical", Controlador.teclado)
            );

        float val = (Input.GetKey(KeyCode.Q) ? 1 : 0) + (Input.GetKey(KeyCode.E) ? -1 : 0);

        val *= Time.deltaTime * velValForGreyScale;

        myGetColor.MoveMark(V * velValForColor, val);

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            effective = false;
            foi       = true;
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            effective = true;
            foi       = true;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            EndColorCircle();
            ChangeToColorGrid();
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2) && secManager.GetTargetColorReg != RegistroDeCores.skin)
        {
            EndColorCircle();
            globalCM.StartHud(myGetColor.CurrentColor, secManager.GuardOriginalColor.cor, secManager.VerifyColorReg(), secManager.GetTargetColorReg);
            StartGlobalColorMenu();
        }

        if (foi)
        {
            EndColorCircle();
            secManager.EndChangeColor(effective);
            estado = EstadoDoMenu.main;
        }



        return(true);
    }
コード例 #35
0
        private static async Task RunAppAsync()
        {
            try
            {
                var getChangeService = UnityConfigurationBase.Container.Resolve <IGetChangeService>();
                var coinBoxService   = UnityConfigurationBase.Container.Resolve <ICoinBoxService>();
                var commandReader    = new CommandReader(getChangeService, coinBoxService);

                await commandReader.ReadCommands();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #36
0
 public override void Execute( CommandReader reader )
 {
     string cmdName = reader.Next();
     if( cmdName == null ) {
         game.Chat.Add( "&e/client help: No command name specified. See /client commands for a list of commands." );
     } else {
         Command cmd = game.CommandManager.GetMatchingCommand( cmdName );
         if( cmd != null ) {
             string[] help = cmd.Help;
             for( int i = 0; i < help.Length; i++ ) {
                 game.Chat.Add( help[i] );
             }
         }
     }
 }
コード例 #37
0
        public void IgnoresUnparseableCommands()
        {
            var commands = new string[]
            {
                "REPORT",
                "LEFT",
                "FFSJKF",
                "PLACE 0,0,FOO",
                "RIGHT",
            };

            var results = CommandReader.Read(commands).ToList();

            Check.That(results).HasSize(3);
        }
コード例 #38
0
ファイル: FlatMapGen.cs プロジェクト: fragmer/fCraft
 public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
     string themeName = cmd.Next();
     MapGeneratorParameters newParams;
     if( themeName != null ) {
         newParams = CreateParameters( themeName );
         if( newParams == null ) {
             player.Message( "SetGen: \"{0}\" is not a recognized flat theme name. Available themes are: {1}",
                             themeName, Presets.JoinToString() );
             return null;
         }
     } else {
         newParams = CreateDefaultParameters();
     }
     return newParams;
 }
コード例 #39
0
 public void Execute( string text )
 {
     CommandReader reader = new CommandReader( text );
     if( reader.TotalArgs == 0 ) {
         game.Chat.Add( "&eList of client commands:" );
         PrintDefinedCommands( game );
         game.Chat.Add( "&eTo see a particular command's help, type /client help [cmd name]" );
         return;
     }
     string commandName = reader.Next();
     Command cmd = GetMatchingCommand( commandName );
     if( cmd != null ) {
         cmd.Execute( reader );
     }
 }
コード例 #40
0
        public IBrush MakeBrush(Player player, CommandReader cmd)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }

            if (!cmd.HasNext)
            {
                player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                return(null);
            }

            Block block;

            if (!cmd.NextBlock(player, false, out block))
            {
                return(null);
            }

            string brushName = cmd.Next();

            if (brushName == null || !CommandManager.IsValidCommandName(brushName))
            {
                player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                return(null);
            }
            IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName);

            if (brushFactory == null)
            {
                player.Message("Unrecognized brush \"{0}\"", brushName);
                return(null);
            }

            IBrush newBrush = brushFactory.MakeBrush(player, cmd);

            if (newBrush == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(block, newBrush));
        }
コード例 #41
0
ファイル: MarbledBrush.cs プロジェクト: TheDireMaster/fCraft
        public IBrush MakeBrush(Player player, CommandReader cmd)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }

            List <Block> blocks      = new List <Block>();
            List <int>   blockRatios = new List <int>();

            while (cmd.HasNext)
            {
                int   ratio;
                Block block;
                if (!cmd.NextBlockWithParam(player, true, out block, out ratio))
                {
                    return(null);
                }
                if (block == Block.None)
                {
                    return(null);
                }
                if (ratio < 0 || ratio > 1000)
                {
                    player.Message("{0} brush: Invalid block ratio ({1}). Must be between 1 and 1000.",
                                   Name, ratio);
                    return(null);
                }
                blocks.Add(block);
                blockRatios.Add(ratio);
            }

            switch (blocks.Count)
            {
            case 0:
                return(new MarbledBrush());

            case 1:
                return(new MarbledBrush(blocks[0], blockRatios[0]));

            default:
                return(new MarbledBrush(blocks.ToArray(), blockRatios.ToArray()));
            }
        }
コード例 #42
0
        public override bool ReadParams(CommandReader cmd)
        {
            // get image URL
            string urlstr = cmd.Next();

            if (!WorldCommands.parseUrl(ref urlstr, Player))
            {
                return(false);
            }

            // validate the image URL
            Uri url;

            if (!Uri.TryCreate(urlstr, UriKind.Absolute, out url))
            {
                Player.Message("DrawImage: Invalid URL given.");
                return(false);
            }
            else if (!url.Scheme.Equals(Uri.UriSchemeHttp) && !url.Scheme.Equals(Uri.UriSchemeHttps))
            {
                Player.Message("DrawImage: Invalid URL given. Only HTTP and HTTPS links are allowed.");
                return(false);
            }

            ImageUrl = url;

            // Check if player gave optional second argument (palette name)
            string paletteName = cmd.Next();

            if (paletteName != null)
            {
                Palette = BlockPalette.FindPalette(paletteName);
                if (Palette == null)
                {
                    Player.Message("DrawImage: Unrecognized palette \"{0}\". Available palettes are: \"{1}\"",
                                   paletteName, BlockPalette.Palettes.JoinToString(pal => pal.Name));
                    return(false);
                }
            }
            else
            {
                // default to "Light" (lit single-layer) palette
                Palette = BlockPalette.FindPalette("Light");
            }

            // All set
            return(true);
        }
コード例 #43
0
        public override void Execute( CommandReader reader )
        {
            game.UserEvents.BlockChanged -= BlockChanged;
            block = 0xFF;
            mark1 = new Vector3I( int.MaxValue );
            mark2 = new Vector3I( int.MaxValue );
            persist = false;

            if( !ParseBlock( reader ) ) return;
            string arg = reader.Next();
            if( arg != null && Utils.CaselessEquals( arg, "yes" ) )
                persist = true;

            game.Chat.Add( "&eCuboid: &fPlace or delete a block.", MessageType.ClientStatus3 );
            game.UserEvents.BlockChanged += BlockChanged;
        }
コード例 #44
0
        public IBrush MakeBrush(Player player, CommandReader cmd)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            Block block, altBlock;

            cmd.NextBlock(player, true, out block);
            cmd.NextBlock(player, true, out altBlock);
            return(new CheckeredBrush(block, altBlock));
        }
コード例 #45
0
ファイル: NormalBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush(Player player, CommandReader cmd) {
            if (player == null) throw new ArgumentNullException("player");
            if (cmd == null) throw new ArgumentNullException("cmd");

            List<Block> blocks = new List<Block>();

            while (cmd.HasNext) {
                Block block;
                if (!cmd.NextBlock(player, true, out block)) {
                    return null;
                }
                blocks.Add(block);
            }

            return new NormalBrush(blocks.ToArray());
        }
コード例 #46
0
ファイル: BrushManager.cs プロジェクト: fragmer/fCraft
 static void BrushHandler( Player player, CommandReader cmd ) {
     string brushName = cmd.Next();
     if( brushName == null ) {
         player.Message( player.Brush.Description );
     } else {
         IBrushFactory brushFactory = GetBrushFactory( brushName );
         if( brushFactory == null ) {
             player.Message( "Unrecognized brush \"{0}\"", brushName );
         } else {
             IBrush newBrush = brushFactory.MakeBrush( player, cmd );
             if( newBrush != null ) {
                 player.Brush = newBrush;
                 player.Message( "Brush set to {0}", player.Brush.Description );
             }
         }
     }
 }
コード例 #47
0
 public override void Execute( CommandReader reader )
 {
     List<string> commandNames = new List<string>();
     StringBuilder buffer = new StringBuilder( 64 );
     foreach( Command cmd in game.CommandManager.RegisteredCommands ) {
         string name = cmd.Name;
         if( buffer.Length + name.Length > 64 ) {
             commandNames.Add( buffer.ToString() );
             buffer.Length = 0;
         }
         buffer.Append( name + ", " );
     }
     if( buffer.Length > 0 ) {
         commandNames.Add( buffer.ToString() );
     }
     foreach( string part in commandNames ) {
         game.Chat.Add( part );
     }
 }
コード例 #48
0
ファイル: ReplaceNotBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush( Player player, CommandReader cmd ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );

            Stack<Block> blocks = new Stack<Block>();
            while( cmd.HasNext ) {
                Block block;
                if( !cmd.NextBlock( player, false, out block ) ) return null;
                blocks.Push( block );
            }
            if( blocks.Count == 0 ) {
                return new ReplaceNotBrush();
            } else if( blocks.Count == 1 ) {
                return new ReplaceNotBrush( blocks.ToArray(), Block.None );
            } else {
                Block replacement = blocks.Pop();
                return new ReplaceNotBrush( blocks.ToArray(), replacement );
            }
        }
コード例 #49
0
ファイル: RealisticMapGen.cs プロジェクト: fragmer/fCraft
        public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
            string themeName = cmd.Next();
            if( themeName == null ) {
                return CreateDefaultParameters();
            }

            MapGenTheme theme;
            RealisticMapGenTerrainType terrainType;

            string templateName = cmd.Next();
            if( templateName == null ) {
                player.Message( "SetGen: Realistic MapGen requires both a theme and a terrainType. " +
                                "See &H/Help SetGen Realistic&S or check wiki.fCraft.net for details" );
                return null;
            }

            // parse theme
            bool swapThemeAndTemplate;
            if( EnumUtil.TryParse( themeName, out theme, true ) ) {
                swapThemeAndTemplate = false;

            } else if( EnumUtil.TryParse( templateName, out theme, true ) ) {
                swapThemeAndTemplate = true;

            } else {
                player.Message( "SetGen: Unrecognized theme \"{0}\". Available themes are: {1}",
                                themeName,
                                Enum.GetNames( typeof( MapGenTheme ) ).JoinToString() );
                return null;
            }

            // parse terrainType
            if( swapThemeAndTemplate && !EnumUtil.TryParse( themeName, out terrainType, true ) ) {
                MessageTemplateList( themeName, player );
                return null;
            } else if( !EnumUtil.TryParse( templateName, out terrainType, true ) ) {
                MessageTemplateList( templateName, player );
                return null;
            }

            // TODO: optional parameters for preset customization
            return CreateParameters( terrainType, theme );
        }
コード例 #50
0
ファイル: CheckeredBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush(Player player, CommandReader cmd) {
            if (player == null) throw new ArgumentNullException("player");
            if (cmd == null) throw new ArgumentNullException("cmd");

            Block block, altBlock;

            // first block type is required
            if (!cmd.NextBlock(player, true, out block)) {
                player.Message("{0}: Please specify at least one block type.", Name);
                return null;
            }

            // second block type is optional
            if (cmd.HasNext) {
                if (!cmd.NextBlock(player, true, out altBlock)) return null;
            } else {
                altBlock = Block.None;
            }

            return new CheckeredBrush(block, altBlock);
        }
コード例 #51
0
ファイル: CheckeredBrush.cs プロジェクト: fragmer/fCraft
        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( op == null ) throw new ArgumentNullException( "op" );

            if( cmd.HasNext ) {
                Block block, altBlock;
                if( !cmd.NextBlock( player, true, out block ) ) return null;
                if( cmd.HasNext ) {
                    if( !cmd.NextBlock( player, true, out altBlock ) ) return null;
                } else {
                    altBlock = Block.None;
                }
                Block1 = block;
                Block2 = altBlock;

            } else if( Block1 == Block.None ) {
                player.Message( "{0}: Please specify one or two blocks.", Factory.Name );
                return null;
            }

            return new CheckeredBrush( this );
        }
コード例 #52
0
 public override void Execute( CommandReader reader )
 {
     int width, height, length;
     if( !reader.NextInt( out width ) || !reader.NextInt( out height ) || !reader.NextInt( out length ) ) {
         game.Chat.Add( "&e/client generate: &cInvalid dimensions." );
     } else {
         if( width < 16 || height < 16 || length < 16 ) {
             game.Chat.Add( "&e/client generate: &cDimensions too small." );
             return;
         }
         if( width > 1024 || height > 1024 || length > 1024 ) {
             game.Chat.Add( "&e/client generate: &cDimensions too large." );
             return;
         }
         if( !( game.Network is SinglePlayerServer ) ) {
             game.Chat.Add( "&e/client generate: &cThis command only works in singleplayer mode." );
             return;
         }
         SinglePlayerServer server = (SinglePlayerServer)game.Network;
         server.NewMap();
         game.chatInInputBuffer = null;
         server.MakeMap( width, height, length );
     }
 }
コード例 #53
0
ファイル: PasteDrawOperation.cs プロジェクト: fragmer/fCraft
 public override bool ReadParams(CommandReader cmd) {
     if (Player.GetCopyState() == null) {
         Player.Message("Nothing to paste! Copy something first.");
         return false;
     }
     List<Block> blocks = new List<Block>();
     while (cmd.HasNext) {
         Block block;
         if (!cmd.NextBlock(Player, false, out block)) return false;
         blocks.Add(block);
     }
     if (blocks.Count > 0) {
         Blocks = blocks.ToArray();
     } else if (Not) {
         Player.Message("PasteNot requires at least 1 block.");
         return false;
     }
     Brush = this;
     return true;
 }
コード例 #54
0
 public override bool ReadParams(CommandReader cmd) {
     return true;
 }
コード例 #55
0
ファイル: CloudyBrush.cs プロジェクト: fragmer/fCraft
        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation state ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( state == null ) throw new ArgumentNullException( "state" );

            List<Block> blocks = new List<Block>();
            List<int> blockRatios = new List<int>();
            while( cmd.HasNext ) {
                int ratio;
                Block block;
                if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
                if( ratio < 1 || ratio > MaxRatio ) {
                    player.Message( "Cloudy brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
                                    ratio, MaxRatio );
                    return null;
                }
                blocks.Add( block );
                blockRatios.Add( ratio );
            }

            if( blocks.Count == 0 ) {
                if( Blocks.Length == 0 ) {
                    player.Message( "{0} brush: Please specify at least one block.", Factory.Name );
                    return null;
                } else {
                    return new CloudyBrush( this );
                }
            } else if( blocks.Count == 1 ) {
                return new CloudyBrush( blocks[0], blockRatios[0] );
            } else {
                return new CloudyBrush( blocks.ToArray(), blockRatios.ToArray() );
            }
        }
コード例 #56
0
ファイル: CloudyBrush.cs プロジェクト: fragmer/fCraft
        public IBrush MakeBrush( Player player, CommandReader cmd ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );

            List<Block> blocks = new List<Block>();
            List<int> blockRatios = new List<int>();
            bool scaleSpecified = false,
                 turbulenceSpecified = false,
                 seedSpecified = false;
            int scale = 100,
                turbulence = 100;
            UInt16 seed = CloudyBrush.NextSeed();

            while( true ) {
                int offset = cmd.Offset;
                string rawNextParam = cmd.Next();
                if( rawNextParam == null ) break;

                if( rawNextParam.EndsWith( "%" ) ) {
                    string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
                    int tempScale;
                    if( !Int32.TryParse( numPart, out tempScale ) ) {
                        player.Message( "Cloudy brush: To specify scale, write a number followed by a percentage (e.g. 100%)." );
                        return null;
                    }
                    if( scaleSpecified ) {
                        player.Message( "Cloudy brush: Scale has been specified twice." );
                        return null;
                    }
                    if( scale < 1 || tempScale > CloudyBrush.MaxScale ) {
                        player.Message( "Cloudy brush: Invalid scale ({0}). Must be between 1 and {1}",
                                        scale, CloudyBrush.MaxScale );
                        return null;
                    }
                    scale = tempScale;
                    scaleSpecified = true;
                    continue;

                } else if( rawNextParam.EndsWith( "T", StringComparison.OrdinalIgnoreCase ) ) {
                    string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
                    int tempTurbulence;
                    if( Int32.TryParse( numPart, out tempTurbulence ) ) {
                        if( turbulenceSpecified ) {
                            player.Message( "Cloudy brush: Turbulence has been specified twice." );
                            return null;
                        }
                        if( turbulence < 1 || tempTurbulence > CloudyBrush.MaxScale ) {
                            player.Message( "Cloudy brush: Invalid turbulence ({0}). Must be between 1 and {1}",
                                            turbulence, CloudyBrush.MaxScale );
                            return null;
                        }
                        turbulence = tempTurbulence;
                        turbulenceSpecified = true;
                        continue;
                    }

                } else if( rawNextParam.EndsWith( "S", StringComparison.OrdinalIgnoreCase ) ) {
                    string numPart = rawNextParam.Substring( 0, rawNextParam.Length - 1 );
                    try {
                        seed = UInt16.Parse( numPart, System.Globalization.NumberStyles.HexNumber );
                        if( seedSpecified ) {
                            player.Message( "Cloudy brush: Seed has been specified twice." );
                            return null;
                        }
                        seedSpecified = true;
                        continue;
                    } catch {
                        seed = CloudyBrush.NextSeed();
                    }
                }

                cmd.Offset = offset;
                int ratio;
                Block block;
                if( !cmd.NextBlockWithParam( player, true, out block, out ratio ) ) return null;
                if( ratio < 1 || ratio > CloudyBrush.MaxRatio ) {
                    player.Message( "Cloudy brush: Invalid block ratio ({0}). Must be between 1 and {1}.",
                                    ratio, CloudyBrush.MaxRatio );
                    return null;
                }
                blocks.Add( block );
                blockRatios.Add( ratio );
            }

            CloudyBrush madeBrush;
            if( blocks.Count == 0 ) {
                madeBrush = new CloudyBrush();
            } else if( blocks.Count == 1 ) {
                madeBrush = new CloudyBrush( blocks[0], blockRatios[0] );
            } else {
                madeBrush = new CloudyBrush( blocks.ToArray(), blockRatios.ToArray() );
            }

            madeBrush.Frequency /= ( scale / 100f );
            madeBrush.Persistence *= ( turbulence / 100f );
            madeBrush.Seed = seed;

            return madeBrush;
        }
コード例 #57
0
ファイル: ReplaceNotBrush.cs プロジェクト: fragmer/fCraft
        public IBrushInstance MakeInstance( Player player, CommandReader cmd, DrawOperation op ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( cmd == null ) throw new ArgumentNullException( "cmd" );
            if( op == null ) throw new ArgumentNullException( "op" );

            Stack<Block> blocks = new Stack<Block>();
            while( cmd.HasNext ) {
                Block block;
                if( !cmd.NextBlock( player, false, out block ) ) return null;
                blocks.Push( block );
            }

            if( blocks.Count == 0 && Blocks == null ) {
                player.Message( "ReplaceNot brush requires at least 1 block." );
                return null;
            }

            if( blocks.Count > 0 ) {
                if( blocks.Count > 1 ) Replacement = blocks.Pop();
                Blocks = blocks.ToArray();
            }

            return new ReplaceNotBrush( this );
        }
コード例 #58
0
ファイル: VanillaMapGen.cs プロジェクト: fragmer/fCraft
 public override MapGeneratorParameters CreateParameters( Player player, CommandReader cmd ) {
     if( cmd.HasNext ) {
         player.Message( "Vanilla map generator does not take any parameters; using defaults." );
     }
     return new VanillaMapGenParameters();
 }
コード例 #59
0
ファイル: DrawOpWithBrush.cs プロジェクト: fragmer/fCraft
 IBrush IBrushFactory.MakeBrush( Player player, CommandReader cmd ) {
     return this;
 }
コード例 #60
0
ファイル: DrawOpWithBrush.cs プロジェクト: fragmer/fCraft
 public abstract bool ReadParams( CommandReader cmd );