updated code for tournament adjustments

main
hecht 7 years ago
parent 4621896dba
commit 1c31547763

@ -108,13 +108,13 @@ echo "<b> $kampf_a1[name] vs. $kampf_a2[name]";
}
#######################Clan Kampf
if($ab == "Clanfight") {
if($ab == "Clanfight" || $ab == "Turnier") {
if(isEventToFetchAwaiting($char_id)) {
echo "<SCRIPT language='JavaScript'>";
?>
function showfight(){
var Info = window.open("./event_abholen.php?<?php echo $abholstring; ?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
var Info = window.open("./event_abholen.php?<?php echo $abholstring.'&type='.$ab; ?>","","status=no,hotkeys=no,Height=600,Width=820,scrollbars=yes");
}
<?php
@ -122,7 +122,7 @@ echo "</SCRIPT>";
$zeit_in_sek = getEventStatusBlocked($char_id);
?>
<p align=center><b>Clan Kampf</b><br>&nbsp; <br>
<p align=center><b><?php echo $ab; ?></b><br>&nbsp; <br>
<div align='center' id='timer'>
<?php
if($zeit_in_sek <= 0){
@ -136,7 +136,7 @@ $zeit_in_sek = getEventStatusBlocked($char_id);
</div>
<?php
} else {
echo '<p align="center">Im Moment muss der Char vom Clanfight noch nicht abgeholt werden!</p>';
echo '<p align="center">Im Moment muss der Char vom '.$ab.' noch nicht abgeholt werden!</p>';
}
}

@ -410,6 +410,11 @@ function displayClanFightMenuWithClanLocked($user) {
$active_clan_challange_ids = getActiveChallengeIDs($user_clan['id']);
$old_challenge_ids = getHistoricalChallengeIDs($user_clan['id']);
?>
<script>
function showFight(challenge_id){
window.open("./clan/kampf_anzeige.php?challenge="+challenge_id,"","status=no,hotkeys=no,Height=600,Width=929,scrollbars=yes");
}
</script>
<div align="center">
<table width="500" border="0">
<tr>
@ -486,11 +491,11 @@ function displayClanFightMenu($user) {
$authorized = isAuthorizedClanfightCoordinator($user_clan['id'], $user['id']);
?>
<SCRIPT language="JavaScript">
<script>
function showFight(challenge_id){
window.open("./clan/kampf_anzeige.php?challenge="+challenge_id,"","status=no,hotkeys=no,Height=600,Width=929,scrollbars=yes");
}
</SCRIPT>
</script>
<div align="center">
<table width="500">

@ -12,9 +12,9 @@ include_once(ROOT_PATH.'/include/kampf_anzeige.inc.php');
include_once (ROOT_PATH . '/include/event.inc.php');
include_once (ROOT_PATH . '/include/parse.inc.php');
function fetchProcessing($user, $char) {
function fetchProcessing($user, $char, $type) {
$char_id = $char['id'];
$event_ids = getEventIdsToFetch($char_id);
$event_ids = getEventIdsToFetch($char_id, $type);
if(count($event_ids) == 0) {
return 'Es gibt nix zum Abholen!<br>';
}
@ -27,6 +27,11 @@ function fetchProcessing($user, $char) {
foreach ($fight_ids as $event_fight_id) {
displayEventFight($event_id, $event_fight_id);
}
// only continue for clan-fights
if ( $type != EVENT_CLAN_FIGHT ) {
break;
}
}
return NULL;
}
@ -39,12 +44,13 @@ function fetchProcessing($user, $char) {
<body>
<?php
$char_id = validateUnsignedInteger($_GET['char_id'], null);
$type = string2EventType(validateStringCritical($_GET['type'], null));
$char = getChar($char_id);
if($char['besitzer'] != $user_ida['id']) {
echo 'Du kannst den char nicht abholen, da er dir nicht geh&ouml;rt!';
} else {
$res = fetchProcessing($user_ida, $char);
$res = fetchProcessing($user_ida, $char, $type);
if($res != NULL) {
echo $res;
}

@ -221,7 +221,7 @@ if(checkLoginData($_SESSION['user'],$_SESSION['password'])){
displayDefines($_REQUEST);
} else if($_REQUEST['choose'] == 'tournament'){
//_POST['name'] anstatt _REQUEST weil schon durch username überschrieben wird
displayTournamentMenu($_REQUEST['action'], $_REQUEST['klein'], $_REQUEST['wochen'], $_REQUEST['wochenst'], $_REQUEST['minlevel'], $_REQUEST['maxlevel'], $_REQUEST['fusion'], $_REQUEST['special'], $_REQUEST['gain'], $_REQUEST['randomize'], $_POST['name'], $_REQUEST['anzahl']);
displayTournamentMenu($_REQUEST);
}else {
displayOptions();
}

@ -22,7 +22,7 @@ function displayTournamentOptions() {
</tr>
<tr>
<td>Art</td>
<td style="text-align: center"><select id="input" name="name">
<td style="text-align: center"><select id="input" name="art">
<option value="klein">Anf&auml;ngerturnier</option>
<option value="wochen">Wochenturnier</option>
<option value="wochenst">Wochenturnier non-Fusion</option>
@ -87,6 +87,41 @@ function displayTournamentOptions() {
</select>
</td>
</tr>
<tr>
<td>Ausrüstung ignorieren?</td>
<td style="text-align: center"><select id="input" name="itemless">
<option value="1">ja</option>
<option value="0">nein</option>
</select>
</td>
</tr>
<tr>
<td>Chance auf eine Frucht</td>
<td style="text-align: center"><select id="input" name="fruit">
<?php
for ($i = 0; $i <= 100; ++$i) {
?>
<option value="<?php echo $i; ?>"><?php echo $i; ?>%</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Fruchttyp</td>
<td style="text-align: center"><select id="input" name="fruit_type">
<?php
$types = array('natur', 'Logia', 'Paramecia', 'Zoan');
foreach ($types as $type) {
?>
<option value="<?php echo $type; ?>"><?php echo $type; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<!-- <tr>
<td>Gruppenphase?</td>
<td style="text-align: center"><select id="input" name="gruppenphase">
@ -122,7 +157,19 @@ function displayTournamentOptions() {
<?php
}
function displayCheckTournament($minlvl, $maxlvl, $fusion, $special, $gain, $random, $name, $anzahl) {
function displayCheckTournament($request) {
$name = $request['art'];
$anzahl = $request['anzahl'];
$fusion = $request['fusion'];
$special = $request['special'];
$minlvl = $request['minlevel'];
$maxlvl = $request['maxlevel'];
$gain = $request['gain'];
$random = $request['randomize'];
$itemless = $request['itemless'];
$fruit_chance = $request['fruit'];
$fruit_type = $request['fruit_type'];
if(is_numeric($minlvl) && is_numeric($maxlvl)) {?>
<table width="80%">
<tr>
@ -132,7 +179,8 @@ function displayCheckTournament($minlvl, $maxlvl, $fusion, $special, $gain, $ran
<td style="text-align: center"><a
href="<?php echo $GLOBALS['URL_TO_TURNIER'].'?fusion='.$fusion.'&special='.
$special.'&minlevel='.$minlvl.'&maxlevel='.$maxlvl.'&gain='.$gain.'&randomize='.
$random.'&name='.$name.'&anzahl='.$anzahl;?>"
$random.'&name='.$name.'&anzahl='.$anzahl.'&itemless='.$itemless.'&fruit='.
$fruit_chance.'&fruit_type='.$fruit_type;?>"
target="_blank">Turnier starten!</a>
</td>
<td style="text-align: center"><a
@ -148,7 +196,11 @@ function displayCheckTournament($minlvl, $maxlvl, $fusion, $special, $gain, $ran
}
}
function displayEditFee($klein, $wochen, $wochenst) {
function displayEditFee($request) {
$klein = $request['klein'];
$wochen = $request['wochen'];
$wochenst = $request['wochenst'];
$change = FALSE;
if($klein !== NULL || $wochen !== null) {
if($klein !== NULL && $klein != TURNIER_ANFAENGER_GEBUEHR) {
@ -227,16 +279,16 @@ function displayEditFee($klein, $wochen, $wochenst) {
<?php
}
function displayTournamentMenu($action, $klein, $wochen, $wochenst, $minlvl, $maxlvl, $fusion, $special, $gain, $random, $name, $anzahl) {
switch ($action) {
function displayTournamentMenu($request) {
switch ($request['action']) {
case 'checktnmt':
displayCheckTournament($minlvl, $maxlvl, $fusion, $special, $gain, $random, $name, $anzahl);
displayCheckTournament($request);
break;
case 'tnmt':
displayTournamentOptions();
break;
case 'fee':
displayEditFee($klein, $wochen, $wochenst);
displayEditFee($request);
break;
default:
?>

@ -58,10 +58,10 @@
if($my_charz['status'] == 'Frei' ){
$temp = 'Status: '.$my_charz['status'];
$quicklink = "<hr><a href=schatz.php?char_id=$my_charz[id] id=popup>Auf Schatzsuche schicken</a><br><a href=index.php?as=char_profil&char_id=$my_charz[id] id=popup>Attacken einstellen</a>";
} else if($my_charz['status'] == 'Turnier' OR $my_charz['status'] == 'Kampf Erstellt'){
} else if($my_charz['status'] == 'Kampf Erstellt'){
$temp = 'Status: '.$my_charz['status'];
$quicklink = '';
} else if($my_charz['status'] == 'Clanfight' && !isEventToFetchAwaiting($my_charz['id'])) {
} else if($my_charz['status'] == 'Clanfight' && !isEventToFetchAwaiting($my_charz['id'], EVENT_CLAN_FIGHT)) {
$temp = 'Status: '.$my_charz['status'];
} else{
$temp = "<a href=index.php?as=abholen&ab=".$statustemp."&char_id=".$my_charz['id']." id=popup>Status: ".$my_charz['status']."</a>";

@ -194,7 +194,7 @@ function acceptChallengeRequest($challenged_clan, array $user) {
if(isClanLocked($clan_challenge['clan_challenged']) || isClanLocked($clan_challenge['clan_requester'])) {
// okay we cannot accept the challenge so make it inactive!
db_query('UPDATE clan_challenge_requests SET active = FALSE WHERE clan_challenge_id = ' .$clan_challenge_id);
db_query('UPDATE clan_challenge_requests SET active = FALSE WHERE clan_challenged = ' .$clan_challenge['clan_challenged']. ' AND clan_requester = ' .$clan_challenge['clan_requester']. ' AND challenged_time = "' .$clan_challenge['challenged_time']. '"');
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
@ -412,7 +412,7 @@ function getActiveChallengeIDs($clanid) {
return $array;
}
$sql = 'SELECT cc.clan_challenge_id FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE clan_id = ' . $clanid . ' AND calculated = TRUE AND enddate > now() ORDER BY cc.date DESC ' . $addition;
$sql = 'SELECT cc.clan_challenge_id FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE clan_id = ' . $clanid . ' AND calculated = TRUE AND enddate > now() ORDER BY cc.date DESC ';
$qry = db_query($sql);
while($row = mysqli_fetch_row($qry)) {
$array[] = $row[0];
@ -448,6 +448,7 @@ function getHistoricalChallengeIDs($clanid, $limit = NULL) {
}
$sql = 'SELECT cc.clan_challenge_id FROM clan_challenges AS cc inner join clan_challenge_clans AS ccp ON cc.clan_challenge_id = ccp.clan_challenge_id WHERE clan_id = ' . $clanid . ' AND calculated = TRUE AND enddate < now() ORDER BY cc.date DESC ' . $addition;
$qry = db_query($sql);
$array = array();
while($row = mysqli_fetch_row($qry)) {
$array[] = $row[0];
}
@ -602,10 +603,10 @@ function joinChallenge($clan_challenge_id, array $user, $charid, $slot ) {
} else if($char['status'] == 'Clanfight') {
if(isCharBusyWithClanfighting($charid)) {
$row[0] = '???'; // we do not know when the fight is starting!
} else if(getOngoingEventCount($charid) >= MAX_COUNT_PARALLEL_CFS) {
} else if(getOngoingEventCount($charid, EVENT_CLAN_FIGHT) >= MAX_COUNT_PARALLEL_CFS) {
$row[0] = 'MAX';
} else {
$row[0] = getEventStatusBlocked($char_id);
$row[0] = getEventStatusBlocked($charid);
}
} else {
$row = mysqli_fetch_row(db_query('SELECT dauer - ' . time() . ' FROM kampf WHERE db_satz='.$charid ));
@ -883,7 +884,6 @@ function calculateDavyBackClanFight($clan_challenge_id, $event_id, array $clan_i
if(count($clan_char_array[$clan_ids[0]]) != count($clan_char_array[$clan_ids[1]])) {
return 'Davy Back Fights können nur zwischen Clans mit der selben Anzahl von Chars ausgetragen werden!';
}
$result = 0;
$count_chars = count($clan_char_array[$clan_ids[0]]);
// okay ... now do the calculation!
for($runde = 1; $runde<=$count_chars;$runde++) {
@ -891,7 +891,7 @@ function calculateDavyBackClanFight($clan_challenge_id, $event_id, array $clan_i
$char_clan_2 = $clan_char_array[$clan_ids[1]][$runde];
// we do not need to know right now who won the battle! This is required in the post processing (cronjob)!
$winner = battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration);
$winner = calculateEventFight($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration, 0.01, 0.01);
if($winner['id'] == $char_clan_1['id']){
$sql = 'UPDATE clan_challenge_clans SET points = points + 1 WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = ' .$clan_ids[0];
// echo $sql . '<br>';
@ -902,6 +902,10 @@ function calculateDavyBackClanFight($clan_challenge_id, $event_id, array $clan_i
db_query($sql);
}
}
$end_time = $start_time + $count_chars* $duration;
db_query('UPDATE event_chars SET block_end = \''.date("Y-m-d H:i:s",$end_time).'\' WHERE event_id = '.$event_id);
return $start_time + ($runde-1) * $duration;
}
@ -914,7 +918,6 @@ function calculateSurvivalClanFight($clan_challenge_id, $event_id, array $clan_i
if(count($clan_char_array[$clan_ids[0]]) != count($clan_char_array[$clan_ids[1]])) {
return 'Survival Fights können nur zwischen Clans mit der selben Anzahl von Chars ausgetragen werden!';
}
$count_chars = count($clan_char_array[$clan_ids[0]]);
$counter_clan_1 = 1;
$counter_clan_2 = 1;
@ -925,7 +928,7 @@ function calculateSurvivalClanFight($clan_challenge_id, $event_id, array $clan_i
// As long as char 1 and char 2 are set
while($char_clan_1 != NULL && $char_clan_2 != NULL) {
$runde++;
$sieger = battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration);
$sieger = calculateEventFight($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration, 0.01, 0.01);
if($sieger['id'] != $char_clan_1['id']) {
// the loser is of clan 1
$char_clan_1 = $clan_char_array[$clan_ids[0]][++$counter_clan_1];
@ -940,60 +943,10 @@ function calculateSurvivalClanFight($clan_challenge_id, $event_id, array $clan_i
}
$end_time = $start_time + $runde * $duration;
db_query('UPDATE event_chars SET block_end = \''.date("Y-m-d H:i:s",$end_time).'\' WHERE event_id = '.$event_id);
return $char_clan_1 != null?1:-1;
}
/**
* This function calculates the battle between two chars.
* @param int $event_id the event id
* @param array $char1
* @param array $char2
* @param int $attack_set the attack set that should be used!
* @return the winners array
*/
function battle($event_id, array $char1, array $char2, $attack_set, $startTimestamp, $endTimestamp) {
$char1['attacken'] = implode(',', getAttackSet($char1['id'], $attack_set));
$char2['attacken'] = implode(',', getAttackSet($char2['id'], $attack_set));
$combinedArray = calculateFight($char1, $char2);
$exp = calculateExperience($char1, $char2, $combinedArray['winner'], 0.01); // very few exp
$combinedArray['data'][KEY_EXP_CHAR1] = $exp[$char1['id']];
$combinedArray['data'][KEY_EXP_CHAR2] = $exp[$char2['id']];
$arena = calculateArenaData(null, $char1, $char2, 0.01);
$combinedArray['data'][KEY_LOGE] = $arena['loge'];
$combinedArray['data'][KEY_SITZ] = $arena['sitz'];
$combinedArray['data'][KEY_STEH] = $arena['steh'];
if($combinedArray['winner'] == $char1['id']) {
$combinedArray['data'][KEY_GELD_CHAR1] = $arena['geld'] * 0.7;
$combinedArray['data'][KEY_GELD_CHAR2] = $arena['geld'] * 0.3;
} else {
$combinedArray['data'][KEY_GELD_CHAR2] = $arena['geld'] * 0.7;
$combinedArray['data'][KEY_GELD_CHAR1] = $arena['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, $startTimestamp, $endTimestamp);
// 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;
}
function getClanFightCapableClanIds() {
$clan_info = getAllClans();

@ -8,6 +8,7 @@
include_once(ROOT_PATH.'/include/user.inc.php');
include_once (ROOT_PATH . '/include/defines.inc.php');
include_once (ROOT_PATH . '/include/items.inc.php');
defineIfNotDefined('EVENT_TEST', 0);
defineIfNotDefined('EVENT_SCHATZ_SUCHE', 1);
@ -149,16 +150,16 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
// now we have a $event_fight_id ;) lets insert the other stuff ;)
for($round = 0; $round < count($roundsArray) ; $round++) {
// persist this round ^^"
// first persist char1
$chara_1 = $roundsArray[$round]['char1_array'];
$visible_ts = date("Y-m-d H:i:s", ($startTimestamp + ($endTimestamp - $startTimestamp) / 10) * $round);
$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']===NULL?'NULL': '\''.$roundsArray[$round]['atk_char1'].'\'' ).', '. ($roundsArray[$round]['dmg_char1']===NULL?'NULL': '\''.$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", $visible_ts).'\')';
$res = db_query($sql);
@ -168,7 +169,7 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
$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 .= ' 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).'\')';
$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", $visible_ts).'\')';
$res = db_query($sql);
if(!$res)
@ -181,18 +182,26 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime
// echo $sql . ' <br>';
db_query($sql);
}
}
db_query('UPDATE event_chars SET block_begin = \''.date("Y-m-d H:i:s",$startTimestamp).'\', block_end = \''.date("Y-m-d H:i:s",$endTimestamp).'\' WHERE event_id = ' . $event_id);
function getEventIdsToFetch($char_id, $type = NULL) {
$sql_appendix = ($type === NULL) ? '' : ' inner join events e on ec.event_id = e.event_id AND event_type = '.$type;
}
$sql = 'SELECT ec.event_id FROM event_chars ec '.$sql_appendix.' WHERE block_begin <= now() AND (block_end < now() AND abgeholt = FALSE) AND char_id = ' .$char_id . ' ORDER BY ec.event_id ASC';
$qry = db_query($sql);
$result = array();
while ($row = mysqli_fetch_row($qry)) {
$result[] = $row[0];
}
return $result;
}
function getEventStatus($charid) {
$sql = 'SELECT event_type FROM event_chars ec inner join events e on ec.event_id = e.event_id where (block_end > now() or abgeholt = FALSE) and char_id = ' . $charid;
// echo $sql . '<br>';
$qry = db_query($sql);
$row = mysqli_fetch_assoc($qry);
switch ($row['event_type']) {
$event_ids = getEventIdsToFetch($charid);
if (count($event_ids) > 0) {
$event = getEvent($event_ids[0]);
switch ($event['event_type']) {
case EVENT_TEST:
return 'Test';
case EVENT_SCHATZ_SUCHE:
@ -208,38 +217,46 @@ function getEventStatus($charid) {
case EVENT_CLAN_FIGHT:
return 'Clanfight';
}
}
return NULL;
}
function getOngoingEventCount($charid) {
$sql = 'SELECT count(*) FROM event_chars e WHERE abgeholt = FALSE AND char_id = ' .$charid;
$row = mysqli_fetch_row(db_query($sql));
return $row[0];
function string2EventType($text) {
switch($text) {
case 'Schatz Suche':
return EVENT_SCHATZ_SUCHE;
case 'Turnier':
return EVENT_TURNIER;
case 'Kampf':
return EVENT_KAMPF;
case 'Liga':
return EVENT_LIGA;
case 'Wanted':
return EVENT_WANTED;
case 'Clanfight':
return EVENT_CLAN_FIGHT;
default:
return NULL;
}
}
function getEventStatusBlocked($charid) {
$sql = 'SELECT Timestampdiff(Second,now(),MAX(block_end)) FROM event_chars WHERE abgeholt = FALSE AND char_id = ' . $charid;
// echo $sql . '<br>';
$row = mysqli_fetch_row(db_query($sql));
return $row[0];
function getOngoingEventCount($charid, $type = NULL) {
$event_ids = getEventIdsToFetch($charid, $type);
return count($event_ids);
}
function isEventToFetchAwaiting($charid) {
$sql = 'SELECT count(*) FROM event_chars e WHERE abgeholt = FALSE AND char_id = ' .$charid;
$row = mysqli_fetch_row(db_query($sql));
return $row[0] > 0;
return getOngoingEventCount($charid) > 0;
}
function getEventIdsToFetch($char_id) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end < now() and abgeholt = FALSE AND char_id = ' .$char_id . ' ORDER BY event_id ASC';
$qry = db_query($sql);
$result = array();
while ($row = mysqli_fetch_row($qry)) {
$result[] = $row[0];
function getEventStatusBlocked($charid) {
$event_ids = getEventIdsToFetch($charid);
if (count($event_ids) > 0) {
$sql = 'SELECT Timestampdiff(Second,now(),MAX(block_end)) FROM event_chars WHERE event_id = ' . $event_ids[0];
$row = mysqli_fetch_row(db_query($sql));
return $row[0];
}
return $result;
return 0;
}
function abholenChar(array $user, $event_id, $char_id) {
@ -272,9 +289,32 @@ function abholenChar(array $user, $event_id, $char_id) {
return 'Der Char hat in diesem Event keinen Fight bestritten!';
}
$char_meta = getEventCharMetaData($event_id, $event_char['event_char_id']);
$char_exp = 0;
$char_aexp = 0;
$char_geld = 0;
if (isset($char_meta[KEY_EXP_CHAR1])) {
$char_exp += $char_meta[KEY_EXP_CHAR1];
}
if (isset($char_meta[KEY_AXP_CHAR1])) {
$char_aexp += $char_meta[KEY_AXP_CHAR1];
}
if (isset($char_meta[KEY_GELD_CHAR1])) {
$char_geld += $char_meta[KEY_GELD_CHAR1];
}
if (isset($char_meta[KEY_ITM_CHAR1])) {
$items = getItemsMap();
$item = lookupItem($items, $char_meta[KEY_ITM_CHAR1]);
createItemForUser($item, $event_char['user_id']);
echo '<script language="JavaScript">alert(\''.$char['name'].' hat das Item '.$item['name'].' gewonnen!\');</script>';
}
// Okay and now calculate those fights?
// Get the "chars" data :)
foreach ($fight_ids as $fight_id) {
@ -344,6 +384,16 @@ function getEventFight($event_id, $event_fight_id) {
function getEventFightMetaData($event_id, $event_fight_id) {
$qry = db_query('SELECT * FROM event_fight_metadata WHERE event_id = ' . $event_id. ' AND event_fight_id = ' .$event_fight_id);
$result = array();
while($row = mysqli_fetch_assoc($qry)) {
$result[$row['key']]= $row['value'];
}
return $result;
}
function getEventCharMetaData($event_id, $event_char_id) {
$qry = db_query('SELECT * FROM event_char_metadata WHERE event_id = ' . $event_id. ' AND event_char_id = ' .$event_char_id);
$result = array();
while($row = mysqli_fetch_assoc($qry)) {
$result[$row['key']]= $row['value'];
}

@ -390,6 +390,10 @@ function displayEventFight($event_id, $event_fight_id) {
// 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()';
$qry = db_query($sql);
$char1_rounds = array();
$char2_rounds = array();
while($row = mysqli_fetch_assoc($qry)) {
if($event_fight_data['host'] == $row['event_char_id']) {
$char1_rounds[$row['round']] = $row;

@ -17,13 +17,14 @@ include_once(ROOT_PATH.'/include/fehlerausgabe.inc.php');
// Um Copy&PasteFehler zu umgehen!
function displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2, $colspan = 1){
function displaySomething($event_id, $id, $new_max_turnier, $char_nic1, $char_nic2, $colspan = 1) {
// echo '<a href="event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$id[$z].'"><b>'.$char_nick1[$z].'</b> vs. '.$char_nick2[$z].' -> Runde: '.$round[$z].'</a>';
?>
<td width="430" height="150" valign="middle" align="center" colspan="<?php echo $colspan; ?>">
<a href="last_fight2.php?kampf_id=<?php echo $id[$new_max_turnier]; ?>&spleoic=turnier_kampf&art=<?php echo $art; ?>"><?php echo $char_nic1[$new_max_turnier]; ?></a>
<a href="event_kampf_anzeige.php?event_id=<?php echo $event_id; ?>&event_fight_id=<?php echo $id[$new_max_turnier]; ?>"><?php echo $char_nic1[$new_max_turnier]; ?></a>
</td>
<td width="430" valign="middle" align="center" colspan="<?php echo $colspan; ?>">
<a href="last_fight2.php?kampf_id=<?php echo $id[$new_max_turnier]; ?>&spleoic=turnier_kampf&art=<?php echo $art; ?>"><?php echo $char_nic2[$new_max_turnier]; ?></a>
<a href="event_kampf_anzeige.php?event_id=<?php echo $event_id; ?>&event_fight_id=<?php echo $id[$new_max_turnier]; ?>"><?php echo $char_nic2[$new_max_turnier]; ?></a>
</td>
<?php
}
@ -35,46 +36,78 @@ $art = validateString($_GET['art']);
// Unkritisch
$charm = $_GET['charm'];
if($art == 'woche') { $art = 'wochen'; }
$turnier = mysqli_fetch_array(db_query('SELECT hp1, id FROM turnier_kampf WHERE art=\''.$art.'\' LIMIT 1'));
if(!$turnier['id']) {
$turnier_daten = mysqli_fetch_assoc(db_query('SELECT * from turniere WHERE art = "'.$art.'" ORDER BY datum DESC LIMIT 1'));
if(!$turnier_daten) {
displayErrorMessage(NULL,'Turnier fand noch nicht statt!',$back);
}
else if($charm == 1) {
$max_turnier = mysqli_num_rows(db_query('SELECT id FROM turnier_kampf WHERE art=\''.$art.'\''));
$event_id = $turnier_daten['event_id'];
$event_fight_ids = getEventFightIds($event_id);
$max_turnier = count($event_fight_ids);
echo '<link rel="stylesheet" type="text/css" href="design/style3.css">';
$turnier_date = date('d.m.Y');
$turnier_date = $turnier_daten['datum'];
$turnier_info = db_query('SELECT win, char1, char2, id, round, dauer FROM turnier_kampf WHERE art=\''.$art.'\' ORDER BY id ASC');
$u=0;
$pl = 300;
while($row=mysqli_fetch_array($turnier_info)) {
$char_info1 = getChar($row['char1']);
$char_info2 = getChar($row['char2']);
$eventChars = array();
$char_nick1 = array();
$char_nick2 = array();
$char_nic1[] = array();
$char_nic2[] = array();
$char1 = array();
$char2 = array();
$win = array();
$round = array();
$dauer = array();
foreach ($event_fight_ids as $event_fight_id) {
$event_fight = getEventFight($event_id, $event_fight_id);
$host_id = $event_fight['host'];
$qry = db_query('SELECT event_char_id FROM event_fight_rounds where event_id = '.$event_id.' and event_fight_id = '.$event_fight_id.' and round = 0');
$char_info1 = NULL;
$char_info2 = NULL;
while( $row = mysqli_fetch_row($qry) ) {
$char_data = $eventChars[$row[0]];
if ($char_data === NULL) {
$char_data = getEventChar($event_id, $row[0]);
$eventChars[$row[0]] = $char_data;
}
if ($row[0] == $host_id) {
$char_info1 = $char_data;
} else {
$char_info2 = $char_data;
}
}
$dauer[] = $event_fight['passed'];
$dauer[] = $row['dauer'];
if(($pl * $u) + $dauer[0] < time()) {
$char_nic1[]='<img src="'.$char_info1['bild'].'" width="75" height="75" border="0"><br>'.$char_info1['name'];
$char_nic2[]='<img src="'.$char_info2['bild'].'" width="75" height="75" border="0"><br>'.$char_info2['name'];
if ($event_fight['passed'] == 1) {
$char_nic1[]='<img src="'.$char_info1['char_bild'].'" width="75" height="75" border="0"><br>'.$char_info1['char_name'];
$char_nic2[]='<img src="'.$char_info2['char_bild'].'" width="75" height="75" border="0"><br>'.$char_info2['char_name'];
} else {
$char_nic1[]='<img src="design/bilder/avatare/Char.gif" width="75" height="75" border="0"><br>???';
$char_nic2[]='<img src="design/bilder/avatare/Char.gif" width="75" height="75" border="0"><br>???';
}
$char_nick1[]=$char_info1['name'];
$char_nick2[]=$char_info2['name'];
$char1[]=$row['char1'];
$char2[]=$row['char2'];
$char_nick1[]=$char_info1['char_name'];
$char_nick2[]=$char_info2['char_name'];
$char1[]=$char_info1['event_char_id'];
$char2[]=$char_info1['event_char_id'];
$win[]=$row['win'];
$id[]=$row['id'];
$round[]=$row['round'];
$win[]=$event_fight['winner'];
$round[]=getEventFightMetaData($event_id, $event_fight_id)['round'];
$u++;
}
$maxs = $max_turnier-1;
$win_char = getChar($win[$maxs]);
$maxs = $max_turnier-1;
$win_char = $eventChars[$win[$maxs]];
?>
<html>
@ -89,12 +122,12 @@ $win_char = getChar($win[$maxs]);
<?php
if(($pl * $max_turnier) + $dauer[0] < time()) {
if( $dauer[count($dauer) - 1] == 1) {
?>
<tr>
<td width="900" height="150" colspan="8" valign="middle" align="center">
<img src="<?php echo $win_char['bild']; ?>" width="75" height="75">
<br><?php echo $win_char['name']; ?>
<img src="<?php echo $win_char['char_bild']; ?>" width="75" height="75">
<br><?php echo $win_char['char_name']; ?>
</td>
</tr>
<?php
@ -110,21 +143,21 @@ if(($pl * $max_turnier) + $dauer[0] < time()) {
// Keine Ahnung was da angezeigt werden soll
echo '<tr>';
$new_max_turnier = $max_turnier-1;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2, 4);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2, 4);
echo '</tr><tr>';
$new_max_turnier = $max_turnier-3;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2, 2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2, 2);
$new_max_turnier = $max_turnier-2;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2, 2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2, 2);
echo '</tr><tr>';
$new_max_turnier = $max_turnier-7;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2);
$new_max_turnier = $max_turnier-6;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2);
$new_max_turnier = $max_turnier-5;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2);
$new_max_turnier = $max_turnier-4;
displaySomething($id, $new_max_turnier, $art, $char_nic1, $char_nic2);
displaySomething($event_id, $event_fight_ids, $new_max_turnier, $char_nic1, $char_nic2);
echo '</tr>';
?>
</table>
@ -149,15 +182,16 @@ while($x < count($char_nick1) - 6) {
}
echo '<tr><td height="15" valign="middle" bgcolor="'.$mul.'" align="center">';
if(($x * 300) + $dauer[0] < time()) {
if($dauer[$x - 1] == 1) {
if($char1[$z] == $win[$z]) {
echo '<a href="last_fight2.php?kampf_id='.$id[$z].'&spleoic=turnier_kampf&art='.$art.'"><b>'.$char_nick1[$z].'</b> vs. '.$char_nick2[$z].' -> Runde: '.$round[$z].'</a>';
echo '<a href="event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight_ids[$z].'"><b>'.$char_nick1[$z].'</b> vs. '.$char_nick2[$z].' -> Runde: '.$round[$z].'</a>';
} else {
echo '<a href="last_fight2.php?kampf_id='.$id[$z].'&spleoic=turnier_kampf&art='.$art.'">'.$char_nick1[$z].' vs. <b>'.$char_nick2[$z].'</b> -> Runde: '.$round[$z].'</a>';
echo '<a href="event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight_ids[$z].'">'.$char_nick1[$z].' vs. <b>'.$char_nick2[$z].'</b> -> Runde: '.$round[$z].'</a>';
}
} else {
if($k8 == 0) {
echo $char_nick1[$z].' vs. '.$char_nick2[$z].' -> Runde: '.$round[$z];
echo '<a href="event_kampf_anzeige.php?event_id='.$event_id.'&event_fight_id='.$event_fight_ids[$z].'">'.$char_nick1[$z].' vs. '.$char_nick2[$z].' -> Runde: '.$round[$z].'</a>';
$k8++;
}
}
@ -174,4 +208,3 @@ while($x < count($char_nick1) - 6) {
</html>
<?php
}
?>

Loading…
Cancel
Save