Breaking news Teripets is coming back
Join grophland, support VPL
View RSS Feed

Sim

RTS/TBS Simulation (need feedback)

Rate this Entry
I need some feedback on what people think of my latest engine idea.

I have started planning my simulation game which I have thought about creating sometime ago. Its basicly like a RTS/TBS without the actual intense graphics rendering. Before each round your select your units to attempt missions against an opposing team.

Here is the structure of my table's so far.


The basic user and settings table.
Code:
CREATE TABLE `_user` (
  `userID` int(11) NOT NULL auto_increment,
  `userHandle` varchar(20) NOT NULL default '',
  `userPass` varchar(255) NOT NULL default '',
  `userRank` int(1) NOT NULL default '0',
  `userEmail` varchar(255) NOT NULL default '',
  `userRef` int(11) NOT NULL default '0',
  `userRefs` int(5) NOT NULL default '0',
  `userImage` varchar(5) NOT NULL default '0',
  `userLastIP` varchar(15) NOT NULL default '',
  `userPage` varchar(100) NOT NULL default '',
  `userTheme` varchar(25) NOT NULL default '',
  `userPageTitle` varchar(100) NOT NULL default '',
  `userRegDate` int(12) NOT NULL default '0',
  `userActCode` int(5) NOT NULL default '0',
  `userLastActive` int(12) NOT NULL default '0',
  `userGender` enum('Male','Female') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Male',
  `userCredits` int(10) NOT NULL DEFAULT '0',
  `userURL` varchar(255) NOT NULL DEFAULT '',
  `userURLTitle` varchar(50) NOT NULL DEFAULT '',
  `userText` text,
  PRIMARY KEY  (`userID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;

CREATE TABLE `settings` (
  `settingID` int(11) NOT NULL AUTO_INCREMENT,
  `settingType` varchar(20) NOT NULL DEFAULT '0',
  `settingResult` varchar(3) NOT NULL DEFAULT '',
  PRIMARY KEY (`settingID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;



INSERT INTO `settings` (`settingType`, `settingResult`) VALUES ('version', '1.0');
battle table will be used for each game, where battleStatus is either "y" for yes, "n" for no, or "w" for waiting for oppoment.
Code:
CREATE TABLE `battles` (
  `battleID` int(11) NOT NULL AUTO_INCREMENT,
  `battleMapID` int(11) NOT NULL DEFAULT '0',
  `battleUserID1` int(11) NOT NULL DEFAULT '0',
  `battleUserID2` int(11) NOT NULL DEFAULT '0',
  `battleStatus` varchar(1) NOT NULL DEFAULT 'w',
  PRIMARY KEY (`cPartID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=0;

the simple race and units. races not really required but could add extra fun to game allowing different units for each race/team/clan/gang
Code:
CREATE TABLE `races` (
  `raceID` int(11) NOT NULL auto_increment,
  `raceName` varchar(50) NOT NULL default '',
  `raceImageFType` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`raceID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;

//dps = damage per second

CREATE TABLE `units` (
  `unitID` int(11) NOT NULL auto_increment,
  `unitName` varchar(50) NOT NULL default '',
  `unitHP` int(3) NOT NULL default '',
  `unitAtt` int(3) NOT NULL default '',
  `unitSpd` int(3) NOT NULL default '',
  `unitRange` int(3) NOT NULL default '',
  `unitDPS` int(3) NOT NULL default '',
  `unitImageFType` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`unitID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;

maps table where users will be virtually battling it out on. It will basicly be one image (an Image Map)
mapPixelYard is how many yards each pixel is which will use the unitSpd for when sending them on missions.
mapPlayers for how many players can play on map at once.

map_locs will be all the places on the image Map from maps.
locMapID refrences the map ID.
locXY is the starting x,y of the image map location
locWidthHeight will be the height and width of the x,y map location
Code:
CREATE TABLE `maps` (
  `mapID` int(11) NOT NULL auto_increment,
  `mapName` varchar(50) NOT NULL default '',
  `mapPixelYard` int(6) NOT NULL default '',
  `mapPlayers` int(2) NOT NULL default '',
  `mapImageFType` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`mapID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;

CREATE TABLE `map_locs` (
  `locID` int(11) NOT NULL auto_increment,
  `locMapID` int(11) NOT NULL default '',
  `locName` varchar(50) NOT NULL default '',
  `locXY` varchar(10) NOT NULL default '',
  `locWidthHeight` varchar(10) NOT NULL default '',
  PRIMARY KEY  (`mapID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;
I will use a cop and robber game as an example here

I decided to do away with buildings so the game isn't really focused on pumping units, so instead its based on missions instead. I am still pondering on what mission's will be addeed such as "Sending X units to Recruit", "Send X units robbing", ect. for robbers. For cops it would be like "Sending X units to Recruit", "Send X units investigating robberies" or something. Idea is not set in stone and could be used for much more then just a cop and robber game.

training will increase all of a units specific stat that was trained such as defense.

ReqTrainingID is for multiple training of same thing
ReqRounds is how many rounds it will take to train the stat
reqCredits is incomplete. I am debating on how the money system will work right now, so if anyone's got any idea's on that. I am interested.

I created a seperate table for the rewards of the training just in case that more then one stat would be increased. Depending on how the money system will work and if any inventory system will be used, I may be adding a training_requirements table. ;\
Code:
CREATE TABLE `trainings` (
  `trainingsID` int(11) NOT NULL auto_increment,
  `trainingsUnitID` int(11) NOT NULL default '',
  `trainingsReqTrainingID` int(11) NOT NULL default '',
  `trainingReqRounds` int(2) NOT NULL default '',
  `trainingReqCredits` int(2) NOT NULL default '',
  PRIMARY KEY  (`trainingsID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;

CREATE TABLE `trainings_bonuses` (
  `trainingBonusID` int(11) NOT NULL auto_increment,
  `trainingsBonusRefID` int(11) NOT NULL default '',
  `trainingBonusType` varchar(5) NOT NULL default '',
  `trainingBonus` varchar(10) NOT NULL default '',
  PRIMARY KEY  (`trainingBonusID`)
) ENGINE=MyISAM  AUTO_INCREMENT=1 ;
Note: this is not finalized. I would like to hear people's suggestions. Though the basic concept of the game is finalized. Furthermore; the game each player in battle will select there actions, then once they are both done selecting there action, the round will begin.

Submit "RTS/TBS Simulation (need feedback)" to Digg Submit "RTS/TBS Simulation (need feedback)" to StumbleUpon Submit "RTS/TBS Simulation (need feedback)" to Google Submit "RTS/TBS Simulation (need feedback)" to del.icio.us

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments

  1. spektyr's Avatar
    I like your design so far, and I have several suggestions that are based purely on my preferences, and won't cause you problems if you like what you have already.

    First, you should use InnoDB if you have the option, because it will perform better than MyISAM when under heavy load. MyISAM does table locking, which means that only one query can interact with a table at a time. InnoDB does row locking, so each table can be accessed by multiple queries, but rows can only be accessed by one query at a time. InnoDB is much better for concurrency.
    http://www.mikebernat.com/blog/MySQL_-_InnoDB_vs_MyISAM

    Second, I suggest not prefacing each column with the name of the table (battleID, mapID locXY, etc.). Since you already know what the table is called and will hopefully be accessing instances under a readable name, it causes redundancy. In your code you'll be doing something like $mymap->mapName, when $map1->name is much cleaner.
    ** Your training table is inconsistent: the first 3 columns use "trainings" with an 's' as the prefix, and the last two use "training" without the 's'. Fix that, at the very least. It will cause you many headaches!

    Try to use foreign keys wherever you can to keep your data consistent. The term is 'referential integrity' - that is, you are not only saying "this row references a user," you are guaranteeing it. Foreign keys will keep you from accidentally referencing a user who has been deleted or who doesn't exist. In the battle table, for example, you have the mapID. Put a foreign key on that row so that the battle always refers to a map and cannot refer to anything else. In that table foreign keys can also be put on both of the players. Of course, foreign keys can only be added to innoDB tables, so this may be a moot point if you choose to continue using MyISAM.
    http://www.techrepublic.com/article/...-mysql/6035435

    What is the settings table for exactly? You use it to set the version of each user to 1.0 (I am assuming this is the project version) - will each user not be upgraded automatically? Do you plan the settings table to hold anything else? If not, you should just have a version column in the users table.

    About the units - Is that table holding the base units (like "Infantry" or "Cavalry" - the list of units a user can own), or does the units table hold the specific instances of those units (user-owned)? Because there is no reference to the owner user I am guessing it's the base unit table, so you'll also need the table indicating what kind of units and how many belong to each user.

    Your `mapPlayers` field in the maps table is interesting because in the battle table you only have two columns for the players - player1 and player2. If there are going to be a variable number of players in each game, you should move the players to a separate table which ties the players and battle together:
    `players`
    -battleID
    -playerID

    This prevents you from potentially violating first normal form in the future if you decide to have the battle table have 3 or more slots for players.
    ** I am assuming that each battle is by default a two-player battle. If your battles can be one OR two player battles, then you are already violating 1NF and should split out players as I've shown here.
    http://en.wikipedia.org/wiki/First_normal_form

    Could you explain your training bonus table more? Is the RefID the ID of a training that is happening? What is bonusType? A name like "defense"? It doesn't seem so because the length is only 5 characters, but I'm not sure what else it would be. And what is the actual trainingBonus column? I am expecting it to be a number, like 1 (an additional +1 stat to strength, or something), except it's a varchar. I may have more suggestions for you based on your answers to this.


    So this may seem like a lot, but I thank you! Here I was, bored, and you pose questions about something I love to talk about! Database design is seriously the most interesting part of building a game. I hope I haven't offended you by all my suggestions - I certainly have some prejudices and you're welcome to overlook them. Good luck with your game! It looks like a lot of fun so far, and I'm looking forward to playing it when you're done.
  2. sunandshadow's Avatar
    If you want to use placeholder graphics, letters of the alphabet (ascii art) are quite popular. You could draw the field in black and white or other colors not used by players (pipes and underscores and such are good for this, you could even do trees and stuff if you wanted), then each team's units could be the letter that unit's name starts with in that team's color.