Commit f6ed1fc2 authored by Nemo Ma's avatar Nemo Ma Committed by GitHub

Merge pull request #80 from clean-master/update-botservice-threads

update botservice
parents d155915a 34d4029e
@echo off
set BOT_CD=1
cd ..
:loop
php bot/revbotservice.php
timeout /t %BOT_CD%
goto loop
#!/bin/bash
BOT_CD=2
cd ..
while true; do
php bot/revbotservice.php
sleep $BOT_CD
done
php bot/revbotservice.php
......@@ -82,7 +82,10 @@ function bot_acts($id)
{
$flag = search($bdata);
}
unset($bdata['clbpara']['botact']['moveto']);
if(isset($bdata['clbpara']['botact']['moveto']))
{
unset($bdata['clbpara']['botact']['moveto']);
}
echo $log;
echo "bot {$bdata['name']} 行动完成。";
player_save($bdata);
......
<?php
define('CURSCRIPT', 'revbotservice');
include './include/common.inc.php';
include GAME_ROOT.'./include/game.func.php';
include GAME_ROOT.'./bot/revbot.func.php';
if($gamestate > 10)
{
if(!empty($gamevars['botplayer']))
{
# bot初始化
$ids = bot_player_valid($gamevars['botplayer']);
unset($gamevars['botplayer']);
$gamevars['botid'] = $ids;
save_gameinfo();
echo "所有BOT初始化完成,共计:".(count($ids))."个";
}
elseif(!empty($gamevars['botid']))
{
foreach($gamevars['botid'] as $botid)
{
$flag = bot_acts($botid);
if($flag == 0)
{
unset($gamevars['botid'][array_search($botid,$gamevars['botid'])]);
save_gameinfo();
if(empty($gamevars['botid'])) break;
include GAME_ROOT . './include/game.func.php';
include GAME_ROOT . './bot/revbot.func.php';
$id = 0;
if ($gamestate > 10) {
$ids = bot_player_valid(1);
$id = $ids[0];
unset($gamevars['botplayer']);
$gamevars['botid'] = $ids;
save_gameinfo();
echo "BOT初始化完成,id:" . ($id) . "\n";
ob_end_flush();
}
while (true) {
if ($gamestate > 10) {
var_dump($gamevars['botplayer']);
if (!empty($gamevars['botplayer'])) {
# bot初始化
$ids = bot_player_valid(1);
$id = $ids[0];
unset($gamevars['botplayer']);
$gamevars['botid'] = $ids;
save_gameinfo();
echo "BOT初始化完成,id:" . ($id) . "\n";
ob_end_flush();
} elseif (!empty($gamevars['botid'])) { {
$flag = bot_acts($id);
if ($flag == 0) {
unset($gamevars['botid'][array_search($botid, $gamevars['botid'])]);
save_gameinfo();
if (empty($gamevars['botid'])) break;
}
echo "所有BOT行动完成\n";
ob_end_flush();
}
sleep(1);
}
echo "所有BOT行动完成";
sleep(2);
}
}
?>
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment