Hello its me again ;D
And I have a new question.
I am trying to upgrade my little game and decided that it should be Turn based strategy something like CIV3 expect that you have only one settlement and you have to manage what your peoples do. It now contains 2,5D (passive rendering) map with some crappy graphics ;D, working tech research, and job systems.
So I decided that it needs some item transportation system and created it. Then I got an idea that my people cant carry much and need items that could help them to carry more items. But I am unsure how correctly implement it. I could try to create new class called Container which could contain other items, but that way I must refactor my transportation, jobs and item storing system. Or should I add more fields to my item class, but way I must refactor item storing system and jobs system. I think there is some flaws in my design.
Item storing system:
Item class is called Daiktas. It represents stack of items and contains fields DaiktoKodas (Item code), Dydis (1 item size), Kiekis (amount or stock), Size (whole object size) and some other minor variables like name, place, …
Size=Kiekis*Dydis. If any of those variables change value other 2 is recalculated to maintain correct ratio.
My building class is called Pastatas. It contains HashMap and some other variables like Talpa (capacity), Uzimta (used space) and some other.
Items are placed in biulding if them Size is lower that free space in that building (Talpa-Uzimta). DaiktoKodas is used as key to place then in HashMap. Each time adding or removing and item uzimta is changed by that item size(+= or -=).
Transportation system:
Asmuo (person) have ArrayList<Nešulys> that contains all items that he is carrying.
Nešulys class contain Daiktas needed to transport and start and end coordinates.
Asmuo also have field Job which tells what action he can perform if is not travelling.
Jobs system is simply. It just look at asmuo.job and get recipe form HashMap containing all recipes. And then if there is enough needed items at that place creates new items. If there is shortage he go and look for then in other buildings.
I think there may be some flaws. And i don’t know what to change to implement Item-Container concept.
Thanks in advance for your advice.