示例#1
0
function AM_getDirectionAnimals($direction, $itemName = '')
{
    $animals = array();
    $animals = AM_getAnimals();
    $arr = array();
    $i = 0;
    foreach ($animals as $animal) {
        if ($animal['direction'] == $direction) {
            if ($itemName == '' || $animal['itemName'] == $itemName) {
                $arr[$i] = $animal;
                $i++;
            }
        }
    }
    return $arr;
}
示例#2
0
function TB_run_animalmanager($getFarm = null)
{
    global $TB_settings;
    global $AM_settings;
    //########################################################################
    // animalmanager functions
    //########################################################################
    echo "AnimalManager\r\n";
    $farm = $getFarm;
    // rotate / move +++++++++++++++++++++++++
    $animals = count(AM_getAnimals($TB_settings['AM_ItemName']));
    $movingAnimals = count(AM_getMovingAnimals($TB_settings['AM_ItemName']));
    $standingAnimals = $animals - $movingAnimals;
    // rotate ++++++++++++++++++++++++++++++++
    if ($TB_settings['AM_direction'] != '-1') {
        if ($animals - count(AM_getDirectionAnimals(3, $TB_settings['AM_ItemName'])) > 0) {
            AM_doRotate($TB_settings['AM_ItemName']);
            $TB_settings['TB_needReload'] = true;
        }
    }
    if (!$TB_settings['AM_saveSettings']) {
        $TB_settings['AM_direction'] = '-1';
    }
    // move ++++++++++++++++++++++++++++++++++
    if ($TB_settings['AM_move'] != 'nothing') {
        if ($TB_settings['AM_move'] == true) {
            AM_doWalk($TB_settings['AM_ItemName']);
            $TB_settings['TB_needReload'] = true;
        } else {
            AM_doWalk($TB_settings['AM_ItemName']);
            $TB_settings['TB_needReload'] = true;
        }
    }
    if (!$TB_settings['AM_saveSettings']) {
        $TB_settings['AM_move'] = 'nothing';
    }
    if (!$TB_settings['AM_saveSettings']) {
        $TB_settings['AM_ItemName'] = '';
    }
    // animal mover ++++++++++++++++++++++++++
    foreach ($AM_settings as $className => $animals) {
        $buildings = AM_loadBuildingObject($className, false);
        foreach ($buildings as $building) {
            $buildingID = $building['id'];
            if ($TB_settings[$buildingID]['AM_moveTo'] != 'nothing') {
                if (!isset($farm)) {
                    AddLog2('TB - reloding farm');
                    DoInit();
                    $farm = TB_buildFarmArray();
                }
                $re = AM_animalMover($className, $building, $farm);
                $TB_settings['TB_needReload'] = true;
                foreach ($animals as $animal) {
                    $TB_settings[$buildingID]['AM_move_' . $animal] = 0;
                }
                $TB_settings[$buildingID]['AM_moveTo'] = 'nothing';
                if (is_array($re)) {
                    $farm = $re;
                }
            }
        }
    }
    return $farm;
}
示例#3
0
function AM_buildDropDown()
{
    global $TB_settings;
    $animals = array();
    $animals = AM_getAnimals();
    $tmp = array();
    $tmp[''] = '';
    foreach ($animals as $animal) {
        $tmp[$animal['itemName']] = $animal['itemName'];
    }
    ksort($tmp);
    echo '<select name="ItemName" size="1" onchange="this.form.submit();">';
    foreach ($tmp as $animal) {
        if ($TB_settings['AM_ItemName'] == $animal) {
            echo '<option selected>' . $animal . '</option>';
        } else {
            echo '<option>' . $animal . '</option>';
        }
    }
    echo '</select>';
}