diff --git a/ag/clan/add.php b/ag/clan/add.php
index 55d3237..4abc040 100644
--- a/ag/clan/add.php
+++ b/ag/clan/add.php
@@ -22,44 +22,6 @@ $pagenum = validateUnsignedInteger($_GET['pagenum'], null);
$action = $_GET['action'];
$user = $user_ida;
-function joinClan($user, $clanid){
- $sql = 'SELECT * FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid.' and valid > now();';
- $clan_user = mysql_fetch_assoc(mysql_query($sql));
-
- if($clan_user){
- $clan = getClan($clanid);
- $members = getClanMembersCount($clanid);
- $members_max = getMaximumMembers($clan['id']);
-
- if($members >= $members_max){
- displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen (Clan voll)!',displayHistoryBackLink());
- return;
- } else{
- $sql = 'UPDATE user SET clan = '.$clanid.' WHERE id = '.$user['id'];
- // echo $sql.'
';
- mysql_query($sql);
-
- // unset the leader if the user is moving from one clan to another
- mysql_query('UPDATE clan SET leader = NULL WHERE leader = ' .$user['id']);
- mysql_query('UPDATE clan SET co_leader = NULL WHERE co_leader = ' .$user['id']);
-
- displayErrorMessage('Aufgenommen','Du wurdest erfolgreich in den Clan aufgenommen!','weiter');
- }
- } else{
- displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen!',displayHistoryBackLink());
- return;
- }
- mysql_query('DELETE FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid);
-}
-
-function denyClan($user, $clanid){
- mysql_query('DELETE FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid);
- if(mysql_affected_rows() > 0){
- displayErrorMessage('Abgelehnt','Du hast die Einladung erfolgreich abgelehnt!','weiter');
- } else{
- displayErrorMessage(NULL,'Einladung des Clans konnte nicht abgelehnt werden!',displayHistoryBackLink());
- }
-}
if ($action == 'accept') {
joinClan($user_ida, $clanid);
diff --git a/ag/event_kampf_anzeige.php b/ag/event_kampf_anzeige.php
new file mode 100644
index 0000000..25ba42e
--- /dev/null
+++ b/ag/event_kampf_anzeige.php
@@ -0,0 +1,21 @@
+';
+}
+?>
\ No newline at end of file
diff --git a/ag/include/arena.inc.php b/ag/include/arena.inc.php
index 63dd7bd..228b2f2 100644
--- a/ag/include/arena.inc.php
+++ b/ag/include/arena.inc.php
@@ -21,6 +21,7 @@ function calculateArenaData($owner_id, $char_1, $char_2, $factor){
$arena['steh'] = 1000000;
$arena['sitz'] = 1000000;
$arena['loge'] = 1000000;
+ $arena['zustand'] = 1;
} else {
$arena = mysql_fetch_assoc(mysql_query('SELECT * FROM arena WHERE besitzer = '.$owner_id));
}
diff --git a/ag/include/char.inc.php b/ag/include/char.inc.php
index a9375c6..70a81d2 100644
--- a/ag/include/char.inc.php
+++ b/ag/include/char.inc.php
@@ -16,6 +16,7 @@
*/
// required for status calculation!
+include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/event.inc.php');
include_once($_SERVER['DOCUMENT_ROOT'].'ag/include/clan_fights.inc.php');
/*
@@ -73,6 +74,12 @@ function getStatus($charid, $buffer_enabled = true) {
return 'Clanfight';
}
+ $event_status = getEventStatus($charid);
+ if($event_status !== NULL) {
+ $GLOBALS['char_buffered_statuses'][$charid] = $event_status;
+ return $event_status;
+ }
+
$GLOBALS['char_buffered_statuses'][$charid] = 'Frei';
return 'Frei';
}
diff --git a/ag/include/clan.inc.php b/ag/include/clan.inc.php
index 38559b4..c750279 100644
--- a/ag/include/clan.inc.php
+++ b/ag/include/clan.inc.php
@@ -7,6 +7,7 @@
*/
include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/defines.inc.php');
+include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/clan_fights.inc.php');
defineIfNotDefined('MAX_CHARS_CLANSIGN', 8);
$GLOBALS['clan_buffered_instances'] = array ();
@@ -186,4 +187,48 @@ function fireMember($user, $member){
}
+function joinClan($user, $clanid){
+ // last chance to lock the clan if in the old situation it was having to few members ;)
+ isClanLocked($clanid); // we only require the calculation not the result!
+
+ $sql = 'SELECT * FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid.' and valid > now();';
+ $clan_user = mysql_fetch_assoc(mysql_query($sql));
+
+ if($clan_user){
+ $clan = getClan($clanid);
+ $members = getClanMembersCount($clanid);
+ $members_max = getMaximumMembers($clan['id']);
+
+ if($members >= $members_max){
+ displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen (Clan voll)!',displayHistoryBackLink());
+ return;
+ } else{
+ $sql = 'UPDATE user SET clan = '.$clanid.' WHERE id = '.$user['id'];
+ // echo $sql.'
';
+ mysql_query($sql);
+
+ // unset the leader if the user is moving from one clan to another
+ mysql_query('UPDATE clan SET leader = NULL WHERE leader = ' .$user['id']);
+ mysql_query('UPDATE clan SET co_leader = NULL WHERE co_leader = ' .$user['id']);
+
+ displayErrorMessage('Aufgenommen','Du wurdest erfolgreich in den Clan aufgenommen!','weiter');
+ }
+ } else{
+ displayErrorMessage(NULL,'Konnte die Einladung des Clans nicht annehmen!',displayHistoryBackLink());
+ return;
+ }
+ mysql_query('DELETE FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid);
+}
+
+function denyClan($user, $clanid){
+ mysql_query('DELETE FROM user_clan_invitations WHERE userid = '.$user['id'].' and clanid = '.$clanid);
+ if(mysql_affected_rows() > 0){
+ displayErrorMessage('Abgelehnt','Du hast die Einladung erfolgreich abgelehnt!','weiter');
+ } else{
+ displayErrorMessage(NULL,'Einladung des Clans konnte nicht abgelehnt werden!',displayHistoryBackLink());
+ }
+}
+
+
+
?>
diff --git a/ag/include/clan_fights.inc.php b/ag/include/clan_fights.inc.php
index 9f88020..8026082 100644
--- a/ag/include/clan_fights.inc.php
+++ b/ag/include/clan_fights.inc.php
@@ -18,8 +18,12 @@ include_once ($_SERVER['DOCUMENT_ROOT'] . 'ag/include/event.inc.php');
defineIfNotDefined('MIN_MEMBERS', 5);
defineIfNotDefined('MAX_OPEN_REQUESTS', 3);
+defineIfNotDefined('CLANFIGHTS_MAX_FIGHTS_PER_24H', 6);
defineIfNotDefined('DAVY_BACK_FIGHT', 1);
defineIfNotDefined('SURVIVAL', 2);
+defineIfNotDefined('DURATION_DAVY_BACK_FIGHT', 10);
+defineIfNotDefined('DURATION_SURVIVAL_FIGHT', 10);
+
defineIfNotDefined('ATTACK_SET_DAVY_BACK_FIGHT', 2);
defineIfNotDefined('ATTACK_SET_SURVIVAL', 2);
@@ -61,6 +65,8 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
+
+
if(!semaphoreUP($ressource_clan1)) {
return 'Fehler beim Verarbeiten der Anfrage für \'' . $clan['clanname'] . '\' versuche es bitte nochmal! ';
}
@@ -98,6 +104,28 @@ function challengeClan(array $user, $clanid, $anzahl = 5, $type = DAVY_BACK_FIGH
return 'Konnte den anderen Clan nicht herausfordern, da dieser Clan schoneinmal in den letzten 24 Stunden herausgefordert wurde!';
}
+ // it should not be possible to challenge a clan that already has an open match that is not yet calculated! ( not completely possible in sql)
+ $sql = 'select count(k.anzahl) as anzahl from (SELECT count(*) as anzahl FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where (calculated = 1 or enddate > now()) and clan_id IN ('.$user['clan'].', '.$clanid.') group by c.clan_challenge_id) k where k.anzahl = 0';
+ //echo $sql .'
';
+ $row = mysql_fetch_assoc(mysql_query($sql));
+ if($row['anzahl'] > 0) {
+ semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
+ semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
+ return 'Du kannst einen Clan nicht herausfordern, wenn derzeit gerade ein Clanfight zwischen euch läuft oder offen ist!';
+ }
+
+ // now calculate how many open fights we currently had or have!
+ $sql = 'select count(*) as anzahl from (SELECT count(*) as anz FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where calculated = 0 or TIMESTAMPADD(day, -1, now()) < enddate and clan_id IN ('.$user['clan'].', '.$clanid.') group by clan_id) k where k.anz >= ' . CLANFIGHTS_MAX_FIGHTS_PER_24H;
+ //echo $sql .'
';
+ $row = mysql_fetch_assoc(mysql_query($sql));
+
+ if($row['anzahl'] > 0) {
+ semaphoreDown($ressource_clan1); // free the previously reserved semaphore!
+ semaphoreDown($ressource_clan2); // free the previously reserved semaphore!
+ return 'Einer der beiden Clans hat das Limit von ' . CLANFIGHTS_MAX_FIGHTS_PER_24H . ' offenen und abgeschlossenen Clanfights innerhalb von 24 erreicht. Daher kann die Herausforderung nicht versandt werden!';
+ }
+
+
// Fordere heraus!
mysql_query('INSERT INTO clan_challenge_requests(clan_requester, clan_challenged, type, challenged_time, anzahl_chars, active) VALUES('.$user['clan'].', '.$clanid.','.$type.' , TIMESTAMPADD(HOUR, CURRENT_TIMESTAMP, 4), '.$anzahl.', true)');
@@ -154,6 +182,15 @@ function acceptChallengeRequest($challenged_clan, array $user) {
return 'Einer der Clans erfüllt die Anforderungen an Clanfights nichtmehr (wahrscheinlich zu wenig Members)!';
}
+ // now calculate how many open fights we currently had or have! // FIXME: Good idea to pach this in a semaphore?
+ $sql = 'select count(*) as anzahl from (SELECT count(*) as anz FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where calculated = 0 or TIMESTAMPADD(day, -1, now()) < enddate and clan_id IN ('.$clan_challenge['clan_challenged'].', '.$clan_challenge['clan_requester'].') group by clan_id) k where k.anz >= ' . CLANFIGHTS_MAX_FIGHTS_PER_24H;
+// echo $sql . '
';
+ $row = mysql_fetch_assoc(mysql_query($sql));
+
+ if($row['anzahl'] > 0) {
+ return 'Einer der beiden Clans hat das Limit von ' . CLANFIGHTS_MAX_FIGHTS_PER_24H . ' offenen und abgeschlossenen Clanfights innerhalb von 24 erreicht. Daher kann die Herausforderung nicht angenommen werden!';
+ }
+
$oclan = getClan($clan_challenge['clan_requester']);
mysql_query('UPDATE clan_challenge_requests SET active = false WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenged_clan . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())');
@@ -483,6 +520,8 @@ function leaveChallenge($clan_challenge_id, array $user, $charid) {
function calculateChallenge($clan_challenge_id) {
$challenge = getChallenge($clan_challenge_id);
+ $start_time = time();
+
// okay the calculated flag is already set so readout all the required data for further processing!
$clan_ids = getParticipatingClanIDs($clan_challenge_id);
$clan_chars = array();
@@ -497,23 +536,32 @@ function calculateChallenge($clan_challenge_id) {
}
}
+ $result = NULL;
+
// okay now determine the type of fight
switch($challenge['type']) {
case DAVY_BACK_FIGHT:
- return calculateDavyBackClanFight($event_id, $clan_ids, $clan_chars);
+ $result = calculateDavyBackClanFight($event_id, $clan_ids, $clan_chars, $start_time);
+ if(!is_numeric($result))
+ return $result;
break;
case SURVIVAL:
- return calculateSurvivalClanFight($event_id, $clan_ids, $clan_chars);
+ return calculateSurvivalClanFight($event_id, $clan_ids, $clan_chars, $start_time);
+ if(!is_numeric($result))
+ return $result;
break;
default:
// cannot create anything -.-
return 'Der Clanfight Typ "'.$challenge['type'].'" wird nicht unterstützt, bitte melde dich beim Administrator!' ;
}
+ mysql_query('UPDATE clan_challenges set event_id = '.$event_id.', enddate = \''.date("Y-m-d H:i:s",$result).'\' WHERE clan_challenge_id = ' .$clan_challenge_id);
+
return NULL;
}
-function calculateDavyBackClanFight($event_id, array $clan_ids, array $clan_char_array) {
+function calculateDavyBackClanFight($event_id, array $clan_ids, array $clan_char_array, $start_time) {
+ $duration = DURATION_DAVY_BACK_FIGHT * 60;
// okay, davy back fights are 1 vs. 1 and the winner is the one that has won the most fights.
if(count($clan_char_array) != 2) {
return 'Davy Back Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array);
@@ -528,11 +576,13 @@ function calculateDavyBackClanFight($event_id, array $clan_ids, array $clan_char
$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)!
- battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT);
+ battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_DAVY_BACK_FIGHT, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration);
}
+ return $start_time + ($runde-1) * $duration;
}
-function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char_array) {
+function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char_array, $start_time) {
+ $duration = DURATION_SURVIVAL_FIGHT * 60;
// okay, survival fights are 1 vs. 1 and the winner is the one that has the last man standing.
if(count($clan_char_array) != 2) {
return 'Survival Fights können nur zwischen 2 Clans ausgetragen werden und nicht von ' . count($clan_char_array);
@@ -547,9 +597,11 @@ function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char
$char_clan_1 = $clan_char_array[$clan_ids[0]][$counter_clan_1];
$char_clan_2 = $clan_char_array[$clan_ids[1]][$counter_clan_2];
+ $runde = 0;
// As long as char 1 and char 2 are set
while($char_clan_1 != NULL && $char_clan_2 != NULL) {
- $sieger = battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL);
+ $runde++;
+ $sieger = battle($event_id, $char_clan_1, $char_clan_2, ATTACK_SET_SURVIVAL, $start_time + ($runde-1) * $duration, $start_time + $runde * $duration);
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];
@@ -559,6 +611,7 @@ function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char
$char_clan_2 = $clan_char_array[$clan_ids[1]][++$counter_clan_2];
$char_clan_1 = $sieger; // the new array contains the adjusted health parameter
}
+ return $start_time + $runde * $duration;
}
}
@@ -571,7 +624,7 @@ function calculateSurvivalClanFight($event_id, array $clan_ids, array $clan_char
* @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) {
+function battle($event_id, array $char1, array $char2, $attack_set, $startTimestamp, $endTimestamp) {
$char1['attacken'] = implode(',', getCharAttackSet($char1['id'], $attack_set));
$char2['attacken'] = implode(',', getCharAttackSet($char2['id'], $attack_set));
@@ -582,21 +635,22 @@ function battle($event_id, array $char1, array $char2, $attack_set) {
$combinedArray['data'][KEY_EXP_CHAR1] = $exp[$char1['id']];
$combinedArray['data'][KEY_EXP_CHAR2] = $exp[$char2['id']];
- $arena = calculateArenaData(null, $char_1, $char_2, 0.01);
+ $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] = $result['geld'] * 0.7;
- $combinedArray['data'][KEY_GELD_CHAR2] = $result['geld'] * 0.3;
+ $combinedArray['data'][KEY_GELD_CHAR1] = $arena['geld'] * 0.7;
+ $combinedArray['data'][KEY_GELD_CHAR2] = $arena['geld'] * 0.3;
} else {
- $combinedArray['data'][KEY_GELD_CHAR2] = $result['geld'] * 0.7;
- $combinedArray['data'][KEY_GELD_CHAR1] = $result['geld'] * 0.3;
+ $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);
+ persistFight($event_id, $combinedArray, $startTimestamp, $endTimestamp);
return;
// now get the winners array
diff --git a/ag/include/event.inc.php b/ag/include/event.inc.php
index 33a94ff..2b85a55 100644
--- a/ag/include/event.inc.php
+++ b/ag/include/event.inc.php
@@ -17,13 +17,6 @@ defineIfNotDefined('EVENT_LIGA', 4);
defineIfNotDefined('EVENT_WANTED', 5);
defineIfNotDefined('EVENT_CLAN_FIGHT', 6);
-// The fights duration is fixed
-defineIfNotDefined('DURATIONTYPE_FIGHT', 0);
-// The fights duration is resolved by the amount of rounds
-defineIfNotDefined('DURATIONTYPE_ROUND', 1);
-// The fights duration is fixed but the time ouf rounds is resolved!
-defineIfNotDefined('DURATIONTYPE_FIGHT_RESOLVED_ROUNDS', 2);
-
defineIfNotDefined('KEY_LOGE', 'LOGE');
defineIfNotDefined('KEY_SITZ', 'SITZ');
defineIfNotDefined('KEY_STEH', 'STEH');
@@ -64,8 +57,8 @@ function addParticipant($event_id, array $char) {
$hp = explode(',', $char['hp']);
$mp = explode(',', $char['mp']);
- $sql = 'INSERT INTO event_chars(event_id, event_char_id, char_id, char_name, char_bild, user_id, user_name, hp, mp, strength, speed, defense, luck, stamina)';
- $sql .= ' value('. $event_id . ', '.$char['id'] .', '.$char['id'] .', \''.$char['name'].'\', \''.$char['bild'].'\', '.$char['besitzer'].', \''.$user['nickname'].'\', '.$hp[1].', '.$mp[1].', '.$char['starke'].', '.$char['speed'].', '.$char['verteidigung'].', '.$char['glueck'].', '.$char['ausdauer'].')';
+ $sql = 'INSERT INTO event_chars(event_id, event_char_id, char_id, char_name, char_bild, user_id, user_name, hp, mp, strength, speed, defense, luck, stamina, block_begin, block_end)';
+ $sql .= ' value('. $event_id . ', '.$char['id'] .', '.$char['id'] .', \''.$char['name'].'\', \''.$char['bild'].'\', '.$char['besitzer'].', \''.$user['nickname'].'\', '.$hp[1].', '.$mp[1].', '.$char['starke'].', '.$char['speed'].', '.$char['verteidigung'].', '.$char['glueck'].', '.$char['ausdauer'].', now(), TIMESTAMPADD(Minute, 1, now()))';
// echo $sql . '
';
@@ -84,7 +77,7 @@ function addParticipant($event_id, array $char) {
* @param int $durationValue the amount of time in minutes
* @return int the id of the fight
*/
-function persistFight($event_id, array $combinedArray, $startTimestamp, $durationType, $durationValue) {
+function persistFight($event_id, array $combinedArray, $startTimestamp, $endTimestamp) {
// persist a fight of two chars (calculated by the wrapper) ^^"
//echo 'The fight was about ' . count($combinedArray) . ' rounds
';
@@ -99,7 +92,7 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $duratio
while(!$finished) {
$sql = 'SELECT IFNULL(max(event_fight_id),0) + 1 FROM event_fights';
$row = mysql_fetch_row(mysql_query($sql));
- $sql = 'INSERT INTO event_fights(event_id, event_fight_id, host, winner) values('.$event_id.', \''.$row[0].'\', '. $hostId . ', ' . $winnerId .')';
+ $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).'\')';
if(mysql_query($sql) === FALSE)
break;
$finished = mysql_affected_rows() > 0;
@@ -116,8 +109,8 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $duratio
// first persist char1
$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'].', \''. $roundsArray[$round]['atk_char1'] .'\', \''. $roundsArray[$round]['dmg_char1'] .'\')';
+ $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).'\')';
// echo $sql .'
';
@@ -125,8 +118,8 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $duratio
// now persist char2
$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'].', \''. $roundsArray[$round]['atk_char2'] .'\', \''. $roundsArray[$round]['dmg_char2'] .'\')';
+ $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).'\')';
// echo $sql .'
';
@@ -139,6 +132,34 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $duratio
// echo $sql . '
';
mysql_query($sql);
}
+
+ mysql_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 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() and char_id = ' . $charid;
+
+ $qry = mysql_query($sql);
+ $row = mysql_fetch_assoc($qry);
+ switch ($row['event_type']) {
+ case EVENT_TEST:
+ return 'Test';
+ case EVENT_SCHATZ_SUCHE:
+ return 'Schatzsuche';
+ case EVENT_TURNIER:
+ return 'Turnier';
+ case EVENT_KAMPF:
+ return 'Kampf';
+ case EVENT_LIGA:
+ return 'Liga';
+ case EVENT_WANTED:
+ return 'Wanted';
+ case EVENT_CLAN_FIGHT:
+ return 'Clanfight';
+ }
}
+
?>
\ No newline at end of file
diff --git a/ag/include/kampf_anzeige.inc.php b/ag/include/kampf_anzeige.inc.php
index a92f320..1627ead 100644
--- a/ag/include/kampf_anzeige.inc.php
+++ b/ag/include/kampf_anzeige.inc.php
@@ -41,7 +41,7 @@ function displayCharTable($charbild, $charname, $starke, $ver, $speed, $ausdauer
-
+
';
+
+
+echo '' .
+ 'Der Fight läuft noch! | '.
+ ' ';
+
+
+echo '' .
+ ''.$char1_status.' | '.
+ '??? | '.
+ ''.$char2_status.' | '.
+ '??? | ' .
+ ' ';
+
+
+echo ' | ';
+echo ' ';
+echo ' | ';
+
+}
+
+function displaySummary($char1_name, $char2_name, $sieger, $exp_char1, $exp_char2, $money_char1, $money_char2, $arena_exp1 = NULL, $arena_exp2 = NULL, $loge = NULL, $sitz = NULL, $steh = NULL){
echo '';
@@ -86,6 +110,8 @@ echo '' .
''.$char2_name.' | ' .
' ';
+ if($exp_char1 !== NULL || $exp_char2 !== NULL) {
+
echo '' .
'Exp + | ' .
''.$exp_char1.' | ' .
@@ -93,22 +119,60 @@ echo ' ' .
''.$exp_char2.' | '.
' ';
+ }
+
+ if($money_char1 !== NULL || $money_char2 !== NULL) {
+
echo ''.
'Geld + | '.
''.$money_char1.' | '.
'Geld + | '.
''.$money_char2.' | ' .
' ';
-
-echo ''.
- 'Arena Exp + | '.
- ''.$arena_exp1.' | '.
- 'Arena Exp + | '.
- ''.$arena_exp2.' | ' .
- ' ';
+ }
+ if($arena_exp1 !== NULL || $arena_exp2 !== NULL) {
+ echo ''.
+ 'Arena Exp + | '.
+ ''.$arena_exp1.' | '.
+ 'Arena Exp + | '.
+ ''.$arena_exp2.' | ' .
+ ' ';
+ }
+
+ echo ' | ';
+echo ' ';
+
+ if($loge !== NULL || $steh !== NULL || $sitz !== NULL) {
+ ?>
+
+
+
+
+
+ Zuschauer |
+ |
+
+
+ Stehplätze |
+ |
+
+
+ Sitzplätze |
+ |
+
+
+ Logenplätze |
+ |
+
+
+ |
+
+
+ |
';
+ }
-echo '';
}
function displayFinalResult($items, $exp, $money, $final_result){
@@ -132,11 +196,11 @@ echo '' .
'';
// Letze Eintrag von Items ist false!!
if(!$items[0]){
- echo ' ';
+ echo ' ';
} else{
for($i=0;$items[$i];$i++){
echo $items[$i]['name'].' ';
- }
+ }
}
echo' |
';
echo '' .
@@ -169,25 +233,25 @@ function displaySchatzSuche($char){
echo 'Schatzsuche in '.$ort['stadt'].' |
';
// Hole die Ergebnisse die auch in die Datenbank eingetragen werden muessen!
- $row = mysql_fetch_assoc(mysql_query('Select sum(exp) as exp, sum(geld) as geld, count(*) as anzahl from quest_fights where charid = '.$char['id']));
+ $row = mysql_fetch_assoc(mysql_query('Select sum(exp) as exp, sum(geld) as geld, count(*) as anzahl from quest_fights where charid = '.$char['id']));
// Ermittle den Endzustand des Chars
$end_qf = mysql_fetch_assoc(mysql_query('select max(fightnr) as mf from quest_fights where charid = '.$char['id']));
$end_qr = mysql_fetch_assoc(mysql_query('select max(roundnr) as mr from quest_rounds where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_round = mysql_fetch_assoc(mysql_query('Select * from quest_rounds where roundnr = '.$end_qr['mr'].' and fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
$last_fight = mysql_fetch_assoc(mysql_query('Select * from quest_fights where fightnr = '.$end_qf['mf'].' and charid = '.$char['id']));
-
+
// Ermittle die Reqs des Chars!
$sql = 'SELECT c_attack as a_name, count(*) as anzahl FROM quest_rounds q where roundnr > 0 and charid = '.$char['id'].' group by c_attack';
// echo $sql.'
';
$reqs = mysql_query($sql);
-
+
while($row_r = mysql_fetch_assoc($reqs)){
$c_attacken[] = $row_r;
// print_r($c_attacken);
// echo '
';
}
-
+
if($last_fight['sieger'] == $char['id']){
$final_result = 'won';
// Nur wer gewinnt bekommt was!
@@ -201,19 +265,19 @@ function displaySchatzSuche($char){
$c_attacken[$i]['anzahl'] = floor($c_attacken[$i]['anzahl'] * $lose_rate);
}
}
-
+
// Zeige als erstes die Zusammenfassung an!
displayFinalResult($items, $row['exp'], $row['geld'], $final_result);
-
+
// Lade nun die Fights runter
$sql = 'Select * from quest_fights where charid = '.$char['id'];
$qry = mysql_query($sql);
while($fight = mysql_fetch_assoc($qry)){
displaySchatzSucheFight($quest, $char, $fight);
}
-
+
submitCharChanges($char['id'], $items, $row['exp'], $row['geld'], $quest['ortid'], array($last_round['c_hp']) , array($last_round['c_mp']), $c_attacken);
echo '