Exemplo n.º 1
0
        public override void Deserialize( GenericReader reader )
        {
            m_CustomSellList = new ArrayList();
            m_CustomBuyList = new ArrayList();

            base.Deserialize( reader );

            int version = reader.ReadInt();
            m_Treasury = (Container)reader.ReadItem();
            if ( version < 4) obsoleteNation = (Nation)reader.ReadInt();

            int sellcount = reader.ReadInt();
            int buycount = reader.ReadInt();

            for( int i = 0; i < sellcount; i++ )
            {
                VendorEntry entry = new VendorEntry( reader );
                entry.Type = StringToType( entry.TypeName );

                if( entry.Type != null )
                    m_CustomSellList.Add( entry );
            }

            for( int i = 0; i < buycount; i++ )
            {
                VendorEntry entry = new VendorEntry( reader );
                entry.Type = StringToType( entry.TypeName );

                if( entry.Type != null )
                    m_CustomBuyList.Add( entry );
            }

            m_NewSellInfo = new VendorEntry();
            m_NewBuyInfo = new VendorEntry();
        }
Exemplo n.º 2
0
        private void UpdateList( VendorEntry entry, ArrayList list )
        {
            if( entry.TypeName == null || entry.TypeName.Length < 1 || ( !entry.Remove && (entry.Price < 1 || entry.ItemName == null || entry.ItemName.Length < 1) ) )
            {
                this.Say( "Insufficient information." );
                return;
            }

            entry.Type = StringToType( entry.TypeName );

            if( entry.Type == null )
            {
                this.Say( "Invalid type." );
                return;
            }

            bool found = false;

            for( int i = 0; i < list.Count; i++ )
            {
                VendorEntry oldEntry = (VendorEntry)list[i];

                if( oldEntry.Type == entry.Type )
                {
                    list.Remove( oldEntry );

                    if( entry.Remove )
                        this.Say( "Entry removed successfully." );

                    else
                    {
                        list.Add( new VendorEntry( entry.ItemName, entry.TypeName, entry.Price, entry.Type ) );
                        this.Say( "Entry replaced successfully." );
                    }

                    found = true;
                    break;
                }
            }

            if( !found )
            {
                if( entry.Remove )
                    this.Say( "Chosen type could not be removed because it was not in the list." );

                else
                {
                    list.Add( new VendorEntry( entry.ItemName, entry.TypeName, entry.Price, entry.Type ) );
                    this.Say( "New entry added successfully." );
                }
            }
        }
Exemplo n.º 3
0
        public static void Serialize( GenericWriter writer, VendorEntry info )
        {
            writer.Write( (int) 1 ); // version

            writer.Write( (string)info.m_TypeName );
            writer.Write( (int)info.m_Price );
            writer.Write( (bool)info.m_Remove );
            writer.Write( (string)info.m_ItemName );
        }