Example #1
0
function checkorderBuilder($order)
{
    global $HTTP_POST_FILES, $i, $lang, $buf, $ord_version, $cur_ver, $ord_md5key, $auth;
    $ar = unpack_data($order);
    $glad = get_gladiators($auth->user);
    $cnt = 0;
    $skl = 0;
    foreach ($ar[Squad] as $k => $v) {
        $cnt += count($v);
        if (!($k > 0 && $k < 6)) {
            $er .= "Неправильная позиция ";
        }
        if ($ar[TypeID] != 1 && !($k == 1)) {
            $er .= "Неправильная позиция ";
        }
        foreach ($v as $l => $p) {
            if ($ar[TypeID] > 2 && !(6 - $l <= $ar[LimitGlad])) {
                $er .= "Неправильная позиция ";
            }
            if ($ar[TypeID] == 2 && !($l == 5)) {
                $er .= "Неправильная позиция ";
            }
            if (!($l > 0 && $l < 6)) {
                exit;
            }
            if (!$glad[$p]) {
                $er .= "Гладиатор {$p} не найден в Вашем отряде" . " ";
            }
            if ($glad[$p][Injury] > 0) {
                $er .= $glad[$p][Name] . " травмирован!" . " ";
            }
            if ($glad[$p][TypeID] > 7) {
                $extra = 1;
            }
            $skl += $glad[$p][Level];
        }
    }
    if ($cnt == 0) {
        exit;
    }
    if ($cnt < $ar[LimitGlad] && $ar[TypeID] == 3) {
        $er .= "Вам необходимо выставить ровно {$ar['LimitGlad']} гладиаторов в серии поединков" . " ";
    }
    if ($ar[LimitGlad] && $cnt > $ar[LimitGlad]) {
        $er .= "Превышен лимит гладиаторов ({$ar['LimitGlad']}). " . " ";
    }
    if (round($ar[LimitSkl]) && round($skl) > round($ar[LimitSkl])) {
        $er .= "Превышен лимит уровня гладиаторов ({$ar['LimitSkl']})" . " ";
    }
    if (!$ar[ExtraGlad] && $extra) {
        $er .= "Специальные типы гладиаторов к этому бою не допускаются (лучники, конные и колесничьи)" . " ";
    }
    if ($er) {
        mysql_query("set @error='{$er}'");
    }
    return $er;
}
Example #2
0
function load($orderData)
{
    //echo "load";
    global $auth;
    global $tournamentId;
    $arr = null;
    if ($orderData) {
        //$orderData=stripslashes($orderData);
        $arr = unpack_data($orderData);
    } else {
        if (!$tournamentId) {
            $res = mysql_query("select OrderFile from ut_orders where name='" . $_POST["filename"] . "' and TeamID=" . $auth->team);
        } else {
            $res = mysql_query("select OrderFile from ut_orders where tournamentId={$tournamentId} and TeamID=" . $auth->team);
        }
        $data = mysql_fetch_row($res);
        if ($data) {
            $arr = unpack_data($data[0]);
        } else {
            echo "can't find an order:" . $_POST["filename"];
            return;
        }
    }
    foreach (array_keys($arr) as $key) {
        //			echo $key." => ".$arr[$key]."<br>";
    }
    $nameWindow = $_GET["id"] && !$_GET["first"] ? "window" : "window.parent";
    echo "\n\t\t\t{$nameWindow};\n\t\t\t<script>\n\n\t\t\t\tvar win = {$nameWindow};\n\n\t\t\t\twin.clearTasks();\n\t\t\t\tfor(i=0; i<win.zones.length;i++)\n\n\t\t\t\t\tfor(j=0; j<win.zones[i].players.length;j++)\n\n\t\t\t\t\t\twin.SetPlayerToBase(win.zones[i].players[j].playerDiv,win.zones[i]);\n\n\n\t\t\t\t";
    $k = 0;
    for ($i = 0; $i < $arr["zonesCount"]; $i++) {
        $playersInZone = $arr["zone" . $i];
        for ($j = 0; $j < $playersInZone; $j++) {
            if ($arr["player" . $k]) {
                echo "win.AddPlayerToZoneById(win.zones[{$i}]," . $arr["player" . $k] . ");\n";
                $k++;
            }
        }
    }
    for ($i = 0; $i < $arr["reservePlayersCount"]; $i++) {
        echo "win.AddReservePlayer(" . $arr["reservePlayer" . $i] . "," . ($i + 1) . ");\n";
    }
    //match
    //echo "win.document.getElementById('match_type').value = 1;\n";
    //echo "win.match_type_cahnge(win.document.getElementById('match_type'));";
    echo "win.document.getElementById('match_tactics').value = 0;\n";
    echo "win.document.getElementById('match_passes').value = 0;\n";
    echo "win.document.getElementById('match_strategy').value =0;\n";
    echo "win.document.getElementById('match_pressing').checked = false;\n";
    /*echo "win.document.getElementById('match_type').value = ".$arr["match_type"].";\n";
    		//echo "win.match_type_cahnge(win.document.getElementById('match_type'));";
    		if($arr["match_type"]==1)
    		{
    			echo "win.document.getElementById('friendly_match_type').value = ".$arr["friendly_type"].";\n";
    			echo "win.friendly_match_type_changed(win.document.getElementById('friendly_match_type'));";
    			if($arr["friendly_type"]==0)
    			{
    				echo "win.document.getElementById('friendly_match_command').value = ".$arr["friendly_command"].";\n";
    			}
    		}*/
    echo "win.getSliderByInput(win.document.getElementById('match_tactics')).SetValue(" . $arr["tactic"] . ");\n";
    echo "win.document.getElementById('match_passes').value = " . $arr["passes"] . ";\n";
    echo "win.document.getElementById('match_strategy').value = " . $arr["strategy"] . ";\n";
    echo "win.document.getElementById('match_pressing').checked = " . (1 == $arr["pressing"] ? "true" : "false") . ";\n";
    //subst
    echo "win.clearSubs();";
    for ($i = 0; $i < $arr["subsCount"]; $i++) {
        echo "win.newsubs();\n";
        echo "win.document.getElementById('subs_injury_checked" . $i . "').checked=false;\n";
        echo "win.document.getElementById('subsIn" . $i . "').value=" . $arr["subsPlayerIn" . $i] . ";\n";
        echo "win.document.getElementById('subsOut" . $i . "').value=" . $arr["subsPlayerOut" . $i] . ";\n";
        $subType = $arr["subsType" . $i];
        if ($subType == 1 || $subType == 3 || $subType == 5 || $subType == 7) {
            echo "win.document.getElementById('subs_injury_checked" . $i . "').checked=true;\n";
        }
        if ($subType == 2 || $subType == 3 || $subType == 6 || $subType == 7) {
            echo "win.document.getElementById('subs_time_checked" . $i . "').checked=true;\n";
            echo "win.document.getElementById('subs_time" . $i . "').value=" . $arr["subsTime" . $i] . ";\n";
        }
        if ($subType == 4 || $subType == 5 || $subType == 6 || $subType == 7) {
            echo "win.document.getElementById('subs_goals_checked" . $i . "').checked=true;\n";
            echo "win.document.getElementById('subs_goals_token" . $i . "').value=" . $arr["subsGoalsToken" . $i] . ";\n";
            echo "win.document.getElementById('subs_goals_count" . $i . "').value=" . $arr["subsGoalsCount" . $i] . ";\n";
        }
    }
    if ($arr["captain"]) {
        echo "win.document.getElementById('role_Captain').value=" . $arr["captain"] . ";\n";
    }
    if ($arr["leftCorners"]) {
        echo "win.document.getElementById('role_LeftCorners').value=" . $arr["leftCorners"] . ";\n";
    }
    if ($arr["rightCorners"]) {
        echo "win.document.getElementById('role_RightCorners').value=" . $arr["rightCorners"] . ";\n";
    }
    if ($arr["freeKick"]) {
        echo "win.document.getElementById('role_FreeKicks').value=" . $arr["freeKick"] . ";\n";
    }
    if ($arr["penalty"]) {
        echo "win.document.getElementById('role_Penalties').value=" . $arr["penalty"] . ";\n";
    }
    //tasks
    $taskCount = 0;
    for ($i = 0; $i < $arr["tasksTypesCount"]; $i++) {
        for ($j = 0; $j < $arr["tasksPlayersCount" . $i]; $j++) {
            echo "win.addTask();\n";
            echo "win.document.getElementById('task_task{$taskCount}').value='" . $arr["tasksType" . $i] . "';\n";
            echo "win.document.getElementById('task_player{$taskCount}').value='" . $arr["tasksType" . $i . "PlayerID" . $j] . "';\n";
            $taskCount++;
        }
    }
    echo "</script>";
}