Пример #1
0
        public void MakeWithTypeChart()
        {
            var coll = new List<Line>();
            var tc = new Gen6TypeChart();
            var types = tc.Types;
            for( var i = 0; i < types.Length; i++ )
            {
                coll.Add( tc.For( new[] { types[i] } ) );
                /*		for( var j = i + 1; j < types.Length; j++ )
                        {
                            coll.Add( tc.For( new[] { types[i], types[j] } ) );
                        }*/
            }
            var _headerIndexes = new Dictionary<MonsterType, int>
            {
            { MonsterType.Normal, 0 },
            { MonsterType.Fire, 1 },
            { MonsterType.Water, 2 },
            { MonsterType.Electric, 3 },
            { MonsterType.Grass, 4 },
            { MonsterType.Ice, 5 },
            { MonsterType.Fighting, 6 },
            { MonsterType.Poison, 7 },
            { MonsterType.Ground, 8 },
            { MonsterType.Flying, 9 },
            { MonsterType.Psychic, 10 },
            { MonsterType.Bug, 11 },
            { MonsterType.Rock, 12 },
            { MonsterType.Ghost, 13 },
            { MonsterType.Dragon, 14 },
            { MonsterType.Dark, 15 },
            { MonsterType.Steel, 16 },
            { MonsterType.Fairy, 17 }
            };

            for( int i = 0; i < _headerIndexes.Count; i++ )
            {
                var mt = (MonsterType) i;
                if( _headerIndexes.ContainsKey( mt ) )
                    Debug.WriteLine( mt + ": " + _headerIndexes[mt] + "," );
                else
                    Debug.WriteLine( "-1" );
            }

            var _serializer = JsonSerializer.Create( new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            } );
            if( File.Exists( @"C:\src\git\PokeSave\pokedb_mobile\x_chart.json" ) )
                File.Delete( @"C:\src\git\PokeSave\pokedb_mobile\x_chart.json" );
            using( var jsonWriter = new JsonTextWriter( new StreamWriter( File.OpenWrite( @"C:\src\git\PokeSave\pokedb_mobile\x_chart.json" ), Encoding.UTF8 ) ) )
            {
                _serializer.Serialize( jsonWriter, coll.Select( MakeMin ).ToArray() );
            }
        }
Пример #2
0
        public void CanCombineTypesToCorrectLine()
        {
            var chart = new Gen6TypeChart();
            var lg = chart.For( MonsterType.Ground );
            var lf = chart.For( MonsterType.Flying );
            var combo = chart.For( new[] { MonsterType.Ground, MonsterType.Flying } );

            Assert.AreEqual( 0m, lg.AttackedBy( MonsterType.Electric ) );
            Assert.AreEqual( 0m, combo.AttackedBy( MonsterType.Electric ) );
            Assert.AreEqual( 2m, lf.AttackedBy( MonsterType.Electric ) );

            Assert.AreEqual( 2m, lg.AttackedBy( MonsterType.Ice ) );
            Assert.AreEqual( 4m, combo.AttackedBy( MonsterType.Ice ) );
            Assert.AreEqual( 2m, lf.AttackedBy( MonsterType.Ice ) );

            Assert.AreEqual( 2m, lg.AttackedBy( MonsterType.Grass ) );
            Assert.AreEqual( 1m, combo.AttackedBy( MonsterType.Grass ) );
            Assert.AreEqual( .5m, lf.AttackedBy( MonsterType.Grass ) );
        }