View file manager1/function.php

File size: 9.42Kb
<?php

define('_IN_JOHNCMS', 1);

/*---------------------Фанаты у клуба..----------------------*/
function fans($con, $club)
{
    $tt = file("" . $con . "/tt.dat");
    for ($i = 0; $i <= count($tt); $i++) {
        $ex = explode('|', $tt[$i]);
        if ($ex[0] == $club) {
            $tbl = $i;
        }
    }

    $fans = 0;
    if ($tbl == 0) {
        $fans = $fans + 500;
    } elseif ($tbl == 1) {
        $fans = $fans + 450;
    } elseif ($tbl == 2) {
        $fans = $fans + 380;
    } elseif ($tbl == 3) {
        $fans = $fans + 310;
    } elseif ($tbl == 4) {
        $fans = $fans + 270;
    } elseif ($tbl == 5) {
        $fans = $fans + 200;
    } elseif ($tbl == 6) {
        $fans = $fans + 130;
    } elseif ($tbl == 7) {
        $fans = $fans + 70;
    } else {
        $fans = $fans + 60;
    }
    $player = file("" . $con . "/" . $club . ".dat");
    for ($i = 0; $i < count($player); $i++) {
        $ex = explode('|', $player[$i]);
        $gg = $ex[3] + $ex[4] + $ex[5] + $ex[6] + $ex[7] + $ex[8];
        if ($gg > 540) {
            $fans = $fans + 100;
        } elseif ($gg > 530) {
            $fans = $fans + 90;
        } elseif ($gg > 520) {
            $fans = $fans + 80;
        } elseif ($gg > 510) {
            $fans = $fans + 70;
        } elseif ($gg > 500) {
            $fans = $fans + 60;
        } elseif ($gg > 490) {
            $fans = $fans + 50;
        } elseif ($gg > 480) {
            $fans = $fans + 40;
        } elseif ($gg > 470) {
            $fans = $fans + 40;
        } elseif ($gg > 460) {
            $fans = $fans + 30;
        } elseif ($gg > 450) {
            $fans = $fans + 20;
        }
    }

    return $fans;
}

function zarabotok($con, $club)
{
    // Вычисляем зарплату игроков
    $vst = file("" . $con . "/" . $club . ".dat");
    $zp = 0;
    foreach ($vst as $key => $val) {
        $ex = explode("|", $val);
        $ex[2] = (int)$ex[2];

        if ($ex[2] <= 5000000) {
            $zp = "1000";
        }
        if ($ex[2] > 5000000 && $ex[2] <= 10000000) {
            $zp = "5000";
        }

        if ($ex[2] > 10000000 && $ex[2] <= 20000000) {
            $zp = "25000";
        }
        if ($ex[2] > 20000000 && $ex[2] <= 30000000) {
            $zp = "50000";
        }
        if ($ex[2] > 30000000 && $ex[2] <= 40000000) {
            $zp = "100000";
        }
        if ($ex[2] > 40000000) {
            $zp = "250000";
        }

    }

    // Вычисляем заработок от спонсоров
    $sponsors_club = file("sponsors_clubs.dat");
    $sponsors = file("sponsors.dat");

    $sp = 0;

    $count_sponsors_club = sizeof($sponsors_club);
    $count_sponsors = sizeof($sponsors);

    for ($y = 1; $y <= $count_sponsors_club; $y++) {
        $spon_c = explode("|", $sponsors_club[$y]);
        if ($spon_c[1] == $club)
            $id_s = $spon_c[0];

        for ($x = 1; $x <= $count_sponsors; $x++) {
            $spon = explode("|", $sponsors[$x]);
            if ($spon[0] == $id_s)
                $sp = $sp + $spon[2];
        }
    }

    // Вычисляем заработок от построек
    $rest = file("" . $con . "/" . $club . ".inf");
    $post = 0;
    $ex = explode("|", $rest[0]);

    $dom = array(1 => "a", 2 => "b", 3 => "c", 4 => "d", 5 => "e", 6 => "f", 7 =>
        "g", 8 => "h", 9 => "i", 10 => "v", 11 => "o", 12 => "r");
    $money = array("a" => 50000, "d" => 40000, "c" => 30000, "d" => 20000, "e" =>
        10000, "f" => 10000, "g" => 40000, "h" => 50000, "i" => 20000, "v" => 30000, "o" =>
        15000, "r" => 300000);
    for ($q = 0; $q <= 24; $q++) {
        for ($w = 1; $w <= 12; $w++) {
            if ($ex[$q] == $dom[$w]) {
                $d = $dom[$w];
                $post = $post + $money[$d];
            }
        }
    }

    // Вычисляем прибыль
    $zarabotok = $post + $sp - $zp;
    return $zarabotok;
}

