Jump to content
  • Advertisement
Sign in to follow this  
LongInteger

My football manager game

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im making a simple console football manager game where teams have set money and overall skill and then im going to have it so tht you pick from a bunch of players. This is where i have the problem. I have set a base team with a name, skill and money which is constructed when the game starts in the constructors, the problem is how do i go about adding players the team will have a player array or something to hold the 5 players but how do i get them into my team Would i have to have an overloaded constructor such as Tem::Team() and team::Team(Player myplayer) - Player being the class player where i store his individual stats Is this how i would do it cos my game will be quite simple. The way it will play is u have x amount of money invest in the best team and get the best players and over time ull get more money, more skill/less skill and the idea is to win the league. If there are other ways i can do it id gladly appreciate it but please dont comment on my game design or play i simply want to know how to go about making a team that later lets you add players and sponsors or whatever . . .to keep it simple try and help me understand how i would add players. thanks

Share this post


Link to post
Share on other sites
Advertisement
Heres a few things:

i assume you have a collection of football-players that the game-player must choose from

implementing this i would give each of the football-teams a collection of pointers to players, and have a method on the team addPlayer taking a pointer to the player to add, you would then call this function from your UI/AI

you might want to make the linkage 2 way so you can tell if the player is already on a team, or remove it from your collection of football-players and only keep the reference in your team array- i would go with the 2 way linkage

I would make the constructor take an array of players (im assuming you would need to load multiple players at once after restoring a saved game) and a default constructor (new game teams are probably blank?)

Hope that helped :)

Share this post


Link to post
Share on other sites
sort of, heres but im having touble following you, thasnks for the reply tho i appreciate it

This is how the game atm starts up.

Game clss called which inits 4 teams at the moment for eg

m_pTeamHawks->SetTeam("Hawks", 50, 50, 10million) //obviously this would be 0's

This is how the base team will be set up. When at the head of the game you have chosen which team you wat to control the idea is to use ur budget to get players signe up, the teams skill or lets say 'Presence' dictates how some players will react to ur offers, so for eg picking a local team like elsam their skill would be like 5 so a player in the roster with a high skill value will likly turn any offer down.

these players who u pick will be stored somewhere in an array but they must in the end or before u end the day belong to a team. so say we pick john and geoff as 2 of out 5 they will be stored in out team . . .this is my question, how do i store these players as part of that team, would i use an overloaded constructor to take players and these players will be stored ina naother teamplayers array?

sorry if im not making myself clear cos its geting to me now a bit, beforei do any crazy calculation algs i want to get all the teams set up and a method to place all the players in the available teams. To make it simple im going to have 4 teams with 5 players each, there will be 20 players to choose from but all the 4 teams will have 5 players all from that list with no duplicates, this leads onto another question on how do i store all this.

programming eh . . /sweat

Share this post


Link to post
Share on other sites
ok,

this is how I would do it:

in the team class, add a collection of pointers to players

add methods to the team class that will add/remove POINTERS to the players to this array

then use these methods in your control code (menu buttons, cli, whatever ;) ) to create the teams (you would create the players using a UI and the computers with AI, or just random if your lazy ;) )

if you think it would be usefull you could also add a pointer in the player class to the team they are a member of (2 way link)

so you wind up with an array of players which contains all possible players in the game and then each team will link to the players using pointers

any clearer?

Share this post


Link to post
Share on other sites
Sounds like a cool game. Reminds me of a game I had on my comodore 64 a long time ago.
Have you considered having a couple of players sitting on the bench? (I dont remeber the english word for them. Is it resreves?)
That could add a little challenge to the game ^^
Say you spend all your money on the 5 main players, and have 2 useless reserves waiting on the bench, or spend less money on the 5 main players and have a couple of decent reserves.

What Peter talk about sounds like a good idea for a simple game.
I would defenitly use 2 way link so that when you list the possible players to choose from, you can skip those who already has a team.

class Team;

class Player
{
public:
Player(const string &player_name, int player_cost) : name(player_name), cost(player_cost), home_team(0) {}

string name;
int cost;
Team *home_team;
};

class Team
{
Team()
{
// set all stable players = 0
// set all reserve players = 0
}

Player* stable[5];
Player* reserve[2];
};

// Say this is filled with 20 player attributes read from a file or something
vector<Player> players;

ListAvailablePlayers()
{
for(int i=0; i<players.size(); i++)
if(!players.home_team)
print_player(players);
}

Team::BuyPlayer(int player_index)
{
stable[next_empty_slot] = players[player_index];
players[player_index].home_team = this;
}

I added some pseudoish code here to illustrate.
I dont want to dictate your coding style so I hope you dont mind.

Share this post


Link to post
Share on other sites
that code looks good.. only thing (cus im an OO freak :P ) is that i would make the vector of players and the function either class level members of the Player class or make a factory class for them ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!