Heute ne ganze Menge in Richtung Clanfights gemacht. Die Berechnung sollte nun (zumindest in der Theorie) schonmal klappen. Alle Daten werden in die Datenbank geschrieben. Was nun noch erledigt werden muss ist, dass die Fights zu bestimmten Zeiten "sichtbar" werden!

main
hecht 13 years ago
parent 53aec6bb41
commit 5ee447997f

@ -10,7 +10,6 @@ include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan_fights.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/fehlerausgabe.inc.php');
// GET-Section
if(isset($_GET['action'])) {
@ -454,6 +453,9 @@ function setProfile($what, $value1, $value2, $clanid, $rootlvl){
mysql_query('UPDATE clan SET homepage = \''.$value1.'\' where id = '.$clanid);
return NULL;
case 'Clanzeichen':
if(strlen($value1.$value2) > MAX_CHARS_CLANSIGN) {
return 'Clanzeichen sind ungültig: Summe aus beiden Teilen darf nicht größer als '.MAX_CHARS_CLANSIGN.' Zeichen sein!';
}
mysql_query('UPDATE clan SET clanz_pre = \''.$value1.'\', clanz_suff = \''.$value2.'\' where id = '.$clanid);
return NULL;
case 'Banner':

@ -9,6 +9,8 @@ include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/config.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/designfunctions.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/fehlerausgabe.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/parse.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/clan.inc.php');
// GET-Section
// Kritisch (SQL-Injections)
$clan_name = validateName($_GET['clan_name']);
@ -27,6 +29,11 @@ if ($charm == 1) {
exit;
}
if(strlen($clan_for.$clan_back) > MAX_CHARS_CLANSIGN) {
displayErrorMessage(NULL, 'Clanzeichen sind ungültig: Summe aus beiden Teilen darf nicht größer als '.MAX_CHARS_CLANSIGN.' Zeichen sein!.', displayHistoryBackLink());
exit;
}
if (!$clan_name) {
displayErrorMessage(NULL, 'Sie müssen einen Clannamen haben.', displayHistoryBackLink());
exit;

@ -8,38 +8,21 @@
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/char.inc.php');
//if($chara_1['id']) {
// $arena = mysql_fetch_array(mysql_query("SELECT id, name, ring, platz, lux, preis, level, skill, exp FROM arena WHERE besitzer='$chara_2[besitzer]' LIMIT 1"));
//} else {
// $arena = mysql_fetch_array(mysql_query("SELECT id, name, ring, platz, lux, preis, level, skill, exp FROM arena WHERE besitzer='$user_ida[id]' LIMIT 1"));
//}
//$arena_geld = ($arena['platz'] / 2) + ($arena['ring'] * 3) + ($arena['lux'] * 50);
//$arena_geld /= 4;
//
//$exp1 = explode(",",$arena[exp]);
//$exp1[0] = round($exp1[0]);
//$arena_besucher = ($arena[ring] * 3) + ($arena[lux] * 200);
//if($arena[preis] != 0){
// $arena_besucher = round($arena_besucher / ($arena[preis] / 10));
//} else{
// $arena_besucher = 1;
//}
//if($arena_besucher<0) {
//$arena_besucher = 0;
//}
//
//if($arena_besucher>$arena[platz]) {
//$arena_besucher = $arena[platz];
//}
//
//$arena_einkommen = $arena_besucher * $arena[preis];
function calculateArenaData($owner_id, $char_1, $char_2, $factor){
// echo 'Berechne die Arena-Daten mit Faktor '.$factor;
$lf = 0.7; // Luxus Exponent
$kf_1 = 1/3; // Kampf Exponent a)
$kf_2 = $kf_1 * $kf_1; // Kampf Exponent b)
// default arena!
if($owner_id == NULL) {
$arena['luxus'] = 2;
$arena['level'] = 2;
$arena['steh'] = 1000000;
$arena['sitz'] = 1000000;
$arena['loge'] = 1000000;
}
$arena = mysql_fetch_assoc(mysql_query('SELECT * FROM arena WHERE besitzer = '.$owner_id));
$wert_char1 = max(0.75,min(1.25,$char_1['siege']/($char_1['niederlagen'] + 0.01))) * getPowerLevelWithBuffs($char_1['id']);
$wert_char2 = max(0.75,min(1.25,$char_2['siege']/($char_2['niederlagen'] + 0.01))) * getPowerLevelWithBuffs($char_2['id']);

@ -15,13 +15,13 @@ function getCharAttackSet($char_id, $type) {
$set = array();
if(is_numeric($char_id)) {
$test = 'SELECT Attack_ID,Round FROM attackenset WHERE Char_ID = '.$char_id.' AND Type = '.$type.' ORDER BY Round LIMIT 10;';
$test = 'SELECT Attack_ID,Round FROM attackenset WHERE Char_ID = '.$char_id.' AND Type = '.$type;
$qry = mysql_query($test);
}
$i = 0;
while ($result = mysql_fetch_assoc($qry)) {
$set[] = array("gruppen_id" => $result['gruppen_id'], "gruppen_name" => $result['gruppen_name']);
$set[$result['round']] = $result['attack_id'];
}
return $set;

@ -389,14 +389,4 @@ function getAttacksforChar($charid, $mode = 0) {
return $overview;
}
/**
* This function reads out the attack set of the char
* @param string $name
* @param int $char_id
*/
function getAttackenSet($name, $char_id) {
// TODO: Further implementation
return NULL;
}
?>

@ -7,6 +7,7 @@
*/
define('MAX_CHARS_CLANSIGN', 8);
$GLOBALS['clan_buffered_instances'] = array ();

@ -7,6 +7,8 @@
*/
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/clan.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/attackenset.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/arena.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/kampf_wrapper.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/semaphore.inc.php');
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/event.inc.php');
@ -511,17 +513,45 @@ function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char
* @return the winners array
*/
function battle($event_id, array $char1, array $char2, $attack_set) {
$char1['attacke'] = implode(',', getCharAttackSet($char1['id'], $attack_set));
$char2['attacke'] = implode(',', getCharAttackSet($char2['id'], $attack_set));
$combinedArray = calculateFight($char1, $char2);
$exp = calculateExperience($char1, $char2, $combinedArray['winner'], 0.01); // very few exp
$combinedArray[KEY_EXP_CHAR1] = $exp[$char1['id']];
$combinedArray[KEY_EXP_CHAR2] = $exp[$char2['id']];
$arena = calculateArenaData(null, $char_1, $char_2, 0.01);
$combinedArray[KEY_LOGE] = $arena['loge'];
$combinedArray[KEY_SITZ] = $arena['sitz'];
$combinedArray[KEY_STEH] = $arena['steh'];
if($combinedArray['winner'] == $char1['id']) {
$combinedArray[KEY_GELD_CHAR1] = $result['geld'] * 0.7;
$combinedArray[KEY_GELD_CHAR2] = $result['geld'] * 0.3;
} else {
$combinedArray[KEY_GELD_CHAR2] = $result['geld'] * 0.7;
$combinedArray[KEY_GELD_CHAR1] = $result['geld'] * 0.3;
}
// first persist the fight and then check who was the winner and adjust the char array for him ;)
persistFight($event_id, $combinedArray);
// now determine the winner
// TODO: implement
// now adjust the winners array
// TODO: implement
// now get the winners array
$rounds = $combinedArray['rounds'];
$lastRound = $rounds[count($rounds) - 1];
$newChar = null;
if($lastRound['char1_array']['id'] == $combinedArray['winner']){
$newChar = $lastRound['char1_array'];
} else {
$newChar = $lastRound['char2_array'];
}
$newChar['mp'] = $newChar['mp']. ','.$newChar['mp_max'];
$newChar['hp'] = $newChar['hp']. ','.$newChar['hp_max'];
return $newChar;
}

@ -16,6 +16,25 @@ define('EVENT_LIGA', 4);
define('EVENT_WANTED', 5);
define('EVENT_CLAN_FIGHT', 6);
// The fights duration is fixed
define('DURATION_FIGHT', 0);
// The fights duration is resolved by the amount of rounds
define('DURATION_ROUND', 1);
// The fights duration is fixed but the time ouf rounds is resolved!
define('DURATION_FIGHT_RESOLVED_ROUNDS', 2);
define('KEY_LOGE', 'LOGE');
define('KEY_SITZ', 'SITZ');
define('KEY_STEH', 'STEH');
define('KEY_EXP_CHAR1', 'EXP_CHAR1');
define('KEY_EXP_CHAR2', 'EXP_CHAR2');
define('KEY_GELD_CHAR1', 'GELD_CHAR1');
define('KEY_GELD_CHAR2', 'GELD_CHAR2');
define('KEY_AXP_CHAR1', 'AXP_CHAR1');
define('KEY_AXP_CHAR2', 'AXP_CHAR2');
define('KEY_ITM_CHAR1', 'ITM_CHAR1');
/**
* Creates an event for a given type and returns the id of this event!
* @param string $type
@ -59,18 +78,28 @@ function addParticipant($event_id, array $char) {
* Persists a fight of one event.
* @param int $event_id
* @param array combined array that is calculated in the kampf_wrapper
* @param int $startTimestamp unix timestamp for the start of the battle
* @param int $durationType the duration value (see the DURATION constants)
* @param int $durationValue the amount of time in minutes
* @return int the id of the fight
*/
function persistFight($event_id, array $combinedArray) {
function persistFight($event_id, array $combinedArray, $startTimestamp, $durationType, $durationValue) {
// persist a fight of two chars (calculated by the wrapper) ^^"
//echo 'The fight was about ' . count($combinedArray) . ' rounds <br>';
$roundsArray = $combinedArray['rounds'];
$winnerId = $combinedArray['winner'];
$hostId = $combinedArray['host'];
$data = $combinedArray['data'];
// first get a fight id ;).
$finished = FALSE;
while(!$finished) {
$sql = 'SELECT IFNULL(max(event_fight_id),0) + 1 FROM event_fights';
$row = mysql_fetch_row(mysql_query($sql));
mysql_query('INSERT INTO event_fights(event_id, event_fight_id) values('.$event_id.', \''.$row[0].'\')');
mysql_query('INSERT INTO event_fights(event_id, event_fight_id, host, winner) values('.$event_id.', \''.$row[0].'\, '. $hostId . ', ' . $winnerId .')');
$finished = mysql_affected_rows() > 0;
$event_fight_id = $row[0];
}
@ -79,28 +108,33 @@ function persistFight($event_id, array $combinedArray) {
for($round = 0; $round < count($combinedArray) ; $round++) {
for($round = 0; $round < count($roundsArray) ; $round++) {
// persist this round ^^"
// first persist char1
$chara_1 = $combinedArray[$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)';
$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'].', \''. $combinedArray[$round]['atk_char1'] .'\', \''. $combinedArray[$round]['dmg_char1'] .'\')';
$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'] .'\')';
// echo $sql .'<br>';
mysql_query($sql);
// now persist char2
$chara_2 = $combinedArray[$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)';
$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'].', \''. $combinedArray[$round]['atk_char2'] .'\', \''. $combinedArray[$round]['dmg_char2'] .'\')';
$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'] .'\')';
// echo $sql .'<br>';
mysql_query($sql);
}
// Okay now do we have any additional data left?
foreach ($data as $key => $value) {
$sql = 'INSERT INTO event_fight_metadata(event_id, event_fight_id, key, value) values('.$event_id.','.$event_fight_id.',\''.$key.'\',\''.$value.'\')';
mysql_query($sql);
}
}

@ -6,6 +6,9 @@
*
*/
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/arena.inc.php');
/**
*
* Converts the learn-ids of a char to the attack ids (that can be used to determine the technique)
@ -33,7 +36,7 @@ function convertLearnIDToAttackID (array $learnids, $char_id) {
* Lets char1 fight against char2 (the attacks that are in the entry "attacken" will be used, no conditions!)
* @param array $char1 the char-array for the first char that should be used (like it is)
* @param array $char2 the char-array for the second char that should be used (like it is)
* @return an array with the contents of the several rounds
* @return an array with the contents of the several rounds + metadata
*/
function calculateFight(array $char1, array $char2) {
@ -105,14 +108,15 @@ function calculateFight(array $char1, array $char2) {
}
}
$metaData = array();
$metaData['host'] = $char1['id'];
## Start the fight ;)
// The "rundenArray" has a specific structure. For each round played another entry is placed.
// 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 !
$rundenArray = array();
$tmp_hp = array();
@ -206,10 +210,40 @@ function calculateFight(array $char1, array $char2) {
$x++;
$rundenArray[] = $runde;
}
if(($k_hp[0] > $k_aufgabe[0] && $k_hp[1] > $k_aufgabe[1]) || ($k_hp[0] < $k_aufgabe[0] && $k_hp[1] < $k_aufgabe[1])) {
// Both are above or both are below their limit to surrender?
if($k_hp[0] >= $k_hp[1]) { // If even the creator wins ;)
$metaData['winner'] = $chara_1['id'];
} else {
$metaData['winner'] = $chara_2['id'];
}
} else if($k_hp[0] < $k_aufgabe[0]) { // char1 is about to surrender
$metaData['winner'] = $chara_2['id'];
} else {
$metaData['winner'] = $chara_1['id'];
}
$metaData['rounds'] = $rundenArray;
$metaData['data'] = array();
return $rundenArray;
}
function calculateExperience(array $char1, array $char2, $winner, $factor) {
$exp[$char1['id']] = 0;
$exp[$char2['id']] = 0;
if($winner == $char1['id']) {
$exp[$char1['id']] = (getPowerLevelWithBuffs($chara_1['id']) + getPowerLevelWithBuffs($chara_2['id'])) * 2.2 * $factor;
$exp[$char2['id']] = (getPowerLevelWithBuffs($chara_1['id']) + getPowerLevelWithBuffs($chara_2['id'])) * $factor;
} else {
$exp[$char1['id']] = (getPowerLevelWithBuffs($chara_1['id']) + getPowerLevelWithBuffs($chara_2['id'])) * $factor;
$exp[$char2['id']] = (getPowerLevelWithBuffs($chara_1['id']) + getPowerLevelWithBuffs($chara_2['id'])) * 2.2 * $factor;
}
return $exp;
}
?>
Loading…
Cancel
Save