// Определение страны
function what_country($club)
{
    ########
$arr_ita = array("Atalanta", "Parma", "Cagliari", "Reggina", "Lecce", "Fiorentina",
    "Genoa", "Inter", "Juventus", "Lazio", "Chievo", "Milan", "Napoli", "Palermo",
    "Bologna", "Roma", "Sampdoria", "Siena", "Udinese", "Catania");
$arr_eng = array("Arsenal", "Aston_Villa", "Portsmouth", "Blackburn",
    "Bolton", "Chelsea", "Stock_City", "Everton", "Fullham", "Liverpool",
    "Manchester_City", "Manchester_United", "Blackpool", "Newcastle", "Middlesbrough",
    "West_Bromvich", "Sunderland", "Tottenham", "Hall_City", "Wigan");
$arr_spa = array("Barcelona", "Valencia", "Real_M", "Sevilla", "Atletico_M",
    "Deportivo", "Villarreal", "Malaga", "Betis", "Getafe", "Racing",
    "Sporting_G", "Athletic_B", "Almeria", "Numancia", "Recreativo", "Valladolid",
    "Espanyol", "Mallorca", "Osasuna");
$arr_ger = array("Hoffenheim", "Bayern_M", "Arminia", "Hamburger", "Bayer_L",
    "Borussia_D", "Schalke", "Werder", "Wolfsburg", "Stuttgart", "Cologne",
    "Eintracht", "Hannover_96", "Bochum", "Energie_Cottbus", "Hertha", "Karlsruher",
    "Borussia_M");
$arr_ukr = array("Arsenal_K", "Chornomorets", "Dnepr", "Dynamo_K", "Illichivets",
    "Karpaty", "Lviv", "Kryvbas", "Kharkiv", "Metalist_K", "Metalurg_D",
    "Metalurg_Z", "Shakhtar", "Tavriya", "Vorskla", "Zorya");
$arr_rus = array("Rubin", "CSKA_M", "Dynamo_M", "Amkar", "Zenit",
    "Krylia_Sovetov", "Lokomotiv_M", "Spartak_M", "Khimki", "Terek", "Luch-Energiya",
    "Spartak_N", "Moscow", "Anji", "Saturn", "Shinnik");
$arr_fra = array("Lille", "Marseille", "Lyon", "PSG", "Renn", "Saint-Etienne",
    "Lorient", "Montpellie", "Sochaux", "Bordeaux", "Stade_Brestois", "Nice",
    "Valenciennes", "Toulouse", "Auxerre", "Nancy", "Monaco", "Caen", "Lens",
    "Arles_Avignon");
$arr_por = array("Academica", "Beira-Mar", "Benfica", "Braga", "Feirense",
    "G.Vicente", "Leiria", "Maritimo", "Nacional", "Olhanense", "P.Ferreira",
    "Porto", "Rio_Ave", "Sporting", "V.Guimaraes", "V.Setubal");

if (in_array($club, $arr_ita)) {
    $c = "italy";
}
if (in_array($club, $arr_eng)) {
    $c = "england";
}
if (in_array($club, $arr_spa)) {
    $c = "spain";
}
if (in_array($club, $arr_ger)) {
    $c = "germany";
}
if (in_array($club, $arr_rus)) {
    $c = "russia";
}
if (in_array($club, $arr_ukr)) {
    $c = "ukraine";
}
if (in_array($club, $arr_fra)) {
    $c = "france";
}
if (in_array($club, $arr_por)) {
    $c = "portugal";
}
    ################

    return $c;
}

// Проверка расстановки (Админка)
function placing($con, $club, $rass)
{

    $rasstan = explode("-", $rass); // Вынемаем цыфры

    $a = 0;
    $b = 0;
    $c = 0;

    $file = file("../manager1/" . $con . "/" . $club . ".dat"); // Получаем состав
    for ($i = 0; $i < 11; $i++) {
        $ex = explode("|", $file[$i]);

        if ($ex[1] == 'D')
            $a = $a + 1;

        if ($ex[1] == 'M')
            $b = $b + 1;

        if ($ex[1] == 'F')
            $c = $c + 1;
    }

    if ($rasstan[0] == $a && $rasstan[1] == $b && $rasstan[2] == $c)
        $result = 1;
    else
        $result = 2;

    return $result;
}

function placings($con, $club, $rass)
{

    $rasstan = explode("-", $rass); // Вынемаем цыфры

    $a = 0;
    $b = 0;
    $c = 0;

    $file = file("../manager1/" . $con . "/" . $club . ".dat"); // Получаем состав
    for ($i = 0; $i < 11; $i++) {
        $ex = explode("|", $file[$i]);

        if ($ex[1] == 'D')
            $a = $a + 1;

        if ($ex[1] == 'M')
            $b = $b + 1;

        if ($ex[1] == 'F')
            $c = $c + 1;
    }
    $q = 0;
    if ($rasstan[0] != $a)
        $q = $q + 300;
    if ($rasstan[1] != $b)
        $q = $q + 300;
    if ($rasstan[2] != $c)
        $q = $q + 300;

    return $q;
}

// Расчет силы команд (Админка)
function force_club($con, $club)
{

    // Задаем переменные
    $force = array();
    $j = 1;

    $team = file("../manager1/" . $con . "/" . $club . ".dat"); // Состав
    for ($i = 1; $i <= 11; $i++) {
        $ex = explode("|", $team[$i]);
        $force[$j] = $ex[3] + $ex[4] + $ex[5] + $ex[6] + $ex[7] + $ex[8];
    }
    $force_team = $force[1] + $force[2] + $force[3] + $force[4] + $force[5] + $force[6] +
        $force[7] + $force[8] + $force[9] + $force[10] + $force[11];

    $team_info = file("../manager1/" . $con . "/" . $club . ".txt"); // Параметры клуба
    $exx = explode("|" . $team_info[0]);
    $info = $exx[3] + $exx[4] + $exx[6] + $exx[9] - $exx[5];

    // Итог
    $force_team = $force_team + $info;

    return $force_team;
}

// расчет итога (Админка)
function match_result($one, $two)
{

    // Если первый больше
    if ($one > $two) {
        $r = array("1|0", "2|0", "3|0", "2|1", "3|1", "3|2");
        $res = array_rand($r);
        $result = $r[$res];
    }

    // Если второй больше
    if ($one < $two) {
        $r = array("0|1", "0|2", "0|3", "1|2", "1|3", "2|3");
        $res = array_rand($r);
        $result = $r[$res];
    }

    // Если равны
    if ($one == $two) {
        $r = array("1|1", "2|2", "3|3");
        $res = array_rand($r);
        $result = $r[$res];
    }

    return $result;
}

?>