Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qwgame
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵国君
qwgame
Commits
eeacf968
Commit
eeacf968
authored
Nov 28, 2018
by
hxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c
parent
3dba26d9
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1270 additions
and
149 deletions
+1270
-149
DBUtil.java
src/GameEnvironment/DBUtil.java
+2
-2
GameEnv.java
src/GameEnvironment/GameEnv.java
+8
-7
DBUtil.java
src/GameEnvironment/GameEnvironment/DBUtil.java
+40
-0
GameEnv.java
src/GameEnvironment/GameEnvironment/GameEnv.java
+515
-0
Util.java
src/GameEnvironment/GameEnvironment/Util.java
+51
-0
Attr.java
src/GameEnvironment/GameEnvironment/bean/Attr.java
+26
-0
GoodsInstance.java
src/GameEnvironment/GameEnvironment/bean/GoodsInstance.java
+35
-0
NpcInstance.java
src/GameEnvironment/GameEnvironment/bean/NpcInstance.java
+35
-0
Place.java
src/GameEnvironment/GameEnvironment/bean/Place.java
+61
-0
SuperClass.java
src/GameEnvironment/GameEnvironment/bean/SuperClass.java
+53
-0
ObjectFileUtil.java
src/GameEnvironment/ObjectFileUtil.java
+46
-0
Util.java
src/GameEnvironment/Util.java
+1
-1
Attr.java
src/GameEnvironment/bean/Attr.java
+1
-1
GoodsInstance.java
src/GameEnvironment/bean/GoodsInstance.java
+1
-1
NpcInstance.java
src/GameEnvironment/bean/NpcInstance.java
+1
-1
Place.java
src/GameEnvironment/bean/Place.java
+1
-1
SuperClass.java
src/GameEnvironment/bean/SuperClass.java
+1
-1
ChatCache.java
src/entity/ChatCache.java
+11
-0
Condition.java
src/entity/Condition.java
+2
-0
JConfig.java
src/entity/JConfig.java
+27
-1
UserInfo.java
src/entity/UserInfo.java
+2
-0
MapConstructor.java
src/gameDesign/MapConstructor.java
+137
-46
PlotConstructor.java
src/gameDesign/PlotConstructor.java
+54
-3
ChatCacheController.java
src/processing/ChatCacheController.java
+27
-16
ConditionTableController.java
src/processing/ConditionTableController.java
+10
-3
MyFunc.java
src/processing/MyFunc.java
+2
-0
QuestionMatcher.java
src/processing/QuestionMatcher.java
+19
-8
UserInfoController.java
src/processing/UserInfoController.java
+13
-2
WorldController.java
src/processing/WorldController.java
+50
-5
GameDesignServlet.java
src/servlet/GameDesignServlet.java
+18
-23
GetAnswerServlet.java
src/servlet/GetAnswerServlet.java
+20
-27
No files found.
src/GameEnvironment/DBUtil.java
View file @
eeacf968
package
GameEnvironment
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
db.C3p0Utils
;
import
com.qiwu.chatbotbackend.
db.C3p0Utils
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
...
...
src/GameEnvironment/GameEnv.java
View file @
eeacf968
package
GameEnvironment
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -7,13 +8,13 @@ import java.util.Map;
...
@@ -7,13 +8,13 @@ import java.util.Map;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
GameEnvironment.bean.Attr
;
import
com.qiwu.chatbotbackend.
GameEnvironment.bean.Attr
;
import
GameEnvironment.bean.GoodsInstance
;
import
com.qiwu.chatbotbackend.
GameEnvironment.bean.GoodsInstance
;
import
GameEnvironment.bean.SuperClass
;
import
com.qiwu.chatbotbackend.
GameEnvironment.bean.SuperClass
;
import
GameEnvironment.bean.NpcInstance
;
import
com.qiwu.chatbotbackend.
GameEnvironment.bean.NpcInstance
;
import
GameEnvironment.bean.Place
;
import
com.qiwu.chatbotbackend.
GameEnvironment.bean.Place
;
public
class
GameEnv
implements
Serializable
{
public
class
GameEnv
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
Map
<
String
,
SuperClass
>
npcClassIndex
;
public
Map
<
String
,
SuperClass
>
npcClassIndex
;
public
Map
<
String
,
NpcInstance
>
npcInstanceIndex
;
public
Map
<
String
,
NpcInstance
>
npcInstanceIndex
;
...
...
src/GameEnvironment/GameEnvironment/DBUtil.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
;
import
com.qiwu.chatbotbackend.db.C3p0Utils
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
public
class
DBUtil
{
public
static
String
queryEnvJsonByBotName
(
String
botName
)
throws
Exception
{
Connection
conn
=
C3p0Utils
.
getConnection
();
String
sql
=
"select * from generate_json_tb where bot_name = ?"
;
String
result
=
"{}"
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botName
));
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
result
=
rs
.
getString
(
"env_json_text"
);
ps
.
close
();
rs
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
}
src/GameEnvironment/GameEnvironment/GameEnv.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSON
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.Attr
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.GoodsInstance
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.SuperClass
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.NpcInstance
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.Place
;
public
class
GameEnv
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
Map
<
String
,
SuperClass
>
npcClassIndex
;
public
Map
<
String
,
NpcInstance
>
npcInstanceIndex
;
public
Map
<
String
,
SuperClass
>
goodsClassIndex
;
public
Map
<
String
,
GoodsInstance
>
goodsInstanceIndex
;
public
Map
<
String
,
Place
>
placeIndex
;
public
GameEnv
(
String
botName
)
throws
Exception
{
// 通过文件来初始化游戏环境
// String fullName = "test.json";
// String jsonString = Util.getJsonString(fullName);
// System.out.println(jsonString);
String
jsonString
=
DBUtil
.
queryEnvJsonByBotName
(
botName
);
Map
<
String
,
Object
>
gameProjectMap
=
JSON
.
parseObject
(
jsonString
);
// System.out.println(gameProjectMap);
if
(!
gameProjectMap
.
isEmpty
())
{
// 地图
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"map"
);
this
.
placeIndex
=
new
HashMap
<
String
,
Place
>();
Map
<
String
,
Object
>
placeMapTmp
=
new
HashMap
();
if
(!
map
.
isEmpty
())
{
for
(
String
key:
map
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
map
.
get
(
key
);
placeMapTmp
.
put
(
key
,
(
String
)
one
.
get
(
"name"
));
Place
place
=
new
Place
();
place
.
setIntro
((
String
)
one
.
get
(
"intro"
));
place
.
setName
((
String
)
one
.
get
(
"name"
));
placeIndex
.
put
((
String
)
one
.
get
(
"name"
),
place
);
}
for
(
String
tmp:
placeMapTmp
.
keySet
())
{
List
<
Place
>
ableGos
=
new
ArrayList
<
Place
>();
List
<
Long
>
ableGoLongs
=
(
List
<
Long
>)((
Map
<
String
,
Object
>)
map
.
get
(
tmp
)).
get
(
"canGo"
);
for
(
int
j
=
0
;
j
<
ableGoLongs
.
size
();
j
++)
{
String
idName
=
String
.
valueOf
(
ableGoLongs
.
get
(
j
));
ableGos
.
add
(
placeIndex
.
get
(
placeMapTmp
.
get
(
idName
)));
}
placeIndex
.
get
(
placeMapTmp
.
get
(
tmp
)).
setAbleGo
(
ableGos
);
}
}
// npc
// npc class
Map
<
String
,
Object
>
npcClasses
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"npc"
);
Map
<
String
,
Object
>
npcNames
=
new
HashMap
<
String
,
Object
>();
this
.
npcClassIndex
=
new
HashMap
<
String
,
SuperClass
>();
this
.
npcInstanceIndex
=
new
HashMap
<
String
,
NpcInstance
>();
if
(!
npcClasses
.
isEmpty
())
{
for
(
String
classKey:
npcClasses
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
npcClasses
.
get
(
classKey
);
// class
Map
<
String
,
Object
>
oneClass
=
(
Map
<
String
,
Object
>)
one
.
get
(
"class"
);
SuperClass
npcClass
=
new
SuperClass
();
npcClass
.
setName
(
classKey
);
npcClass
.
setIntro
((
String
)
oneClass
.
get
(
"intro"
));
List
<
Attr
>
attrs
=
new
ArrayList
<
Attr
>();
for
(
String
attrKey:
oneClass
.
keySet
())
{
if
(!
attrKey
.
equals
(
"intro"
)
&&
!
attrKey
.
equals
(
"class"
)
&&
!
attrKey
.
equals
(
""
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
attrKey
);
attr
.
setValue
((
String
)
oneClass
.
get
(
attrKey
));
attrs
.
add
(
attr
);
}
}
npcClass
.
setAttrs
(
attrs
);
// instance
Map
<
String
,
Object
>
instances
=
(
Map
<
String
,
Object
>)
one
.
get
(
"instance"
);
for
(
String
instanceKey:
instances
.
keySet
())
{
Map
<
String
,
Object
>
instance
=
new
HashMap
<
String
,
Object
>();
NpcInstance
npcInstance
=
new
NpcInstance
();
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
npcNames
.
put
(
instanceKey
,
(
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
List
<
Attr
>
npcInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(!
instanceAttrKey
.
equals
(
"name"
)&&!
instanceAttrKey
.
equals
(
"intro"
)&&!
instanceAttrKey
.
equals
(
"placeId"
)&&!
instanceAttrKey
.
equals
(
"placeName"
)&&!
instanceAttrKey
.
equals
(
"class"
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
npcInstanceAttrs
.
add
(
attr
);
}
}
npcInstance
.
setAttrs
(
npcInstanceAttrs
);
Place
place
=
null
;
if
(
instanceAttrMap
.
get
(
"placeId"
)!=
null
)
{
place
=
placeIndex
.
get
(((
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)))).
get
(
"name"
));
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
if
(
npcInstances
==
null
)
{
npcInstances
=
new
ArrayList
<
NpcInstance
>();
}
npcInstances
.
add
(
npcInstance
);
place
.
setNpcInstances
(
npcInstances
);
}
List
<
NpcInstance
>
npcInstanceClass
=
npcClass
.
getNpcInstances
();
if
(
npcInstanceClass
==
null
)
{
npcInstanceClass
=
new
ArrayList
<
NpcInstance
>();
}
npcInstanceClass
.
add
(
npcInstance
);
npcClass
.
setNpcInstances
(
npcInstanceClass
);
npcInstance
.
setPlace
(
place
);
this
.
npcInstanceIndex
.
put
((
String
)
instanceAttrMap
.
get
(
"name"
),
npcInstance
);
}
this
.
npcClassIndex
.
put
(
classKey
,
npcClass
);
}
}
// goods
Map
<
String
,
Object
>
goodsClasses
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"goods"
);
this
.
goodsClassIndex
=
new
HashMap
<
String
,
SuperClass
>();
this
.
goodsInstanceIndex
=
new
HashMap
<
String
,
GoodsInstance
>();
if
(!
goodsClasses
.
isEmpty
())
{
for
(
String
classKey:
goodsClasses
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
goodsClasses
.
get
(
classKey
);
// class
Map
<
String
,
Object
>
oneClass
=
(
Map
<
String
,
Object
>)
one
.
get
(
"class"
);
SuperClass
goodsClass
=
new
SuperClass
();
goodsClass
.
setName
(
classKey
);
goodsClass
.
setIntro
((
String
)
oneClass
.
get
(
"intro"
));
List
<
Attr
>
attrs
=
new
ArrayList
<
Attr
>();
for
(
String
attrKey:
oneClass
.
keySet
())
{
if
(!
attrKey
.
equals
(
"intro"
)&&!
attrKey
.
equals
(
"placeId"
)&&!
attrKey
.
equals
(
"npcName"
)&&!
attrKey
.
equals
(
"class"
)&&!
attrKey
.
equals
(
"placeName"
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
attrKey
);
attr
.
setValue
((
String
)
oneClass
.
get
(
attrKey
));
attrs
.
add
(
attr
);
}
}
goodsClass
.
setAttrs
(
attrs
);
// instance
Map
<
String
,
Object
>
instances
=
(
Map
<
String
,
Object
>)
one
.
get
(
"instance"
);
for
(
String
instanceKey:
instances
.
keySet
())
{
Map
<
String
,
Object
>
instance
=
new
HashMap
<
String
,
Object
>();
GoodsInstance
goodsInstance
=
new
GoodsInstance
();
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
goodsInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
goodsInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
List
<
Attr
>
goodsInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(
instanceAttrKey
!=
"placeId"
&&
instanceAttrKey
!=
"npcId"
&&
instanceAttrKey
!=
"name"
&&
instanceAttrKey
!=
"intro"
)
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
goodsInstanceAttrs
.
add
(
attr
);
}
}
goodsInstance
.
setAttrs
(
goodsInstanceAttrs
);
if
(
instanceAttrMap
.
get
(
"placeId"
)!=
null
)
{
Place
place
=
placeIndex
.
get
(((
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)))).
get
(
"name"
));
goodsInstance
.
setPlace
(
place
);
List
<
GoodsInstance
>
placeGoodsInstances
=
place
.
getGoodsInstances
();
if
(
placeGoodsInstances
==
null
)
{
placeGoodsInstances
=
new
ArrayList
<
GoodsInstance
>();
}
placeGoodsInstances
.
add
(
goodsInstance
);
place
.
setGoodsInstances
(
placeGoodsInstances
);
}
if
(
instanceAttrMap
.
get
(
"npcId"
)!=
null
){
NpcInstance
npc
=
this
.
npcInstanceIndex
.
get
(
npcNames
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"npcId"
))));
goodsInstance
.
setNpc
(
npc
);
List
<
GoodsInstance
>
npcGoodsInstances
=
npc
.
getGoodsInstances
();
if
(
npcGoodsInstances
==
null
)
{
npcGoodsInstances
=
new
ArrayList
<
GoodsInstance
>();
}
npcGoodsInstances
.
add
(
goodsInstance
);
npc
.
setGoodsInstances
(
npcGoodsInstances
);
}
List
<
GoodsInstance
>
goodsInstancesClass
=
goodsClass
.
getGoodsInstances
();
if
(
goodsInstancesClass
==
null
)
{
goodsInstancesClass
=
new
ArrayList
<
GoodsInstance
>();
}
goodsInstancesClass
.
add
(
goodsInstance
);
goodsClass
.
setGoodsInstances
(
goodsInstancesClass
);
this
.
goodsInstanceIndex
.
put
((
String
)
instanceAttrMap
.
get
(
"name"
),
goodsInstance
);
}
this
.
goodsClassIndex
.
put
(
classKey
,
goodsClass
);
}
}
}
}
/********************************************地点******************************************/
// 周围有什么
public
List
<
String
>
queryAroundAllBySite
(
String
site
){
List
<
String
>
queryGoods
=
this
.
queryAroundGoodsBySite
(
site
);
List
<
String
>
queryNpc
=
this
.
queryAroundNpcBySite
(
site
);
queryGoods
.
addAll
(
queryNpc
);
return
queryGoods
;
}
// 周围有什么人
public
List
<
String
>
queryAroundNpcBySite
(
String
site
){
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
String
>
queryNpc
=
new
ArrayList
<
String
>();
if
(
place
!=
null
)
{
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
if
(
npcInstances
!=
null
)
{
for
(
int
i
=
0
;
i
<
npcInstances
.
size
();
i
++)
{
queryNpc
.
add
(
npcInstances
.
get
(
i
).
getName
());
}
}
}
return
queryNpc
;
}
// 周围有什么物品
public
List
<
String
>
queryAroundGoodsBySite
(
String
site
){
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
String
>
queryGoods
=
new
ArrayList
<
String
>();
if
(
place
!=
null
)
{
List
<
GoodsInstance
>
goodsInstances
=
place
.
getGoodsInstances
();
if
(
goodsInstances
!=
null
)
{
for
(
int
i
=
0
;
i
<
goodsInstances
.
size
();
i
++)
{
queryGoods
.
add
(
goodsInstances
.
get
(
i
).
getName
());
}
}
}
return
queryGoods
;
}
// 我现在能去哪
public
List
<
String
>
queryCanGoBySite
(
String
site
){
List
<
String
>
ableGoString
=
new
ArrayList
<
String
>();
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
Place
>
ableGos
=
place
.
getAbleGo
();
for
(
int
i
=
0
;
i
<
ableGos
.
size
();
i
++)
{
ableGoString
.
add
(
ableGos
.
get
(
i
).
getName
());
}
return
ableGoString
;
}
// 两点之间的路径
public
List
<
String
>
queryPathBySite
(
String
start
,
String
destination
){
return
null
;
}
/******************************************通过npc获取物品列表**********************************************/
// 通过npcName获取所有物品名称列表
public
List
<
String
>
queryGoodsByNpcName
(
String
npcName
){
List
<
String
>
goodsNames
=
new
ArrayList
<
String
>();
if
(
this
.
npcInstanceIndex
.
get
(
npcName
)!=
null
)
{
List
<
GoodsInstance
>
goodsInstances
=
this
.
npcInstanceIndex
.
get
(
npcName
).
getGoodsInstances
();
if
(
goodsInstances
!=
null
)
{
for
(
int
i
=
0
;
i
<
goodsInstances
.
size
();
i
++)
{
goodsNames
.
add
(
goodsInstances
.
get
(
i
).
getName
());
}
}
}
return
goodsNames
;
}
/**************************************物品***************************/
// 通过类和地点查询所有物品名称
public
List
<
String
>
queryGoodsByClassAndSite
(
String
className
,
String
site
){
List
<
String
>
goodsNames
=
new
ArrayList
<
String
>();
List
<
GoodsInstance
>
placeGoodsInstances
=
null
;
List
<
GoodsInstance
>
goodsInstances
=
null
;
if
(
this
.
placeIndex
.
get
(
site
)!=
null
&&
this
.
goodsClassIndex
.
get
(
className
)!=
null
)
{
placeGoodsInstances
=
this
.
placeIndex
.
get
(
site
).
getGoodsInstances
();
goodsInstances
=
this
.
goodsClassIndex
.
get
(
className
).
getGoodsInstances
();
for
(
int
i
=
0
;
i
<
placeGoodsInstances
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
goodsInstances
.
size
();
j
++)
{
if
(
placeGoodsInstances
.
get
(
i
)
==
goodsInstances
.
get
(
j
))
{
goodsNames
.
add
(
placeGoodsInstances
.
get
(
i
).
getName
());
}
}
}
}
return
goodsNames
;
}
// 查询指定物品
public
GoodsInstance
queryGoodsByGoodsName
(
String
name
){
GoodsInstance
goodsInstance
=
this
.
goodsInstanceIndex
.
get
(
name
);
return
goodsInstance
;
}
// 查询指定物品的简介
public
String
queryGoodsIntroByGoodsName
(
String
name
){
GoodsInstance
goodsInstance
=
this
.
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
!=
null
)
{
return
goodsInstance
.
getIntro
();
}
else
{
return
null
;
}
}
// 查询指定物品的属性值
public
String
queryGoodsAttrByGoodsName
(
String
name
,
String
attrName
){
GoodsInstance
goodsInstance
=
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
==
null
)
{
goodsInstance
=
queryGoodsByGoodsName
(
attrName
);
attrName
=
name
;
}
if
(
goodsInstance
!=
null
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
if
(
attrName
.
equals
(
"location"
))
{
if
(
goodsInstance
.
getPlace
()!=
null
)
{
return
goodsInstance
.
getPlace
().
getName
();
}
}
if
(
attrName
.
equals
(
"owner"
))
{
if
(
goodsInstance
.
getNpc
()!=
null
)
{
return
goodsInstance
.
getNpc
().
getName
();
}
}
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
if
(
attrs
.
get
(
i
).
getName
().
equals
(
attrName
))
{
return
attrs
.
get
(
i
).
getValue
();
}
}
return
null
;
}
else
{
return
null
;
}
}
// 查询指定物品的所有属性
public
List
<
String
>
queryGoodsAllAttrByGoodsName
(
String
name
){
List
<
String
>
attrnames
=
new
ArrayList
<
String
>();
GoodsInstance
goodsInstance
=
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
!=
null
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
attrnames
.
add
(
attrs
.
get
(
i
).
getName
());
}
return
attrnames
;
}
else
{
return
null
;
}
}
/**************************************npc*****************************************/
// 通过地点和类查询所有的npc名陈
public
List
<
String
>
queryNpcByClassAndSite
(
String
className
,
String
site
){
List
<
String
>
npcNames
=
new
ArrayList
<
String
>();
List
<
NpcInstance
>
placeNpcInstances
=
this
.
placeIndex
.
get
(
site
).
getNpcInstances
();
List
<
NpcInstance
>
npcInstances
=
this
.
goodsClassIndex
.
get
(
className
).
getNpcInstances
();
NpcInstance
npcInstance
=
new
NpcInstance
();
for
(
int
i
=
0
;
i
<
placeNpcInstances
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
npcInstances
.
size
();
j
++)
{
if
(
placeNpcInstances
.
get
(
i
)
==
npcInstances
.
get
(
j
))
{
npcNames
.
add
(
placeNpcInstances
.
get
(
i
).
getName
());
}
}
}
return
npcNames
;
}
// 查询指定的npc
public
NpcInstance
queryNpcByNpcName
(
String
npcName
){
NpcInstance
npcInstance
=
this
.
npcInstanceIndex
.
get
(
npcName
);
return
npcInstance
;
}
// 查询指定NPC简介
public
String
queryNpcIntroByNpcName
(
String
name
){
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
!=
null
)
{
return
npcInstance
.
getIntro
();
}
else
{
return
null
;
}
}
// 查询指定npc的属性值
public
String
queryNpcAttrByNpcName
(
String
name
,
String
attrName
){
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
==
null
)
{
npcInstance
=
queryNpcByNpcName
(
attrName
);
attrName
=
name
;
}
if
(
attrName
.
equals
(
"location"
))
{
if
(
npcInstance
.
getPlace
()!=
null
)
{
return
npcInstance
.
getPlace
().
getName
();
}
}
if
(
npcInstance
!=
null
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
if
(
attrs
.
get
(
i
).
getName
().
equals
(
attrName
))
{
return
attrs
.
get
(
i
).
getValue
();
}
}
return
null
;
}
else
{
return
null
;
}
}
// 查询指定npc的所有属性
public
List
<
String
>
queryNpcAttrsByNpcName
(
String
name
){
List
<
String
>
attrNames
=
new
ArrayList
<
String
>();
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
!=
null
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
attrNames
.
add
(
attrs
.
get
(
i
).
getName
());
}
return
attrNames
;
}
else
{
return
null
;
}
}
// 增加
public
boolean
insert
(
String
name
){
String
[]
names
=
name
.
split
(
"_"
);
if
(
names
.
length
==
3
){
if
(
names
[
0
].
equals
(
"goods"
)){
SuperClass
goodsClass
=
this
.
goodsClassIndex
.
get
(
names
[
1
]);
List
<
Attr
>
goodsClassAttrs
=
goodsClass
.
getAttrs
();
GoodsInstance
goodsInstance
=
new
GoodsInstance
();
List
<
Attr
>
goodsInstanceAttr
=
new
ArrayList
<
Attr
>();
goodsInstance
.
setName
(
names
[
2
]);
goodsInstance
.
setIntro
(
goodsClass
.
getIntro
());
for
(
int
i
=
0
;
i
<
goodsClassAttrs
.
size
();
i
++){
Attr
attr
=
new
Attr
();
attr
.
setName
(
goodsClassAttrs
.
get
(
i
).
getName
());
attr
.
setValue
(
goodsClassAttrs
.
get
(
i
).
getValue
());
goodsInstanceAttr
.
add
(
attr
);
}
goodsInstance
.
setAttrs
(
goodsInstanceAttr
);
this
.
goodsInstanceIndex
.
put
(
names
[
2
],
goodsInstance
);
return
true
;
}
else
if
(
names
[
0
].
equals
(
"npc"
))
{
SuperClass
npcClass
=
this
.
npcClassIndex
.
get
(
names
[
1
]);
List
<
Attr
>
npcClassAttrs
=
npcClass
.
getAttrs
();
NpcInstance
npcInstance
=
new
NpcInstance
();
List
<
Attr
>
npcInstanceAttr
=
new
ArrayList
<
Attr
>();
npcInstance
.
setName
(
names
[
2
]);
npcInstance
.
setIntro
(
npcClass
.
getIntro
());
for
(
int
i
=
0
;
i
<
npcClassAttrs
.
size
();
i
++){
Attr
attr
=
new
Attr
();
attr
.
setName
(
npcClassAttrs
.
get
(
i
).
getName
());
attr
.
setValue
(
npcClassAttrs
.
get
(
i
).
getValue
());
npcInstanceAttr
.
add
(
attr
);
}
npcInstance
.
setAttrs
(
npcInstanceAttr
);
this
.
npcInstanceIndex
.
put
(
names
[
2
],
npcInstance
);
return
true
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
// 改变
public
boolean
update
(
String
name
,
String
value
)
{
String
[]
names
=
name
.
split
(
"_"
);
if
(
names
.
length
==
4
){
if
(
names
[
0
].
equals
(
"goods"
)){
List
<
GoodsInstance
>
goodsInstancesByClass
=
this
.
goodsClassIndex
.
get
(
names
[
1
]).
getGoodsInstances
();
boolean
goodsInstanceBoolean
=
false
;
GoodsInstance
goodsInstance
=
this
.
goodsInstanceIndex
.
get
(
names
[
2
]);
for
(
int
i
=
0
;
i
<
goodsInstancesByClass
.
size
();
i
++)
{
if
(
goodsInstance
==
goodsInstancesByClass
.
get
(
i
))
{
goodsInstanceBoolean
=
true
;
}
}
if
(
goodsInstanceBoolean
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
for
(
int
j
=
0
;
j
<
attrs
.
size
();
j
++)
{
if
(
names
[
3
].
equals
(
attrs
.
get
(
j
).
getName
()))
{
attrs
.
get
(
j
).
setValue
(
value
);
return
true
;
}
}
return
true
;
}
else
{
return
false
;
}
}
else
if
(
names
[
0
].
equals
(
"npc"
))
{
List
<
NpcInstance
>
npcInstancesByClass
=
this
.
npcClassIndex
.
get
(
names
[
1
]).
getNpcInstances
();
boolean
npcInstanceBoolean
=
false
;
NpcInstance
npcInstance
=
this
.
npcInstanceIndex
.
get
(
names
[
2
]);
for
(
int
i
=
0
;
i
<
npcInstancesByClass
.
size
();
i
++)
{
if
(
npcInstance
==
npcInstancesByClass
.
get
(
i
))
{
npcInstanceBoolean
=
true
;
}
}
if
(
npcInstanceBoolean
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
j
=
0
;
j
<
attrs
.
size
();
j
++)
{
if
(
names
[
3
].
equals
(
attrs
.
get
(
j
).
getName
()))
{
attrs
.
get
(
j
).
setValue
(
value
);
return
true
;
}
}
return
true
;
}
else
{
return
false
;
}
}
}
return
false
;
}
// 增删改通用
public
boolean
CUD
(
String
name
,
String
operator
,
String
value
){
if
(
operator
.
equals
(
"insert"
))
{
return
this
.
insert
(
name
);
}
else
if
(
operator
.
equals
(
"update"
))
{
return
this
.
update
(
name
,
value
);
}
else
if
(
operator
.
equals
(
"delete"
))
{
return
false
;
}
else
{
return
false
;
}
}
}
src/GameEnvironment/GameEnvironment/Util.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
public
class
Util
{
public
static
String
getJsonString
(
String
fullName
)
{
Reader
reader
=
null
;
String
jsonString
=
""
;
try
{
// System.out.println("以字符为单位读取文件内容,一次读多个字节:");
// 一次读多个字符
char
[]
tempchars
=
new
char
[
256
];
int
charread
=
0
;
reader
=
new
InputStreamReader
(
new
FileInputStream
(
fullName
));
// 读入多个字符到字符数组中,charread为一次读取字符数
while
((
charread
=
reader
.
read
(
tempchars
))
!=
-
1
)
{
// 同样屏蔽掉\r不显示
if
((
charread
==
tempchars
.
length
)
&&
(
tempchars
[
tempchars
.
length
-
1
]
!=
'\r'
))
{
// System.out.println(tempchars);
jsonString
=
jsonString
+
String
.
valueOf
(
tempchars
);
// System.out.print(tempchars);
}
else
{
for
(
int
i
=
0
;
i
<
charread
;
i
++)
{
if
(
tempchars
[
i
]
==
'\r'
)
{
continue
;
}
else
{
jsonString
=
jsonString
+
tempchars
[
i
];
// System.out.print(tempchars[i]);
}
}
}
}
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
finally
{
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e1
)
{
}
}
}
return
jsonString
;
}
}
src/GameEnvironment/GameEnvironment/bean/Attr.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
public
class
Attr
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
value
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
@Override
public
String
toString
()
{
return
"Attr [name="
+
name
+
", value="
+
value
+
"]"
;
}
}
src/GameEnvironment/GameEnvironment/bean/GoodsInstance.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
GoodsInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Place
place
;
private
NpcInstance
npc
;
public
Place
getPlace
()
{
return
place
;
}
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
}
public
NpcInstance
getNpc
()
{
return
npc
;
}
public
void
setNpc
(
NpcInstance
npc
)
{
this
.
npc
=
npc
;
}
@Override
public
String
toString
()
{
String
placeName
=
""
;
if
(
place
!=
null
)
{
placeName
=
place
.
getName
();
}
String
npcName
=
""
;
if
(
npc
!=
null
)
{
npcName
=
npc
.
getName
();
}
return
super
.
toString
()+
"GoodsInstance [placeName="
+
placeName
+
", npcName="
+
npcName
+
"]"
;
}
}
src/GameEnvironment/GameEnvironment/bean/NpcInstance.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
NpcInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Place
place
;
private
List
<
GoodsInstance
>
goodsInstances
;
public
Place
getPlace
()
{
return
place
;
}
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
}
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
@Override
public
String
toString
()
{
String
placeName
=
""
;
if
(
place
!=
null
)
{
placeName
=
place
.
getName
();
}
int
goodsInstancesSize
=
0
;
if
(
goodsInstances
!=
null
)
{
goodsInstancesSize
=
goodsInstances
.
size
();
}
return
super
.
toString
()+
"NpcInstance [placeName="
+
placeName
+
", goodsInstancesSize="
+
goodsInstancesSize
+
"]"
;
}
}
src/GameEnvironment/GameEnvironment/bean/Place.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
Place
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
intro
;
private
List
<
Place
>
ableGo
;
private
List
<
NpcInstance
>
npcInstances
;
private
List
<
GoodsInstance
>
goodsInstances
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getIntro
()
{
return
intro
;
}
public
void
setIntro
(
String
intro
)
{
this
.
intro
=
intro
;
}
public
List
<
Place
>
getAbleGo
()
{
return
ableGo
;
}
public
void
setAbleGo
(
List
<
Place
>
ableGo
)
{
this
.
ableGo
=
ableGo
;
}
public
List
<
NpcInstance
>
getNpcInstances
()
{
return
npcInstances
;
}
public
void
setNpcInstances
(
List
<
NpcInstance
>
npcInstances
)
{
this
.
npcInstances
=
npcInstances
;
}
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
@Override
public
String
toString
()
{
int
ableGoSize
=
0
;
int
npcInstancesSize
=
0
;
int
goodsInstancesSize
=
0
;
if
(
ableGo
!=
null
)
{
ableGoSize
=
ableGo
.
size
();
}
if
(
npcInstances
!=
null
)
{
npcInstancesSize
=
npcInstances
.
size
();
}
if
(
goodsInstances
!=
null
)
{
goodsInstancesSize
=
goodsInstances
.
size
();
}
return
"Place [name="
+
name
+
", intro="
+
intro
+
", ableGo="
+
ableGoSize
+
", npcInstances="
+
npcInstancesSize
+
", goodsInstances="
+
goodsInstancesSize
+
"]"
;
}
}
src/GameEnvironment/GameEnvironment/bean/SuperClass.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
intro
;
private
List
<
Attr
>
attrs
;
private
List
<
GoodsInstance
>
goodsInstances
;
private
List
<
NpcInstance
>
npcInstances
;
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
public
List
<
NpcInstance
>
getNpcInstances
()
{
return
npcInstances
;
}
public
void
setNpcInstances
(
List
<
NpcInstance
>
npcInstances
)
{
this
.
npcInstances
=
npcInstances
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getIntro
()
{
return
intro
;
}
public
void
setIntro
(
String
intro
)
{
this
.
intro
=
intro
;
}
public
List
<
Attr
>
getAttrs
()
{
return
attrs
;
}
public
void
setAttrs
(
List
<
Attr
>
attrs
)
{
this
.
attrs
=
attrs
;
}
@Override
public
String
toString
()
{
int
goodsInstanceSize
=
0
;
if
(
goodsInstances
!=
null
)
{
goodsInstanceSize
=
goodsInstances
.
size
();
}
return
"SuperClass [name="
+
name
+
", intro="
+
intro
+
"goodsInstancesSize="
+
goodsInstanceSize
+
", attrs="
+
attrs
+
"]"
;
}
}
src/GameEnvironment/ObjectFileUtil.java
0 → 100644
View file @
eeacf968
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
public
class
ObjectFileUtil
{
// obj 任意可以序列化的对象 fileAllName 文件全名
public
static
boolean
writeObjectToFile
(
Object
obj
,
String
fileAllName
)
{
File
file
=
new
File
(
fileAllName
);
FileOutputStream
out
;
try
{
out
=
new
FileOutputStream
(
file
);
ObjectOutputStream
objOut
=
new
ObjectOutputStream
(
out
);
objOut
.
writeObject
(
obj
);
objOut
.
flush
();
objOut
.
close
();
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
// fileAllName 文件全名
public
static
Object
readObjectFromFile
(
String
fileAllName
)
{
Object
temp
=
null
;
File
file
=
new
File
(
fileAllName
);
FileInputStream
in
;
try
{
in
=
new
FileInputStream
(
file
);
ObjectInputStream
objIn
=
new
ObjectInputStream
(
in
);
temp
=
objIn
.
readObject
();
objIn
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
temp
;
}
}
src/GameEnvironment/Util.java
View file @
eeacf968
package
GameEnvironment
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
...
src/GameEnvironment/bean/Attr.java
View file @
eeacf968
package
GameEnvironment
.
bean
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
...
src/GameEnvironment/bean/GoodsInstance.java
View file @
eeacf968
package
GameEnvironment
.
bean
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
...
...
src/GameEnvironment/bean/NpcInstance.java
View file @
eeacf968
package
GameEnvironment
.
bean
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
...
...
src/GameEnvironment/bean/Place.java
View file @
eeacf968
package
GameEnvironment
.
bean
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
...
...
src/GameEnvironment/bean/SuperClass.java
View file @
eeacf968
package
GameEnvironment
.
bean
;
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
...
...
src/entity/ChatCache.java
View file @
eeacf968
...
@@ -12,6 +12,17 @@ public class ChatCache {
...
@@ -12,6 +12,17 @@ public class ChatCache {
private
Map
<
String
,
String
>
infoPoint
=
null
;
private
Map
<
String
,
String
>
infoPoint
=
null
;
private
GameEnv
gameEnv
=
null
;
private
GameEnv
gameEnv
=
null
;
private
boolean
reloading
=
false
;
public
boolean
isReloading
()
{
return
reloading
;
}
public
void
setReloading
(
boolean
reloading
)
{
this
.
reloading
=
reloading
;
}
public
Map
<
String
,
String
>
getInfoPoint
()
{
public
Map
<
String
,
String
>
getInfoPoint
()
{
return
infoPoint
;
return
infoPoint
;
...
...
src/entity/Condition.java
View file @
eeacf968
...
@@ -21,6 +21,7 @@ public class Condition {
...
@@ -21,6 +21,7 @@ public class Condition {
public
HashMap
<
String
,
String
>
featureMap
=
new
HashMap
<
String
,
String
>();
public
HashMap
<
String
,
String
>
featureMap
=
new
HashMap
<
String
,
String
>();
public
String
indexName
=
""
;
public
String
indexName
=
""
;
public
int
id
=
0
;
public
int
id
=
0
;
public
String
configName
=
""
;
public
String
status
=
"waiting"
;
public
String
status
=
"waiting"
;
//public ArrayList<String> indexName = new ArrayList<String>();
//public ArrayList<String> indexName = new ArrayList<String>();
...
@@ -40,6 +41,7 @@ public class Condition {
...
@@ -40,6 +41,7 @@ public class Condition {
this
.
updateKnowledge
=
originCondition
.
updateKnowledge
;
this
.
updateKnowledge
=
originCondition
.
updateKnowledge
;
this
.
indexName
=
originCondition
.
indexName
;
this
.
indexName
=
originCondition
.
indexName
;
this
.
id
=
originCondition
.
id
;
this
.
id
=
originCondition
.
id
;
this
.
configName
=
originCondition
.
configName
;
this
.
status
=
originCondition
.
status
;
this
.
status
=
originCondition
.
status
;
this
.
activePriority
=
originCondition
.
activePriority
+
basePriority
;
this
.
activePriority
=
originCondition
.
activePriority
+
basePriority
;
this
.
auxiliaryPriority
=
originCondition
.
auxiliaryPriority
+
baseAuxiliaryPriority
;
this
.
auxiliaryPriority
=
originCondition
.
auxiliaryPriority
+
baseAuxiliaryPriority
;
...
...
src/entity/JConfig.java
View file @
eeacf968
...
@@ -30,8 +30,25 @@ public class JConfig {
...
@@ -30,8 +30,25 @@ public class JConfig {
private
String
hisPremise
=
""
;
private
String
hisPremise
=
""
;
public
String
getFeature
()
{
return
feature
;
}
public
void
setFeature
(
String
feature
)
{
this
.
feature
=
feature
;
}
private
String
feature
=
""
;
private
String
feature
=
""
;
private
String
reply
=
""
;
private
String
reply
=
""
;
public
String
getNextStep
()
{
return
nextStep
;
}
public
void
setNextStep
(
String
nextStep
)
{
this
.
nextStep
=
nextStep
;
}
private
String
nextStep
=
""
;
private
String
nextStep
=
""
;
public
void
setConfigName
(
String
configName
)
{
public
void
setConfigName
(
String
configName
)
{
...
@@ -52,6 +69,14 @@ public class JConfig {
...
@@ -52,6 +69,14 @@ public class JConfig {
private
String
status
=
"waiting"
;
private
String
status
=
"waiting"
;
public
String
getUpdateKnowledge
()
{
return
updateKnowledge
;
}
public
void
setUpdateKnowledge
(
String
updateKnowledge
)
{
this
.
updateKnowledge
=
updateKnowledge
;
}
private
String
updateKnowledge
=
""
;
private
String
updateKnowledge
=
""
;
private
String
nextStepStatus
=
"return"
;
private
String
nextStepStatus
=
"return"
;
...
@@ -285,7 +310,8 @@ public class JConfig {
...
@@ -285,7 +310,8 @@ public class JConfig {
String
text
=
curPremise
+
"|"
+
String
text
=
curPremise
+
"|"
+
hisPremise
+
"|"
+
hisPremise
+
"|"
+
feature
+
","
+
updateKnowledge
+
","
+
nextStepStatus
+
"|"
+
feature
+
","
+
updateKnowledge
+
","
+
nextStepStatus
+
"|"
+
"auxiliaryPriority="
+
auxiliaryPriority
+
"|=>|"
+
"auxiliaryPriority="
+
auxiliaryPriority
+
"|"
+
"configName="
+
configName
+
"|=>|"
+
reply
+
"|"
+
reply
+
"|"
+
"nextStep="
+
nextStep
+
"|"
+
"nextStep="
+
nextStep
+
"|"
+
"status="
+
status
+
"|"
+
"status="
+
status
+
"|"
+
...
...
src/entity/UserInfo.java
View file @
eeacf968
...
@@ -19,6 +19,7 @@ public class UserInfo {
...
@@ -19,6 +19,7 @@ public class UserInfo {
this
.
id2config
=
new
HashMap
<
Integer
,
String
>();
this
.
id2config
=
new
HashMap
<
Integer
,
String
>();
this
.
id2condition
=
new
HashMap
<
Integer
,
Condition
>();
this
.
id2condition
=
new
HashMap
<
Integer
,
Condition
>();
this
.
varInitialMap
=
new
HashMap
<
String
,
String
>();
this
.
varInitialMap
=
new
HashMap
<
String
,
String
>();
this
.
name2condition
=
new
HashMap
<
String
,
Condition
>();
}
}
public
HashMap
<
String
,
List
<
Condition
>>
conditionTable
;
public
HashMap
<
String
,
List
<
Condition
>>
conditionTable
;
...
@@ -27,6 +28,7 @@ public class UserInfo {
...
@@ -27,6 +28,7 @@ public class UserInfo {
public
HashMap
<
String
,
String
>
extraInfo
;
public
HashMap
<
String
,
String
>
extraInfo
;
public
HashMap
<
Integer
,
String
>
id2config
;
public
HashMap
<
Integer
,
String
>
id2config
;
public
HashMap
<
Integer
,
Condition
>
id2condition
;
public
HashMap
<
Integer
,
Condition
>
id2condition
;
public
HashMap
<
String
,
Condition
>
name2condition
;
//存储需要初始化的变量
//存储需要初始化的变量
public
HashMap
<
String
,
String
>
varInitialMap
;
public
HashMap
<
String
,
String
>
varInitialMap
;
...
...
src/gameDesign/MapConstructor.java
View file @
eeacf968
...
@@ -65,7 +65,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -65,7 +65,7 @@ public class MapConstructor extends ElementConstructor {
try
{
try
{
conditionDescription
.
put
(
"site"
,
"当前地点"
);
conditionDescription
.
put
(
"site"
,
"当前地点"
);
varInitialMap
.
put
(
"site"
,
"海边"
);
JSONObject
map
=
gameElements
.
getJSONObject
(
"map"
);
JSONObject
map
=
gameElements
.
getJSONObject
(
"map"
);
Map
<
String
,
String
>
question2keyword
=
JSONObject
.
toJavaObject
(
map
.
getJSONObject
(
"question"
),
Map
.
class
);
Map
<
String
,
String
>
question2keyword
=
JSONObject
.
toJavaObject
(
map
.
getJSONObject
(
"question"
),
Map
.
class
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
...
@@ -87,6 +87,9 @@ public class MapConstructor extends ElementConstructor {
...
@@ -87,6 +87,9 @@ public class MapConstructor extends ElementConstructor {
generateSurroundingPeople
();
generateSurroundingPeople
();
generateSurroundThings
();
generateSurroundThings
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
operationStatus
=
0
;
operationStatus
=
0
;
message
=
"地图处理出现异常"
;
message
=
"地图处理出现异常"
;
...
@@ -106,6 +109,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -106,6 +109,7 @@ public class MapConstructor extends ElementConstructor {
conditionName
+
"::match-Include="
+
zainaliKeywords
,
" "
,
conditionName
+
"::match-Include="
+
zainaliKeywords
,
" "
,
"match"
,
"你在{site-2}"
,
"yaobuyao"
,
""
"match"
,
"你在{site-2}"
,
"yaobuyao"
,
""
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
@@ -132,36 +136,76 @@ public class MapConstructor extends ElementConstructor {
...
@@ -132,36 +136,76 @@ public class MapConstructor extends ElementConstructor {
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
if
(
i
==
j
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
placeKeywords
"match"
,
"你已经在"
+
placeB
+
"了"
,
"yaobuyao"
,
""
+
",is_neighbour:"
+
conditionName
+
"::match-Include=0"
,
"site::match-Include="
+
placeA
,
"match,return-0"
,
"你已经在"
+
placeB
+
"了"
,
" "
,
""
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
continue
;
}
;
if
(
pathMatirx
[
i
][
j
]
==
1
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
placeKeywords
"match"
,
placeB
+
"就在附近哦"
,
"yaobuyao"
,
""
+
",is_neighbour:"
+
conditionName
+
"::match-Include=1"
,
"site::match-Include="
+
placeA
,
"match,return-0"
,
placeB
+
"就在旁边哦"
,
" "
,
""
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
int
k
=
preTable
[
i
][
j
];
pathNode
=
""
;
while
(
k
!=
j
)
{
pathNode
+=
(
String
)
locations
.
getJSONObject
(
k
).
get
(
"name"
);
k
=
preTable
[
k
][
j
];
}
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
placeKeywords
"match"
,
"经过"
+
pathNode
+
"就可以到达"
+
placeB
,
"yaobuyao"
,
""
+
",is_neighbour:"
+
conditionName
+
"::match-Include=2"
,
"site::match-Include="
+
placeA
,
"match,return-0"
,
"{map_reply-2}"
,
" "
,
"map_reply:queryPathBySite:"
+
conditionName
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
// if (i == j) {
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords, "site::match-Include=" + placeA,
// "match", "你已经在" + placeB + "了", "yaobuyao", ""
// );
// jConfigList.add(jConfig);
// continue;
// }
// ;
// if (pathMatirx[i][j] == 1) {
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords, "site::match-Include=" + placeA,
// "match", placeB + "就在附近哦", "yaobuyao", ""
// );
// jConfigList.add(jConfig);
//
// } else if (pathMatirx[i][j] > 1 && pathMatirx[i][j] < Integer.MAX_VALUE) {
// int k = preTable[i][j];
// pathNode = "";
// while (k != j) {
// pathNode += (String) locations.getJSONObject(k).get("name");
// k = preTable[k][j];
// }
//
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords, "site::match-Include=" + placeA,
// "match", "经过" + pathNode + "就可以到达" + placeB, "yaobuyao", ""
// );
// jConfigList.add(jConfig);
// }
}
}
}
}
}
}
...
@@ -188,8 +232,9 @@ public class MapConstructor extends ElementConstructor {
...
@@ -188,8 +232,9 @@ public class MapConstructor extends ElementConstructor {
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
"site::match-Include="
+
placeA
,
"match
"
,
"你可以去"
+
pathNode
,
"yaobuyao"
,
"
"
"match
,return-0"
,
"你可以去{map_reply-2}"
+
pathNode
,
" "
,
"map_reply:queryCanGoBySite:
"
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
}
...
@@ -227,48 +272,91 @@ public class MapConstructor extends ElementConstructor {
...
@@ -227,48 +272,91 @@ public class MapConstructor extends ElementConstructor {
lastTaskReply
=
"任务线"
+
placeB
+
"最后的回答"
;
lastTaskReply
=
"任务线"
+
placeB
+
"最后的回答"
;
if
(
i
==
j
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
placeKeywords
"match"
,
"你已经在"
+
placeB
+
"了"
,
"yaobuyao"
,
""
+
",is_neighbour:"
+
conditionName
+
"::match-Include=0"
,
"site::match-Include="
+
placeA
,
"match,return-0"
,
"你已经在"
+
placeB
+
"了"
,
" "
,
""
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
continue
;
}
;
//如果两点相邻
if
(
pathMatirx
[
i
][
j
]
==
1
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
conditionName
+
"::match-Include="
+
placeKeywords
+
","
+
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
+
","
+
lastTaskCondition
+
"::match-Include=null"
+
","
+
lastTaskReply
+
"::match-Include=null"
,
"site::match-Include="
+
placeA
+
","
+
lastTaskCondition
+
"::match-Include=null"
+
","
+
lastTaskReply
+
"::match-Include=null"
,
"match, reutrn-0"
,
"地点尚未激活"
,
"yaobuyao"
,
""
"match, reutrn-0"
,
"地点尚未激活"
,
"yaobuyao"
,
""
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
conditionName
+
"::match-Include="
+
placeKeywords
+
","
+
conditionName
+
"::match-Include="
+
placeKeywords
,
"match"
,
"{"
+
lastTaskReply
+
"-2}"
,
"yaobuyao"
,
"site:"
+
placeB
+
"-<-process-nextStep:var={"
+
lastTaskCondition
+
"-2}"
"site::match-Include="
+
placeA
,
"match, reutrn-0"
,
"{"
+
lastTaskReply
+
"-2}"
,
"yaobuyao"
,
"site:"
+
placeB
+
"-<-process-nextStep:var={"
+
lastTaskCondition
+
"-2}"
);
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
//如果两点不是相邻点
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
int
k
=
preTable
[
i
][
j
];
pathNode
=
""
;
while
(
k
!=
j
)
{
pathNode
+=
(
String
)
locations
.
getJSONObject
(
k
).
get
(
"name"
);
k
=
preTable
[
k
][
j
];
}
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
conditionName
+
"::match-Include="
+
placeKeywords
"site::match-Include="
+
placeA
,
+
",is_neighbour:"
+
conditionName
+
"::match-Include=2"
,
"match"
,
"从"
+
placeA
+
"不能直接到达"
+
placeB
+
", 需要经过"
+
pathNode
+
"才能到达"
+
placeB
,
"yaobuyao"
,
""
"site::match-Include="
+
placeA
,
"match,return-0"
,
"{map_reply-2}"
,
" "
,
"map_reply:queryPathBySite:"
+
conditionName
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
// if (i == j) {
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords, "site::match-Include=" + placeA,
// "match", "你已经在" + placeB + "了", "yaobuyao", ""
// );
// jConfigList.add(jConfig);
// continue;
// }
// ;
//
// //如果两点相邻
// if (pathMatirx[i][j] == 1) {
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords,
// "site::match-Include=" + placeA + "," + lastTaskCondition + "::match-Include=null" + "," + lastTaskReply + "::match-Include=null",
// "match, reutrn-0", "地点尚未激活", "yaobuyao", ""
// );
// jConfigList.add(jConfig);
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords, "site::match-Include=" + placeA,
// "match", "{" + lastTaskReply + "-2}", "yaobuyao", "site:" + placeB + "-<-process-nextStep:var={" + lastTaskCondition +"-2}"
// );
// jConfigList.add(jConfig);
//
//
// //如果两点不是相邻点
// } else if (pathMatirx[i][j] > 1 && pathMatirx[i][j] < Integer.MAX_VALUE) {
//
//
// int k = preTable[i][j];
// pathNode = "";
// while (k != j) {
// pathNode += (String) locations.getJSONObject(k).get("name");
// k = preTable[k][j];
// }
// jConfig = new JConfig(
// conditionName + "::match-Include=" + placeKeywords,
// "site::match-Include=" + placeA,
// "match", "从" + placeA + "不能直接到达" + placeB + ", 需要经过" + pathNode + "才能到达" + placeB, "yaobuyao", ""
// );
// jConfigList.add(jConfig);
// }
}
}
}
}
}
}
...
@@ -281,6 +369,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -281,6 +369,7 @@ public class MapConstructor extends ElementConstructor {
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundNpcBySite:"
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundNpcBySite:"
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
@@ -292,6 +381,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -292,6 +381,7 @@ public class MapConstructor extends ElementConstructor {
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundGoodsBySite:"
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundGoodsBySite:"
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
@@ -303,6 +393,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -303,6 +393,7 @@ public class MapConstructor extends ElementConstructor {
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundAllBySite:"
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundAllBySite:"
);
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
...
src/gameDesign/PlotConstructor.java
View file @
eeacf968
...
@@ -432,6 +432,8 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -432,6 +432,8 @@ public class PlotConstructor extends ElementConstructor {
List
<
String
>
adjNodeList
=
null
;
List
<
String
>
adjNodeList
=
null
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
root
.
put
(
"nextUnknownText"
,
varInitialMap
.
get
(
"unknownText"
));
root
.
put
(
"nextUnknownText"
,
varInitialMap
.
get
(
"unknownText"
));
root
.
put
(
"parentId"
,
"null"
);
root
.
put
(
"parentId"
,
"null"
);
...
@@ -602,6 +604,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -602,6 +604,7 @@ public class PlotConstructor extends ElementConstructor {
String
startPlace
=
(
String
)
root
.
get
(
"place"
);
String
startPlace
=
(
String
)
root
.
get
(
"place"
);
varInitialMap
.
put
(
"site"
,
startPlace
);
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
(
String
)
root
.
get
(
"conditionName"
));
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
(
String
)
root
.
get
(
"conditionName"
));
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
(
String
)
jsonObject
.
get
(
"plotStartText"
));
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
(
String
)
jsonObject
.
get
(
"plotStartText"
));
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
"任务线"
+
startPlace
+
"最后一个condition"
);
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
"任务线"
+
startPlace
+
"最后一个condition"
);
...
@@ -680,13 +683,23 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -680,13 +683,23 @@ public class PlotConstructor extends ElementConstructor {
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
+
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
+
"-<-"
+
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
+
"-<-game_step:"
+
botName
+
"_plot_"
+
nextId
;
"-<-"
+
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
+
"-<-game_step:"
+
botName
+
"_plot_"
+
nextId
;
List
<
String
>
curPremiseList
=
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
);
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
)
,
curPremiseList
,
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
updateKnowledge
,
updateKnowledge
,
""
,
extraHP
,
extraUK
,
""
,
extraHP
,
extraUK
,
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
"0"
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
"0"
);
);
if
(
curPremiseList
.
size
()
==
0
){
jConfig
.
setFeature
(
jConfig
.
getFeature
()
+
",activate,post::all(http://simqa.sz.chewrobot.com:28081/game)"
);
jConfig
.
setNextStep
(
"queryskip1,queryskip2"
);
jConfig
.
setUpdateKnowledge
(
jConfig
.
getUpdateKnowledge
()
+
"-<-临时变量1:{nextStep-3}-<-临时变量2:{reply-3}"
);
jConfig
.
setNextStepStatus
(
"active"
);
}
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
...
@@ -723,7 +736,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -723,7 +736,7 @@ public class PlotConstructor extends ElementConstructor {
if
(
curUnknownText
.
equals
(
""
))
{
if
(
curUnknownText
.
equals
(
""
))
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include=unknown"
,
conditionName
+
"::match-Include=unknown"
,
extraHP
=
"任务线_"
+
location
+
"进度::match-Include="
+
parentId
,
"任务线_"
+
location
+
"进度::match-Include="
+
parentId
,
"match,return-0,post::all("
+
CHITCHAT_URL
+
")"
,
"match,return-0,post::all("
+
CHITCHAT_URL
+
")"
,
" "
,
" "
,
" "
,
" "
,
...
@@ -741,12 +754,45 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -741,12 +754,45 @@ public class PlotConstructor extends ElementConstructor {
*/
*/
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-Smaller=90"
,
"match"
,
"{临时变量2-2}"
,
" "
,
"process-nextStep:{临时变量1-2}"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"queryskip1"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-BiggerOrEqual=90"
,
"match"
,
"{common_answer-2}, {临时变量2-2}"
,
" "
,
"process-nextStep:{临时变量1-2}"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"queryskip2"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=not_found"
,
"match"
,
"{临时变量2-2}"
,
" "
,
"process-nextStep:{临时变量1-2}"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"queryskip3"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=not_found"
,
"match,return-0"
,
"{unknownText-2}"
,
" "
,
""
" "
,
"qa_status::match-Include=not_found"
,
"match,return-0"
,
"{unknownText-2}"
,
" "
,
""
);
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown1"
);
jConfig
.
setConfigName
(
"unknown1"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=not_found,unknownText::match-Include=null"
,
"match,return-0"
,
" "
,
"qa_status::match-Include=not_found,unknownText::match-Include=null"
,
"match,return-0"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
...
@@ -755,6 +801,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -755,6 +801,7 @@ public class PlotConstructor extends ElementConstructor {
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown2"
);
jConfig
.
setConfigName
(
"unknown2"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
...
@@ -766,6 +813,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -766,6 +813,7 @@ public class PlotConstructor extends ElementConstructor {
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown3"
);
jConfig
.
setConfigName
(
"unknown3"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
...
@@ -775,6 +823,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -775,6 +823,7 @@ public class PlotConstructor extends ElementConstructor {
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown4"
);
jConfig
.
setConfigName
(
"unknown4"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
...
@@ -783,6 +832,8 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -783,6 +832,8 @@ public class PlotConstructor extends ElementConstructor {
);
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
...
@@ -792,7 +843,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -792,7 +843,7 @@ public class PlotConstructor extends ElementConstructor {
@Override
@Override
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){
if
(
idList
.
size
()
!=
0
)
{
if
(
idList
.
size
()
!=
0
)
{
jConfig
=
new
JConfig
(
" "
,
" "
,
"activate,post::all(http://simqa.sz.chewrobot.com:28081/game)"
,
""
,
idList
.
get
(
idList
.
size
()
-
5
)
+
","
+
idList
.
get
(
idList
.
size
()
-
4
)
+
","
+
idList
.
get
(
idList
.
size
()
-
3
)
+
","
+
idList
.
get
(
idList
.
size
()
-
2
)
+
","
+
idList
.
get
(
idList
.
size
()
-
1
)
,
""
);
jConfig
=
new
JConfig
(
" "
,
" "
,
"activate,post::all(http://simqa.sz.chewrobot.com:28081/game)"
,
""
,
"unknown4,unknown3,unknown2,unknown1,common_answer"
,
""
);
jConfig
.
setNextStepStatus
(
"active"
);
jConfig
.
setNextStepStatus
(
"active"
);
JSONObject
json
=
jConfig
.
toJson
(
this
.
getConditionDescription
());
JSONObject
json
=
jConfig
.
toJson
(
this
.
getConditionDescription
());
helper
.
insertConfigByBotId
(
botId
,
json
,
idList
,
categoryId
);
helper
.
insertConfigByBotId
(
botId
,
json
,
idList
,
categoryId
);
...
...
src/processing/ChatCacheController.java
View file @
eeacf968
...
@@ -106,10 +106,10 @@ public class ChatCacheController {
...
@@ -106,10 +106,10 @@ public class ChatCacheController {
if
(!
dir
.
exists
())
if
(!
dir
.
exists
())
dir
.
mkdir
();
dir
.
mkdir
();
ObjectFileUtil
.
writeObjectToFile
(
chatCache
.
getGameEnv
(),
String
.
format
(
ENV_PATH
,
chatKey
.
split
(
"
~
"
)[
0
]));
ObjectFileUtil
.
writeObjectToFile
(
chatCache
.
getGameEnv
(),
String
.
format
(
ENV_PATH
,
chatKey
.
split
(
"
-
"
)[
0
]));
File
file
=
new
File
(
String
.
format
(
INFO_PATH
,
chatKey
.
split
(
"
~
"
)[
0
]));
File
file
=
new
File
(
String
.
format
(
INFO_PATH
,
chatKey
.
split
(
"
-
"
)[
0
]));
FileWriter
fw
=
new
FileWriter
(
file
);
FileWriter
fw
=
new
FileWriter
(
file
);
String
jsonString
=
JSON
.
toJSONString
(
chatCache
.
getInfoPoint
());
String
jsonString
=
JSON
.
toJSONString
(
chatCache
.
getInfoPoint
());
...
@@ -124,34 +124,43 @@ public class ChatCacheController {
...
@@ -124,34 +124,43 @@ public class ChatCacheController {
return
saveFlag
;
return
saveFlag
;
}
}
public
static
ChatCache
loadChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userInfo
)
throws
Exception
{
public
static
ChatCache
loadChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userInfo
,
Boolean
loadCacheStatus
)
throws
Exception
{
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
GameEnv
gameEnv
=
null
;
GameEnv
gameEnv
=
null
;
Map
<
String
,
String
>
infoPoint
=
null
;
Map
<
String
,
String
>
infoPoint
=
null
;
String
key
=
chatKey
.
split
(
"
~
"
)[
0
];
String
key
=
chatKey
.
split
(
"
-
"
)[
0
];
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
line
,
pair
[];
String
line
,
pair
[];
Map
<
String
,
String
>
infoPoints
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
infoPoints
=
new
HashMap
<
String
,
String
>();
try
{
try
{
File
file
=
new
File
(
String
.
format
(
ENV_PATH
,
key
));
if
(
file
.
exists
()){
gameEnv
=
(
GameEnv
)
ObjectFileUtil
.
readObjectFromFile
(
String
.
format
(
ENV_PATH
,
key
));
gameEnv
=
(
GameEnv
)
ObjectFileUtil
.
readObjectFromFile
(
String
.
format
(
ENV_PATH
,
key
));
}
else
{
throw
new
IOException
(
"环境存档不存在"
);
}
File
file
=
new
File
(
String
.
format
(
INFO_PATH
,
key
));
file
=
new
File
(
String
.
format
(
INFO_PATH
,
key
));
FileReader
fr
=
new
FileReader
(
file
);
FileReader
fr
=
new
FileReader
(
file
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
String
jsonStr
=
br
.
readLine
();
String
jsonStr
=
br
.
readLine
();
infoPoint
=
(
Map
)
JSON
.
parseObject
(
jsonStr
);
infoPoint
=
(
Map
)
JSON
.
parseObject
(
jsonStr
);
// context.setAttribute(userName, );
// context.setAttribute(userName, );
chatCache
=
new
ChatCache
(
gameEnv
,
infoPoint
);
chatCache
=
new
ChatCache
(
gameEnv
,
infoPoint
);
chatCache
.
setReloading
(
true
);
br
.
close
();
fr
.
close
()
;
loadCacheStatus
=
true
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
System
.
out
.
println
(
e
.
toString
()
);
chatCache
=
new
ChatCache
(
userInfo
);
chatCache
=
new
ChatCache
(
userInfo
);
loadCacheStatus
=
false
;
}
}
return
chatCache
;
return
chatCache
;
...
@@ -162,18 +171,13 @@ public class ChatCacheController {
...
@@ -162,18 +171,13 @@ public class ChatCacheController {
public
static
synchronized
ChatCache
getChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userinfo
,
Boolean
loadCache
)
throws
Exception
{
public
static
synchronized
ChatCache
getChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userinfo
,
Map
<
String
,
String
[]>
receiveParamters
,
Boolean
loadCacheStatus
)
throws
Exception
{
Map
<
String
,
ChatCache
>
chatCacheMap
=
null
;
Map
<
String
,
ChatCache
>
chatCacheMap
=
null
;
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
if
(
loadCache
){
loadChatCache
(
chatKey
,
context
,
userinfo
);
}
if
(
context
.
getAttribute
(
"chatCache"
)
==
null
)
{
if
(
context
.
getAttribute
(
"chatCache"
)
==
null
)
{
chatCacheMap
=
new
HashMap
<
String
,
ChatCache
>();
chatCacheMap
=
new
HashMap
<
String
,
ChatCache
>();
chatCacheMap
.
put
(
chatKey
,
new
ChatCache
(
userinfo
));
//
chatCacheMap.put(chatKey, new ChatCache(userinfo));
context
.
setAttribute
(
"chatCache"
,
chatCacheMap
);
context
.
setAttribute
(
"chatCache"
,
chatCacheMap
);
}
else
{
}
else
{
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
...
@@ -185,7 +189,12 @@ public class ChatCacheController {
...
@@ -185,7 +189,12 @@ public class ChatCacheController {
try
{
try
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
chatCache
=
chatCacheMap
.
get
(
chatKey
);
if
(
chatCache
==
null
){
if
(
chatCache
==
null
){
if
(
receiveParamters
.
containsKey
(
"yaobuyao"
)
&&
(
receiveParamters
.
get
(
"yaobuyao"
)[
0
].
contains
(
"开始游戏"
)
||
receiveParamters
.
get
(
"yaobuyao"
)[
0
].
contains
(
"继续游戏"
)||
receiveParamters
.
get
(
"yaobuyao"
)[
0
].
contains
(
"开始"
)))
{
chatCache
=
loadChatCache
(
chatKey
,
context
,
userinfo
,
loadCacheStatus
);
}
else
{
chatCache
=
new
ChatCache
(
userinfo
);
chatCache
=
new
ChatCache
(
userinfo
);
}
chatCacheMap
.
put
(
chatKey
,
chatCache
);
chatCacheMap
.
put
(
chatKey
,
chatCache
);
}
}
//historyInfoPoint = (Map<String, String>) context.getAttribute("chat_key+"+userinfo.userName);
//historyInfoPoint = (Map<String, String>) context.getAttribute("chat_key+"+userinfo.userName);
...
@@ -213,14 +222,16 @@ public class ChatCacheController {
...
@@ -213,14 +222,16 @@ public class ChatCacheController {
Iterator
<
String
>
it
=
chatCacheMap
.
keySet
().
iterator
();
Iterator
<
String
>
it
=
chatCacheMap
.
keySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
chatKey
=
it
.
next
();
chatKey
=
it
.
next
();
if
(
curChatKey
.
equals
(
chatKey
))
if
(
curChatKey
.
equals
(
chatKey
))
{
saveChatCache
(
chatKey
,
chatCacheMap
.
get
(
chatKey
));
continue
;
continue
;
}
history
=
chatCacheMap
.
get
(
chatKey
).
getInfoPoint
();
history
=
chatCacheMap
.
get
(
chatKey
).
getInfoPoint
();
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
now
=
System
.
currentTimeMillis
();
now
=
System
.
currentTimeMillis
();
if
(
now
-
lastChatTime
>
ChatCacheController
.
TIME_OUT
)
{
if
(
now
-
lastChatTime
>
ChatCacheController
.
TIME_OUT
)
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
chatCache
=
chatCacheMap
.
get
(
chatKey
);
saveChatCache
(
"1909509284"
,
chatCache
);
saveChatCache
(
chatKey
,
chatCache
);
it
.
remove
();
it
.
remove
();
}
}
}
}
...
...
src/processing/ConditionTableController.java
View file @
eeacf968
...
@@ -28,10 +28,10 @@ public class ConditionTableController {
...
@@ -28,10 +28,10 @@ public class ConditionTableController {
UserInfo
userInfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
UserInfo
userInfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
if
(
userInfo
.
id2config
.
containsKey
(
id
))
{
if
(
userInfo
.
id2config
.
containsKey
(
id
))
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
id
);
//-------------------
//-------------------
try
{
try
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
id
);
conditionName
=
oldCondition
.
indexName
;
conditionName
=
oldCondition
.
indexName
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -49,6 +49,7 @@ public class ConditionTableController {
...
@@ -49,6 +49,7 @@ public class ConditionTableController {
}
}
}
}
userInfo
.
name2condition
.
remove
(
oldCondition
.
configName
);
userInfo
.
id2config
.
remove
(
id
);
userInfo
.
id2config
.
remove
(
id
);
userInfo
.
id2condition
.
remove
(
id
);
userInfo
.
id2condition
.
remove
(
id
);
}
else
{
}
else
{
...
@@ -64,8 +65,9 @@ public class ConditionTableController {
...
@@ -64,8 +65,9 @@ public class ConditionTableController {
for
(
int
configId
:
idGroup
)
{
for
(
int
configId
:
idGroup
)
{
if
(
userInfo
.
id2config
.
containsKey
(
configId
))
{
if
(
userInfo
.
id2config
.
containsKey
(
configId
))
{
try
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
configId
);
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
configId
);
try
{
conditionName
=
oldCondition
.
indexName
;
conditionName
=
oldCondition
.
indexName
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -83,6 +85,7 @@ public class ConditionTableController {
...
@@ -83,6 +85,7 @@ public class ConditionTableController {
}
}
}
}
userInfo
.
name2condition
.
remove
(
oldCondition
.
configName
);
userInfo
.
id2config
.
remove
(
configId
);
userInfo
.
id2config
.
remove
(
configId
);
userInfo
.
id2condition
.
remove
(
configId
);
userInfo
.
id2condition
.
remove
(
configId
);
}
else
{
}
else
{
...
@@ -115,6 +118,10 @@ public class ConditionTableController {
...
@@ -115,6 +118,10 @@ public class ConditionTableController {
List
<
Condition
>
conditionList
=
new
ArrayList
<
Condition
>();
List
<
Condition
>
conditionList
=
new
ArrayList
<
Condition
>();
userinfo
.
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
userinfo
.
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
}
}
if
(!
condition
.
configName
.
equals
(
""
)){
userinfo
.
name2condition
.
put
(
condition
.
configName
,
condition
);
}
userinfo
.
conditionTable
.
get
(
condition
.
indexName
).
add
(
condition
);
userinfo
.
conditionTable
.
get
(
condition
.
indexName
).
add
(
condition
);
userinfo
.
id2config
.
put
(
id
,
configLine
);
userinfo
.
id2config
.
put
(
id
,
configLine
);
userinfo
.
id2condition
.
put
(
id
,
condition
);
userinfo
.
id2condition
.
put
(
id
,
condition
);
...
...
src/processing/MyFunc.java
View file @
eeacf968
...
@@ -134,7 +134,9 @@ public class MyFunc {
...
@@ -134,7 +134,9 @@ public class MyFunc {
}
else
{
}
else
{
jobj
.
put
(
"status"
,
0
);
jobj
.
put
(
"status"
,
0
);
jobj
.
put
(
"parameter"
,
"修改condition失败"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/processing/QuestionMatcher.java
View file @
eeacf968
...
@@ -331,11 +331,13 @@ public class QuestionMatcher {
...
@@ -331,11 +331,13 @@ public class QuestionMatcher {
String
keywrod
=
gameEnv
.
queryNpcAttrByNpcName
(
nameSeries
[
3
],
nameSeries
[
4
]);
String
keywrod
=
gameEnv
.
queryNpcAttrByNpcName
(
nameSeries
[
3
],
nameSeries
[
4
]);
}
}
}
else
if
(
actionName
.
startsWith
(
"goods_"
)){
}
else
if
(
actionName
.
startsWith
(
"goods_"
))
{
if
(
nameSeries
.
length
==
4
)
{
if
(
nameSeries
.
length
==
4
)
{
keyword
=
gameEnv
.
queryGoodsAttrByGoodsName
(
nameSeries
[
2
],
nameSeries
[
3
]);
keyword
=
gameEnv
.
queryGoodsAttrByGoodsName
(
nameSeries
[
2
],
nameSeries
[
3
]);
System
.
out
.
println
(
"return"
+
keyword
);
System
.
out
.
println
(
"return"
+
keyword
);
}
}
}
else
if
(
actionName
.
startsWith
(
"is_neighbour"
)){
//keyword = gameEnv.isNeighbour(historyInfoPoint.get("site"), actionName.split(":")[1]);
}
else
{
}
else
{
keyword
=
infoPoint
.
get
(
actionName
);
keyword
=
infoPoint
.
get
(
actionName
);
...
@@ -832,7 +834,7 @@ public class QuestionMatcher {
...
@@ -832,7 +834,7 @@ public class QuestionMatcher {
}
}
ChatCacheController
.
updateChatCache4Insert
(
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
context
);
//context.setAttribute("chat_key+"+userinfo.botAccount,historyInfoPoint);
//context.setAttribute("chat_key+"+userinfo.botAccount,historyInfoPoint);
...
@@ -884,7 +886,7 @@ public class QuestionMatcher {
...
@@ -884,7 +886,7 @@ public class QuestionMatcher {
key
=
it
.
next
();
key
=
it
.
next
();
value
=
historyInfoPoint
.
get
(
key
);
value
=
historyInfoPoint
.
get
(
key
);
if
(
value
!=
null
&&
!
value
.
equals
(
" "
)
&&
!
value
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
)
&&
!
key
.
endsWith
(
"最后的回答"
)
&&
!
key
.
endsWith
(
"最后一个condition"
))
if
(
value
!=
null
&&
!
value
.
equals
(
" "
)
&&
!
value
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
)
&&
!
key
.
endsWith
(
"最后的回答"
)
&&
!
key
.
endsWith
(
"最后一个condition"
)
&&
!
key
.
startsWith
(
"临时变量"
)
)
debugInfo
+=
(
" "
+
key
+
":\'"
+
value
+
"\' "
);
debugInfo
+=
(
" "
+
key
+
":\'"
+
value
+
"\' "
);
}
}
...
@@ -1205,13 +1207,18 @@ public class QuestionMatcher {
...
@@ -1205,13 +1207,18 @@ public class QuestionMatcher {
Condition
newCondition
,
originCondition
;
Condition
newCondition
,
originCondition
;
for
(
String
configIdStr
:
activateList
.
split
(
","
))
{
for
(
String
configIdStr
:
activateList
.
split
(
","
))
{
if
(!
StringUtils
.
isNumeric
(
configIdStr
))
try
{
continue
;
if
(
StringUtils
.
isNumeric
(
configIdStr
))
{
configId
=
Integer
.
parseInt
(
configIdStr
);
configId
=
Integer
.
parseInt
(
configIdStr
);
configStr
=
userinfo
.
id2config
.
get
(
configId
);
configStr
=
userinfo
.
id2config
.
get
(
configId
);
if
(
configStr
!=
null
)
{
originCondition
=
userinfo
.
id2condition
.
get
(
configId
);
originCondition
=
userinfo
.
id2condition
.
get
(
configId
);
}
else
{
originCondition
=
userinfo
.
name2condition
.
get
(
configIdStr
);
}
configId
=
originCondition
.
id
;
newCondition
=
new
Condition
(
originCondition
,
basePriority
,
baseAuxiliaryPriority
);
newCondition
=
new
Condition
(
originCondition
,
basePriority
,
baseAuxiliaryPriority
);
//condition = QuestionMatcher.buildCondition(condition, configStr);
//condition = QuestionMatcher.buildCondition(condition, configStr);
...
@@ -1223,6 +1230,10 @@ public class QuestionMatcher {
...
@@ -1223,6 +1230,10 @@ public class QuestionMatcher {
activatedMap
.
put
(
configId
,
newCondition
);
activatedMap
.
put
(
configId
,
newCondition
);
activatedQueue
.
add
(
newCondition
);
activatedQueue
.
add
(
newCondition
);
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
logWriter
.
record
(
"----------激活失败:"
+
configIdStr
,
5
);
}
}
}
}
...
...
src/processing/UserInfoController.java
View file @
eeacf968
...
@@ -94,7 +94,6 @@ public class UserInfoController {
...
@@ -94,7 +94,6 @@ public class UserInfoController {
element
=
line
.
replace
(
"\n"
,
""
).
split
(
"\\|=\\>\\|"
);
element
=
line
.
replace
(
"\n"
,
""
).
split
(
"\\|=\\>\\|"
);
premises
=
element
[
0
].
split
(
"\\|"
);
premises
=
element
[
0
].
split
(
"\\|"
);
//System.out.println("element[0]:" + element[0]);
feature
=
premises
[
2
];
feature
=
premises
[
2
];
cur_premises
=
premises
[
0
].
split
(
","
);
cur_premises
=
premises
[
0
].
split
(
","
);
history_premises
=
premises
[
1
].
split
(
","
);
history_premises
=
premises
[
1
].
split
(
","
);
...
@@ -102,7 +101,12 @@ public class UserInfoController {
...
@@ -102,7 +101,12 @@ public class UserInfoController {
if
(
premises
.
length
<
4
)
if
(
premises
.
length
<
4
)
condition
.
auxiliaryPriority
=
0
;
condition
.
auxiliaryPriority
=
0
;
else
else
condition
.
auxiliaryPriority
=
Integer
.
parseInt
(
premises
[
3
].
split
(
"="
)[
1
]);
condition
.
auxiliaryPriority
=
Integer
.
parseInt
(
premises
[
3
].
split
(
"="
,
2
)[
1
]);
if
(
premises
.
length
<
5
)
condition
.
configName
=
""
;
else
condition
.
configName
=
premises
[
4
].
split
(
"="
,
2
)[
1
];
next
=
element
[
1
].
split
(
"\\|"
);
next
=
element
[
1
].
split
(
"\\|"
);
...
@@ -187,6 +191,7 @@ public class UserInfoController {
...
@@ -187,6 +191,7 @@ public class UserInfoController {
userinfo
.
id2config
.
clear
();
userinfo
.
id2config
.
clear
();
userinfo
.
configStr
=
""
;
userinfo
.
configStr
=
""
;
userinfo
.
varInitialMap
.
clear
();
userinfo
.
varInitialMap
.
clear
();
userinfo
.
name2condition
.
clear
();
}
else
{
}
else
{
conditionTable
=
userinfo
.
conditionTable
;
conditionTable
=
userinfo
.
conditionTable
;
...
@@ -200,6 +205,7 @@ public class UserInfoController {
...
@@ -200,6 +205,7 @@ public class UserInfoController {
if
(
line
.
trim
().
equals
(
""
))
if
(
line
.
trim
().
equals
(
""
))
continue
;
continue
;
line
=
line
.
replace
(
"\n"
,
""
);
line
=
line
.
replace
(
"\n"
,
""
);
//在用户信息中添加额外信息,如设为active的action
//在用户信息中添加额外信息,如设为active的action
if
(
line
.
contains
(
"extraInfo"
))
{
if
(
line
.
contains
(
"extraInfo"
))
{
extraElements
=
line
.
split
(
"\\|"
,
-
1
);
extraElements
=
line
.
split
(
"\\|"
,
-
1
);
...
@@ -216,6 +222,9 @@ public class UserInfoController {
...
@@ -216,6 +222,9 @@ public class UserInfoController {
conditionList
.
add
(
condition
);
conditionList
.
add
(
condition
);
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
if
(
condition
.
id
!=
0
)
{
if
(
condition
.
id
!=
0
)
{
if
(!
condition
.
configName
.
equals
(
""
)){
userinfo
.
name2condition
.
put
(
condition
.
configName
,
condition
);
}
userinfo
.
id2config
.
put
(
condition
.
id
,
line
);
userinfo
.
id2config
.
put
(
condition
.
id
,
line
);
userinfo
.
id2condition
.
put
(
condition
.
id
,
condition
);
userinfo
.
id2condition
.
put
(
condition
.
id
,
condition
);
}
}
...
@@ -223,9 +232,11 @@ public class UserInfoController {
...
@@ -223,9 +232,11 @@ public class UserInfoController {
}
}
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
System
.
out
.
println
(
"数据格式有误"
);
System
.
out
.
println
(
"数据格式有误"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
System
.
out
.
println
(
line
);
}
}
}
}
...
...
src/processing/WorldController.java
View file @
eeacf968
...
@@ -89,31 +89,76 @@ public class WorldController {
...
@@ -89,31 +89,76 @@ public class WorldController {
switch
(
valuePair
[
0
])
{
switch
(
valuePair
[
0
])
{
case
"queryAroundAllBySite"
:
case
"queryAroundAllBySite"
:
sites
=
gameEnv
.
queryAroundAllBySite
(
historyInfoPoint
.
get
(
"site"
));
sites
=
gameEnv
.
queryAroundAllBySite
(
historyInfoPoint
.
get
(
"site"
));
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有"
;
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"啥都没有"
;
}
}
break
;
break
;
case
"queryAroundNpcBySite"
:
case
"queryAroundNpcBySite"
:
sites
=
gameEnv
.
queryAroundNpcBySite
(
historyInfoPoint
.
get
(
"site"
));
sites
=
gameEnv
.
queryAroundNpcBySite
(
historyInfoPoint
.
get
(
"site"
));
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有"
;
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"啥都没有"
;
}
}
break
;
break
;
case
"queryAroundGoodsBySite"
:
case
"queryAroundGoodsBySite"
:
sites
=
gameEnv
.
queryAroundGoodsBySite
(
historyInfoPoint
.
get
(
"site"
));
sites
=
gameEnv
.
queryAroundGoodsBySite
(
historyInfoPoint
.
get
(
"site"
));
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有"
;
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"啥都没有"
;
}
}
break
;
break
;
case
"queryCanGoBySite"
:
case
"queryCanGoBySite"
:
sites
=
gameEnv
.
queryCanGoBySite
(
historyInfoPoint
.
get
(
"site"
));
sites
=
gameEnv
.
queryCanGoBySite
(
historyInfoPoint
.
get
(
"site"
));
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"没什么地方可去的,继续玩吧"
;
else
{
returnStr
=
"可以去"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"没什么地方可去的,继续玩吧"
;
}
}
break
;
break
;
case
"queryPathBySite"
:
case
"queryPathBySite"
:
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
break
;
}
if
(
sites
==
null
||
sites
.
size
()
==
0
)
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有
"
;
returnStr
=
"就在附近哦
"
;
else
{
else
{
returnStr
=
"有
"
;
returnStr
=
"通过
"
;
if
(
sites
.
size
()
>
0
)
{
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
returnStr
+=
"、"
+
site
;
}
else
{
}
else
{
returnStr
=
"啥都没有
"
;
returnStr
=
"就在附近哦
"
;
}
}
}
}
break
;
}
}
}
}
else
{
//增删改统一使用
}
else
{
//增删改统一使用
gameEnv
.
CUD
(
varName
,
valuePair
[
0
],
valuePair
[
1
]);
gameEnv
.
CUD
(
varName
,
valuePair
[
0
],
valuePair
[
1
]);
...
...
src/servlet/GameDesignServlet.java
View file @
eeacf968
...
@@ -19,7 +19,6 @@ import java.io.*;
...
@@ -19,7 +19,6 @@ import java.io.*;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.*
;
import
java.util.*
;
import
static
java
.
lang
.
System
.
out
;
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
public
class
GameDesignServlet
extends
HttpServlet
{
public
class
GameDesignServlet
extends
HttpServlet
{
...
@@ -68,14 +67,14 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -68,14 +67,14 @@ public class GameDesignServlet extends HttpServlet {
JSONObject
gameElements
=
helper
.
queryGameElementsByBotId
(
dataId
);
JSONObject
gameElements
=
helper
.
queryGameElementsByBotId
(
dataId
);
out
.
println
(
gameElements
.
toJSONString
());
System
.
out
.
println
(
gameElements
.
toJSONString
());
botId
=
(
Integer
)
gameElements
.
get
(
"botId"
);
botId
=
(
Integer
)
gameElements
.
get
(
"botId"
);
botAccount
=
(
String
)
gameElements
.
get
(
"botAccount"
);
botAccount
=
(
String
)
gameElements
.
get
(
"botAccount"
);
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
out
.
println
(
"botId:"
+
botId
+
",botAccount:"
+
botAccount
);
System
.
out
.
println
(
"botId:"
+
botId
+
",botAccount:"
+
botAccount
);
//假设重建用户信息
//假设重建用户信息
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
...
@@ -91,7 +90,7 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -91,7 +90,7 @@ public class GameDesignServlet extends HttpServlet {
try
{
try
{
flag
=
botInit
(
botId
,
userinfo
,
helper
);
flag
=
botInit
(
botId
,
userinfo
,
helper
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
out
.
println
(
"清空旧数据失败"
);
System
.
out
.
println
(
"清空旧数据失败"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -135,7 +134,7 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -135,7 +134,7 @@ public class GameDesignServlet extends HttpServlet {
}
}
if
(
constructor
.
getOperationStatus
()
==
1
)
{
if
(
constructor
.
getOperationStatus
()
==
1
)
{
out
.
println
(
moduleName
);
System
.
out
.
println
(
moduleName
);
//先清空再插入
//先清空再插入
idList
.
clear
();
idList
.
clear
();
helper
.
batchInsertVariableByBotId
(
botId
,
constructor
);
helper
.
batchInsertVariableByBotId
(
botId
,
constructor
);
...
@@ -167,7 +166,12 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -167,7 +166,12 @@ public class GameDesignServlet extends HttpServlet {
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
botAccount
,
userinfo
);
context
.
setAttribute
(
botAccount
,
userinfo
);
ConditionTableController
.
writeConfigText
(
botAccount
,
userinfo
);
ConditionTableController
.
writeConfigText
(
botAccount
,
userinfo
);
Boolean
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
);
String
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
);
if
(!
postResult
.
equals
(
"success"
)){
returnStatus
=
0
;
returnMessage
=
postResult
;
}
}
}
helper
.
destroy
();
helper
.
destroy
();
...
@@ -191,20 +195,11 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -191,20 +195,11 @@ public class GameDesignServlet extends HttpServlet {
try
{
PrintWriter
out
=
response
.
getWriter
();
PrintWriter
out
=
response
.
getWriter
();
out
.
append
(
responseJSONObject
.
toString
());
out
.
append
(
responseJSONObject
.
toString
());
}
catch
(
IOException
e
)
{
out
.
flush
();
e
.
printStackTrace
();
}
finally
{
if
(
out
!=
null
)
{
out
.
close
();
}
}
}
}
...
@@ -226,13 +221,13 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -226,13 +221,13 @@ public class GameDesignServlet extends HttpServlet {
return
deleteConfigFlag
&&
deleteVariableFlag
;
return
deleteConfigFlag
&&
deleteVariableFlag
;
}
}
public
boolean
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
){
public
String
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
){
String
startCondition
;
String
startCondition
;
String
botName
=
(
String
)
gameElements
.
get
(
"botName"
);
String
botName
=
(
String
)
gameElements
.
get
(
"botName"
);
JSONObject
returnMessage
=
null
;
JSONObject
returnMessage
=
null
;
JSONObject
actionPostData
=
new
JSONObject
();
JSONObject
actionPostData
=
new
JSONObject
();
out
.
println
(
"root"
+
root
.
toJSONString
());
System
.
out
.
println
(
"root"
+
root
.
toJSONString
());
startCondition
=
(
String
)
root
.
get
(
"conditionName"
);
startCondition
=
(
String
)
root
.
get
(
"conditionName"
);
actionPostData
.
put
(
"startCondition"
,
startCondition
);
actionPostData
.
put
(
"startCondition"
,
startCondition
);
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
...
@@ -242,7 +237,7 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -242,7 +237,7 @@ public class GameDesignServlet extends HttpServlet {
actionPostData
.
put
(
"welcome"
,
(
String
)
gameElements
.
get
(
"plotStartText"
));
actionPostData
.
put
(
"welcome"
,
(
String
)
gameElements
.
get
(
"plotStartText"
));
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
out
.
println
(
actionPostData
.
toJSONString
());
System
.
out
.
println
(
actionPostData
.
toJSONString
());
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
try
{
try
{
...
@@ -251,12 +246,12 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -251,12 +246,12 @@ public class GameDesignServlet extends HttpServlet {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
((
Integer
)
returnMessage
.
get
(
"status"
)
==
1
)
{
if
((
Integer
)
returnMessage
.
get
(
"status"
)
==
1
)
{
return
true
;
return
"success"
;
}
else
{
}
else
{
out
.
println
(
returnMessage
.
get
(
"parameter"
));
System
.
out
.
println
(
returnMessage
.
get
(
"parameter"
));
out
.
println
(
"剧情初始化
失败"
);
System
.
out
.
println
(
"语义关系修改
失败"
);
return
false
;
return
(
String
)
returnMessage
.
get
(
"parameter"
)
;
}
}
}
}
...
...
src/servlet/GetAnswerServlet.java
View file @
eeacf968
...
@@ -32,16 +32,12 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -32,16 +32,12 @@ public class GetAnswerServlet extends HttpServlet {
Map
<
String
,
String
>
historyInfoPoint
=
null
;
Map
<
String
,
String
>
historyInfoPoint
=
null
;
Solution
bestMatch
=
null
;
Solution
bestMatch
=
null
;
Condition
ansCondition
=
null
;
Condition
ansCondition
=
null
;
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
;
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
,
chatKey
=
""
;
String
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
].
split
(
"-"
)[
0
];
chatKey
=
botName
+
"~"
+
chatKey
;
receiveParamters
.
get
(
"chat_key"
)[
0
]
=
chatKey
;
receiveParamters
.
get
(
"chat_key"
)[
0
]
=
chatKey
;
OutputStream
out
=
response
.
getOutputStream
();
OutputStream
out
=
response
.
getOutputStream
();
ServletContext
context
=
this
.
getServletContext
();
ServletContext
context
=
this
.
getServletContext
();
boolean
debugFlag
=
false
;
boolean
debugFlag
=
false
;
...
@@ -50,8 +46,6 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -50,8 +46,6 @@ public class GetAnswerServlet extends HttpServlet {
LogWriter
logWriter
=
new
LogWriter
(
LOG_PATH
,
chatKey
);
LogWriter
logWriter
=
new
LogWriter
(
LOG_PATH
,
chatKey
);
UserInfo
userinfo
=
null
;
UserInfo
userinfo
=
null
;
UserInfoController
uiController
=
new
UserInfoController
();
UserInfoController
uiController
=
new
UserInfoController
();
try
{
try
{
...
@@ -67,16 +61,9 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -67,16 +61,9 @@ public class GetAnswerServlet extends HttpServlet {
if
(
userinfo
!=
null
)
{
if
(
userinfo
!=
null
)
{
//获得用户历史信息
//获得用户历史信息
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
Boolean
loadCacheStatus
=
Boolean
.
valueOf
(
false
);
try
{
try
{
Boolean
loadCache
=
false
;
chatCache
=
ChatCacheController
.
getChatCache
(
chatKey
,
context
,
userinfo
,
receiveParamters
,
loadCacheStatus
);
if
(
receiveParamters
.
containsKey
(
"yaobuyao"
))
{
String
startKeyword
=
receiveParamters
.
get
(
"yaobuyao"
)[
0
];
if
(
startKeyword
.
equals
(
"开始游戏"
)
||
startKeyword
.
equals
(
"继续游戏"
)
||
startKeyword
.
equals
(
"继续"
)
||
startKeyword
.
equals
(
"开始"
))
{
loadCache
=
true
;
}
}
chatCache
=
ChatCacheController
.
getChatCache
(
chatKey
,
context
,
userinfo
,
loadCache
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -88,7 +75,7 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -88,7 +75,7 @@ public class GetAnswerServlet extends HttpServlet {
* 如果读档失败,则开始新的游戏,读档失败的判断标准是除了初始化数据外没有其他任何数据
* 如果读档失败,则开始新的游戏,读档失败的判断标准是除了初始化数据外没有其他任何数据
*/
*/
if
(
userinfo
.
varInitialMap
.
size
()
-
chatCache
.
getInfoPoint
().
size
()
==
0
)
{
if
(
!
chatCache
.
isReloading
()
)
{
historyInfoPoint
=
chatCache
.
getInfoPoint
();
historyInfoPoint
=
chatCache
.
getInfoPoint
();
...
@@ -114,14 +101,6 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -114,14 +101,6 @@ public class GetAnswerServlet extends HttpServlet {
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
//清理超时的用户数据
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
ChatCacheController
.
TIME_OUT
)
{
ChatCacheController
.
updateChatCache4Delete
(
chatKey
,
context
);
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
}
//bestMatch.setAnswer(" \n" + return_str + "\n " + bestMatch.getAnswer());
}
else
{
}
else
{
bestMatch
=
new
Solution
(
0
,
" \n"
+
return_str
+
"\n "
+
state
,
"nextStep="
+
historyInfoPoint
.
get
(
"currentAction"
));
bestMatch
=
new
Solution
(
0
,
" \n"
+
return_str
+
"\n "
+
state
,
"nextStep="
+
historyInfoPoint
.
get
(
"currentAction"
));
}
}
...
@@ -132,10 +111,24 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -132,10 +111,24 @@ public class GetAnswerServlet extends HttpServlet {
}
}
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
ChatCacheController
.
updateChatCache4Insert
(
curInfoPoint
,
historyInfoPoint
,
chatCache
.
getGameEnv
(),
context
);
//清理超时的用户数据
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
ChatCacheController
.
TIME_OUT
)
{
ChatCacheController
.
updateChatCache4Delete
(
chatKey
,
context
);
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
}
}
else
{
}
else
{
System
.
out
.
println
(
"----------读档中------------"
);
String
nextStep
=
chatCache
.
getInfoPoint
().
get
(
"currentAction"
);
String
nextStep
=
chatCache
.
getInfoPoint
().
get
(
"currentAction"
);
String
reply
=
chatCache
.
getInfoPoint
().
get
(
"lastReply"
);
String
reply
=
chatCache
.
getInfoPoint
().
get
(
"lastReply"
);
bestMatch
=
new
Solution
(
1
,
reply
,
"nextStep="
+
nextStep
);
bestMatch
=
new
Solution
(
1
,
"--读取存档--"
+
reply
,
"nextStep="
+
nextStep
);
}
}
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
}
else
{
}
else
{
...
...
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