It is now possible to call the "abholen" method for clan fights. Then the whole data required for the char will be calculated and assigned at once.

main
hecht 13 years ago
parent 84fe500a8a
commit cd765c128e

@ -17,7 +17,8 @@ function getCharAttackSet($char_id, $type) {
$set = array(1 => 0,2 => 0,3 => 0,4 => 0,5 => 0,6 => 0,7 => 0,8 => 0,9 => 0,10 => 0); $set = array(1 => 0,2 => 0,3 => 0,4 => 0,5 => 0,6 => 0,7 => 0,8 => 0,9 => 0,10 => 0);
if(is_numeric($char_id)) { if(is_numeric($char_id)) {
$test = 'SELECT Attack_ID,Round FROM attackenset WHERE Char_ID = '.$char_id.' AND Type = '.$type; $test = 'SELECT attack_id,`round` FROM attackenset WHERE Char_ID = '.$char_id.' AND Type = '.$type;
// echo $test . '<br>';
$qry = mysql_query($test); $qry = mysql_query($test);
} }

@ -73,8 +73,7 @@ function addParticipant($event_id, array $char) {
* @param int $event_id * @param int $event_id
* @param array combined array that is calculated in the kampf_wrapper * @param array combined array that is calculated in the kampf_wrapper
* @param int $startTimestamp unix timestamp for the start of the battle * @param int $startTimestamp unix timestamp for the start of the battle
* @param int $durationType the duration value (see the DURATION constants) * @param int $endTimestamp unix timestamp for the end of the battle
* @param int $durationValue the amount of time in minutes
* @return int the id of the fight * @return int the id of the fight
*/ */
function persistFight($event_id, array $combinedArray, $startTimestamp, $endTimestamp) { function persistFight($event_id, array $combinedArray, $startTimestamp, $endTimestamp) {
@ -92,9 +91,11 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
while(!$finished) { while(!$finished) {
$sql = 'SELECT IFNULL(max(event_fight_id),0) + 1 FROM event_fights'; $sql = 'SELECT IFNULL(max(event_fight_id),0) + 1 FROM event_fights';
$row = mysql_fetch_row(mysql_query($sql)); $row = mysql_fetch_row(mysql_query($sql));
$sql = 'INSERT INTO event_fights(event_id, event_fight_id, host, winner, visible) values('.$event_id.', \''.$row[0].'\', '. $hostId . ', ' . $winnerId .', \''.date("Y-m-d H:i:s",$endTimestamp).'\')'; $sql = 'INSERT INTO event_fights(event_id, event_fight_id, host, winner, `starting`, visible) values('.$event_id.', \''.$row[0].'\', '. $hostId . ', ' . $winnerId .', \''.date("Y-m-d H:i:s",$startTimestamp).'\', \''.date("Y-m-d H:i:s",$endTimestamp).'\')';
if(mysql_query($sql) === FALSE) if(mysql_query($sql) === FALSE) {
echo $sql . '<br>';
break; break;
}
$finished = mysql_affected_rows() > 0; $finished = mysql_affected_rows() > 0;
$event_fight_id = $row[0]; $event_fight_id = $row[0];
} }
@ -110,18 +111,18 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
$chara_1 = $roundsArray[$round]['char1_array']; $chara_1 = $roundsArray[$round]['char1_array'];
$sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage, visible)'; $sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage, visible)';
$sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_1['id'].','. $chara_1['hp'].', '. $chara_1['mp'].', '. $chara_1['starke'].', '. $chara_1['speed'].', '. $chara_1['verteidigung'].', '. $chara_1['glueck'].', '. $chara_1['ausdauer'].', \''. $roundsArray[$round]['atk_char1'] .'\', \''. $roundsArray[$round]['dmg_char1'] .'\', \''.date("Y-m-d H:i:s",$endTimestamp).'\')'; $sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_1['id'].',\''. $chara_1['hp'].'\', \''. $chara_1['mp'].'\', '. $chara_1['starke'].', '. $chara_1['speed'].', '. $chara_1['verteidigung'].', '. $chara_1['glueck'].', '. $chara_1['ausdauer'].', '. ($roundsArray[$round]['atk_char1']===NULL?'NULL': '\''.$roundsArray[$round]['atk_char1'].'\'' ).', '. ($roundsArray[$round]['dmg_char1']===NULL?'NULL': '\''.$roundsArray[$round]['dmg_char1'].'\'' ).', \''.date("Y-m-d H:i:s",$endTimestamp).'\')';
// echo $sql .'<br>'; echo $sql .'<br>';
mysql_query($sql); mysql_query($sql);
// now persist char2 // now persist char2
$chara_2 = $roundsArray[$round]['char2_array']; $chara_2 = $roundsArray[$round]['char2_array'];
$sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage, visible)'; $sql = 'INSERT INTO event_fight_rounds(event_id, event_fight_id, round, event_char_id, hp, mp, strength, speed, defense, luck, stamina, attack, damage, visible)';
$sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_2['id'].', '. $chara_2['hp'].', '. $chara_2['mp'].', '. $chara_2['starke'].', '. $chara_2['speed'].', '. $chara_2['verteidigung'].', '. $chara_2['glueck'].', '. $chara_2['ausdauer'].', \''. $roundsArray[$round]['atk_char2'] .'\', \''. $roundsArray[$round]['dmg_char2'] .'\', \''.date("Y-m-d H:i:s",$endTimestamp).'\')'; $sql .= ' values('.$event_id.','.$event_fight_id.','.$round.',' .$chara_2['id'].',\''. $chara_2['hp'].'\', \''. $chara_2['mp'].'\', '. $chara_2['starke'].', '. $chara_2['speed'].', '. $chara_2['verteidigung'].', '. $chara_2['glueck'].', '. $chara_2['ausdauer'].', '. ($roundsArray[$round]['atk_char2']===NULL?'NULL': '\''.$roundsArray[$round]['atk_char2'].'\'' ).', '. ($roundsArray[$round]['dmg_char2']===NULL?'NULL': '\''.$roundsArray[$round]['dmg_char2'].'\'' ).', \''.date("Y-m-d H:i:s",$endTimestamp).'\')';
// echo $sql .'<br>'; echo $sql .'<br>';
mysql_query($sql); mysql_query($sql);
} }
@ -161,5 +162,125 @@ function getEventStatus($charid) {
} }
} }
function abholenChar(array $user, $event_id, $char_id) {
// okay, first checking the basic things
$char = getChar($charid);
if($char['besitzer'] != $user) {
return 'Du kannst den Char nicht abholen weil er dir nicht gehört!!';
}
$ressource = 'User:'.$user_ida['id'];
if(!semaphoreUP($ressource)){ // TRUE, diese Anfrage darf bearbeitet werden
return 'Verarbeitung gerade in Gange, bitte warten...';
}
$event_char = getEventChar($event_id, $char_id);
if($event_char === NULL) {
semaphoreDown($ressource); // free the previously reserved semaphore!
return 'Der Char hat an diesem Event garnicht teil genommen!';
}
if($event_char['abgeholt'] == TRUE) {
semaphoreDown($ressource); // free the previously reserved semaphore!
return 'Der Char wurde schon abgeholt!';
}
// now get the ids of fights that the char has at the event!
$fight_ids = getEventFightIdsByChar($event_id, $char_id);
if(count($fight_ids) <= 0) {
semaphoreDown($ressource); // free the previously reserved semaphore!
return 'Der Char hat in diesem Event keinen Fight bestritten!';
}
$char_exp = 0;
$char_aexp = 0;
$char_geld = 0;
// Okay and now calculate those fights?
// Get the "chars" data :)
foreach ($fight_ids as $fight_id) {
$fight = getEventFight($event_id, $fight_id);
$fight_meta = getEventFightMetaData($event_id, $fight_id);
if($fight['host'] == $char_id) {
$char_exp += $fight_meta['KEY_EXP_CHAR1'];
$char_aexp += $fight_meta['KEY_AXP_CHAR1'];
$char_geld += $fight_meta['KEY_GELD_CHAR1'];
} else {
$char_exp += $fight_meta['KEY_EXP_CHAR2'];
$char_aexp += $fight_meta['KEY_AXP_CHAR2'];
$char_geld += $fight_meta['KEY_GELD_CHAR2'];
}
}
// add the experience to the char
addExpToChar($char_id, $char_exp);
// add the experience to the arena
if($char_aexp > 0) {
addExpToArena($char['besitzer'], $char_aexp);
}
addMoneyToUser($char['besitzer'], $char_geld);
// Okay and now we want to learn the attacks :)
$sql = 'SELECT attack, count(attack) as anzahl FROM event_fight_rounds e group by attack where event_id = ' . $event_id . ' AND event_char_id = ' . $char_id;
$qry = mysql_query($sql);
$attacken_usage = array();
while($row = mysql_fetch_assoc($qry)) {
$attacken_usage[] = array('id' => $row['attack'], 'anzahl' => $row['anzahl']);
}
addAttackUsageToChar($char_id, $attacken_usage);
return $fight_ids; // Return the fight ids that the char has participated in!
}
function getEvent($event_id) {
$result = mysql_fetch_assoc(mysql_query('SELECT * FROM events WHERE event_id = ' . $event_id));
if($result)
return $result;
return NULL;
}
function getEventChar($event_id, $event_char_id) {
$result = mysql_fetch_assoc(mysql_query('SELECT * FROM event_chars WHERE event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id));
if($result)
return $result;
return NULL;
}
function getEventFight($event_id, $event_fight_id) {
$result = mysql_fetch_assoc(mysql_query('SELECT * FROM event_fights WHERE event_id = ' . $event_id. ' AND event_fight_id = ' .$event_fight_id ));
if($result)
return $result;
return NULL;
}
function getEventFightMetaData($event_id, $event_fight_id) {
$qry = mysql_query('SELECT * FROM event_fight_metadata WHERE event_id = ' . $event_id. ' AND event_fight_id = ' .$event_fight_id);
while($row = mysql_fetch_assoc($qry)) {
$result[$row['key']]= $row['value'];
}
return $result;
}
function getEventFightIds($event_id) {
$qry = mysql_query('SELECT event_fight_id FROM event_fights WHERE event_id = ' . $event_id . ' ORDER by event_fight_id ASC');
$result = array();
while($row = mysql_fetch_assoc($qry)) {
$result[]= $row['event_fight_id'];
}
return $result;
}
// this is more tricky XD
function getEventFightIdsByChar($event_id, $event_char_id) {
$sql = 'SELECT event_fight_id FROM event_fight_rounds where event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id . ' AND `round` = 0';
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
$result[]= $row['event_fight_id'];
}
return $result;
}
?> ?>

@ -13,7 +13,7 @@ function beautifyNumericValue($value, $step){
// RUNDEN(POTENZ(10;ABRUNDEN(MAX(LOG(I3;10);2)))/4;0) // RUNDEN(POTENZ(10;ABRUNDEN(MAX(LOG(I3;10);2)))/4;0)
$tmp = round(pow(10,floor(max(log($value,10),2)))/$step); $tmp = round(pow(10,floor(max(log($value,10),2)))/$step);
return round($value / $tmp) * $tmp; return round($value / $tmp) * $tmp;
} }
function calculateRequiredExpChars($level){ function calculateRequiredExpChars($level){
@ -28,7 +28,7 @@ function calculateRequiredExpChars($level){
$g08 = pow($level*$level,8) * pow(10,-26); $g08 = pow($level*$level,8) * pow(10,-26);
$g09 = pow($level*$level,9) * pow(10,-30); $g09 = pow($level*$level,9) * pow(10,-30);
$g10 = pow($level*$level,10) * pow(10,-33); $g10 = pow($level*$level,10) * pow(10,-33);
return beautifyNumericValue($g01 + $g02 + $g03 + $g04 + $g06 + $g07 + $g08 + $g09 + $g10, 8); return beautifyNumericValue($g01 + $g02 + $g03 + $g04 + $g06 + $g07 + $g08 + $g09 + $g10, 8);
// return $g01 + $g02 + $g03 + $g04 + $g06 + $g07 + $g08 + $g09 + $g10; // return $g01 + $g02 + $g03 + $g04 + $g06 + $g07 + $g08 + $g09 + $g10;
} }
@ -46,25 +46,29 @@ function calculateRequiredExpArena($level){
return beautifyNumericValue($g00 + $g01 + $g02 + $g03 + $g04, 8); return beautifyNumericValue($g00 + $g01 + $g02 + $g03 + $g04, 8);
} }
/** /**
* *
* @param $attacken array of 10 arrays with entry (anzahl and a_name) * @param $attacken array of 10 arrays with entry (anzahl and a_name)
* @return unknown_type * @return unknown_type
*/ */
function addAttackUsageToChar($char_id, $attacken){ function addAttackUsageToChar($char_id, $attacken){
$char = getChar($char_id, false); // We really want the actual char!! $char = getChar($char_id, false); // We really want the actual char!!
// Erstmal die Attacken vermerken! // Erstmal die Attacken vermerken!
for($i=0;$i<count($attacken);$i++){ for($i=0;$i<count($attacken);$i++){
// So jetzt nur noch die reqs einpflegen // So jetzt nur noch die reqs einpflegen
$sql = 'Update lernen set benutzt = benutzt + '.$attacken[$i]['anzahl'].' where name = \''.$attacken[$i]['a_name'].'\' and besitzer = '.$char_id; if($$attacken[$i]['id'] === NULL) {
$sql = 'Update lernen set benutzt = benutzt + '.$attacken[$i]['anzahl'].' where name = \''.$attacken[$i]['a_name'].'\' and besitzer = '.$char_id;
} else {
$sql = 'Update lernen set benutzt = benutzt + '.$attacken[$i]['anzahl'].' where at_id = \''.$attacken[$i]['id'].'\' and besitzer = '.$char_id;
}
// echo $sql.'<br>'; // echo $sql.'<br>';
mysql_query($sql); mysql_query($sql);
} }
// Sooo und nun gehts darum ob wir neue Attacken lernen können // Sooo und nun gehts darum ob wir neue Attacken lernen können
// Ersma die ganzen Infos laden // Ersma die ganzen Infos laden
$sql = 'SELECT * FROM lernen where besitzer = '.$char_id; $sql = 'SELECT * FROM lernen where besitzer = '.$char_id;
$qry = mysql_query($sql); $qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)){ while($row = mysql_fetch_assoc($qry)){
$lern[$row['at_id']] = $row; // Zum späteren Check ob die Reqs erfüllt sind $lern[$row['at_id']] = $row; // Zum späteren Check ob die Reqs erfüllt sind
@ -76,24 +80,24 @@ function addAttackUsageToChar($char_id, $attacken){
$zusatz = ' AND id NOT IN('.join($atkid,',').')'; $zusatz = ' AND id NOT IN('.join($atkid,',').')';
} }
// Lernbare Attacken auswählen // Lernbare Attacken auswählen
if(!is_null($char['frucht'])){ if(!is_null($char['frucht'])){
$sql = 'select * from attacken where (Frucht is NULL or Frucht = (Select id from wochen_markt where item = \''.$char['frucht'].'\')) and (rassen != \'\' and rassen != \'0\') and level <= '.$char['level'].$zusatz; $sql = 'select * from attacken where (Frucht is NULL or Frucht = (Select id from wochen_markt where item = \''.$char['frucht'].'\')) and (rassen != \'\' and rassen != \'0\') and level <= '.$char['level'].$zusatz;
} else { } else {
$sql = 'select * from attacken where (Frucht is NULL) and (rassen != \'\' and rassen != \'0\') and level <= '.$char['level'].$zusatz; $sql = 'select * from attacken where (Frucht is NULL) and (rassen != \'\' and rassen != \'0\') and level <= '.$char['level'].$zusatz;
} }
// echo $sql.'<br>'; // echo $sql.'<br>';
$qry = mysql_query($sql); $qry = mysql_query($sql);
// Das geht leider nicht mit dieser Datenstruktur direkt auszuwählen // Das geht leider nicht mit dieser Datenstruktur direkt auszuwählen
$raceid[] = getCharRaceId($char_id); $raceid[] = getCharRaceId($char_id);
if(!is_null(getFusionRaceId($char_id))){ if(!is_null(getFusionRaceId($char_id))){
$raceid[] = getFusionRaceId($char_id); $raceid[] = getFusionRaceId($char_id);
} }
// So und nun arbeite jede Attacke durch die nur im geringsten Lernbar sein könnte ... // So und nun arbeite jede Attacke durch die nur im geringsten Lernbar sein könnte ...
while($row = mysql_fetch_assoc($qry)) { while($row = mysql_fetch_assoc($qry)) {
// Erstmal checken ob es eine Fruchtattacke ist (durch die SQL-Anweisung werden alle nicht zutreffenden Früchte ausgeblockt) // Erstmal checken ob es eine Fruchtattacke ist (durch die SQL-Anweisung werden alle nicht zutreffenden Früchte ausgeblockt)
$learnable = false; $learnable = false;
@ -114,7 +118,7 @@ function addAttackUsageToChar($char_id, $attacken){
} }
} }
} }
if($learnable){ if($learnable){
// Haben wir die benötigten Attacken auch oft genug genutzt?? // Haben wir die benötigten Attacken auch oft genug genutzt??
$r_atck = preg_split('#,#', $row['req_atk']); $r_atck = preg_split('#,#', $row['req_atk']);
@ -122,17 +126,17 @@ function addAttackUsageToChar($char_id, $attacken){
if($r_atck[$u] != '0' && $lern[$r_atck[$u]]['benutzt'] < $row['geld']){ if($r_atck[$u] != '0' && $lern[$r_atck[$u]]['benutzt'] < $row['geld']){
// Passt nicht? dann brauchen wir garnich weiter machen // Passt nicht? dann brauchen wir garnich weiter machen
// echo 'Der Char kann '.$row['name'].' nicht lernen, weil er die Attacke '.$lern[$r_atck[$u]]['name'].' nur '.$lern[$r_atck[$u]]['benutzt'].' mal eingesetzt hat und nicht '.$row['geld'].'<br>'; // echo 'Der Char kann '.$row['name'].' nicht lernen, weil er die Attacke '.$lern[$r_atck[$u]]['name'].' nur '.$lern[$r_atck[$u]]['benutzt'].' mal eingesetzt hat und nicht '.$row['geld'].'<br>';
$learnable = false; $learnable = false;
break; break;
} }
} }
} }
if($learnable){ if($learnable){
mysql_query('INSERT lernen SET name=\''.$row['name'].'\', at_id=\''.$row['id'].'\', besitzer=\''.$char_id.'\', aktiv=\'1\''); mysql_query('INSERT lernen SET name=\''.$row['name'].'\', at_id=\''.$row['id'].'\', besitzer=\''.$char_id.'\', aktiv=\'1\'');
echo '<script language="JavaScript">alert(\''.$char['name'].' hat die Technik '.$row['name'].' gelernt!\');</script>'; echo '<script language="JavaScript">alert(\''.$char['name'].' hat die Technik '.$row['name'].' gelernt!\');</script>';
} }
} }
} }
function addExpToChar($char_id, $n_exp){ function addExpToChar($char_id, $n_exp){
@ -146,7 +150,7 @@ function addExpToChar($char_id, $n_exp){
// Level UP!! // Level UP!!
$lvls++; $lvls++;
$char['level']++; $char['level']++;
$char_exp[0] -= $char_exp[1]; $char_exp[0] -= $char_exp[1];
$char_exp[1] = calculateRequiredExpChars($char['level']); $char_exp[1] = calculateRequiredExpChars($char['level']);
$tp += calculateTrainingPoints($char['level']); $tp += calculateTrainingPoints($char['level']);
@ -180,7 +184,7 @@ function addExpToArena($user_id, $n_exp){
// Level UP!! // Level UP!!
$lvls++; $lvls++;
$arena['level']++; $arena['level']++;
$arena_exp[0] -= $arena_exp[1]; $arena_exp[0] -= $arena_exp[1];
$arena_exp[1] = calculateRequiredExpArena($arena['level']); $arena_exp[1] = calculateRequiredExpArena($arena['level']);
} }

@ -69,12 +69,26 @@ function displayAttacks($attacke1, $schaden1, $attacke2, $schaden2){
} }
function displayFightNotAvailable() {
echo '<tr><td colspan="3"><table class="stylish" width="50%""><tr><td><table width="100%">';
echo '<tr>' .
'<th class="greenstats" colspan="4">Der Fight existiert nicht oder hat noch nicht angefangen!</th>'.
'</tr>';
echo '</table></td></tr>';
echo '</table>';
echo '</td></tr>';
}
function displayFightIsOngoing($char1_name, $char2_name) { function displayFightIsOngoing($char1_name, $char2_name) {
echo '<tr><td colspan="3"><table class="stylish" width="50%""><tr><td><table width="100%">'; echo '<tr><td colspan="3"><table class="stylish" width="50%""><tr><td><table width="100%">';
echo '<tr>' . echo '<tr>' .
'<td class="greenstats" colspan="4">Der Fight läuft noch!</td>'. '<th class="greenstats" colspan="4">Der Fight läuft noch!</th>'.
'</tr>'; '</tr>';
@ -338,7 +352,14 @@ function displayEventFight($event_id, $event_fight_id) {
echo '<html><head><link rel="stylesheet" type="text/css" href="design/FightStyle.css"></head><body><table width="100%">'; echo '<html><head><link rel="stylesheet" type="text/css" href="design/FightStyle.css"></head><body><table width="100%">';
// :D // :D
// first readout the required event data // first readout the required event data
$event_fight_data = mysql_fetch_assoc(mysql_query('SELECT *, visible <= now() as passed FROM event_fights WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id )); $sql = 'SELECT *, visible <= now() as passed FROM event_fights WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id . ' AND `starting` <= now()';
//echo $sql . '<br>';
$event_fight_data = mysql_fetch_assoc(mysql_query($sql));
if(!$event_fight_data){
displayFightNotAvailable();
echo '</table></body></html>';
return;
}
// Okay and now get the data of the chars ;) // Okay and now get the data of the chars ;)
$sql = 'SELECT * FROM event_chars e where event_id = '.$event_id.' and event_char_id IN (SELECT event_char_id from event_fight_rounds where event_id = '.$event_id.' and event_fight_id = '.$event_fight_id.' and `round` = 0)'; $sql = 'SELECT * FROM event_chars e where event_id = '.$event_id.' and event_char_id IN (SELECT event_char_id from event_fight_rounds where event_id = '.$event_id.' and event_fight_id = '.$event_fight_id.' and `round` = 0)';
// echo $sql . '<br>'; // echo $sql . '<br>';
@ -357,7 +378,6 @@ function displayEventFight($event_id, $event_fight_id) {
// Platziere den Table-Header // Platziere den Table-Header
echo '<tr><th class="top" colspan="3">'.$char1['char_name'].' Vs '.$char2['char_name'].'</th></tr>'; echo '<tr><th class="top" colspan="3">'.$char1['char_name'].' Vs '.$char2['char_name'].'</th></tr>';
displayEventFightRound($char1, $char2, array(), array(), 0);
// now get the round data :D // now get the round data :D
$sql = 'SELECT * from event_fight_rounds WHERE event_id = ' .$event_id . ' AND event_fight_id = ' .$event_fight_id . ' and visible <= now()'; $sql = 'SELECT * from event_fight_rounds WHERE event_id = ' .$event_id . ' AND event_fight_id = ' .$event_fight_id . ' and visible <= now()';
$qry = mysql_query($sql); $qry = mysql_query($sql);
@ -370,11 +390,9 @@ function displayEventFight($event_id, $event_fight_id) {
} }
for($i=0;$i<count($char1_rounds);$i++) { for($i=0;$i<count($char1_rounds);$i++) {
displayEventFightRound($char1, $char2, $char1_rounds[$i], $char2_rounds[$i], $i+1); displayEventFightRound($char1, $char2, $char1_rounds[$i], $char2_rounds[$i], $i);
} }
// TODO: check if this fight is fully visible!
// readout the meta-data of this fight :D // readout the meta-data of this fight :D
$sql = 'SELECT * FROM event_fight_metadata WHERE event_id = ' .$event_id . ' AND event_fight_id = ' .$event_fight_id; $sql = 'SELECT * FROM event_fight_metadata WHERE event_id = ' .$event_id . ' AND event_fight_id = ' .$event_fight_id;
$qry = mysql_query($sql); $qry = mysql_query($sql);
@ -406,24 +424,24 @@ function displayEventFightRound(array $char1_data, array $char2_data, array $cha
} }
echo '<tr><th class="round" colspan="3">'.$runde.'</th></tr>'; echo '<tr><th class="round" colspan="3">'.$runde.'</th></tr>';
$c1_str = $roundnr==0?$char1_data['strength']:$char1_round_data['strength']; $c1_str = $char1_round_data['strength'];
$c1_def = $roundnr==0?$char1_data['defense']:$char1_round_data['defense']; $c1_def = $char1_round_data['defense'];
$c1_spd = $roundnr==0?$char1_data['speed']:$char1_round_data['speed']; $c1_spd = $char1_round_data['speed'];
$c1_stm = $roundnr==0?$char1_data['stamina']:$char1_round_data['stamina']; $c1_stm = $char1_round_data['stamina'];
$c1_lck = $roundnr==0?$char1_data['luck']:$char1_round_data['luck']; $c1_lck = $char1_round_data['luck'];
$c1_hp = $roundnr==0?$char1_data['hp']:$char1_round_data['hp']; $c1_hp = $char1_round_data['hp'];
$c1_hpMax = $char1_data['hp']; $c1_hpMax = $char1_data['hp'];
$c1_mp = $roundnr==0?$char1_data['mp']:$char1_round_data['mp']; $c1_mp = $char1_round_data['mp'];
$c1_mpMax = $char1_data['mp']; $c1_mpMax = $char1_data['mp'];
$c2_str = $roundnr==0?$char2_data['strength']:$char2_round_data['strength']; $c2_str = $char2_round_data['strength'];
$c2_def = $roundnr==0?$char2_data['defense']:$char2_round_data['defense']; $c2_def = $char2_round_data['defense'];
$c2_spd = $roundnr==0?$char2_data['speed']:$char2_round_data['speed']; $c2_spd = $char2_round_data['speed'];
$c2_stm = $roundnr==0?$char2_data['stamina']:$char2_round_data['stamina']; $c2_stm = $char2_round_data['stamina'];
$c2_lck = $roundnr==0?$char2_data['luck']:$char2_round_data['luck']; $c2_lck = $char2_round_data['luck'];
$c2_hp = $roundnr==0?$char2_data['hp']:$char2_round_data['hp']; $c2_hp = $char2_round_data['hp'];
$c2_hpMax = $char2_data['hp']; $c2_hpMax = $char2_data['hp'];
$c2_mp = $roundnr==0?$char2_data['mp']:$char2_round_data['mp']; $c2_mp = $char2_round_data['mp'];
$c2_mpMax = $char2_data['mp']; $c2_mpMax = $char2_data['mp'];
// Bild + Avantarinfo | Attacken + Schaden | Bild + Avantarinfo // Bild + Avantarinfo | Attacken + Schaden | Bild + Avantarinfo

@ -18,7 +18,7 @@ include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/arena.inc.php');
function convertLearnIDToAttackID (array $learnids, $char_id) { function convertLearnIDToAttackID (array $learnids, $char_id) {
$result = array(); $result = array();
$sql = 'SELECT id, at_id FROM lernen WHERE id IN ('.implode(',', $learnids).') AND besitzer = ' . $char_id; $sql = 'SELECT id, at_id FROM lernen WHERE id IN ('.implode(',', $learnids).') AND besitzer = ' . $char_id;
// echo $sql .'<br>'; // echo $sql .'<br>';
$qry = mysql_query($sql); $qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) { while($row = mysql_fetch_assoc($qry)) {
for($i=0;$i<count($learnids);$i++) { for($i=0;$i<count($learnids);$i++) {
@ -108,7 +108,6 @@ function calculateFight(array $char1, array $char2) {
} }
} }
$metaData = array(); $metaData = array();
$metaData['host'] = $char1['id']; $metaData['host'] = $char1['id'];
## Start the fight ;) ## Start the fight ;)
@ -117,7 +116,19 @@ function calculateFight(array $char1, array $char2) {
// An entry contains { char1_array*, char2_array*, atk_char1, atk_char2, dmg_char1, dmg_char2 } // An entry contains { char1_array*, char2_array*, atk_char1, atk_char2, dmg_char1, dmg_char2 }
// the char arrays contain the stats of the chars at the end of the round ! // the char arrays contain the stats of the chars at the end of the round !
$rundenArray = array(); $chara_1['hp'] = $k_hp[0];
$chara_1['hp_max'] = $k_hp1[1];
$chara_1['mp'] = $k_mp[0];
$chara_1['mp_max'] = $k_mp1[1];
$chara_2['hp'] = $k_hp[1];
$chara_2['hp_max'] = $k_hp2[1];
$chara_2['mp'] = $k_hp[1];
$chara_2['mp_max'] = $k_hp2[1];
$runde['char1_array'] = $chara_1;
$runde['char2_array'] = $chara_2;
$rundenArray = array($runde);
$tmp_hp = array(); $tmp_hp = array();
while ($k_hp[0] > $k_aufgabe[0] AND $k_hp[1] > $k_aufgabe[1] AND $x < 10) { while ($k_hp[0] > $k_aufgabe[0] AND $k_hp[1] > $k_aufgabe[1] AND $x < 10) {
@ -203,8 +214,9 @@ function calculateFight(array $char1, array $char2) {
$runde['char1_array'] = $chara_1; $runde['char1_array'] = $chara_1;
$runde['char2_array'] = $chara_2; $runde['char2_array'] = $chara_2;
$runde['atk_char1'] = $technick1['name'];
$runde['atk_char2'] = $technick2['name']; $runde['atk_char1'] = $k_attacke1[$x];
$runde['atk_char2'] = $k_attacke2[$x];
$runde['dmg_char1'] = $schaden_1; $runde['dmg_char1'] = $schaden_1;
$runde['dmg_char2'] = $schaden_2; $runde['dmg_char2'] = $schaden_2;

@ -25,6 +25,10 @@ function getUser($userid, $buffer_enabled = true) {
return $GLOBALS['user_buffered_instances'][$userid]; return $GLOBALS['user_buffered_instances'][$userid];
} }
function addMoneyToUser($userid, $amount) {
mysql_query('update user set geld = geld + ' . $amount . ' WHERE id = ' .$userid);
}
function checkSessionPasswort($userid, $password){ function checkSessionPasswort($userid, $password){
$sql = 'SELECT passwort from user where id = \''.$userid.'\''; $sql = 'SELECT passwort from user where id = \''.$userid.'\'';

@ -547,6 +547,7 @@ CREATE TABLE `event_chars` (
`defense` int(11) NOT NULL, `defense` int(11) NOT NULL,
`luck` int(11) NOT NULL, `luck` int(11) NOT NULL,
`stamina` int(11) NOT NULL, `stamina` int(11) NOT NULL,
`abgeholt` tinyint(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`event_id`,`event_char_id`), PRIMARY KEY (`event_id`,`event_char_id`),
KEY `char_bild` (`char_bild`), KEY `char_bild` (`char_bild`),
CONSTRAINT `event_chars_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `event_chars_event_id` FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
@ -586,8 +587,8 @@ CREATE TABLE `event_fight_rounds` (
`defense` int(11) NOT NULL, `defense` int(11) NOT NULL,
`luck` int(11) NOT NULL, `luck` int(11) NOT NULL,
`stamina` int(11) NOT NULL, `stamina` int(11) NOT NULL,
`attack` varchar(30) NOT NULL, `attack` varchar(30) DEFAULT NULL,
`damage` varchar(30) NOT NULL, `damage` varchar(30) DEFAULT NULL,
`visible` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `visible` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`event_id`,`event_fight_id`,`event_char_id`,`round`), PRIMARY KEY (`event_id`,`event_fight_id`,`event_char_id`,`round`),
KEY `event_fight_rounds_chars` (`event_id`,`event_char_id`), KEY `event_fight_rounds_chars` (`event_id`,`event_char_id`),
@ -604,7 +605,8 @@ DROP TABLE IF EXISTS `event_fights`;
CREATE TABLE `event_fights` ( CREATE TABLE `event_fights` (
`event_id` int(10) unsigned NOT NULL, `event_id` int(10) unsigned NOT NULL,
`event_fight_id` int(10) unsigned NOT NULL, `event_fight_id` int(10) unsigned NOT NULL,
`visible` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `visible` timestamp NOT NULL,
`started` timestamp NOT NULL,
`host` int(10) unsigned NOT NULL, `host` int(10) unsigned NOT NULL,
`winner` int(10) unsigned NOT NULL, `winner` int(10) unsigned NOT NULL,
PRIMARY KEY (`event_id`,`event_fight_id`), PRIMARY KEY (`event_id`,`event_fight_id`),

Loading…
Cancel
Save