Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (564)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Design question  (Read 1080 times)
0 Members and 1 Guest are viewing this topic.
Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Posted 2011-10-23 10:21:56 »

Hello its me again  Grin
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  Grin, 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.
Offline aazimon
« Reply #1 - Posted 2011-10-27 18:19:17 »

Let me see if I understand what you have. A person class can carry some items. You want to add a container class, allowing the person to have a container. So, does teh person class have a method to "get items"? If so, you would want to change that method to check if the person has a container and then return the container's items.
And class that uses person would still call the same method to get items.
Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Reply #2 - Posted 2011-10-28 13:23:57 »

Thanks for your reply. Your idea is good but only a half. But my question was about my item system. (storing, transporting).
I must admit that this my post maybe was a little too complicated for you to understand (almost 200 views and first reply appeared only after week) or maybe that was your laziness to read my text wall.
Edit: I just read post about bots (http://www.java-gaming.org/topics/jagex-kills-refection-appearently/24969/msg/213476/view/topicseen.html#msg213476) and it start making sense. Cheesy
p.s. sorry if I insult anyone I don't mean to.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #3 - Posted 2011-10-28 18:47:22 »

A Container class probably makes sense conceptually. Each person has a bag or a car has a trunk or whatever and those are all containers, and the container is what determines how many items they have. But considering the functionality of a Container is probably just to be a List with a size limit, it doesn't seem like it needs to be a whole class. You could get away with an Interface that's like ItemHolder or something, and have methods like getItem(), canGetItem(), dropItem(), itemCount() etc.

But, you know, semantics. Either way it seems like you're on the right track, more or less. Or if you just have a Unit class or whatever and all Units can potentially carry something, just put all the functions in there and give them an itemCount variable or something that you can set from subclasses.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Grunnt (20 views)
2014-09-23 14:38:19

radar3301 (14 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (75 views)
2014-09-10 13:57:51

TehJavaDev (108 views)
2014-09-10 06:39:09
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!