Exemplo n.º 1
0
        public static IPokemon CreatePokemon(int level, int id = 0)
        {
            IPokemon pokemon;

            level = level < 1 || level > 100 ? 5 : level;

            if (id != 0)
            {
                id = PokemonList.Pokemons.Any(p => p.Key == id) ? id : 1;

                pokemon = (IPokemon)PokemonList.Pokemons
                          .Where(p => p.Key == id)
                          .First()
                          .Value
                          .Clone();
            }
            else
            {
                var availablePokemons = PokemonList.Pokemons.Where(p => p.Value.MinimalLevel <= level && p.Value.MinimalLevel > 0);
                pokemon = (IPokemon)availablePokemons
                          .ElementAt(GenerateRandomNumber.GetRandomNumber(0, availablePokemons.Count()))
                          .Value
                          .Clone();
            }

            pokemon.Level     = level;
            pokemon.Stats     = PokemonStatsFactory.CreateStats(pokemon.Stats, level);
            pokemon.HPCurrent = pokemon.HPMax = pokemon.Stats.Health;
            pokemon.Attacks   = PokemonAttacksFactory.GetAttacks(pokemon);

            return(pokemon);
        }
Exemplo n.º 2
0
        private void configView()
        {
            SetContentView(Resource.Layout.Main);
            rand = new GenerateRandomNumber();
            // Get our button from the layout resource,
            // and attach an event to it
            Button   button = FindViewById <Button>(Resource.Id.MyButton);
            EditText count  = FindViewById <EditText>(Resource.Id.selected_count);

            try
            {
                mList = FindViewById <ListView>(Resource.Id.listViewResultd);

                button.Click += delegate {
                    var counter = Convert.ToInt32(count.Text);

                    if (adapter != null)
                    {
                        adapter.ClearData();
                    }
                    adapter = new MyCustomListAdapter(this, rand.GenerateList(counter));

                    mList.Adapter = adapter;
                };
            }
            catch (Java.Lang.Exception ex)
            {
            }
        }
Exemplo n.º 3
0
 public static IPokemonStats GetCalculatedStats(IPokemonStats pokemonBaseStats, int level)
 {
     return(new PokemonStats
     {
         Health = ((10 + pokemonBaseStats.Health + GenerateRandomNumber.GetRandomNumber(0, 20) + 50) * level) / 50 + 10,
         Attack = (((10 + pokemonBaseStats.Attack + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         Defence = (((10 + pokemonBaseStats.Defence + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         SpecialAttack = (((10 + pokemonBaseStats.SpecialAttack + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         SpecialDefence = (((10 + pokemonBaseStats.SpecialDefence + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5,
         Speed = (((10 + pokemonBaseStats.Speed + GenerateRandomNumber.GetRandomNumber(0, 20)) * 2) * level) / 100 + 5
     });
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            void PressKey(string name)
            {
                Console.WriteLine($"\n\nPress any key to start {name}\n\n");
                Console.ReadKey();
            }

            using (var qsim = new QuantumSimulator())
            {
                PressKey("Reversable gate");

                for (int i = 0; i < 5; ++i)
                {
                    var initialValue = i % 2 == 0 ? Result.Zero : Result.One;
                    var result       = ReversableGate.Run(qsim, initialValue).Result;
                    Console.WriteLine($"Reversable gate result is: " +
                                      $"{result}. Initial value: {initialValue}");
                }

                PressKey("Measurement superposition collapsing");

                for (int i = 0; i < 15; ++i)
                {
                    var initialValue = i % 2 == 0 ? Result.One : Result.Zero;
                    var result       = MeasurementCollapsingSuperposition
                                       .Run(qsim, initialValue).Result;
                    Console.WriteLine(
                        $"Reversable gate result is: {result.Item1}. " +
                        $"Result2: {result.Item2}. Inital value: {initialValue}");
                }

                PressKey("Random number generator");

                for (int i = 0; i < 10; ++i)
                {
                    var randomNumber = GenerateRandomNumber.Run(qsim).Result;
                    Console.WriteLine($"Random number is: {randomNumber}");
                }

                PressKey("Bell test");

                Result[] initials = new Result[] { Result.Zero, Result.One };
                foreach (var initial in initials)
                {
                    var res = BellTest.Run(qsim, 1000, initial).Result;

                    var(numZeros, numOnes, agrees) = res;
                    Console.WriteLine($"" +
                                      $"Init:{initial,-4} " +
                                      $"0s={numZeros,-4} " +
                                      $"1s={numOnes,-4} " +
                                      $"Agrees = {agrees,-4}");
                }

                PressKey("Deutsch-Jozsa");

                var const0Result   = Constant0.Run(qsim).Result;
                var const1Result   = Constant1.Run(qsim).Result;
                var negationResult = Negation.Run(qsim).Result;
                var identityResult = Identity.Run(qsim).Result;

                Console.WriteLine($"Const0: " +
                                  $"{const0Result.Item1} " +
                                  $"{const0Result.Item2} " +
                                  $"{const0Result.Item3}");

                Console.WriteLine($"Const1: " +
                                  $"{const1Result.Item1} " +
                                  $"{const1Result.Item2} " +
                                  $"{const1Result.Item3}");

                Console.WriteLine($"Identity: " +
                                  $"{identityResult.Item1} " +
                                  $"{identityResult.Item2} " +
                                  $"{identityResult.Item3}");

                Console.WriteLine($"Negation: " +
                                  $"{negationResult.Item1} " +
                                  $"{negationResult.Item2} " +
                                  $"{negationResult.Item3}");

                PressKey("Teleportation part 1");

                for (int i = 0; i < 5; ++i)
                {
                    Console.WriteLine($"Teleport (msg==false): " +
                                      $"{SendMessage.Run(qsim, false).Result}");
                }

                PressKey("Teleportation part 2");

                for (int i = 0; i < 5; ++i)
                {
                    Console.WriteLine($"Teleport (msg==true): " +
                                      $"{SendMessage.Run(qsim, true).Result}");
                }
            }

            Console.WriteLine("\n\nEnd");
            Console.ReadKey();
        }
Exemplo n.º 5
0
 public IAttack GetEnemyAttack() => EnemyPokemon.Attacks.ElementAt(GenerateRandomNumber.GetRandomNumber(0, EnemyPokemon.Attacks.Count));
Exemplo n.º 6
0
 public static bool CalculateChance(int chance, int maxRange = 100)
 {
     return(GenerateRandomNumber.GetRandomNumber(0, maxRange) <= chance);
 }