function CompareEqItem(Context) {

    //the player's class; 
    //type is Number.
    const PlayerClass = Context.PlayerClass;
    //the slot of the alternate item;
    //type is Number;
    const EquipSlot = Context.EquipSlot;
    // information of the equipped item, value is the item information.
    const Equipped = Context.Equipped;
    // information about the alternate item
    const Alternate = Context.Alternate;

    // logic
    let prop = null;
    let anotherProp = null;

    if (Alternate.Propertys.get(326) != null) {
        // Eth
        if (Alternate.Propertys.get(298) == null && Alternate.Propertys.get(299) == null) {
            return false;
        }
    }

    if (EquipSlot == 4) {
        // Weapon
        if (Alternate.ItemType == 38) {
            return false;
        }
        if (Equipped == null) {
            return true;
        }
        prop = Equipped.Propertys.get(14);
        anotherProp = Alternate.Propertys.get(14);
        let prop2 = Alternate.Propertys.get(15);
        // One-Hand
        if ((prop != null || prop2 != null) && anotherProp != null) {
            if (Alternate.ItemQualities > Equipped.ItemQualities) {
                return true;
            }
            let val = prop != null ? parseInt(prop.Values[1]) : parseInt(prop2.Values[1]);
            if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[1]) > val) {
                return true;
            }
        }
        // Two-Hand
        prop = Equipped.Propertys.get(15);
        anotherProp = Alternate.Propertys.get(15);
        if (prop != null && anotherProp != null) {
            let isBow = Equipped.ItemType == 27 || Equipped.ItemType == 85;
            let isABow = Alternate.ItemType == 27 || Equipped.ItemType == 85;
            let isXBow = Equipped.ItemType == 35;
            let isAXBow = Equipped.ItemType == 35;
            if (!isBow && !isABow && !isXBow && !isAXBow) {
                if (Alternate.ItemQualities > Equipped.ItemQualities) {
                    return true;
                }
                if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[1]) > parseInt(prop.Values[1])) {
                    return true
                }
            }
            else {
                if (isBow && isABow) {
                    if (Alternate.ItemQualities > Equipped.ItemQualities) {
                        return true;
                    }
                    if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[1]) > parseInt(prop.Values[1])) {
                        return true
                    }
                }
                if (isXBow && isAXBow) {
                    if (Alternate.ItemQualities > Equipped.ItemQualities) {
                        return true;
                    }
                    if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[1]) > parseInt(prop.Values[1])) {
                        return true
                    }
                }
            }
        }
    } else if (EquipSlot == 5) {
        // Shields
        anotherProp = Alternate.Propertys.get(10);
        if (anotherProp != null) {
            let rightHandItem = d.GetEquippedItem(4);
            if (rightHandItem == null || rightHandItem.Propertys.get(15) == null) {
                if (Equipped == null) {
                    return true;
                }
                if (Alternate.ItemQualities > Equipped.ItemQualities) {
                    return true;
                }
                prop = Equipped.Propertys.get(10);
                if (prop != null) {
                    if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[0]) > parseInt(prop.Values[0])) {
                        return true;
                    }
                }
            }
        }
    } else if (EquipSlot == 6) {
        // Right Ring
        if (Equipped == null) {
            return true;
        }
        if (d.GetEquippedItem(7) == null) {
            return false;
        }
        if (Alternate.ItemQualities > Equipped.ItemQualities) {
            return true;
        }
    } else if (EquipSlot == 7) {
        // Left Ring
        if (Equipped == null) {
            return true;
        }
        if (Alternate.ItemQualities > Equipped.ItemQualities) {
            return true;
        }
    } else if (EquipSlot == 11 || EquipSlot == 12) {
        return false;
    } else {
        if (Equipped == null) {
            return true;
        }
        if (Alternate.ItemQualities > Equipped.ItemQualities) {
            return true;
        }
        prop = Equipped.Propertys.get(10);
        anotherProp = Alternate.Propertys.get(10);
        if (prop != null && anotherProp != null) {
            {
                if (Alternate.ItemQualities == Equipped.ItemQualities && parseInt(anotherProp.Values[0]) > parseInt(prop.Values[0])) {
                    return true;
                }
            }
        }
    }
    return false;
}