class Character
{
public:
Character(string charClass, string name);
string getName();
string getClass();
int getBaseHP();
int getBaseMP();
int getMaxHP();
int getMaxMP();
int getLevel();
void levelUp();
int getFreeStatPoints();
bool addPointToStat(char whichStat);
void getShrineStatus(bool shrineArray[]);
void setShrineStatus(bool shrineArray[]);
void getJelocStatus(bool shrineArray[]);
void setJelocStatus(bool shrineArray[]);
int getHPBases();
void setHPBases(int HPbases);
int getMPBases();
void setMPBases(int MPbases);
int getAlignment();
void setAlignment(int align);
};
//------------------------------------------------------------------------------------------------
// Name: CreateNewCharacter
// Desc: Generates a new entry in the character database
//------------------------------------------------------------------------------------------------
BOOL AdminDatabase::CreateNewCharacter( const CHAR* pName, Gender g, Race r, Class c, BYTE Str,
BYTE Agi, BYTE Con, BYTE Int, BYTE Wis,
DWORD* pReturnedCharacterID )
{
// This structure temporarily holds all of the information about the character
Character character;
ZeroMemory( &character, sizeof(Character) );
// Copy in data directly from the parameters
strncpy_s( character.Name, 32, pName, 26 ); // TODO: get rid of numeric constants
character.avatarGender = g;
character.avatarRace = r;
character.avatarClass = c;
// Get the maximum value for each stat for this race and make sure the stats aren't
// messed up. They can't exceed the maximum or dip below 10, and the total must be
// between (5*10) and (25 + 5*10)
BYTE maxStr, maxAgi, maxCon, maxInt, maxWis;
GetMaxStartingStats( character.avatarRace, &maxStr, &maxAgi, &maxCon, &maxInt, &maxWis );
int totalStats = Str + Agi + Con + Int + Wis;
if( (Str > maxStr) || (Agi > maxAgi) || (Con > maxCon) || (Int > maxInt) || (Wis > maxWis) ||
(Str < 10) || (Agi < 10) || (Con < 10) || (Int < 10) || (Wis < 10) ||
(totalStats <5> 25 + 5*10) ||
(character.avatarGender >= __GENDER_COUNT__) ||
(character.avatarRace >= __RACE_COUNT__) ||
(character.avatarClass >= __CLASS_COUNT__) )
return FALSE;
// Save the character stats into the structure
character.Str = Str;
character.Agi = Agi;
character.Con = Con;
character.Int = Int;
character.Wis = Wis;
// Initialize default character settings
// TODO: add initializers here
character.Level = 1;
character.MapID = 0;
character.MapX = -37224.020f;
character.MapY = 4887.287f;
character.CurrentHP = character.MaxHP = 10;
character.CurrentMP = character.MaxMP = 10;
// Make sure this name isn't already taken (this algorithm is really slow and could probably
// be improved by some sort of hashing)
BeginCharacterCS();
for( CharacterIterator ch = m_Characters.begin(); ch != m_Characters.end(); ++ch )
if( 0 == strcmp( ch->second.Name, pName ) ) { EndCharacterCS(); return FALSE; }
// Get the next ID for this character
character.UniqueID = ++m_NextCharacterID;
// Add this character to the database
CharacterInsertResult result = m_Characters.insert( CharacterEntry( character.UniqueID, character ) );
// Leave the critical section
EndCharacterCS();
// Make sure it succeeded
if( !result.second ) return FALSE;
// Return this ID
*pReturnedCharacterID = character.UniqueID;
// It has been added successfully
return TRUE;
}
Ender wrote:The original system had a large random factor to it. Is it safe to assume we won't be having any of that? Getting bad chest pulls is bad enough, but add a chance for bad hp/mp gains every level and it tends to disgruntle players.
Users browsing this forum: No registered users and 1 guest