Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
e03b622d
Commit
e03b622d
authored
Mar 24, 2023
by
hisuinohoshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rev botservice phase 0.6
变化: - 为bot脚本添加自动初始化逻辑与进程锁; - 暂时禁止bot使用礼品盒类道具;
parent
f48f7db7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
34 deletions
+74
-34
.gitignore
.gitignore
+1
-0
bot/bot_enable.bat.sample
bot/bot_enable.bat.sample
+1
-4
bot/revbot.func.php
bot/revbot.func.php
+2
-2
bot/revbotservice.php
bot/revbotservice.php
+68
-26
include/common.inc.php
include/common.inc.php
+1
-1
include/global.func.php
include/global.func.php
+1
-1
No files found.
.gitignore
View file @
e03b622d
...
@@ -41,6 +41,7 @@ gamedata/bak/
...
@@ -41,6 +41,7 @@ gamedata/bak/
gamedata/templates/
gamedata/templates/
templates/default/lastgb.htm
templates/default/lastgb.htm
templates/default/lastnews.htm
templates/default/lastnews.htm
bot/lock/
# PSD Material
# PSD Material
*.psd
*.psd
...
...
bot/bot_enable.bat.sample
View file @
e03b622d
@echo off
@echo off
PATH=%PATH%;C:\wamp64\bin\php\php7.4.0
PATH=%PATH%;C:\wamp64\bin\php\php7.4.0
php -v
php -v
set BOT_CD=2
cd ..
cd ..
:loop
php bot/revbotservice.php
php bot/revbotservice.php
timeout /t %BOT_CD%
goto loop
\ No newline at end of file
bot/revbot.func.php
View file @
e03b622d
...
@@ -315,13 +315,13 @@ function bot_use_items(&$pa)
...
@@ -315,13 +315,13 @@ function bot_use_items(&$pa)
continue
;
continue
;
}
}
# 礼盒直接开
# 礼盒直接开
if
(
strpos
(
$pa
[
'itmk'
.
$i
],
'p'
)
!==
false
)
/*
if(strpos($pa['itmk'.$i],'p')!==false)
{
{
do{
do{
itemuse($i,$pa);
itemuse($i,$pa);
}while(!empty($pa['itms'.$i]));
}while(!empty($pa['itms'.$i]));
continue;
continue;
}
}
*/
# 技能书、攻防药直接吃 300效以下陷阱直接用
# 技能书、攻防药直接吃 300效以下陷阱直接用
if
(
strpos
(
$pa
[
'itmk'
.
$i
],
'M'
)
===
0
||
strpos
(
$pa
[
'itmk'
.
$i
],
'V'
)
===
0
||
(
strpos
(
$pa
[
'itmk'
.
$i
],
'T'
)
===
0
&&
$pa
[
'itme'
.
$i
]
<=
300
)
)
if
(
strpos
(
$pa
[
'itmk'
.
$i
],
'M'
)
===
0
||
strpos
(
$pa
[
'itmk'
.
$i
],
'V'
)
===
0
||
(
strpos
(
$pa
[
'itmk'
.
$i
],
'T'
)
===
0
&&
$pa
[
'itme'
.
$i
]
<=
300
)
)
{
{
...
...
bot/revbotservice.php
View file @
e03b622d
...
@@ -3,39 +3,81 @@ define('CURSCRIPT', 'revbotservice');
...
@@ -3,39 +3,81 @@ 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'
;
# 注意:因为进程锁的存在,运行bot脚本时必须确保游戏处于未开始状态
# 否则请先中止游戏,并手动清空lock目录下所有文件,然后确保游戏正处于未开始状态下运行脚本
# 进程初始化
bot_prepare_flag
:
$id
=
0
;
$id
=
0
;
if
(
$gamestate
>
10
)
{
$dir
=
GAME_ROOT
.
'./bot/lock/'
;
$ids
=
bot_player_valid
(
1
);
$scdir
=
scandir
(
$dir
);
$id
=
$ids
[
0
];
# 为进程创建对应编号的进程锁
unset
(
$gamevars
[
'botplayer'
]);
$process_id
=
$scdir
?
count
(
$scdir
)
-
1
:
1
;
$gamevars
[
'botid'
]
=
$ids
;
touch
(
$dir
.
$process_id
.
'.lock'
);
save_gameinfo
();
echo
"BOT初始化完成,id:"
.
(
$id
)
.
"
\n
"
;
while
(
true
)
{
load_gameinfo
();
echo
"进程id【
{
$process_id
}
】正在运行,当前游戏状态:
{
$gamestate
}
\n
"
;
ob_end_flush
();
ob_end_flush
();
}
sleep
(
1
);
while
(
true
)
{
# bot初始化阶段
if
(
$gamestate
>
10
)
{
if
(
$gamestate
>
10
&&
!
empty
(
$gamevars
[
'botplayer'
]))
var_dump
(
$gamevars
[
'botplayer'
]);
{
if
(
!
empty
(
$gamevars
[
'botplayer'
]))
{
$scdir
=
scandir
(
$dir
);
# bot初始化
# 在这个阶段 进程锁数量应该是与进程id一一对应的,建议先只运行一个脚本校对进程锁数量
# 如果发现进程锁数量与进程id不能对应,则可能是系统原因,文件夹lock内存在其他隐藏文件,记得根据差值自己调整$scnums后面的 + -
$scnums
=
count
(
$scdir
)
-
2
;
echo
"当前进程锁数量:"
.
$scnums
\n
;
ob_end_flush
();
# 进程锁数量等于当前编号ID时,才会进行初始化
if
(
$process_id
==
$scnums
)
{
$ids
=
bot_player_valid
(
1
);
$ids
=
bot_player_valid
(
1
);
$id
=
$ids
[
0
];
$id
=
$ids
[
0
];
unset
(
$gamevars
[
'botplayer'
]);
//unset($gamevars['botplayer']);
$gamevars
[
'botid'
]
=
$ids
;
$gamevars
[
'botid'
][]
=
$id
;
$gamevars
[
'botplayer'
]
--
;
save_gameinfo
();
save_gameinfo
();
echo
"BOT初始化完成,id:"
.
(
$id
)
.
"
\n
"
;
# 解锁
sleep
(
1
);
unlink
(
$dir
.
$process_id
.
'.lock'
);
echo
"BOT初始化完成,id:"
.
(
$id
)
.
"
\n
剩余待初始化bot数量:
{
$gamevars
[
'botplayer'
]
}
"
;
ob_end_flush
();
goto
bot_act_flag
;
}
else
{
echo
"有其他进程正在进行初始化,等待中...
\n
"
;
ob_end_flush
();
ob_end_flush
();
}
elseif
(
!
empty
(
$gamevars
[
'botid'
]))
{
{
sleep
(
1
);
$flag
=
bot_acts
(
$id
);
}
if
(
$flag
==
0
)
{
}
unset
(
$gamevars
[
'botid'
][
array_search
(
$botid
,
$gamevars
[
'botid'
])]);
}
save_gameinfo
();
if
(
empty
(
$gamevars
[
'botid'
]))
break
;
# bot开始行动
}
bot_act_flag
:
echo
"所有BOT行动完成
\n
"
;
while
(
$id
)
ob_end_flush
();
{
load_gameinfo
();
if
(
$gamestate
>
10
)
{
if
(
!
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
"
\n
BOT:
{
$id
}
行动完成
\n
"
;
ob_end_flush
();
}
}
sleep
(
2
);
sleep
(
1
);
}
else
{
goto
bot_prepare_flag
;
}
}
}
}
\ No newline at end of file
include/common.inc.php
View file @
e03b622d
...
@@ -112,7 +112,7 @@ if(CURSCRIPT !== 'chat'){
...
@@ -112,7 +112,7 @@ if(CURSCRIPT !== 'chat'){
addnews
(
$starttime
,
'newgame'
,
$gamenum
);
addnews
(
$starttime
,
'newgame'
,
$gamenum
);
systemputchat
(
$starttime
,
'newgame'
);
systemputchat
(
$starttime
,
'newgame'
);
//是否部署BOT -> 数量;
//是否部署BOT -> 数量;
$gamevars
[
'botplayer'
]
=
1
;
$gamevars
[
'botplayer'
]
=
2
;
$ginfochange
=
true
;
$ginfochange
=
true
;
}
}
}
}
...
...
include/global.func.php
View file @
e03b622d
...
@@ -305,7 +305,7 @@ function load_gameinfo() {
...
@@ -305,7 +305,7 @@ function load_gameinfo() {
$gamevars
=
json_decode
(
$gamevars
,
true
);
$gamevars
=
json_decode
(
$gamevars
,
true
);
if
(
isset
(
$gamevars
[
'sanmaact'
])
&&
isset
(
$gamevars
[
'sanmadead'
]))
unset
(
$gamevars
[
'sanmaact'
]);
if
(
isset
(
$gamevars
[
'sanmaact'
])
&&
isset
(
$gamevars
[
'sanmadead'
]))
unset
(
$gamevars
[
'sanmaact'
]);
$combonum
=
$gameinfo
[
'combonum'
];
$combonum
=
$gameinfo
[
'combonum'
];
return
;
return
Array
(
$gamestate
,
$gamevars
)
;
}
}
function
save_gameinfo
()
{
function
save_gameinfo
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment