container.cpp
cowmud-0.11/src/container.cpp · 939 B
From the archive cowmud-0.11.tar.gz
Download the archive « Back to the archive contents
#ifndef _CONTAINER_CPP_
#define _CONTAINER_CPP_
#include "defines.h"
#include "container.h"
Container::Container()
{
name = "";
level = 0;
}
void Container::setName(string str)
{
for (uint count = 0; count < str.length(); count++) {
if (count == 0) {
str[count] = makeUpper(str[count]);
} else {
str[count] = makeLower(str[count]);
}
}
name = str;
}
string Container::getName()
{
return name;
}
void Container::setLevel(int lev)
{
level = lev;
}
int Container::getLevel()
{
return level;
}
bool Container::isNameOk()
{
if (getName().length() <= 0 || getName().length() >= 16) {
return false;
}
// Individual character checking
for (uint count = 0; count < getName().length(); count++) {
uint asciicode = (uint)getName()[count];
if (asciicode < 65 || (asciicode > 133 && asciicode < 141) || asciicode > 172) {
return false;
}
}
return true;
}
#endif