From f51e9041f9a0c8a38361a8527c1b26ee3fe43626 Mon Sep 17 00:00:00 2001 From: hecht Date: Mon, 21 Nov 2011 19:06:55 +0000 Subject: [PATCH] Changes for the test.php and for creation of the event_fight_ids --- ag/include/event.inc.php | 2 +- ag/test.php | 47 ++++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/ag/include/event.inc.php b/ag/include/event.inc.php index 25b1bec..a3563e8 100644 --- a/ag/include/event.inc.php +++ b/ag/include/event.inc.php @@ -89,7 +89,7 @@ function persistFight($event_id, array $combinedArray, $startTimestamp, $endTime // first get a fight id ;). $finished = FALSE; 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 WHERE event_id = ' .$event_id; $row = mysql_fetch_row(mysql_query($sql)); $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) { diff --git a/ag/test.php b/ag/test.php index ee8ff27..5862cb3 100644 --- a/ag/test.php +++ b/ag/test.php @@ -16,6 +16,7 @@ $acceptTestCase = true; mysql_query('UPDATE user SET clan = null'); // clean all clans + $ids = getClanFightCapableClanIds(); $row = mysql_fetch_row(mysql_query('SELECT COUNT(*) FROM user WHERE 0 < (SELECT COUNT(*) FROM chars WHERE besitzer = user.id)')); @@ -46,6 +47,7 @@ if(count($ids) < $row[0] / MIN_MEMBERS) { } + mysql_query('DELETE FROM clan_challenge_requests'); mysql_query('DELETE FROM clan_challenges'); mysql_query('DELETE FROM events'); @@ -60,9 +62,15 @@ if(count($ids) < 2) { die(); } -$clan1 = getClan($ids[0]); -$clan2 = getClan($ids[1]); +for($i=0;$i'; $leaderClan1 = getUser($clan1['leader']); $leaderClan2 = getUser($clan2['leader']); @@ -132,17 +140,38 @@ if($acceptTestCase) { $chars1 = getCharsOfUser($leaderClan1['id']); $chars2 = getCharsOfUser($leaderClan2['id']); - - $result = joinChallenge($clan_challenge_id, $leaderClan1, $chars1[0]['id'], 1); + + $found = -1; + + for($i=0;$i'; + } + + + $result = joinChallenge($clan_challenge_id, $leaderClan1, $chars1[$found]['id'], 1); if($result !== NULL) { echo $result .'
'; } - $result = joinChallenge($clan_challenge_id, $leaderClan1, $chars1[1]['id'], 2); - if($result === NULL) { - echo 'Error: Es war möglich einen zweiten Char desselben Users hinzuzufügen!!'; + + $found = -1; + + for($i=0;$i'; } - $result = joinChallenge($clan_challenge_id, $leaderClan2, $chars2[0]['id'], 1); + $result = joinChallenge($clan_challenge_id, $leaderClan2, $chars2[$found]['id'], 1); if($result !== NULL) { echo $result .'
'; } @@ -173,7 +202,7 @@ if($acceptTestCase) { } } - +} ?>