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