This is more a suggestion on your item list.
At some point you may have dozens of potions/swords/armors.
I would add to your list a item type, so Type=Potion, Type=Weapon, Type=Armor
Then you might want to to limit how much they can carry, one way to do that is to give each item a weight.
Another idea for inventory is that you might give each item a Item#
00100=potion1
00101=potion2
00200=Sword1 Iron
00201=Sword2 Steel
00203=Sword2 Silver
In addition, you can give each item type a special value showing where in your inventory it can be carried/used (in this example the first digit).
10100 Bag or backpack
20200 Weapon
30300 Armor
I would work on the item list before you put a lot of work into coding.
You may put your items all on one line, which I think would be easier
Item# Name Value Weight
10100 BluePotion 10 .2
10101 RedPotion 10 .2
If your names have spaces, then you might want to separate them with a marker, such as:
1 2 3 4 5 6 7 8
|
Item# Name Value Weight
10100, Blue Potion, 10, .2
or
10101|Red Potion|20|.2
or with tabs
1234567890123456789012345678901234567890 - < numbers show spacing
10101 Red Potion 20 .2
|
This will make determine if the line was read correctly a lot easier, allow you to check that the item database is not corrupt.
Then figure out if you want to load the file into an array, show only the weapons or show everything available to purchase/sell.