Changes for the test.php and for creation of the event_fight_ids

main
hecht 13 years ago
parent 2970c2d466
commit f51e9041f9

@ -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) {

@ -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<count($ids) - 1;$i+=2) {
calculateClanFight(getClan($ids[$i]), getClan($ids[$i+1]), $acceptTestCase);
}
#$clan1 = getClan($ids[0]);
#$clan2 = getClan($ids[1]);
function calculateClanFight($clan1, $clan2, $acceptTestCase) {
# echo $clan1['id'] . ' ' . $clan2['id'] . ' ' . ($acceptTestCase?'TRUE':'FALSE') . '<br>';
$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<count($chars1);$i++) {
if($chars1[$i]['status'] == 'Frei') {
$found = $i;
break;
}
}
if($found == -1) {
echo 'Konnte keinen freien Char fuer User ' .$leaderClan1 . ' finden<br>';
}
$result = joinChallenge($clan_challenge_id, $leaderClan1, $chars1[$found]['id'], 1);
if($result !== NULL) {
echo $result .'<br>';
}
$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<count($chars2);$i++) {
if($chars2[$i]['status'] == 'Frei') {
$found = $i;
break;
}
}
if($found == -1) {
echo 'Konnte keinen freien Char fuer User ' .$leaderClan2 . ' finden<br>';
}
$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 .'<br>';
}
@ -173,7 +202,7 @@ if($acceptTestCase) {
}
}
}
?>

Loading…
Cancel
Save