Ejemplo n.º 1
0
 public void CanOpenPkmFile()
 {
     var h = File.ReadAllBytes( "testing.pkm" );
     var me = new MonsterEntry( h, true );
     Assert.AreEqual( "MANKEY", me.TypeName );
     Assert.AreEqual( "Scratch", me.Move1Name );
     Assert.AreEqual( 0, me.HPEV );
     Assert.AreEqual( 0, me.Virus );
 }
Ejemplo n.º 2
0
 public PersonalityEngine( MonsterEntry existing )
     : this()
 {
     OriginalTrainer = existing.Shiny ? (uint?) existing.OriginalTrainerId : null;
     Nature = existing.Nature;
     Ability = existing.Ability;
     Evolution = existing.Evolution;
     Gender = new GenderDecision( existing.Gender, existing.TypeInformation );
 }
Ejemplo n.º 3
0
 public void CanSaveAndCreateExactlySamePkmFile()
 {
     var h = File.ReadAllBytes( "testing.pkm" );
     var origin = new byte[h.Length];
     h.CopyTo( origin, 0 );
     var me = new MonsterEntry( h, true );
     var r = me.To3gPkm();
     Assert.AreEqual( origin.Length, r.Length );
     for( int i = 0; i < r.Length; i++ )
         Assert.AreEqual( origin[i], r[i] );
 }
Ejemplo n.º 4
0
 public void CanCorrectChecksumWhenImportingPkm()
 {
     var h = File.ReadAllBytes( "testing.pkm" );
     h[28] = 0;
     var me = new MonsterEntry( h, true );
     me.HPEV = 5;
     var ch = me.CalculatedChecksum;
     var r = me.To3gPkm();
     Assert.AreEqual( ch & 0xff, r[28] );
     Assert.AreEqual( ( ch & 0xff00 ) >> 8, r[29] );
 }
Ejemplo n.º 5
0
 public byte[] To3gPkm()
 {
     var section = new GameSection( RawData );
     var clone = new MonsterEntry( section, 0, Storage );
     clone.Personality = 0;
     for( int i = 32; i < 80; i += 4 )
     {
         section.SetInt( i, clone.GetEncryptedDWord( i ) );
     }
     section.SetInt( 0, Personality );
     section.SetShort( 28, CalculatedChecksum );
     return clone.RawData;
 }
Ejemplo n.º 6
0
 void ExtractPcBuffer()
 {
     var buffer = new PcBuffer( _sections.Skip( 5 ).ToArray() );
     Boxes = new BindingList<Box>();
     PcBuffer = new BindingList<MonsterEntry>();
     PcBuffer.ListChanged += ( a, e ) => InvokePropertyChanged( "PcBuffer" );
     for( int i = 0; i < 420; i++ )
     {
         var entry = new MonsterEntry( buffer, 4 + ( 80 * i ), true );
         var boxnumber = (int) Math.Floor( i / 30.0 );
         if( i % 30 == 0 )
             Boxes.Add( new Box( boxnumber ) );
         PcBuffer.Add( entry );
         Boxes[boxnumber].Content.Add( entry );
     }
 }
Ejemplo n.º 7
0
 public void RepairPokeDex( MonsterEntry m )
 {
     var dexEntry = Dex.FirstOrDefault( a => a.Name == m.TypeInformation.Name );
     if( dexEntry != null )
     {
         dexEntry.Seen = true;
         dexEntry.Owned = true;
     }
 }
Ejemplo n.º 8
0
 public void Setup()
 {
     _b = new byte[100];
     _gs = new GameSection( _b );
     _m = new MonsterEntry( _gs, 0, false );
 }