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);
} }
unset($bdata['clbpara']['botact']['moveto']); if(isset($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']);
# bot初始化 $gamevars['botid'] = $ids;
$ids = bot_player_valid($gamevars['botplayer']); save_gameinfo();
unset($gamevars['botplayer']); echo "BOT初始化完成,id:" . ($id) . "\n";
$gamevars['botid'] = $ids; ob_end_flush();
save_gameinfo(); }
echo "所有BOT初始化完成,共计:".(count($ids))."个"; while (true) {
} if ($gamestate > 10) {
elseif(!empty($gamevars['botid'])) var_dump($gamevars['botplayer']);
{ if (!empty($gamevars['botplayer'])) {
foreach($gamevars['botid'] as $botid) # bot初始化
{ $ids = bot_player_valid(1);
$flag = bot_acts($botid); $id = $ids[0];
if($flag == 0) unset($gamevars['botplayer']);
{ $gamevars['botid'] = $ids;
unset($gamevars['botid'][array_search($botid,$gamevars['botid'])]); save_gameinfo();
save_gameinfo(); echo "BOT初始化完成,id:" . ($id) . "\n";
if(empty($gamevars['botid'])) break; 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