Merge pull request #53 from vankk/master

Increased the mininum lenght and decreased the maxinum lenght
This commit is contained in:
slawkens 2018-05-23 20:54:04 +02:00 committed by GitHub
commit cfef209cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,25 +21,25 @@ $save = isset($_POST['save']) && $_POST['save'] == 1;
if($save) { if($save) {
if(empty($newchar_name)) if(empty($newchar_name))
$errors['name'] = 'Please enter a name for your character!'; $errors['name'] = 'Please enter a name for your character!';
else if(strlen($newchar_name) > 25) else if(strlen($newchar_name) > 21)
$errors['name'] = 'Name is too long. Max. lenght <b>25</b> letters.'; $errors['name'] = 'Name is too long. Max. lenght <b>21</b> letters.';
else if(strlen($newchar_name) < 3) else if(strlen($newchar_name) < 4)
$errors['name'] = 'Name is too short. Min. lenght <b>3</b> letters.'; $errors['name'] = 'Name is too short. Min. lenght <b>4</b> letters.';
else { else {
if(!admin() && !Validator::newCharacterName($newchar_name)) { if(!admin() && !Validator::newCharacterName($newchar_name)) {
$errors['name'] = Validator::getLastError(); $errors['name'] = Validator::getLastError();
} }
$exist = new OTS_Player(); $exist = new OTS_Player();
$exist->find($newchar_name); $exist->find($newchar_name);
if($exist->isLoaded()) { if($exist->isLoaded()) {
$errors['name'] = 'Character with this name already exist.'; $errors['name'] = 'Character with this name already exist.';
} }
} }
if(empty($newchar_sex) && $newchar_sex != "0") if(empty($newchar_sex) && $newchar_sex != "0")
$errors[] = 'Please select the sex for your character!'; $errors[] = 'Please select the sex for your character!';
if(count($config['character_samples']) > 1) if(count($config['character_samples']) > 1)
{ {
if(!isset($newchar_vocation)) if(!isset($newchar_vocation))
@ -47,7 +47,7 @@ if($save) {
} }
else else
$newchar_vocation = $config['character_samples'][0]; $newchar_vocation = $config['character_samples'][0];
if(count($config['character_towns']) > 1) { if(count($config['character_towns']) > 1) {
if(!isset($newchar_town)) if(!isset($newchar_town))
$errors[] = 'Please select a town for your character.'; $errors[] = 'Please select a town for your character.';
@ -55,7 +55,7 @@ if($save) {
else { else {
$newchar_town = $config['character_towns'][0]; $newchar_town = $config['character_towns'][0];
} }
if(empty($errors)) { if(empty($errors)) {
if(!isset($config['genders'][$newchar_sex])) if(!isset($config['genders'][$newchar_sex]))
$errors[] = 'Sex is invalid.'; $errors[] = 'Sex is invalid.';
@ -73,14 +73,14 @@ if($save) {
else else
$newchar_vocation = 0; $newchar_vocation = 0;
} }
if(empty($errors)) if(empty($errors))
{ {
$number_of_players_on_account = $account_logged->getPlayersList()->count(); $number_of_players_on_account = $account_logged->getPlayersList()->count();
if($number_of_players_on_account >= $config['characters_per_account']) if($number_of_players_on_account >= $config['characters_per_account'])
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.$config['characters_per_account'].')</b>!'; $errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.$config['characters_per_account'].')</b>!';
} }
if(empty($errors)) if(empty($errors))
{ {
$char_to_copy_name = $config['character_samples'][$newchar_vocation]; $char_to_copy_name = $config['character_samples'][$newchar_vocation];
@ -89,7 +89,7 @@ if($save) {
if(!$char_to_copy->isLoaded()) if(!$char_to_copy->isLoaded())
$errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config/config.php and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.'; $errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config/config.php and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.';
} }
if(empty($errors)) if(empty($errors))
{ {
if($newchar_sex == "0") if($newchar_sex == "0")
@ -104,19 +104,19 @@ if($save) {
$player->setVocation($char_to_copy->getVocation()); $player->setVocation($char_to_copy->getVocation());
if($db->hasColumn('players', 'promotion')) if($db->hasColumn('players', 'promotion'))
$player->setPromotion($char_to_copy->getPromotion()); $player->setPromotion($char_to_copy->getPromotion());
if($db->hasColumn('players', 'direction')) if($db->hasColumn('players', 'direction'))
$player->setDirection($char_to_copy->getDirection()); $player->setDirection($char_to_copy->getDirection());
$player->setConditions($char_to_copy->getConditions()); $player->setConditions($char_to_copy->getConditions());
$rank = $char_to_copy->getRank(); $rank = $char_to_copy->getRank();
if($rank->isLoaded()) { if($rank->isLoaded()) {
$player->setRank($char_to_copy->getRank()); $player->setRank($char_to_copy->getRank());
} }
if($db->hasColumn('players', 'lookaddons')) if($db->hasColumn('players', 'lookaddons'))
$player->setLookAddons($char_to_copy->getLookAddons()); $player->setLookAddons($char_to_copy->getLookAddons());
$player->setTownId($newchar_town); $player->setTownId($newchar_town);
$player->setExperience($char_to_copy->getExperience()); $player->setExperience($char_to_copy->getExperience());
$player->setLevel($char_to_copy->getLevel()); $player->setLevel($char_to_copy->getLevel());
@ -127,10 +127,10 @@ if($save) {
$player->setManaMax($char_to_copy->getManaMax()); $player->setManaMax($char_to_copy->getManaMax());
$player->setManaSpent($char_to_copy->getManaSpent()); $player->setManaSpent($char_to_copy->getManaSpent());
$player->setSoul($char_to_copy->getSoul()); $player->setSoul($char_to_copy->getSoul());
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++)
$player->setSkill($skill, 10); $player->setSkill($skill, 10);
$player->setLookBody($char_to_copy->getLookBody()); $player->setLookBody($char_to_copy->getLookBody());
$player->setLookFeet($char_to_copy->getLookFeet()); $player->setLookFeet($char_to_copy->getLookFeet());
$player->setLookHead($char_to_copy->getLookHead()); $player->setLookHead($char_to_copy->getLookHead());
@ -155,17 +155,17 @@ if($save) {
$player->setLossItems($char_to_copy->getLossItems()); $player->setLossItems($char_to_copy->getLossItems());
$player->setLossContainers($char_to_copy->getLossContainers()); $player->setLossContainers($char_to_copy->getLossContainers());
} }
$player->save(); $player->save();
$player->setCustomField("created", time()); $player->setCustomField("created", time());
$newchar_created = true; $newchar_created = true;
$account_logged->logAction('Created character <b>' . $player->getName() . '</b>.'); $account_logged->logAction('Created character <b>' . $player->getName() . '</b>.');
unset($player); unset($player);
$player = new OTS_Player(); $player = new OTS_Player();
$player->find($newchar_name); $player->find($newchar_name);
if($player->isLoaded()) { if($player->isLoaded()) {
if($db->hasTable('player_skills')) { if($db->hasTable('player_skills')) {
for($i=0; $i<7; $i++) { for($i=0; $i<7; $i++) {
@ -175,11 +175,11 @@ if($save) {
} }
} }
} }
$loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId().""); $loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId()."");
foreach($loaded_items_to_copy as $save_item) foreach($loaded_items_to_copy as $save_item)
$db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', '".$save_item['attributes']."');"); $db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', '".$save_item['attributes']."');");
echo $twig->render('success.html.twig', array( echo $twig->render('success.html.twig', array(
'title' => 'Character Created', 'title' => 'Character Created',
'description' => 'The character <b>' . $newchar_name . '</b> has been created.<br/> 'description' => 'The character <b>' . $newchar_name . '</b> has been created.<br/>