What are the buying patterns for heroes?

Solution 1:

The hero will first buy an upgrade if possible, then it will replace the weapon if it is broken, then buy accessories and finally heal with potions.

The accessories are checked from the cheapest to most expensive when considering which to buy.

Heroes will not downgrade weapons as the loop that checks for buying a new weapon will only purchase it if it is higher in the list.