Page 1 of 1

Need advice for strategy board game structure.

PostPosted: Thu Mar 29, 2012 1:44 am
by chicoscience
Ok I'm having trouble figuring this out. I'm not a good programmer. I'm more of an IT guy. My previous experience with programing was with python and bash script lol.

Basicaly what i'm trying to do is this.

CITY has gold food soldiers and heroes.
HERO has skills like smithing and attack.

What I did:

Created the variables NAME, GOLD, FOOD, SOLDIERS, SMITHING, ATTACK all as actor variable.
Created a packmanguy actor for every city and every hero. Lets say I have 2 cities and 2 heroes.
Code: Select all
//actor city1
NAME = "Nice City";
GOLD = 1000;
FOOD = 2000;
SOLDIERS = 5000;

//actor city2
NAME = "Good City";
GOLD = 1500;
FOOD = 2500;
SOLDIERS = 15000;

//actor hero1
NAME = "Chuck Norris";
SMITHING = 100;
ATTACK = 100;

//actor hero2
NAME = "Bruce Lee";
SMITHING = 200;
ATTACK = 200;


I can imagine lots of things with this but I get into trouble when I have to associate things. How do I say Bruce Lee is located in city2 for example so I can show on the user interface "You have 1 hero" and give him a button so he can press and see the list of heroes. Let alone see all other attributes the hero has.

I thought of a variable with the location, or use the NAME variable and make a LOCATION variable in the hero actor that would match with the text in the NAME variable. But this way I would have to check every hero in the world or every city in the world so if I have like 100 of each it would be a pain. Also I don't know how I'd do this without specifying each individual actor. A function like "check all actors".

Another solution I thought was when I create the actors and whenever I move the actor or something like that, I would manually update the hero list in the city. I think this is really error prone.

Another solution maybe would to have an array in each city called HEROLIST with the values of the array matching the NAME values of the heroes. A similar "solution" like the other one. Still I don't know how I would use this association to show the rest of the heroes attributes based on this list.

Dang, this stuff is so simple in SQL lol. I'm lost here any help please? :oops:

Re: Need advice for strategy board game structure.

PostPosted: Thu Mar 29, 2012 2:03 am
by skydereign
Do you know about structures and linked lists? It sounds like creating a global array of structures for the cities would be the best way to go about this. And each city would have a list of heroes (which could also be structures, which have the clonename of the actual actor they represent). You could get away with doing this without a linked list, but that means you have to decide on a max number of heroes in a given city, and/or know memory allocation.

Re: Need advice for strategy board game structure.

PostPosted: Thu Mar 29, 2012 3:10 am
by chicoscience
Would te struct/list method allow me to move the hero from a city list to another?

I know I bit about struct. Game a Gogo helped me with it in another topic. But confused about linked lists.

A friend of mine also suggested linked lists. I saw some examples of it but only showing how to make it, not how to access it. Also very differente example from what I'm trying to do so it was hard to understand. That's why I tryied the noob way.

So if I choose the array path I'd have to use the getclone function? Could you please show me an example if not asking too much?

Re: Need advice for strategy board game structure.

PostPosted: Fri Mar 30, 2012 8:05 am
by skydereign
Yeah, if you have a linked list system set up then you could easily move the hero's around. The thing with posting an example is it is heavily based on how you are making your game, and how you want to create the structures. But, the beginning steps are just something like this.
Code: Select all
typedef struct hero_s {
    char clonename[30];
    // other hero states
}hero_t;

typedef struct city_s {
    char name[30]; // name of the city
    hero_t * hero_list; // holds the pointer to the first hero
    // other stats for the city
}city_t;

city_t all_cities[MAX_CITIES]; // array of the cities


You can then initialize the cities into the all_cities array, and use linked list functions to insert heroes and move them around.

Re: Need advice for strategy board game structure.

PostPosted: Fri Mar 30, 2012 8:23 pm
by chicoscience
Thank you sir!