package CustomObjectIdGenerator
int array id
constant heroPrefix = 'W'
constant nonheroPrefix = '%'
boolean helperActivator = initHelper()
function initHelper() returns boolean
for int i = 0 to 2
id[i] = '0'
return true
function nextValid(int c) returns int
int r = c + 1
if r == '_' or r == ','or r == '"'or r == '\' or r == '-'
r++
if r == '_' or r == ','or r == '"'or r == '\' or r == '-'
r++
return r
function fourChar(int a, int b, int c, int d) returns int
return (((((a*256) + b)*256)+c)*256)+d
function newId(int prefix) returns int
if helperActivator
for i = 0 to 2
if id[i] < '~'
id[i] = nextValid(id[i])
for j = 0 to i-1
id[j] = '!'
return fourChar(prefix, id[2], id[1], id[0])
error("No vaild id left")
return 0
public function genId() returns int
return newId(nonheroPrefix)
public function genHeroId() returns int
return newId(heroPrefix)