You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			247 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			247 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			PHP
		
	
<?php
 | 
						|
/*
 | 
						|
 * Created on 08.05.2008
 | 
						|
 *
 | 
						|
 * @copyright (c) 2009 animegame.eu
 | 
						|
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
 | 
						|
 *
 | 
						|
 */
 | 
						|
 | 
						|
 | 
						|
include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
 | 
						|
include_once(ROOT_PATH.'/include/designfunctions.inc.php');
 | 
						|
include_once(ROOT_PATH.'/include/char.inc.php');
 | 
						|
include_once(ROOT_PATH.'/include/parse.inc.php');
 | 
						|
include_once(ROOT_PATH.'/include/exp.inc.php');
 | 
						|
 | 
						|
 | 
						|
 | 
						|
function erstelleUser(){
 | 
						|
	// TODO: Imlementierung
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
// Muss aus einem sicheren Kontext gestartet werden
 | 
						|
function erstelleChar($user, $specialcharname, $newname = '', $picture = '', $lvl = 1, $lp = 0, $hp = 0, $mp = 0, $str = 0, $def = 0, $spd = 0, $end = 0, $lck = 0, $chartype = 'Dragonball'){
 | 
						|
	// If-Anweisungen muessen noch durch Datenbankabfragen ersetzt werden
 | 
						|
	$type = '';
 | 
						|
	$trainingspoints = 0;
 | 
						|
	$special_char = false;
 | 
						|
	$dbz = 'Dragonball';
 | 
						|
	$op = 'Onepiece';
 | 
						|
	$c_type = '';
 | 
						|
 | 
						|
	if($newname == ''){
 | 
						|
		displayErrorMessage(NULL,'Name ist nicht erlaubt!!',displayHistoryBackLink());
 | 
						|
		return false;
 | 
						|
	}
 | 
						|
 | 
						|
	if($specialcharname == 'Mensch') {
 | 
						|
		$HP = 150;
 | 
						|
		$MP =  30;
 | 
						|
		$Starke = 15;
 | 
						|
		$Verteidigung = 9;
 | 
						|
		$Geschwindigkeit = 13;
 | 
						|
		$Gluck = 4;
 | 
						|
		$Ausdauer = 8;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Saiyajin') {
 | 
						|
		$HP = 120;
 | 
						|
		$MP =  30;
 | 
						|
		$Starke = 18;
 | 
						|
		$Verteidigung = 10;
 | 
						|
		$Geschwindigkeit = 9;
 | 
						|
		$Gluck = 5;
 | 
						|
		$Ausdauer = 10;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Dämon') {
 | 
						|
		$HP = 160;
 | 
						|
		$MP =  50;
 | 
						|
		$Starke = 8;
 | 
						|
		$Verteidigung = 15;
 | 
						|
		$Geschwindigkeit = 11;
 | 
						|
		$Gluck = 0;
 | 
						|
		$Ausdauer = 9;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Mutant') {
 | 
						|
		$HP = 180;
 | 
						|
		$MP =  15;
 | 
						|
		$Starke = 13;
 | 
						|
		$Verteidigung = 9;
 | 
						|
		$Geschwindigkeit = 18;
 | 
						|
		$Gluck = 4;
 | 
						|
		$Ausdauer = 5;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Cyborg') {
 | 
						|
		$HP = 250;
 | 
						|
		$MP =  20;
 | 
						|
		$Starke = 11;
 | 
						|
		$Verteidigung = 30;
 | 
						|
		$Geschwindigkeit = 0;
 | 
						|
		$Gluck = 0;
 | 
						|
		$Ausdauer = 0;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Namekianer') {
 | 
						|
		$HP = 100;
 | 
						|
		$MP =  10;
 | 
						|
		$Starke = 18;
 | 
						|
		$Verteidigung = 10;
 | 
						|
		$Geschwindigkeit = 14;
 | 
						|
		$Gluck = 6;
 | 
						|
		$Ausdauer = 10;
 | 
						|
		$type = $dbz;
 | 
						|
	} else if($specialcharname == 'Pirat') {
 | 
						|
		$HP = 100;
 | 
						|
		$MP =  25;
 | 
						|
		$Starke = 20;
 | 
						|
		$Verteidigung = 10;
 | 
						|
		$Geschwindigkeit = 15;
 | 
						|
		$Gluck = 3;
 | 
						|
		$Ausdauer = 7;
 | 
						|
		$type = $op;
 | 
						|
	} else if($specialcharname == 'Schwertkämpfer') {
 | 
						|
		$HP = 100;
 | 
						|
		$MP =  25;
 | 
						|
		$Starke = 25;
 | 
						|
		$Verteidigung = 10;
 | 
						|
		$Geschwindigkeit= 10;
 | 
						|
		$Gluck= 2;
 | 
						|
		$Ausdauer= 8;
 | 
						|
		$type = $op;
 | 
						|
	} else if($specialcharname == 'Grandline Maschine') {
 | 
						|
		$HP = 400;
 | 
						|
		$MP =  5;
 | 
						|
		$Starke = 5;
 | 
						|
		$Verteidigung = 5;
 | 
						|
		$Geschwindigkeit = 5;
 | 
						|
		$Gluck = 0;
 | 
						|
		$Ausdauer = 10;
 | 
						|
		$type = $op;
 | 
						|
	} else if($specialcharname == 'Kaioshin'){
 | 
						|
		$HP = 1000;
 | 
						|
		$MP =  150;
 | 
						|
		$Starke = 100;
 | 
						|
		$Verteidigung = 100;
 | 
						|
		$Geschwindigkeit = 100;
 | 
						|
		$Gluck = 100;
 | 
						|
		$Ausdauer = 100;
 | 
						|
		$type = $dbz;
 | 
						|
		$trainingspoints = 500;
 | 
						|
		$special_char = true;
 | 
						|
		$c_type = $specialcharname;
 | 
						|
	} else if($specialcharname == 'Shichibukai'){
 | 
						|
		$HP = 1000;
 | 
						|
		$MP =  150;
 | 
						|
		$Starke = 100;
 | 
						|
		$Verteidigung = 100;
 | 
						|
		$Geschwindigkeit = 100;
 | 
						|
		$Gluck = 100;
 | 
						|
		$Ausdauer = 100;
 | 
						|
		//$type = $specialcharname; <-- wird überschrieben?!
 | 
						|
		$trainingspoints = 500;
 | 
						|
		$special_char = true;
 | 
						|
		$type = $op;
 | 
						|
		$c_type = $specialcharname;
 | 
						|
	} else if($specialcharname == 'NPC') {
 | 
						|
		$type = $chartype;
 | 
						|
		$HP = $hp;
 | 
						|
		$MP =  $mp;
 | 
						|
		$Starke = $str;
 | 
						|
		$Verteidigung = $def;
 | 
						|
		$Geschwindigkeit = $spd;
 | 
						|
		$Gluck = $lck;
 | 
						|
		$Ausdauer = $end;
 | 
						|
		//reseten der stats, damit kein boost dazukommt
 | 
						|
		$hp = 0;
 | 
						|
		$mp = 0;
 | 
						|
		$str = 0;
 | 
						|
		$def = 0;
 | 
						|
		$spd = 0;
 | 
						|
		$lck = 0;
 | 
						|
		$end = 0;
 | 
						|
		$lp = 0;
 | 
						|
	} else {
 | 
						|
		displayErrorMessage(NULL,'Rasse nicht vorhanden!!',displayHistoryBackLink());
 | 
						|
		return false;
 | 
						|
	}
 | 
						|
	// If-Anweisungen ende
 | 
						|
 | 
						|
	// Werte hinzufügen, falls ein Testcharakter erstellt wird
 | 
						|
	$HP += ($hp*10);
 | 
						|
	$MP += ($mp*5);
 | 
						|
	$Starke += $str;
 | 
						|
	$Verteidigung += $def;
 | 
						|
	$Geschwindigkeit += $spd;
 | 
						|
	$Gluck += $lck;
 | 
						|
	$Ausdauer += $end;
 | 
						|
	$trainingspoints += $lp*2;
 | 
						|
	$LP = ($lvl - 1) * 10;
 | 
						|
 | 
						|
	if($specialcharname != 'NPC') {
 | 
						|
		//Ueberprüfe ob ein Slot frei ist
 | 
						|
		$chars = getCharsOfUser($user['id']);
 | 
						|
		$normal = 0;
 | 
						|
		$special = 0;
 | 
						|
		foreach($chars as $row){
 | 
						|
			if($row['rasse'] == 'Kaioshin' || $row['fusion_rasse'] == 'Kaioshin' || $row['rasse'] == 'Shichibukai' || $row['fusion_rasse'] == 'Shichibukai'){
 | 
						|
				$special++;
 | 
						|
			} else{
 | 
						|
				$normal++;
 | 
						|
			}
 | 
						|
		}
 | 
						|
		$slots_avail = $user['char_max'];
 | 
						|
		if(!$special_char && $special <= 0){
 | 
						|
			$slots_used = $normal;
 | 
						|
		} else{
 | 
						|
			$slots_used = $normal + $special - 1;
 | 
						|
		}
 | 
						|
		//	echo 'Slots used: '.$slots_used.'<br>Slots available: '.$slots_avail.'<br>';
 | 
						|
 | 
						|
		if($slots_used >= $user['char_max']){
 | 
						|
			displayErrorMessage(NULL,'Alle Slots sind schon belegt!!',displayHistoryBackLink());
 | 
						|
			return false;
 | 
						|
		}
 | 
						|
	}
 | 
						|
	// Slotüberprüfung beendet!
 | 
						|
	$sql = 'Insert into chars(name, starke, verteidigung, speed, glueck, ausdauer, hp, mp, level, type, rasse, besitzer, char_type, training_points, lernpunkte, bild, exp) ' .
 | 
						|
				'values(\''.$newname.'\',' .
 | 
						|
						' '.$Starke.',' .
 | 
						|
						' '.$Verteidigung.',' .
 | 
						|
						' '.$Geschwindigkeit.',' .
 | 
						|
						' '.$Gluck.',' .
 | 
						|
						' '.$Ausdauer.',' .
 | 
						|
						' \''.$HP.','.$HP.'\',' .
 | 
						|
						' \''.$MP.','.$MP.'\',' .
 | 
						|
						' '.$lvl.',' .
 | 
						|
						' \''.$type.'\',' .
 | 
						|
						' \''.$specialcharname.'\',' .
 | 
						|
						' '.$user['id'].',' .
 | 
						|
						' \''.$c_type.'\',' .
 | 
						|
						' '.$trainingspoints.',' .
 | 
						|
						' '.$LP.',' .
 | 
						|
						'\''.$picture.'\', '.
 | 
						|
						'\'0,'.calculateRequiredExpChars($lvl).'\'' .
 | 
						|
						')';
 | 
						|
	//echo $sql.'<br>';
 | 
						|
	$identifier = mysql_query($sql);
 | 
						|
	if($identifier == FALSE){
 | 
						|
		if(mysql_fetch_assoc(mysql_query('Select * from chars where name = \''.$newname.'\''))){
 | 
						|
			displayErrorMessage(NULL,'Name schon vorhanden!!',displayHistoryBackLink());
 | 
						|
		} else{
 | 
						|
			displayErrorMessage(NULL,'Erstellen fehlgeschlagen!!',displayHistoryBackLink());
 | 
						|
		}
 | 
						|
		return false; // Hat nich geklappt
 | 
						|
	}
 | 
						|
 | 
						|
	if($specialcharname != 'NPC') {
 | 
						|
		$charsw_id = mysql_fetch_assoc(mysql_query('SELECT id FROM chars WHERE name=\''.$newname.'\''));
 | 
						|
 | 
						|
		mysql_query('INSERT lernen SET at_id=1, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Schlag\', dauer=0');
 | 
						|
		mysql_query('INSERT lernen SET at_id=2, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Kick\', dauer=0');
 | 
						|
		mysql_query('INSERT lernen SET at_id=3, aktiv=1, besitzer='.$charsw_id['id'].', name=\'Block\', dauer=0');
 | 
						|
	}
 | 
						|
	return true; // Hat geklappt
 | 
						|
}
 | 
						|
 | 
						|
?>
 |