示例#1
0
function kampf($id)
{
    include 'einheiten_preise.php';
    include 'def_preise.php';
    // db verbindung
    $dbh = db_connect();
    $select = "SELECT * FROM `missionen` WHERE `id` = '" . $id . "';";
    $result = mysql_query($select);
    $offender = mysql_fetch_array($result);
    $o_omni = $offender['start'];
    $d_omni = $offender['ziel'];
    $select = "SELECT * FROM `user` WHERE `omni` = '" . $o_omni . "';";
    $result = mysql_query($select);
    $offender_user = mysql_fetch_array($result);
    $select = "SELECT * FROM `user` WHERE `omni` = '" . $d_omni . "';";
    $result = mysql_query($select);
    if (mysql_num_rows($result) == 0) {
        $content = 'Es wurde keine Basis bei ' . $d_omni . ' gefunden.';
    } else {
        $defender_user = mysql_fetch_array($result);
        $date = date(U);
        $defender = new_units_check($d_omni);
        $select = "SELECT * FROM `defense` WHERE `omni` = '" . $d_omni . "';";
        $result = mysql_query($select);
        $defender_def = mysql_fetch_array($result);
        $select = "SELECT * FROM `gebauede` WHERE `omni` = '" . $d_omni . "';";
        $result = mysql_query($select);
        $gebaeude = mysql_fetch_array($result);
        $select = "SELECT * FROM `forschungen` WHERE `omni` = '" . $o_omni . "';";
        $result = mysql_query($select);
        $row = mysql_fetch_array($result);
        $o_fuehrung = $row['fuehrung'];
        if (!$o_fuehrung) {
            $o_fuehrung = 0;
        }
        $select = "SELECT * FROM `forschungen` WHERE `omni` = '" . $d_omni . "';";
        $result = mysql_query($select);
        $row = mysql_fetch_array($result);
        $d_fuehrung = $row['fuehrung'];
        if (!$d_fuehrung) {
            $d_fuehrung = 0;
        }
        if ($defender_def['def1'] or $defender_def['def2'] or $defender_def['def3'] or $defender_def['def4']) {
            $content .= 'Auf dem Weg zur Basis bei ' . $d_omni . ' wurden die Einheiten des Angreifers durch <br />';
            if ($defender_def['def1']) {
                $content .= '&nbsp;&nbsp;' . $defender_def['def1'] . ' ' . $def[1]['name'] . '<br />';
            }
            if ($defender_def['def2']) {
                $content .= '&nbsp;&nbsp;' . $defender_def['def2'] . ' ' . $def[2]['name'] . '<br />';
            }
            if ($defender_def['def3']) {
                $content .= '&nbsp;&nbsp;' . $defender_def['def3'] . ' ' . $def[3]['name'] . '<br />';
            }
            if ($defender_def['def4']) {
                $content .= '&nbsp;&nbsp;' . $defender_def['def4'] . ' ' . $def[4]['name'] . '<br />';
            }
            $content .= '&uuml;berrascht, dadurch entstanden folgende Verluste: <br />';
            if ($defender_def['def1'] != 0 and $offender['einh4'] != 0) {
                do {
                    $demont++;
                    if (rand(1, 100) <= 70) {
                        $defender_def['def1']--;
                        $entschaerfung++;
                        if (rand(1, 100) <= 30) {
                            $vo[4]++;
                            $offender['einh4']--;
                        }
                    }
                } while ($offender['einh4'] > $demont and $defender_def['def1'] > 0);
            }
            if ($offender['einh4'] > $demont and $defender_def['def2'] != 0 and $offender['einh4'] != 0) {
                do {
                    $demont++;
                    if (rand(1, 100) <= 65) {
                        $defender_def['def2']--;
                        $entschaerfung++;
                        if (rand(1, 100) <= 40) {
                            $vo[4]++;
                            $offender['einh4']--;
                        }
                    }
                } while ($offender['einh4'] > $demont and $defender_def['def2'] > 0);
            }
            if ($offender['einh4'] > $demont and $defender_def['def3'] != 0 and $offender['einh4'] != 0) {
                do {
                    $demont++;
                    if (rand(1, 100) <= 90) {
                        $defender_def['def3']--;
                        $entschaerfung++;
                        if (rand(1, 100) <= 15) {
                            $vo[4]++;
                            $offender['einh4']--;
                        }
                    }
                } while ($offender['einh4'] > $demont and $defender_def['def3'] > 0);
            }
            if ($offender['einh4'] > $demont and $defender_def['def4'] != 0 and $offender['einh4'] != 0) {
                do {
                    $demont++;
                    if (rand(1, 100) <= 80) {
                        $defender_def['def4']--;
                        $entschaerfung++;
                        if (rand(1, 100) <= 20) {
                            $vo[4]++;
                            $offender['einh4']--;
                        }
                    }
                } while ($offender['einh4'] > $demont and $defender_def['def4'] > 0);
            }
            if (!$entschaerfung) {
                $entschaerfung = keine;
            }
            if ($defender_def['def1'] != 0 and $offender['einh1'] != 0) {
                do {
                    $vo[1]++;
                    $offender['einh1']--;
                    $defender_def['def1']--;
                } while ($offender['einh1'] > 0 and $defender_def['def1'] > 0);
            }
            if ($defender_def['def1'] != 0 and $offender['einh2'] != 0) {
                do {
                    $vo[2]++;
                    $offender['einh2']--;
                    $defender_def['def1']--;
                } while ($offender['einh2'] > 0 and $defender_def['def1'] > 0);
            }
            if ($defender_def['def1'] != 0 and $offender['einh3'] != 0) {
                do {
                    $vo[3]++;
                    $offender['einh3']--;
                    $defender_def['def1']--;
                } while ($offender['einh3'] > 0 and $defender_def['def1'] > 0);
            }
            if ($defender_def['def2'] != 0 and $offender['einh1'] != 0) {
                do {
                    $vo[1]++;
                    $offender['einh1']--;
                    $defender_def['def2']--;
                } while ($offender['einh1'] > 0 and $defender_def['def2'] > 0);
            }
            if ($defender_def['def2'] != 0 and $offender['einh2'] != 0) {
                do {
                    $vo[2]++;
                    $offender['einh2']--;
                    $defender_def['def2']--;
                } while ($offender['einh2'] > 0 and $defender_def['def2'] > 0);
            }
            if ($defender_def['def2'] != 0 and $offender['einh3'] != 0) {
                do {
                    $vo[3]++;
                    $offender['einh3']--;
                    $defender_def['def2']--;
                } while ($offender['einh3'] > 0 and $defender_def['def2'] > 0);
            }
            if ($defender_def['def2'] != 0 and $offender['einh4'] != 0) {
                do {
                    $vo[4]++;
                    $offender['einh4']--;
                    $defender_def['def2']--;
                } while ($offender['einh4'] > 0 and $defender_def['def2'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh12'] != 0) {
                do {
                    $vo[12]++;
                    $offender['einh12']--;
                    $defender_def['def3']--;
                } while ($offender['einh12'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh13'] != 0) {
                do {
                    $vo[13]++;
                    $offender['einh13']--;
                    $defender_def['def3']--;
                } while ($offender['einh13'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh14'] != 0) {
                do {
                    $vo[14]++;
                    $offender['einh14']--;
                    $defender_def['def3']--;
                } while ($offender['einh14'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh15'] != 0) {
                do {
                    $vo[15]++;
                    $offender['einh15']--;
                    $defender_def['def3']--;
                } while ($offender['einh15'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh5'] != 0) {
                do {
                    $vo[5]++;
                    $offender['einh5']--;
                    $defender_def['def3']--;
                } while ($offender['einh5'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def3'] != 0 and $offender['einh6'] != 0) {
                do {
                    $vo[6]++;
                    $offender['einh6']--;
                    $defender_def['def3']--;
                } while ($offender['einh6'] > 0 and $defender_def['def3'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh12'] != 0) {
                do {
                    $vo[12]++;
                    $offender['einh12']--;
                    $defender_def['def4']--;
                } while ($offender['einh12'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh13'] != 0) {
                do {
                    $vo[13]++;
                    $offender['einh13']--;
                    $defender_def['def4']--;
                } while ($offender['einh13'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh14'] != 0) {
                do {
                    $vo[14]++;
                    $offender['einh14']--;
                    $defender_def['def4']--;
                } while ($offender['einh14'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh15'] != 0) {
                do {
                    $vo[15]++;
                    $offender['einh15']--;
                    $defender_def['def4']--;
                } while ($offender['einh15'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh5'] != 0) {
                do {
                    $vo[5]++;
                    $offender['einh5']--;
                    $defender_def['def4']--;
                } while ($offender['einh5'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh6'] != 0) {
                do {
                    $vo[6]++;
                    $offender['einh6']--;
                    $defender_def['def4']--;
                } while ($offender['einh6'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh7'] != 0) {
                do {
                    $vo[7]++;
                    $offender['einh7']--;
                    $defender_def['def4']--;
                } while ($offender['einh7'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh9'] != 0) {
                do {
                    $vo[9]++;
                    $offender['einh9']--;
                    $defender_def['def4']--;
                } while ($offender['einh9'] > 0 and $defender_def['def4'] > 0);
            }
            if ($defender_def['def4'] != 0 and $offender['einh8'] != 0) {
                do {
                    $vo[8]++;
                    $offender['einh8']--;
                    $defender_def['def4']--;
                } while ($offender['einh8'] > 0 and $defender_def['def4'] > 0);
            }
            if ($vo[1]) {
                $content .= '&nbsp;&nbsp;' . $vo[1] . ' ' . $einh[1]['name'] . '<br />';
            }
            if ($vo[2]) {
                $content .= '&nbsp;&nbsp;' . $vo[2] . ' ' . $einh[2]['name'] . '<br />';
            }
            if ($vo[3]) {
                $content .= '&nbsp;&nbsp;' . $vo[3] . ' ' . $einh[3]['name'] . '<br />';
            }
            if ($vo[4]) {
                $content .= '&nbsp;&nbsp;' . $vo[4] . ' ' . $einh[4]['name'] . '<br />';
            }
            if ($vo[5]) {
                $content .= '&nbsp;&nbsp;' . $vo[5] . ' ' . $einh[5]['name'] . '<br />';
            }
            if ($vo[6]) {
                $content .= '&nbsp;&nbsp;' . $vo[6] . ' ' . $einh[6]['name'] . '<br />';
            }
            if ($vo[7]) {
                $content .= '&nbsp;&nbsp;' . $vo[7] . ' ' . $einh[7]['name'] . '<br />';
            }
            if ($vo[8]) {
                $content .= '&nbsp;&nbsp;' . $vo[8] . ' ' . $einh[8]['name'] . '<br />';
            }
            if ($vo[9]) {
                $content .= '&nbsp;&nbsp;' . $vo[9] . ' ' . $einh[9]['name'] . '<br />';
            }
            if ($vo[10]) {
                $content .= '&nbsp;&nbsp;' . $vo[10] . ' ' . $einh[10]['name'] . '<br />';
            }
            if ($vo[11]) {
                $content .= '&nbsp;&nbsp;' . $vo[11] . ' ' . $einh[11]['name'] . '<br />';
            }
            if ($vo[12]) {
                $content .= '&nbsp;&nbsp;' . $vo[12] . ' ' . $einh[12]['name'] . '<br />';
            }
            if ($vo[13]) {
                $content .= '&nbsp;&nbsp;' . $vo[13] . ' ' . $einh[13]['name'] . '<br />';
            }
            if ($vo[14]) {
                $content .= '&nbsp;&nbsp;' . $vo[14] . ' ' . $einh[14]['name'] . '<br />';
            }
            if ($vo[15]) {
                $content .= '&nbsp;&nbsp;' . $vo[15] . ' ' . $einh[15]['name'] . '<br />';
            }
            $content .= '<br />Die Elitesoldaten des Angreifers haben ' . $entschaerfung . ' Minen entsch&auml;rft.<br /><br />';
        }
        $content .= 'Folgende Truppen standen sich am ' . date("d.m.Y \\u\\m H:i", $date) . ' gegen&uuml;ber: <br /><br /><i>Angreifer (' . $offender_user['name'] . '):</i><br />';
        if ($offender['einh1']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh1'] . ' ' . $einh[1]['name'] . '<br />';
        }
        if ($offender['einh2']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh2'] . ' ' . $einh[2]['name'] . '<br />';
        }
        if ($offender['einh3']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh3'] . ' ' . $einh[3]['name'] . '<br />';
        }
        if ($offender['einh4']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh4'] . ' ' . $einh[4]['name'] . '<br />';
        }
        if ($offender['einh5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh5'] . ' ' . $einh[5]['name'] . '<br />';
        }
        if ($offender['einh6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh6'] . ' ' . $einh[6]['name'] . '<br />';
        }
        if ($offender['einh7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh7'] . ' ' . $einh[7]['name'] . '<br />';
        }
        if ($offender['einh8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh8'] . ' ' . $einh[8]['name'] . '<br />';
        }
        if ($offender['einh9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh9'] . ' ' . $einh[9]['name'] . '<br />';
        }
        if ($offender['einh10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh10'] . ' ' . $einh[10]['name'] . '<br />';
        }
        if ($offender['einh11']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh11'] . ' ' . $einh[11]['name'] . '<br />';
        }
        if ($offender['einh12']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh12'] . ' ' . $einh[12]['name'] . '<br />';
        }
        if ($offender['einh13']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh13'] . ' ' . $einh[13]['name'] . '<br />';
        }
        if ($offender['einh14']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh14'] . ' ' . $einh[14]['name'] . '<br />';
        }
        if ($offender['einh15']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh15'] . ' ' . $einh[15]['name'] . '<br />';
        }
        do {
            $count++;
            $type = 'einh' . $count;
            $o_anz = $o_anz + $offender[$type];
            $o_off += ($einh[$count]['off'] + $einh[$count]['off'] / 10 * $o_fuehrung) * $offender[$type];
            $o_def += ($einh[$count]['def'] + $einh[$count]['def'] / 10 * $o_fuehrung) * $offender[$type];
        } while (15 > $count);
        $count = 4;
        do {
            $count++;
            $type = 'def' . $count;
            $d_anz = $d_anz + $defender_def[$type];
            $d_off += ($def[$count]['off'] + $def[$count]['off'] / 10 * $d_fuehrung) * $defender_def[$type];
            $d_def += ($def[$count]['def'] + $def[$count]['def'] / 10 * $d_fuehrung) * $defender_def[$type];
        } while (10 > $count);
        $content .= '<br />F&uuml;hrungsbonus: ' . $o_fuehrung * 10 . '%<br />';
        $content .= 'Einheiten: ' . $o_anz . '<br />';
        $content .= 'Angriffswert: <b>' . $o_off . '</b><br />';
        $content .= 'Verteidigungswert: <b>' . $o_def . '</b><br />';
        $content .= '<br /><i>Verteidiger (' . $defender_user['name'] . '):</i><br />';
        if ($defender['einh1']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh1'] . ' ' . $einh[1]['name'] . '<br />';
        }
        if ($defender['einh2']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh2'] . ' ' . $einh[2]['name'] . '<br />';
        }
        if ($defender['einh3']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh3'] . ' ' . $einh[3]['name'] . '<br />';
        }
        if ($defender['einh4']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh4'] . ' ' . $einh[4]['name'] . '<br />';
        }
        if ($defender['einh5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh5'] . ' ' . $einh[5]['name'] . '<br />';
        }
        if ($defender['einh6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh6'] . ' ' . $einh[6]['name'] . '<br />';
        }
        if ($defender['einh7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh7'] . ' ' . $einh[7]['name'] . '<br />';
        }
        if ($defender['einh8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh8'] . ' ' . $einh[8]['name'] . '<br />';
        }
        if ($defender['einh9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh9'] . ' ' . $einh[9]['name'] . '<br />';
        }
        if ($defender['einh10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh10'] . ' ' . $einh[10]['name'] . '<br />';
        }
        if ($defender['einh11']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh11'] . ' ' . $einh[11]['name'] . '<br />';
        }
        if ($defender['einh12']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh12'] . ' ' . $einh[12]['name'] . '<br />';
        }
        if ($defender['einh13']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh13'] . ' ' . $einh[13]['name'] . '<br />';
        }
        if ($defender['einh14']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh14'] . ' ' . $einh[14]['name'] . '<br />';
        }
        if ($defender['einh15']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh15'] . ' ' . $einh[15]['name'] . '<br />';
        }
        if ($defender_def['def5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def5'] . ' ' . $def[5]['name'] . '<br />';
        }
        if ($defender_def['def6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def6'] . ' ' . $def[6]['name'] . '<br />';
        }
        if ($defender_def['def7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def7'] . ' ' . $def[7]['name'] . '<br />';
        }
        if ($defender_def['def8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def8'] . ' ' . $def[8]['name'] . '<br />';
        }
        if ($defender_def['def9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def9'] . ' ' . $def[9]['name'] . '<br />';
        }
        if ($defender_def['def10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def10'] . ' ' . $def[10]['name'] . '<br />';
        }
        $count = 0;
        do {
            $count++;
            $type = 'einh' . $count;
            $d_anz = $d_anz + $defender[$type];
            $d_off += ($einh[$count]['off'] + $einh[$count]['off'] / 10 * $d_fuehrung) * $defender[$type];
            $d_def += ($einh[$count]['def'] + $einh[$count]['def'] / 10 * $d_fuehrung) * $defender[$type];
        } while (15 > $count);
        $content .= '<br />F&uuml;hrungsbonus: ' . $d_fuehrung * 10 . '%<br />';
        $content .= 'Einheiten: ' . $d_anz . '<br />';
        $content .= 'Angriffswert: <b>' . $d_off . '</b><br />';
        $content .= 'Verteidigungswert: <b>' . $d_def . '</b><br />';
        $bonus = rand(0, 10);
        if ($bonus == 1) {
            $o_off_bonus = 10;
            $bonus = "<br /><b>Der Angreifer konnte den Verteidiger &uuml;berraschen. <br />(+10% Angriff)</b><br />";
        } elseif ($bonus == 2) {
            $o_def_bonus = 10;
            $bonus = "<br /><b>Die Soldaten des Angreifers haben tapfer und mutig gek&auml;mpft. <br />(+10% Verteidigung)</b><br />";
        } elseif ($bonus == 3) {
            $o_off_bonus = 10;
            $bonus = "<br /><b>Der Verteidiger konnte den Angreifer &uuml;berraschen. <br />(+10% Angriff)</b><br />";
        } elseif ($bonus == 4) {
            $d_def_bonus = 10;
            $bonus = "<br /><b>Die Soldaten des Verteidigers haben tapfer und mutig gek&auml;mpft. <br />(+10% Verteidigung)</b><br />";
        } else {
            $bonus = "<br />";
        }
        $j = 0;
        do {
            $i++;
            $einheit = 'einh' . $i;
            $k = 0;
            do {
                $k++;
                if ($k <= $offender[$einheit]) {
                    $soldiers['offender'][$j]['type'] = $i;
                    $soldiers['offender'][$j]['id'] = $k;
                    $soldiers['offender'][$j]['name'] = $einh[$i]['name'];
                    $soldiers['offender'][$j]['off'] = $einh[$i]['off'] + $einh[$i]['off'] / 10 * $o_fuehrung + $einh[$i]['off'] / 100 * $o_off_bonus;
                    $soldiers['offender'][$j]['def'] = $einh[$i]['def'] + $einh[$i]['def'] / 10 * $o_fuehrung + $einh[$i]['def'] / 100 * $o_def_bonus;
                    $j++;
                }
            } while ($k < $offender[$einheit]);
        } while ($i < 15);
        $i = 0;
        $j = 0;
        do {
            $i++;
            $einheit = 'einh' . $i;
            $k = 0;
            do {
                $k++;
                if ($k <= $defender[$einheit]) {
                    $soldiers['defender'][$j]['type'] = $i;
                    $soldiers['defender'][$j]['id'] = $k;
                    $soldiers['defender'][$j]['name'] = $einh[$i]['name'];
                    $soldiers['defender'][$j]['off'] = $einh[$i]['off'] + $einh[$i]['off'] / 10 * $d_fuehrung + $einh[$i]['off'] / 100 * $d_off_bonus;
                    $soldiers['defender'][$j]['def'] = $einh[$i]['def'] + $einh[$i]['def'] / 10 * $d_fuehrung + $einh[$i]['off'] / 100 * $d_def_bonus;
                    $j++;
                }
            } while ($k < $defender[$einheit]);
        } while ($i < 15);
        $i = 1004;
        do {
            $i++;
            $l = $i - 1000;
            $einheit = 'def' . $l;
            $k = 0;
            do {
                $k++;
                if ($k <= $defender_def[$einheit]) {
                    $d_anz++;
                    $soldiers['defender'][$j]['type'] = $i;
                    $soldiers['defender'][$j]['id'] = $k;
                    $soldiers['defender'][$j]['name'] = $def[$l]['name'];
                    $soldiers['defender'][$j]['off'] = $def[$l]['off'] + $def[$l]['off'] / 10 * $d_fuehrung;
                    $soldiers['defender'][$j]['def'] = $def[$l]['def'] + $def[$l]['def'] / 10 * $d_fuehrung;
                    $j++;
                }
            } while ($k < $defender_def[$einheit]);
        } while ($i < 1015);
        if ($d_anz > 0 and $o_anz > 0) {
            $content .= $bonus;
            // neuer kampfmod
            do {
                $kampf .= '<br /><i>Runde ' . ++$round . ':</i><br />';
                $count_offender = count($soldiers['offender']) - 1;
                $count_defender = count($soldiers['defender']) - 1;
                $trooper_offender = 0;
                $trooper_offended = 0;
                do {
                    if ($trooper_offended > $count_defender) {
                        $trooper_offended = 0;
                    }
                    $soldiers['defender'][$trooper_offended]['def'] -= $soldiers['offender'][$trooper_offender]['off'];
                    if ($soldiers['defender'][$trooper_offended]['name']) {
                        // $kampf .= 'Die angreifende Eh. '.$soldiers['offender'][$trooper_offender]['name'].' ('.$soldiers['offender'][$trooper_offender]['off'].'/'.$soldiers['offender'][$trooper_offender]['def'].') schiesst auf Eh. '.$soldiers['defender'][$trooper_offended]['name'].' ('.$soldiers['defender'][$trooper_offended]['off'].'/'.$soldiers['defender'][$trooper_offended]['def'].')<br />';
                    }
                    $trooper_offender++;
                    $trooper_offended = rand(0, $count_defender);
                } while ($trooper_offender < count($soldiers['offender']));
                $trooper_offender = 0;
                $trooper_offended = 0;
                do {
                    if ($trooper_offended > $count_offender) {
                        $trooper_offended = 0;
                    }
                    $soldiers['offender'][$trooper_offended]['def'] -= $soldiers['defender'][$trooper_offender]['off'];
                    if ($soldiers['offender'][$trooper_offended]['name']) {
                        // $kampf .= 'Die verteidigende Eh. '.$soldiers['defender'][$trooper_offender]['name'].' ('.$soldiers['defender'][$trooper_offender]['off'].'/'.$soldiers['defender'][$trooper_offender]['def'].') schiesst auf Eh '.$soldiers['offender'][$trooper_offended]['name'].' ('.$soldiers['offender'][$trooper_offended]['off'].'/'.$soldiers['offender'][$trooper_offended]['def'].')<br />';
                    }
                    $trooper_offender++;
                    $trooper_offended = rand(0, $count_offender);
                } while ($trooper_offender < count($soldiers['defender']));
                // unset kaputte defender
                $trooper_offended = 0;
                $count = count($soldiers['defender']) + 1;
                do {
                    if ($soldiers['defender'][$trooper_offended]['def'] <= 0 and $soldiers['defender'][$trooper_offended]['type'] != 0) {
                        // $v[$soldiers['defender'][$trooper_offended]['type']]++;
                        $vd[$soldiers['defender'][$trooper_offended]['type']]++;
                        unset($soldiers['defender'][$trooper_offended]);
                    }
                    $trooper_offended++;
                } while ($trooper_offended <= $count);
                sort($soldiers['defender']);
                // unset kaputte offender
                $trooper_offended = 0;
                $count = count($soldiers['offender']) + 1;
                do {
                    if ($soldiers['offender'][$trooper_offended]['def'] <= 0 and $soldiers['offender'][$trooper_offended]['type'] != 0) {
                        // $v[$soldiers['offender'][$trooper_offended]['type']]++;
                        $vo[$soldiers['offender'][$trooper_offended]['type']]++;
                        unset($soldiers['offender'][$trooper_offended]);
                    }
                    $trooper_offended++;
                } while ($trooper_offended <= $count);
                sort($soldiers['offender']);
                // echo "---".count( $soldiers['offender'] )."/".count( $soldiers['defender'] )."\n";
                $kampf .= "&nbsp;&nbsp;&nbsp;Angreifer: " . count($soldiers['offender']) . " Einheiten<br />&nbsp;&nbsp;&nbsp;Verteidiger " . count($soldiers['defender']) . " Einheiten<br />";
            } while (count($soldiers['offender']) > 0 and count($soldiers['defender']) > 0 and $round < 100);
            // ende neuer kampfmod
        }
        $i = 0;
        do {
            $i++;
            $tf_eisen += number_format(($vd[$i] + $vo[$i]) * $einh[$i]['eisen'] / 1.5, 0, '', '');
            $tf_titan += number_format(($vd[$i] + $vo[$i]) * $einh[$i]['titan'] / 1.5, 0, '', '');
        } while ($i < 15);
        $i = 1004;
        do {
            $i++;
            $l = $i - 1000;
            $tf_eisen += number_format(($vd[$i] + $vo[$i]) * $def[$l]['eisen'] / 1.5, 0, '', '');
            $tf_titan += number_format(($vd[$i] + $vo[$i]) * $def[$l]['titan'] / 1.5, 0, '', '');
            if ($vd[$i] > 0) {
                $inst[$i] = rand(0, $vd[$i]);
                $inst['text'] .= "&nbsp;&nbsp;" . $inst[$i] . " x " . $def[$l]['name'] . "<br />";
            }
        } while ($i < 1010);
        // verluste in ressis umrechnen
        $i = 0;
        do {
            $i++;
            $vo['eisen'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['eisen'], 0, '', '');
            $vo['titan'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['titan'], 0, '', '');
            $vo['oel'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['oel'], 0, '', '');
            $vo['uran'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['uran'], 0, '', '');
            $vo['gold'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['gold'], 0, '', '');
            $vo['chanje'] += number_format(($vd[$i] - $vo[$i]) * $einh[$i]['chanje'], 0, '', '');
            $vd['eisen'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['eisen'], 0, '', '');
            $vd['titan'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['titan'], 0, '', '');
            $vd['oel'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['oel'], 0, '', '');
            $vd['uran'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['uran'], 0, '', '');
            $vd['gold'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['gold'], 0, '', '');
            $vd['chanje'] += number_format(($vo[$i] - $vd[$i]) * $einh[$i]['chanje'], 0, '', '');
        } while ($i < 15);
        $content .= '<br /><b>Endstand:</b><br /><br />';
        $count = 0;
        do {
            $count++;
            $type = 'einh' . $count;
            $offender[$type] = 0;
        } while (15 > $count);
        $i = 0;
        do {
            if ($soldiers['offender'][$i]['type'] == 1) {
                $offender['einh1']++;
            } elseif ($soldiers['offender'][$i]['type'] == 2) {
                $offender['einh2']++;
            } elseif ($soldiers['offender'][$i]['type'] == 3) {
                $offender['einh3']++;
            } elseif ($soldiers['offender'][$i]['type'] == 4) {
                $offender['einh4']++;
            } elseif ($soldiers['offender'][$i]['type'] == 5) {
                $offender['einh5']++;
            } elseif ($soldiers['offender'][$i]['type'] == 6) {
                $offender['einh6']++;
            } elseif ($soldiers['offender'][$i]['type'] == 7) {
                $offender['einh7']++;
            } elseif ($soldiers['offender'][$i]['type'] == 8) {
                $offender['einh8']++;
            } elseif ($soldiers['offender'][$i]['type'] == 9) {
                $offender['einh9']++;
            } elseif ($soldiers['offender'][$i]['type'] == 10) {
                $offender['einh10']++;
            } elseif ($soldiers['offender'][$i]['type'] == 11) {
                $offender['einh11']++;
            } elseif ($soldiers['offender'][$i]['type'] == 12) {
                $offender['einh12']++;
            } elseif ($soldiers['offender'][$i]['type'] == 13) {
                $offender['einh13']++;
            } elseif ($soldiers['offender'][$i]['type'] == 14) {
                $offender['einh14']++;
            } elseif ($soldiers['offender'][$i]['type'] == 15) {
                $offender['einh15']++;
            }
            $i++;
        } while ($soldiers['offender'][$i]);
        $content .= '<i>Angreifer (' . $offender_user['name'] . '):</i><br />';
        if ($offender['einh1']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh1'] . ' ' . $einh[1]['name'] . '<br />';
        }
        if ($offender['einh2']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh2'] . ' ' . $einh[2]['name'] . '<br />';
        }
        if ($offender['einh3']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh3'] . ' ' . $einh[3]['name'] . '<br />';
        }
        if ($offender['einh4']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh4'] . ' ' . $einh[4]['name'] . '<br />';
        }
        if ($offender['einh5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh5'] . ' ' . $einh[5]['name'] . '<br />';
        }
        if ($offender['einh6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh6'] . ' ' . $einh[6]['name'] . '<br />';
        }
        if ($offender['einh7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh7'] . ' ' . $einh[7]['name'] . '<br />';
        }
        if ($offender['einh8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh8'] . ' ' . $einh[8]['name'] . '<br />';
        }
        if ($offender['einh9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh9'] . ' ' . $einh[9]['name'] . '<br />';
        }
        if ($offender['einh10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh10'] . ' ' . $einh[10]['name'] . '<br />';
        }
        if ($offender['einh11']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh11'] . ' ' . $einh[11]['name'] . '<br />';
        }
        if ($offender['einh12']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh12'] . ' ' . $einh[12]['name'] . '<br />';
        }
        if ($offender['einh13']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh13'] . ' ' . $einh[13]['name'] . '<br />';
        }
        if ($offender['einh14']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh14'] . ' ' . $einh[14]['name'] . '<br />';
        }
        if ($offender['einh15']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $offender['einh15'] . ' ' . $einh[15]['name'] . '<br />';
        }
        $count = 0;
        $o_anz = 0;
        $o_off = 0;
        $o_def = 0;
        do {
            $count++;
            $type = 'einh' . $count;
            $o_anz = $o_anz + $offender[$type];
            $o_off += ($einh[$count]['off'] + $einh[$count]['off'] / 10 * $o_fuehrung) * $offender[$type];
            $o_def += ($einh[$count]['def'] + $einh[$count]['def'] / 10 * $o_fuehrung) * $offender[$type];
        } while (15 > $count);
        if ($o_anz == 0) {
            $content .= '&nbsp;&nbsp;&nbsp;<b>vernichtet</b><br />';
            $vernichtet = 'o';
        }
        $count = 0;
        do {
            $count++;
            $type = 'einh' . $count;
            $defender[$type] = 0;
        } while (15 > $count);
        $defender_def['def5'] = 0;
        $defender_def['def6'] = 0;
        $defender_def['def7'] = 0;
        $defender_def['def8'] = 0;
        $defender_def['def9'] = 0;
        $defender_def['def10'] = 0;
        $i = 0;
        do {
            if ($soldiers['defender'][$i]['type'] == 1) {
                $defender['einh1']++;
            } elseif ($soldiers['defender'][$i]['type'] == 2) {
                $defender['einh2']++;
            } elseif ($soldiers['defender'][$i]['type'] == 3) {
                $defender['einh3']++;
            } elseif ($soldiers['defender'][$i]['type'] == 4) {
                $defender['einh4']++;
            } elseif ($soldiers['defender'][$i]['type'] == 5) {
                $defender['einh5']++;
            } elseif ($soldiers['defender'][$i]['type'] == 6) {
                $defender['einh6']++;
            } elseif ($soldiers['defender'][$i]['type'] == 7) {
                $defender['einh7']++;
            } elseif ($soldiers['defender'][$i]['type'] == 8) {
                $defender['einh8']++;
            } elseif ($soldiers['defender'][$i]['type'] == 9) {
                $defender['einh9']++;
            } elseif ($soldiers['defender'][$i]['type'] == 10) {
                $defender['einh10']++;
            } elseif ($soldiers['defender'][$i]['type'] == 11) {
                $defender['einh11']++;
            } elseif ($soldiers['defender'][$i]['type'] == 12) {
                $defender['einh12']++;
            } elseif ($soldiers['defender'][$i]['type'] == 13) {
                $defender['einh13']++;
            } elseif ($soldiers['defender'][$i]['type'] == 14) {
                $defender['einh14']++;
            } elseif ($soldiers['defender'][$i]['type'] == 15) {
                $defender['einh15']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1005) {
                $defender_def['def5']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1006) {
                $defender_def['def6']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1007) {
                $defender_def['def7']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1008) {
                $defender_def['def8']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1009) {
                $defender_def['def9']++;
            } elseif ($soldiers['defender'][$i]['type'] == 1010) {
                $defender_def['def10']++;
            }
            $i++;
        } while ($soldiers['defender'][$i]);
        $content .= '<br /><i>Verteidiger (' . $defender_user['name'] . '):</i><br />';
        if ($defender['einh1']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh1'] . ' ' . $einh[1]['name'] . '<br />';
        }
        if ($defender['einh2']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh2'] . ' ' . $einh[2]['name'] . '<br />';
        }
        if ($defender['einh3']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh3'] . ' ' . $einh[3]['name'] . '<br />';
        }
        if ($defender['einh4']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh4'] . ' ' . $einh[4]['name'] . '<br />';
        }
        if ($defender['einh5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh5'] . ' ' . $einh[5]['name'] . '<br />';
        }
        if ($defender['einh6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh6'] . ' ' . $einh[6]['name'] . '<br />';
        }
        if ($defender['einh7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh7'] . ' ' . $einh[7]['name'] . '<br />';
        }
        if ($defender['einh8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh8'] . ' ' . $einh[8]['name'] . '<br />';
        }
        if ($defender['einh9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh9'] . ' ' . $einh[9]['name'] . '<br />';
        }
        if ($defender['einh10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh10'] . ' ' . $einh[10]['name'] . '<br />';
        }
        if ($defender['einh11']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh11'] . ' ' . $einh[11]['name'] . '<br />';
        }
        if ($defender['einh12']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh12'] . ' ' . $einh[12]['name'] . '<br />';
        }
        if ($defender['einh13']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh13'] . ' ' . $einh[13]['name'] . '<br />';
        }
        if ($defender['einh14']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh14'] . ' ' . $einh[14]['name'] . '<br />';
        }
        if ($defender['einh15']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender['einh15'] . ' ' . $einh[15]['name'] . '<br />';
        }
        if ($defender_def['def5']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def5'] . ' ' . $def[5]['name'] . '<br />';
        }
        if ($defender_def['def6']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def6'] . ' ' . $def[6]['name'] . '<br />';
        }
        if ($defender_def['def7']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def7'] . ' ' . $def[7]['name'] . '<br />';
        }
        if ($defender_def['def8']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def8'] . ' ' . $def[8]['name'] . '<br />';
        }
        if ($defender_def['def9']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def9'] . ' ' . $def[9]['name'] . '<br />';
        }
        if ($defender_def['def10']) {
            $content .= '&nbsp;&nbsp;&nbsp;' . $defender_def['def10'] . ' ' . $def[10]['name'] . '<br />';
        }
        $count = 0;
        $d_anz = 0;
        $d_off = 0;
        $d_def = 0;
        do {
            $count++;
            $type = 'einh' . $count;
            $d_anz = $d_anz + $defender[$type];
            $d_off += ($einh[$count]['off'] + $einh[$count]['off'] / 10 * $d_fuehrung) * $defender[$type];
            $d_def += ($einh[$count]['def'] + $einh[$count]['def'] / 10 * $d_fuehrung) * $defender[$type];
        } while (15 > $count);
        $count = 4;
        do {
            $count++;
            $type = 'def' . $count;
            $d_anz = $d_anz + $defender_def[$type];
            $d_off += ($def[$count]['off'] + $def[$count]['off'] / 10 * $d_fuehrung) * $defender_def[$type];
            $d_def += ($def[$count]['def'] + $def[$count]['def'] / 10 * $d_fuehrung) * $defender_def[$type];
        } while (10 > $count);
        if ($d_anz == 0) {
            $content .= '&nbsp;&nbsp;&nbsp;<b>vernichtet</b><br />';
            $vernichtet = 'd';
        }
        if ($inst['text']) {
            $defender_def['def5'] += $inst[1005];
            $defender_def['def6'] += $inst[1006];
            $defender_def['def7'] += $inst[1007];
            $defender_def['def8'] += $inst[1008];
            $defender_def['def9'] += $inst[1009];
            $defender_def['def10'] += $inst[1010];
            $content .= "<br /><b>Folgende Verteidigungsanlagen liessen sich reparieren:</b><br />";
            $content .= $inst['text'] . "<br />";
        }
        $count = 0;
        if ($o_anz > 0) {
            do {
                $count++;
                $type = 'einh' . $count;
                if ($offender[$type] > 0) {
                    $space += $offender[$type] * $einh[$count]['space'];
                }
            } while (14 > $count);
            $ressis = ressistand($d_omni);
            $ressis_old = $ressis;
            $ausbeute = rand(40, 90);
            $ressisgesammt = $ressis['eisen'] + $ressis['titan'] + $ressis['oel'] + $ressis['uran'] + $ressis['gold'] + $ressis['chanje'];
            $ressis['eisen'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['eisen'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['eisen'] = 0);
            $ressis['titan'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['titan'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['titan'] = 0);
            $ressis['oel'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['oel'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['oel'] = 0);
            $ressis['uran'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['uran'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['uran'] = 0);
            $ressis['gold'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['gold'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['gold'] = 0);
            $ressis['chanje'] - ($gebaeude['rohstofflager'] * 100 + 500) >= 0 ? $ressis['chanje'] -= $gebaeude['rohstofflager'] * 100 + 500 : ($ressis['chanje'] = 0);
            $pluenderung['eisen'] = number_format($ressis['eisen'] / 100 * $ausbeute, 0, '', '');
            $pluenderung['titan'] = number_format($ressis['titan'] / 100 * $ausbeute, 0, '', '');
            $pluenderung['oel'] = number_format($ressis['oel'] / 100 * $ausbeute, 0, '', '');
            $pluenderung['uran'] = number_format($ressis['uran'] / 100 * $ausbeute, 0, '', '');
            $pluenderung['gold'] = number_format($ressis['gold'] / 100 * $ausbeute, 0, '', '');
            $pluenderung['chanje'] = number_format($ressis['chanje'] / 100 * $ausbeute, 0, '', '');
            $free = $space;
            $pluendern[0]['name'] = 'eisen';
            $pluendern[1]['name'] = 'titan';
            $pluendern[2]['name'] = 'oel';
            $pluendern[3]['name'] = 'uran';
            $pluendern[4]['name'] = 'gold';
            $pluendern[5]['name'] = 'chanje';
            $max = number_format(rand(25, 90), 0, '', '');
            $max = $space / 100 * $max;
            do {
                $rand = rand(0, 2);
                if ($pluenderung[$pluendern[$rand]['name']] > $max) {
                    $pluenderung[$pluendern[$rand]['name']] = $max;
                }
                if (count($pluendern) > 3) {
                    $name = $pluendern[$rand]['name'];
                    unset($pluendern[$rand]);
                    sort($pluendern);
                } else {
                    $rand = rand(0, count($pluendern) - 1);
                    $name = $pluendern[$rand]['name'];
                    unset($pluendern[$rand]);
                    sort($pluendern);
                }
                if ($free - $pluenderung[$name] >= 0) {
                    $free -= $pluenderung[$name];
                } else {
                    $pluenderung[$name] = $free;
                    $free = 0;
                }
            } while (count($pluendern) > 0);
            $content .= '<br /><b><u>Pl&uuml;nderung:</u></b><br /><br />Maximale Gesamtzuladung: ' . $space . '<br />Maximale Ausbeute: ' . $ausbeute . '%<br />';
            $content .= 'Eisen: ' . number_format($pluenderung['eisen'], 0) . '<br />';
            $content .= 'Titan: ' . number_format($pluenderung['titan'], 0) . '<br />';
            $content .= 'Oel: ' . number_format($pluenderung['oel'], 0) . '<br />';
            $content .= 'Uran: ' . number_format($pluenderung['uran'], 0) . '<br />';
            $content .= 'Gold: ' . number_format($pluenderung['gold'], 0) . '<br />';
            $content .= 'Chanje: ' . number_format($pluenderung['chanje'], 0) . '<br />';
            $content .= 'Restplatz: ' . number_format($free, 0) . '<br />';
            $ressis_old['eisen'] -= $pluenderung['eisen'];
            $ressis_old['titan'] -= $pluenderung['titan'];
            $ressis_old['oel'] -= $pluenderung['oel'];
            $ressis_old['uran'] -= $pluenderung['uran'];
            $ressis_old['gold'] -= $pluenderung['gold'];
            $ressis_old['chanje'] -= $pluenderung['chanje'];
            $select = "UPDATE `ressis` SET `eisen` = '" . $ressis_old['eisen'] . "', `titan` = '" . $ressis_old['titan'] . "', `oel` = '" . $ressis_old['oel'] . "', `uran` = '" . $ressis_old['uran'] . "', `gold` = '" . $ressis_old['gold'] . "', `chanje` = '" . $ressis_old['chanje'] . "' WHERE `omni` = '" . $d_omni . "' LIMIT 1;";
            mysql_query($select);
            $select = "UPDATE `missionen` SET `einh1` = '" . $offender['einh1'] . "', `einh2` = '" . $offender['einh2'] . "', `einh3` = '" . $offender['einh3'] . "', `einh4` = '" . $offender['einh4'] . "', `einh5` = '" . $offender['einh5'] . "', `einh6` = '" . $offender['einh6'] . "', `einh7` = '" . $offender['einh7'] . "',  `einh8` = '" . $offender['einh8'] . "', `einh9` = '" . $offender['einh9'] . "', `einh10` = '" . $offender['einh10'] . "',  `einh11` = '" . $offender['einh11'] . "', `einh12` = '" . $offender['einh12'] . "', `einh13` = '" . $offender['einh13'] . "', `einh14` = '" . $offender['einh14'] . "', `einh15` = '" . $offender['einh15'] . "', `eisen` = '" . $pluenderung['eisen'] . "', `titan` = '" . $pluenderung['titan'] . "', `oel` = '" . $pluenderung['oel'] . "', `uran` = '" . $pluenderung['uran'] . "', `gold` = '" . $pluenderung['gold'] . "', `chanje` = '" . $pluenderung['chanje'] . "' WHERE `id` = '" . $id . "' LIMIT 1;";
        } else {
            $select = "DELETE FROM `missionen` WHERE `id` = '" . $id . "' LIMIT 1 ;";
        }
        mysql_query($select);
        $content .= '<br />Durch den Kampf entstandene Tr&uuml;mmer: ' . $tf_eisen . ' Eisen ' . $tf_titan . ' Titan. <br />';
        // supporterstats
        $i = 0;
        do {
            $i++;
            if (!$vo[$i]) {
                $vo[$i] = 0;
            }
            if (!$vd[$i]) {
                $vd[$i] = 0;
            }
            // printf ($vo[$i]." / ".$vd[$i]."\n");
        } while ($i < 15);
        mysql_query("UPDATE `stats` SET `dk1` = dk1 + " . $vo[1] . ", `dk2` = dk2 + " . $vo[2] . ", `dk3` = dk3 + " . $vo[3] . ", `dk4` = dk4 + " . $vo[4] . ", `dk5` = dk5 + " . $vo[5] . ", `dk6` = dk6 + " . $vo[6] . ", `dk7` = dk7 + " . $vo[7] . ", `dk8` = dk8 + " . $vo[8] . ", `dk9` = dk9 + " . $vo[9] . ", `dk10` = dk10 + " . $vo[10] . ", `dk11` = dk11 + " . $vo[11] . ", `dk12` = dk12 + " . $vo[12] . ", `dk13` = dk13 + " . $vo[13] . ", `dk14` = dk14 + " . $vo[14] . ", `dk15` = dk15 + " . $vo[15] . " WHERE `id` = " . $d_omni . ";");
        mysql_query("UPDATE `stats` SET `vk1` = vk1 + " . $vd[1] . ", `vk2` = vk2 + " . $vd[2] . ", `vk3` = vk3 + " . $vd[3] . ", `vk4` = vk4 + " . $vd[4] . ", `vk5` = vk5 + " . $vd[5] . ", `vk6` = vk6 + " . $vd[6] . ", `vk7` = vk7 + " . $vd[7] . ", `vk8` = vk8 + " . $vd[8] . ", `vk9` = vk9 + " . $vd[9] . ", `vk10` = vk10 + " . $vd[10] . ", `vk11` = vk11 + " . $vd[11] . ", `vk12` = vk12 + " . $vd[12] . ", `vk13` = vk13 + " . $vd[13] . ", `vk14` = vk14 + " . $vd[14] . ", `vk15` = vk15 + " . $vd[15] . " WHERE `id` = " . $d_omni . ";");
        mysql_query("UPDATE `stats` SET `dk1` = dk1 + " . $vd[1] . ", `dk2` = dk2 + " . $vd[2] . ", `dk3` = dk3 + " . $vd[3] . ", `dk4` = dk4 + " . $vd[4] . ", `dk5` = dk5 + " . $vd[5] . ", `dk6` = dk6 + " . $vd[6] . ", `dk7` = dk7 + " . $vd[7] . ", `dk8` = dk8 + " . $vd[8] . ", `dk9` = dk9 + " . $vd[9] . ", `dk10` = dk10 + " . $vd[10] . ", `dk11` = dk11 + " . $vd[11] . ", `dk12` = dk12 + " . $vd[12] . ", `dk13` = dk13 + " . $vd[13] . ", `dk14` = dk14 + " . $vd[14] . ", `dk15` = dk15 + " . $vd[15] . " WHERE `id` = " . $o_omni . ";");
        mysql_query("UPDATE `stats` SET `vk1` = vk1 + " . $vo[1] . ", `vk2` = vk2 + " . $vo[2] . ", `vk3` = vk3 + " . $vo[3] . ", `vk4` = vk4 + " . $vo[4] . ", `vk5` = vk5 + " . $vo[5] . ", `vk6` = vk6 + " . $vo[6] . ", `vk7` = vk7 + " . $vo[7] . ", `vk8` = vk8 + " . $vo[8] . ", `vk9` = vk9 + " . $vo[9] . ", `vk10` = vk10 + " . $vo[10] . ", `vk11` = vk11 + " . $vo[11] . ", `vk12` = vk12 + " . $vo[12] . ", `vk13` = vk13 + " . $vo[13] . ", `vk14` = vk14 + " . $vo[14] . ", `vk15` = vk15 + " . $vo[15] . " WHERE `id` = " . $o_omni . ";");
        mysql_query("UPDATE `stats` SET `farm_eisen` = farm_eisen + " . $pluenderung['eisen'] . ", `farm_titan` = farm_titan + " . $pluenderung['titan'] . ", `farm_oel` = farm_oel + " . $pluenderung['oel'] . ", `farm_uran` = farm_uran + " . $pluenderung['uran'] . ", `farm_gold` = farm_gold + " . $pluenderung['gold'] . " WHERE `id` = '" . $o_omni . "' LIMIT 1 ;");
        mysql_query("UPDATE `stats` SET `ripped_eisen` = ripped_eisen + " . $pluenderung['eisen'] . ", `ripped_titan` = ripped_titan + " . $pluenderung['titan'] . ", `ripped_oel` = ripped_oel + " . $pluenderung['oel'] . ", `ripped_uran` = ripped_uran + " . $pluenderung['uran'] . ", `ripped_gold` = ripped_gold + " . $pluenderung['gold'] . " WHERE `id` = '" . $d_omni . "' LIMIT 1 ;");
        // kampfpunkte
        $kp_o = ($vo['eisen'] + $vo['titan'] + $vo['oel'] + $vo['uran'] + $vo['gold'] + $vo['chanje'] * 25) / 100;
        $kp_d = ($vd['eisen'] + $vd['titan'] + $vd['oel'] + $vd['uran'] + $vd['gold'] + $vd['chanje'] * 25) / 100;
        if ($vernichtet == 'o' and $kp_d < 0) {
            $kp_d = 0;
        }
        if ($vernichtet == 'd' and $kp_o < 0) {
            $kp_o = 0;
        }
        $content .= 'Kampfpunkte Angreifer: ' . $kp_o . ' <br />';
        $content .= 'Kampfpunkte Verteidiger: ' . $kp_d . ' <br />';
        if ($vernichtet == 'd') {
            $user = mysql_query("SELECT timestamp FROM `user` WHERE `omni` = '" . $d_omni . "' LIMIT 1;");
            $user = mysql_fetch_array($user);
            if ($user['timestamp'] < date('U') - 3628800) {
                $content .= '<br /><font class="red">Die Basis bei ' . $d_omni . ' wurde durch diesen Angriff komplett zerst&ouml;rt.</font><br />';
                deluser($d_omni);
            }
        }
        // clanwars
        $r1 = mysql_query("SELECT * FROM `clans` WHERE `userid` =" . $o_omni . ";");
        $r1 = @mysql_fetch_array($r1);
        $r2 = mysql_query("SELECT * FROM `clans` WHERE `userid` =" . $d_omni . ";");
        $r2 = @mysql_fetch_array($r2);
        if ($r1 and $r2) {
            $r3 = mysql_query("SELECT * FROM `clanwars` WHERE `clan1` =" . $r1['clanid'] . " AND `clan2` =" . $r2['clanid'] . " AND `ended` = 0;");
            $r3 = @mysql_fetch_array($r3);
            $r4 = mysql_query("SELECT * FROM `clanwars` WHERE `clan2` =" . $r1['clanid'] . " AND `clan1` =" . $r2['clanid'] . " AND `ended` = 0;");
            $r4 = @mysql_fetch_array($r4);
            if ($r3) {
                $select = "UPDATE `clanwars` SET `kampfpunkte1` =`kampfpunkte1`+" . $kp_o . ", `kampfpunkte2` =`kampfpunkte2`+" . $kp_d . ", `ressis1` =`ressis1`+" . ($pluenderung['eisen'] + $pluenderung['titan'] + $pluenderung['oel'] + $pluenderung['uran'] + $pluenderung['gold'] + $pluenderung['chanje'] * 1000) . ", `ressis2` =`ressis2`-" . ($pluenderung['eisen'] + $pluenderung['titan'] + $pluenderung['oel'] + $pluenderung['uran'] + $pluenderung['gold'] + $pluenderung['chanje'] * 1000) . " WHERE `id` = '" . $r3['id'] . "' LIMIT 1;";
                mysql_query($select);
            } elseif ($r4) {
                $select = "UPDATE `clanwars` SET `kampfpunkte1` =`kampfpunkte1`+" . $kp_d . ", `kampfpunkte2` =`kampfpunkte2`+" . $kp_o . ", `ressis1` =`ressis1`-" . ($pluenderung['eisen'] + $pluenderung['titan'] + $pluenderung['oel'] + $pluenderung['uran'] + $pluenderung['gold'] + $pluenderung['chanje'] * 1000) . ", `ressis2` =`ressis2`+" . ($pluenderung['eisen'] + $pluenderung['titan'] + $pluenderung['oel'] + $pluenderung['uran'] + $pluenderung['gold'] + $pluenderung['chanje'] * 1000) . " WHERE `id` = '" . $r4['id'] . "' LIMIT 1;";
                mysql_query($select);
            }
        }
        $select = "UPDATE `user` SET `kampfpunkte` = kampfpunkte + " . $kp_o . " WHERE `omni` = '" . $o_omni . "' LIMIT 1;";
        mysql_query($select);
        $select = "UPDATE `user` SET `kampfpunkte` = kampfpunkte + " . $kp_d . " WHERE `omni` = '" . $d_omni . "' LIMIT 1;";
        mysql_query($select);
        if ($tf_eisen + $tf_titan > 7000) {
            $chanje = rand(number_format(($tf_eisen + $tf_titan) / 2000), number_format(($tf_eisen + $tf_titan) / 500, 0, '', ''));
            if ($vernichtet == 'o') {
                $content .= '<br /><b>F&uuml;r diesen Kampf, bekommt der Kommandant der Basis ' . $d_omni . ' nun ' . $chanje . ' Chanje als Anerkennung.<br /></b>';
                $target = $d_omni;
            }
            if ($vernichtet == 'd') {
                $content .= '<br /><b>F&uuml;r diesen Kampf, bekommt der Kommandant der Basis ' . $o_omni . ' nun ' . $chanje . ' Chanje als Anerkennung.<br /></b>';
                $target = $o_omni;
            }
            $rand = rand(20, 40);
            $select = "INSERT INTO `missionen` ( `id` , `type` , `start` , `ziel` , `started` , `ankunft` , `return` , `speed` , `parsed` , `einh1` , `einh2` , `einh3` , `einh4` , `einh5` , `einh6` , `einh7` , `einh8` , `einh9` , `einh10` , `einh11` , `einh12` , `einh13` , `einh14` , `einh15` , `eisen` , `titan` , `oel` , `uran` , `gold` , `chanje` ) VALUES ( '', '2', '0', '" . $target . "', '" . date('U') . "', '" . (date('U') + $rand * 60) . "', '" . (date('U') + 20000) . "', '666', '0', '', '', '', '', '', '', '', '', '', '', '', '', '', '10', '', '0', '0', '0', '0', '0', '" . $chanje . "' );";
            mysql_query($select);
            $eid = mysql_insert_id($dbh);
            $select = "INSERT INTO `events` ( `id` , `type` , `eid` , `date` ) VALUES ('', '1', '" . $eid . "', '" . (date('U') + $rand * 60) . "');";
            $selectResult = mysql_query($select);
        }
        $select = "UPDATE `hangar` SET `einh1` = '" . $defender['einh1'] . "', `einh2` = '" . $defender['einh2'] . "', `einh3` = '" . $defender['einh3'] . "', `einh4` = '" . $defender['einh4'] . "', `einh5` = '" . $defender['einh5'] . "', `einh6` = '" . $defender['einh6'] . "', `einh7` = '" . $defender['einh7'] . "',  `einh8` = '" . $defender['einh8'] . "', `einh9` = '" . $defender['einh9'] . "', `einh10` = '" . $defender['einh10'] . "',  `einh11` = '" . $defender['einh11'] . "', `einh12` = '" . $defender['einh12'] . "', `einh13` = '" . $defender['einh13'] . "', `einh14` = '" . $defender['einh14'] . "', `einh15` = '" . $defender['einh15'] . "' WHERE `omni` = '" . $d_omni . "' LIMIT 1;";
        mysql_query($select);
        $select = "UPDATE `defense` SET `def1` = '" . $defender_def['def1'] . "', `def2` = '" . $defender_def['def2'] . "', `def3` = '" . $defender_def['def3'] . "', `def4` = '" . $defender_def['def4'] . "', `def5` = '" . $defender_def['def5'] . "', `def6` = '" . $defender_def['def6'] . "', `def7` = '" . $defender_def['def7'] . "',  `def8` = '" . $defender_def['def8'] . "', `def9` = '" . $defender_def['def9'] . "', `def10` = '" . $defender_def['def10'] . "' WHERE `omni` = '" . $d_omni . "' LIMIT 1;";
        mysql_query($select);
        $select = "UPDATE `user` SET `tf_eisen` = '" . ($defender_user['tf_eisen'] + $tf_eisen) . "', `tf_titan` = '" . ($defender_user['tf_titan'] + $tf_titan) . "' WHERE `omni` = '" . $defender_user['omni'] . "' LIMIT 1;";
        mysql_query($select);
        $content .= '<br /><br />';
        $select = "INSERT INTO `berichte` ( `id` , `from` , `to` , `timestamp` , `gelesen` , `subject` , `text` ) VALUES ( '', 'Missionszentrum', '" . $d_omni . "', '" . $offender['ankunft'] . "', '0', 'Angriff von " . $o_omni . "', '" . $content . $kampf . "' );";
        $result = mysql_query($select);
    }
    $select = "INSERT INTO `berichte` ( `id` , `from` , `to` , `timestamp` , `gelesen` , `subject` , `text` ) VALUES ( '', 'Missionszentrum', '" . $o_omni . "', '" . $offender['ankunft'] . "', '0', 'Kampfbericht bei " . $d_omni . "', '" . $content . $kampf . "' );";
    $result = mysql_query($select);
}
示例#2
0
        if ($_SESSION['eh'][$i] != $_POST['x' . $i]) {
            die('CHEATVERSUCH!');
        }
    }
} while ($i < 15);
$i = 0;
// get playerinfo template and replace tags
$status = template('playerinfo');
$status = tag2value('name', $_SESSION['user']['name'], $status);
$status = tag2value('base', $_SESSION['user']['base'], $status);
$status = tag2value('ubl', $_SESSION['user']['omni'], $status);
$status = tag2value('points', $_SESSION['user']['points'], $status);
// add playerinfo to html
$content .= $status;
// checken ob einheiten fertig sind und dann hangar setzen
$hangar = new_units_check($_SESSION[user][omni]);
// neue nachrichten
//$content .= neue_nachrichten();
// ressourcen berechnen und ausgeben
$ressis = ressistand($_SESSION[user][omni]);
// mit datenbank verbinden
$dbh = db_connect();
// forschungen
$select = "SELECT * FROM `forschungen` WHERE `omni` = '" . $_SESSION[user][omni] . "';";
$result = mysql_query($select);
$forschung = mysql_fetch_array($result);
// gebaeude
$select = "SELECT * FROM `gebauede` WHERE `omni` = '" . $_SESSION[user][omni] . "';";
$selectResult = mysql_query($select);
$gebaeude = mysql_fetch_array($selectResult);
// neuesten timestamp holen
示例#3
0
文件: markt.php 项目: o-wars/o-wars
// Basisfunktionen laden
include "functions.php";
include "einheiten_preise.php";
// check session
logincheck();
// html head setzen
$content = template('head');
// get playerinfo template and replace tags
$status = template('playerinfo');
$status = tag2value('name', $_SESSION['user']['name'], $status);
$status = tag2value('base', $_SESSION['user']['base'], $status);
$status = tag2value('ubl', $_SESSION['user']['omni'], $status);
$status = tag2value('points', $_SESSION['user']['points'], $status);
$content .= $status;
unset($status);
$hangar = new_units_check($_SESSION['user']['omni']);
$dbh = db_connect();
$ressis = ressistand($_SESSION['user']['omni']);
if ($_POST['ek_eisen'] < 0) {
    $_POST['ek_eisen'] = 0;
}
if ($_POST['vk_eisen'] < 0) {
    $_POST['vk_eisen'] = 0;
}
if ($_POST['ek_titan'] < 0) {
    $_POST['ek_titan'] = 0;
}
if ($_POST['vk_titan'] < 0) {
    $_POST['vk_titan'] = 0;
}
if ($_POST['ek_oel'] < 0) {
示例#4
0
function ressistand($omni)
{
    // datenbank verbindung herstellen
    $dbh = db_connect();
    include 'einheiten_preise.php';
    $select = "SELECT * FROM `ressis` WHERE `omni` = '" . $omni . "' ;";
    $selectResult = mysql_query($select);
    $row = mysql_fetch_array($selectResult);
    $select = "SELECT * FROM `gebauede` WHERE `omni` = '" . $omni . "' ;";
    $selectResult = mysql_query($select);
    $gebaeude = mysql_fetch_array($selectResult);
    // checken ob einheiten fertig sind und dann hangar setzen
    $hangar = new_units_check($omni);
    do {
        $count++;
        $type = 'einh' . $count;
        $used = $used + $hangar[$type] * $einh[$count]['size'];
    } while (15 > $count);
    $free = $gebaeude['hangar'] * 25 - $used;
    $result = mysql_query("SELECT * FROM `clans` WHERE `userid` = '" . $_SESSION['user']['omni'] . "';");
    $clans = mysql_fetch_array($result);
    $members = mysql_num_rows(mysql_query("SELECT * FROM clans WHERE clanid = '" . $clans['clanid'] . "';"));
    $users = mysql_num_rows(mysql_query("SELECT * FROM user;"));
    $rate = round($members / ($users / 100), 2);
    if ($rate < 20) {
        $eisen_bonus = $gebaeude[eisenmine] * 30 / 100 * ($gebaeude['eisenmine'] * 5);
        $titan_bonus = $gebaeude[titanmine] * 20 / 100 * ($gebaeude['titanmine'] * 5);
        $oel_bonus = $gebaeude[oelpumpe] * 25 / 100 * ($gebaeude['oelpumpe'] * 5);
        $uran_bonus = $gebaeude[uranmine] * 12 / 100 * ($gebaeude['uranmine'] * 5);
        $e = explode('.', $eisen_bonus);
        $eisen_bonus = $e[0];
        $e = explode('.', $titan_bonus);
        $titan_bonus = $e[0];
        $e = explode('.', $oel_bonus);
        $oel_bonus = $e[0];
        $e = explode('.', $uran_bonus);
        $uran_bonus = $e[0];
    }
    // aktuellen ressi stand berechnen
    $eisen = (date('U') - $row['eisentimestamp']) / 60 / 60 * (40 + $gebaeude['eisenmine'] * 30 + $eisen_bonus) + $row['eisen'];
    $titan = (date('U') - $row['titantimestamp']) / 60 / 60 * (20 + $gebaeude['titanmine'] * 20 + $titan_bonus) + $row['titan'];
    $oel = (date('U') - $row['oeltimestamp']) / 60 / 60 * (32 + $gebaeude['oelpumpe'] * 25 + $oel_bonus) + $row['oel'];
    $uran = (date('U') - $row['urantimestamp']) / 60 / 60 * ($gebaeude['uranmine'] * 12 + $uran_bonus) + $row['uran'];
    $gold = (date('U') - $row['goldtimestamp']) / 60 / 60 * (4 + ($gebaeude['eisenmine'] + $gebaeude['titanmine'] + $gebaeude['oelpumpe'] + $gebaeude['uranmine'])) + $row['gold'];
    if ($row['ueberlagerbar'] <= date('U')) {
        if (number_format($eisen, 0, '', '') >= $gebaeude['rohstofflager'] * 7500 + 5000) {
            $eisen = $gebaeude['rohstofflager'] * 7500 + 5000;
            $select = "UPDATE `ressis` SET `eisentimestamp` = '" . date("U") . "', `eisen` = '" . $eisen . "' WHERE `omni` = '" . $omni . "' ;";
            $selectResult = mysql_query($select);
        }
        if (number_format($titan, 0, '', '') >= $gebaeude['rohstofflager'] * 7500 + 5000) {
            $titan = $gebaeude['rohstofflager'] * 7500 + 5000;
            $select = "UPDATE `ressis` SET `titantimestamp` = '" . date("U") . "', `titan` = '" . $titan . "' WHERE `omni` = '" . $omni . "' ;";
            $selectResult = mysql_query($select);
        }
        if (number_format($oel, 0, '', '') >= $gebaeude['rohstofflager'] * 7500 + 5000) {
            $oel = $gebaeude['rohstofflager'] * 7500 + 5000;
            $select = "UPDATE `ressis` SET `oeltimestamp` = '" . date("U") . "', `oel` = '" . $oel . "' WHERE `omni` = '" . $omni . "' ;";
            $selectResult = mysql_query($select);
        }
        if (number_format($uran, 0, '', '') >= $gebaeude['rohstofflager'] * 7500 + 5000) {
            $uran = $gebaeude['rohstofflager'] * 7500 + 5000;
            $select = "UPDATE `ressis` SET `urantimestamp` = '" . date("U") . "', `uran` = '" . $uran . "' WHERE `omni` = '" . $omni . "' ;";
            $selectResult = mysql_query($select);
        }
        if (number_format($gold, 0, '', '') >= $gebaeude['rohstofflager'] * 7500 + 5000) {
            $gold = $gebaeude['rohstofflager'] * 7500 + 5000;
            $select = "UPDATE `ressis` SET `goldtimestamp` = '" . date("U") . "', `gold` = '" . $gold . "' WHERE `omni` = '" . $omni . "' ;";
            $selectResult = mysql_query($select);
        }
    }
    // die neuen ressis speichern
    if (number_format($eisen, 0, '', '') > number_format($row['eisen'], 0, '', '')) {
        $select = "UPDATE `ressis` SET `eisentimestamp` = '" . date("U") . "', `eisen` = '" . $eisen . "' WHERE `omni` = '" . $omni . "' ;";
        $selectResult = mysql_query($select);
    }
    if (number_format($titan, 0, '', '') > number_format($row['titan'], 0, '', '')) {
        $select = "UPDATE `ressis` SET `titantimestamp` = '" . date("U") . "', `titan` = '" . $titan . "' WHERE `omni` = '" . $omni . "' ;";
        $selectResult = mysql_query($select);
    }
    if (number_format($oel, 0, '', '') > number_format($row['oel'], 0, '', '')) {
        $select = "UPDATE `ressis` SET `oeltimestamp` = '" . date("U") . "', `oel` = '" . $oel . "' WHERE `omni` = '" . $omni . "' ;";
        $selectResult = mysql_query($select);
    }
    if (number_format($uran, 0, '', '') > number_format($row['uran'], 0, '', '')) {
        $select = "UPDATE `ressis` SET `urantimestamp` = '" . date("U") . "', `uran` = '" . $uran . "' WHERE `omni` = '" . $omni . "' ;";
        $selectResult = mysql_query($select);
    }
    if (number_format($gold, 0, '', '') > number_format($row['gold'], 0, '', '')) {
        $select = "UPDATE `ressis` SET `goldtimestamp` = '" . date("U") . "', `gold` = '" . $gold . "' WHERE `omni` = '" . $omni . "' ;";
        $selectResult = mysql_query($select);
    }
    // ausgabe
    $ressis['eisen'] = $eisen;
    $ressis['titan'] = $titan;
    $ressis['oel'] = $oel;
    $ressis['uran'] = $uran;
    $ressis['gold'] = $gold;
    $ressis['chanje'] = $row['chanje'];
    $ressis['hangar'] = $free;
    $ressis['ueberlagerbar'] = $row['ueberlagerbar'];
    $ressis_template = template(ressis);
    $eisen_html = explode('.', $ressis['eisen']);
    $eisen_html = $eisen_html[0];
    $titan_html = explode('.', $ressis['titan']);
    $titan_html = $titan_html[0];
    $oel_html = explode('.', $ressis['oel']);
    $oel_html = $oel_html[0];
    $uran_html = explode('.', $ressis['uran']);
    $uran_html = $uran_html[0];
    $gold_html = explode('.', $ressis['gold']);
    $gold_html = $gold_html[0];
    list($ressis['display_eisen']) = explode('.', $ressis['eisen']);
    list($ressis['display_titan']) = explode('.', $ressis['titan']);
    list($ressis['display_oel']) = explode('.', $ressis['oel']);
    list($ressis['display_uran']) = explode('.', $ressis['uran']);
    list($ressis['display_gold']) = explode('.', $ressis['gold']);
    $ressis_template = tag2value('_eisen', number_format($eisen_html, 0), $ressis_template);
    $ressis_template = tag2value('_titan', number_format($titan_html, 0), $ressis_template);
    $ressis_template = tag2value('_oel', number_format($oel_html, 0), $ressis_template);
    $ressis_template = tag2value('_uran', number_format($uran_html, 0), $ressis_template);
    $ressis_template = tag2value('_gold', number_format($gold_html, 0), $ressis_template);
    $ressis_template = tag2value('_chanje', number_format($ressis['chanje'], 0), $ressis_template);
    $ressis_template = tag2value('_hangar', number_format($ressis['hangar'], 0), $ressis_template);
    $ressis['html'] = $ressis_template;
    return $ressis;
}