private static IEnumerable <ChangeInfo> GetScenarioPokemonChangelist(IScenarioPokemonService beforeService, IScenarioPokemonService afterService)
    {
        List <ChangeInfo> changelist = new();

        PropertyInfo[] props = typeof(ScenarioPokemon).GetProperties().Where(i => i.PropertyType.IsValueType).ToArray();

        foreach (var scenario in EnumUtil.GetValues <ScenarioId>())
        {
            foreach (int i in beforeService.Retrieve((int)scenario).ValidIds())
            {
                var beforeObj = beforeService.Retrieve((int)scenario).Retrieve(i);
                var afterObj  = afterService.Retrieve((int)scenario).Retrieve(i);

                foreach (var prop in props)
                {
                    var beforeVal = prop.GetValue(beforeObj);
                    var afterVal  = prop.GetValue(afterObj);
                    if (!beforeVal.Equals(afterVal))
                    {
                        changelist.Add(new("ScenarioPokemon", $"Scenario_{scenario}_Id_{i}", prop.Name, beforeVal.ToString(), afterVal.ToString()));
                    }
                }
            }
        }

        return(changelist);
    }
Beispiel #2
0
    public void SetModel(int scenario, IChildScenarioWarriorService childScenarioWarriorService)
    {
        Items.Clear();
        foreach (int id in childScenarioWarriorService.ValidIds())
        {
            var    sw             = childScenarioWarriorService.Retrieve(id);
            string pokemon        = "Default";
            string pokemonAbility = "Default";

            if (!sw.ScenarioPokemonIsDefault(0))
            {
                var spid = sw.GetScenarioPokemon(0);
                var childScenarioPokemonService = _scenarioPokemonService.Retrieve(scenario);
                if (childScenarioPokemonService.ValidateId(spid))
                {
                    var sp        = childScenarioPokemonService.Retrieve(spid);
                    int pokemonId = (int)sp.Pokemon;
                    int abilityId = (int)sp.Ability;
                    if (_pokemonService.ValidateId(pokemonId))
                    {
                        pokemon = _pokemonService.IdToName(pokemonId);
                    }
                    if (_abilityService.ValidateId(abilityId))
                    {
                        pokemonAbility = _abilityService.IdToName(abilityId);
                    }
                }
            }

            Items.Add(new ScenarioWarriorGridItemViewModel(id, sw, pokemon, pokemonAbility));
        }
    }
Beispiel #3
0
    public void ReadsCorrectValues()
    {
        var eevee = service.Retrieve((int)ScenarioId.TheLegendOfRansei).Retrieve(0);

        eevee.Data.Should().Equal(new byte[] { 0x00, 0x00, 0xFC, 0x03, 0xEF, 0xBD, 0x87, 0x04 });

        var oshawott = service.Retrieve((int)ScenarioId.TheLegendOfRansei).Retrieve(5);

        oshawott.Data.Should().Equal(new byte[] { 0x69, 0x00, 0xBE, 0x09, 0xEF, 0xBD, 0x57, 0x02 });

        var placeholder = service.Retrieve((int)ScenarioId.TheLegendOfRansei).Retrieve(199);

        placeholder.Data.Should().Equal(new byte[] { 0xC8, 0x00, 0xA4, 0x1A, 0xEF, 0xBD, 0x07, 0x08 });

        var fromAnotherScenario = service.Retrieve((int)ScenarioId.RanseisGreatestBeauty).Retrieve(1);

        fromAnotherScenario.Data.Should().Equal(new byte[] { 0x47, 0x00, 0xFC, 0x03, 0xEF, 0xBD, 0xC7, 0x02 });
    }
Beispiel #4
0
 private void ValidateAbilities()
 {
     foreach (ScenarioId scenario in EnumUtil.GetValues <ScenarioId>())
     {
         int id = 0;
         foreach (var scenarioWarrior in _scenarioWarriorService.Retrieve((int)scenario).Enumerate())
         {
             if (scenarioWarrior.ScenarioPokemonIsDefault(0))
             {
                 continue;
             }
             var scenarioPokemon = _scenarioPokemonService.Retrieve((int)scenario).Retrieve(scenarioWarrior.GetScenarioPokemon(0));
             var pokemon         = _pokemonService.Retrieve((int)scenarioPokemon.Pokemon);
             var abilities       = new[] { pokemon.Ability1, pokemon.Ability2, pokemon.Ability3 };
             if (!abilities.Contains(scenarioPokemon.Ability))
             {
                 ReportConditional($"Scenario={scenario}, ScenarioWarrior={id}, ScenarioPokemon={scenarioWarrior.GetScenarioPokemon(0)}, Pokemon={pokemon.Name}: has ability {scenarioPokemon.Ability} which is not on of {scenarioPokemon.Pokemon}'s abilities "
                                   + $"({pokemon.Ability1}, {pokemon.Ability2}, {pokemon.Ability3})");
             }
             id++;
         }
     }
 }