コード例 #1
0
        int obtain( Character &ch, long qty ) override {
            ch.moves -= obtain_cost( ch, qty );

            item obj = target()->split( qty );
            if( !obj.is_null() ) {
                return ch.get_item_position( &ch.i_add( obj ) );
            } else {
                int inv = ch.get_item_position( &ch.i_add( *target() ) );
                remove_item();
                return inv;
            }
        }
コード例 #2
0
        int obtain( Character &ch, long qty ) override {
            ch.mod_moves( -obtain_cost( ch, qty ) );

            if( &ch.i_at( ch.get_item_position( target() ) ) == target() ) {
                // item already in target characters inventory at base of stack
                return ch.get_item_position( target() );
            }

            item obj = target()->split( qty );
            if( !obj.is_null() ) {
                return ch.get_item_position( &ch.i_add( obj, should_stack ) );
            } else {
                int inv = ch.get_item_position( &ch.i_add( *target(), should_stack ) );
                remove_item();  // This also takes off the item from whoever wears it.
                return inv;
            }
        }
コード例 #3
0
        int obtain( Character &ch, long qty ) override {
            ch.moves -= obtain_cost( ch, qty );

            if( who.is_worn( *target() ) ) {
                target()->on_takeoff( dynamic_cast<player &>( who ) );
            }

            if( &ch.i_at( ch.get_item_position( target() ) ) == target() ) {
                // item already in target characters inventory at base of stack
                return ch.get_item_position( target() );
            }

            item obj = target()->split( qty );
            if( !obj.is_null() ) {
                return ch.get_item_position( &ch.i_add( obj ) );
            } else {
                int inv = ch.get_item_position( &ch.i_add( *target() ) );
                remove_item();
                return inv;
            }
        }