Planning out a database, need some extra help.

Started by
3 comments, last by ChaosCommand 18 years, 9 months ago
I'm working on Total Tennis Sim (name subject to change) I'm planning out the database. Well, here is what I got so far: ------------------------------------------------------------- Player Details (read as strings... or as char arrays?) Personal: Name Age Nationality Height Description Attitude Player Attributes (Rated from 1 – 20) (read as integers) Technical: Serve Volley Return Curve Physical: Speed Strength Power Jump Mental: Reflexes Positioning Decisions Creativity Shot Ability: Normal Topspin Lob Power ------------------------------------------------------------- Now, I am working on a database editor, the game is going to be run from the command line, and so will the database editor. I will worry about writing to the database from the editor later. But my question is, how would I set up to read in the data and store it to be used in calculations in my tennis sim engine. Here is what I was thinking: 1.Create the file stream, open the file for read-only. 2.Have each stat on it's own line, and the number for the stat following after it. 3.Create an int for each stat. 4.Create either strings or char arrays (Which would you suggest?) for the name, description, nationality and such. 5.Read in each line, skip to the word, go for the number, read in the number and then store it in the variable, and for the strings, just read in the whole line. 6.Close the file. Now, is that how I should do it, or is there an easier way, or a better way you could think about it. I'm open to suggestions. Thanks in advance EDIT: Oh and btw, if anyone happens to look over what I got so far, and feels that I'm leaving anything out... please... please let me know, the attributes and personal info is all I feel that is needed at the moment, but maybe when I start programming the game, I might realize i need something else, so if anyone has any ideas... just throw it out here, it would help me in the long run.
Advertisement
hmmm.... sounds like a fun game... maybe you could incorporate equipment? like racket make/model? and each racket have can influence those technical/ability points? clothing? type of balls? kinda like a weapon/armor/items thing in RPGs... hehe.. and also, money of course, so u can buy equipment for your player...

also, I think strings are easier to use than char arrays, esp when you wanna read/write files, I gather you'd be using a lot of string tokenising....?
-fuchiefck----------------------------------------------------------"Inside the world that you as a programmer or developer create, you are God" - Zerbst & Duvel
Quote:Original post by fuchiefck
hmmm.... sounds like a fun game... maybe you could incorporate equipment? like racket make/model? and each racket have can influence those technical/ability points? clothing? type of balls? kinda like a weapon/armor/items thing in RPGs... hehe.. and also, money of course, so u can buy equipment for your player...

also, I think strings are easier to use than char arrays, esp when you wanna read/write files, I gather you'd be using a lot of string tokenising....?


I guess strings are better. The ideas you had were nice, but, definately for a different game, one you actually play. Right now i'm searching for the match engine itself, running the match, calculating as real to life as possible. But you did give me an idea, Court type is very important, I didn't account for this at all. Racket type could also be implemented later on, maybe give a bonus to power, and have negative affects as well.

Good stuff.

I made a class for the player in the database, and am working on that.

Here is the match engine itself, in it's extreme infancy

Match Engine.cpp
#include "match engine.h"void matchEngine(){	CPlayer player1;	CPlayer player2;	// Get the stats of the player	// Obviously I need to figure out a way	// to pick the player, and then search in the	// database to get that players info	player1.getStats();	// player 2 as well			// Get conditions (weather, court type *thanks for that*)			// Compute data and match	// Display Commentary	// Update score	// Check if game is over, if not, keep playing	}


Match Engine.h
#include "main.h"void matchEngine();class CPlayer{public:	void getStats();private:	string playerName;	int playerAge;	string playerNationality;	int playerHeight;	string playerDescription;	string playerAttitude;	int playerAttributeServe;	int playerAttributeVolley;	int playerAttributeReturn;	int playerAttributeCurve;	int playerAttributeSpeed;	int playerAttributeStrength;	int playerAttributePower;	int playerAttributeJump;	int playerAttributeReflexes;	int playerAttributePositioning;	int playerAttributeDecisions;	int playerAttributeCreativity;	int playerAttributeShotNormal;	int playerAttributeShotTopspin;	int playerAttributeShotLob;	int playerAttributeShotPower;};


getStats Function *Basically opens the database, and grabs the attributes, stores them in there respected variable
void CPlayer::getStats(){	fstream database;	//Open the file as input-only	database.open(fnameComplete.c_str(), ios::in);	// GET ATTRIBUTES AND STORE IN VARIABLES        // A WHOLE bunch of crap you don't want to see        // Finished with file, close it	database.close();}




There is a lot of other stuff and files, but that is the basics to what i'm working on right now.

On the TODO List:
1.Figure out how to pick the tennis player out of the database, and read that players info and stats.
2.Finish up the database editor (basically have to make it to write out a new database entry)
3.Finish up the interface (It's the console, but, it is still work to do)
4.Match Text Commentary (... This will cause headaches)
5.AI for the match engine
6.Score system (.. tennis isn't perfect, especially with the numbers for score)
7.... to actually make it this far
Here is a section of the design document for the game
6. Match Engine

The court will be divided up into 8 sections, like a chessboard.

Each section will be a zone of play for each player. In each section actions and reactions will take place and will be evaluated by the AI system and come up with the solution of what will happen and the players will act accordingly.


=========
| A1 | A2 |
|---------|
| B1 | B2 |
|=======|
| C1 | C2 |
|---------|
| D1 | D2 |
=========


Match Engine Flow:
Player > Update Player Location > Player Action > Location of/to Action > After Action (if needed) > Update Player Location


Match Engine Example:
---------------------------------------------------------------------
Score 0 - 0
P1 Morale = Excited
P1 Condition = 100% *Equivalent to stamina, lower condition = higher chance of injury or being tired, not working as hard*
P2 Morale = Calm
P2 Condition = 100%
Crowd Favoring = P2

Player 1 at A1 serves (normal serve) a powerful ball to C2 | P1 Stays
Player 2 at D2 hits (normal shot) the ball back over the net to A2 | P2 Stays
Player 1 at A1 moves (slowly) to A2 and hits (powerful shot) to D1| P1 Moves Forward to B1
Player 2 at D2 moves (quickly) to D1 and dives (Evaluate Chance) but Misses the ball

Update Score
15 - 0
P1 Morale = Very Excited
P1 Condition = 99%
P2 Morale = Determined
P2 Condition = 97%

RESET
---------------------------------------------------------------------


Yeah, so that is basically how it is going to work (as planned). It's my first time attempting a sports simulation, or a big project for any matter.

A lot of work is required, but, I am finally interested in a project and I'm sure I'll finish this one, even if it won't be everything i'd expect, I'm still aiming to finish it.
And I'm sorry this thread turned from a question about a database, to me explaining how the game is going to work out.

It's almost 5 am, I can't think anymore :P

This topic is closed to new replies.

Advertisement