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 @echo off
set BOT_CD=1
cd .. cd ..
:loop
php bot/revbotservice.php php bot/revbotservice.php
timeout /t %BOT_CD%
goto loop
#!/bin/bash #!/bin/bash
BOT_CD=2
cd .. cd ..
while true; do php bot/revbotservice.php
php bot/revbotservice.php
sleep $BOT_CD
done
...@@ -82,7 +82,10 @@ function bot_acts($id) ...@@ -82,7 +82,10 @@ function bot_acts($id)
{ {
$flag = search($bdata); $flag = search($bdata);
} }
if(isset($bdata['clbpara']['botact']['moveto']))
{
unset($bdata['clbpara']['botact']['moveto']); unset($bdata['clbpara']['botact']['moveto']);
}
echo $log; echo $log;
echo "bot {$bdata['name']} 行动完成。"; echo "bot {$bdata['name']} 行动完成。";
player_save($bdata); player_save($bdata);
......
<?php <?php
define('CURSCRIPT', 'revbotservice'); define('CURSCRIPT', 'revbotservice');
include './include/common.inc.php'; include './include/common.inc.php';
include GAME_ROOT.'./include/game.func.php'; include GAME_ROOT . './include/game.func.php';
include GAME_ROOT.'./bot/revbot.func.php'; include GAME_ROOT . './bot/revbot.func.php';
$id = 0;
if($gamestate > 10) if ($gamestate > 10) {
{ $ids = bot_player_valid(1);
if(!empty($gamevars['botplayer'])) $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初始化 # bot初始化
$ids = bot_player_valid($gamevars['botplayer']); $ids = bot_player_valid(1);
$id = $ids[0];
unset($gamevars['botplayer']); unset($gamevars['botplayer']);
$gamevars['botid'] = $ids; $gamevars['botid'] = $ids;
save_gameinfo(); save_gameinfo();
echo "所有BOT初始化完成,共计:".(count($ids))."个"; echo "BOT初始化完成,id:" . ($id) . "\n";
} ob_end_flush();
elseif(!empty($gamevars['botid'])) } elseif (!empty($gamevars['botid'])) { {
{ $flag = bot_acts($id);
foreach($gamevars['botid'] as $botid) if ($flag == 0) {
{ unset($gamevars['botid'][array_search($botid, $gamevars['botid'])]);
$flag = bot_acts($botid);
if($flag == 0)
{
unset($gamevars['botid'][array_search($botid,$gamevars['botid'])]);
save_gameinfo(); save_gameinfo();
if(empty($gamevars['botid'])) break; 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