Beispiel #1
0
function AM_doRotate($itemName = '')
{
    global $TB_settings;
    AddLog2("rotating ...");
    $i = 0;
    $animals = array();
    $animals = AM_getAnimals($itemName);
    $left = count($animals) - count(AM_getDirectionAnimals($TB_settings['AM_direction'], $itemName));
    foreach ($animals as $animal) {
        if ($animal['direction'] != $TB_settings['AM_direction']) {
            $amf = CreateMultAMFRequest($amf, $i, 'move', 'WorldService.performAction');
            $amf->_bodys[0]->_value[1][$i]['params'][1] = $animal;
            $amf->_bodys[0]->_value[1][$i]['params'][1][0]['direction'] = $TB_settings['AM_direction'];
            $amf->_bodys[0]->_value[1][$i]['params'][2][0]['state'] = $animal['state'];
            $amf->_bodys[0]->_value[1][$i]['params'][2][0]['x'] = $animal['position']['x'];
            $amf->_bodys[0]->_value[1][$i]['params'][2][0]['y'] = $animal['position']['y'];
            $amf->_bodys[0]->_value[1][$i]['params'][2][0]['canWander'] = $animal['canWander'];
            $amf->_bodys[0]->_value[1][$i]['params'][2][0]['direction'] = $TB_settings['AM_direction'];
            $i++;
            $left--;
        }
        if ($i >= $TB_settings['TB_speedAction']) {
            $res = RequestAMF($amf);
            if ($res == 'OK') {
                AddLog2('-> ' . $res . ' ' . $left . ' left');
                $i = 0;
            } else {
                AddLog2("ERROR - {$res}");
                return false;
            }
        }
    }
    if ($i > 0) {
        $res = RequestAMF($amf);
        if ($res == 'OK') {
            AddLog2('-> ' . $res);
            return true;
        } else {
            AddLog2("ERROR - {$res}");
            return false;
        }
    } else {
        return true;
    }
}
Beispiel #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;
}
Beispiel #3
0
function TB_prepareTempStats($getItemName = '')
{
    global $TB_settings;
    if (isset($TB_settings['AM_ItemName'])) {
        $itemName = $TB_settings['AM_ItemName'];
    } elseif ($getItemName != '') {
        $itemName = $getItemName;
    } else {
        $itemName = '';
    }
    $settings = array();
    //MysteryGifts
    $settings['countGiftsGiftbox'] = MG_getGifts('giftbox');
    $tmp = MG_getEggs('giftbox');
    $settings['countEggsGiftbox'] = $tmp['count'];
    $settings['countGiftsFarm'] = count(MG_getGifts());
    $settings['countEggsFarm'] = count(MG_getEggs());
    $settings['countGiftsInGiftBox'] = TB_numberGiftBox();
    if ($TB_settings['TB_giftboxLimit'] <= 0) {
        $TB_settings['TB_giftboxLimit'] = 200;
    }
    $settings['maxGiftsToAdd'] = $TB_settings['TB_giftboxLimit'] - $settings['countGiftsInGiftBox'];
    //AnimalsMover
    $settings['itemName'] = $itemName;
    $settings['allAnimals'] = count(AM_getAnimals($itemName));
    $settings['movingAnimals'] = count(AM_getMovingAnimals($itemName));
    $settings['standingAnimals'] = $settings['allAnimals'] - $settings['movingAnimals'];
    $settings['directionAnimals0'] = count(AM_getDirectionAnimals(0, $itemName));
    $settings['directionAnimals1'] = count(AM_getDirectionAnimals(1, $itemName));
    $settings['directionAnimals2'] = count(AM_getDirectionAnimals(2, $itemName));
    $settings['directionAnimals3'] = count(AM_getDirectionAnimals(3, $itemName));
    save_array($settings, ToolBox_temp_stats);
}