for each integer X from 1 to 6 do loop:
if item-type of item carried by HeroManipulatingItem(HMI) in slot X = item-type of item being manipulated(IBM) /// AND /// item carried by HMI in slot X != IBM //// then: set CHECK = yes ////
endloop if CHECK = yes
then:
remove item carried by HMI by type of IBM
remove item carried by HMI by type of IBM
create ITEM and give it to HMI
else:
skip remaining actions.