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
d70969e1
Commit
d70969e1
authored
Dec 01, 2018
by
hxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
routine
parent
2f713101
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
290 additions
and
48 deletions
+290
-48
ChatCache.java
src/entity/ChatCache.java
+1
-0
JConfig.java
src/entity/JConfig.java
+137
-4
CharacterConstructor.java
src/gameDesign/CharacterConstructor.java
+20
-3
ElementConstructor.java
src/gameDesign/ElementConstructor.java
+4
-2
GlobalVariableConstructor.java
src/gameDesign/GlobalVariableConstructor.java
+5
-2
ItemConstructor.java
src/gameDesign/ItemConstructor.java
+16
-3
MapConstructor.java
src/gameDesign/MapConstructor.java
+0
-0
PlotConstructor.java
src/gameDesign/PlotConstructor.java
+0
-0
ChatCacheController.java
src/processing/ChatCacheController.java
+3
-3
QuestionMatcher.java
src/processing/QuestionMatcher.java
+21
-5
WorldController.java
src/processing/WorldController.java
+47
-6
GameDesignServlet.java
src/servlet/GameDesignServlet.java
+35
-19
GetAnswerServlet.java
src/servlet/GetAnswerServlet.java
+1
-1
No files found.
src/entity/ChatCache.java
View file @
d70969e1
...
@@ -59,6 +59,7 @@ public class ChatCache {
...
@@ -59,6 +59,7 @@ public class ChatCache {
k
=
iit
.
next
();
k
=
iit
.
next
();
infoPoint
.
put
(
k
,
userInfo
.
varInitialMap
.
get
(
k
));
infoPoint
.
put
(
k
,
userInfo
.
varInitialMap
.
get
(
k
));
}
}
infoPoint
.
put
(
"lastUpdateTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
}
}
}
}
src/entity/JConfig.java
View file @
d70969e1
...
@@ -8,7 +8,7 @@ import java.util.Iterator;
...
@@ -8,7 +8,7 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
class
JConfig
{
public
class
JConfig
implements
Cloneable
{
private
int
id
=
0
;
private
int
id
=
0
;
private
String
jCurPremise
=
""
;
private
String
jCurPremise
=
""
;
...
@@ -69,6 +69,98 @@ public class JConfig {
...
@@ -69,6 +69,98 @@ public class JConfig {
private
String
status
=
"waiting"
;
private
String
status
=
"waiting"
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getjCurPremise
()
{
return
jCurPremise
;
}
public
void
setjCurPremise
(
String
jCurPremise
)
{
this
.
jCurPremise
=
jCurPremise
;
}
public
String
getjHisPremise
()
{
return
jHisPremise
;
}
public
void
setjHisPremise
(
String
jHisPremise
)
{
this
.
jHisPremise
=
jHisPremise
;
}
public
String
getjFeature
()
{
return
jFeature
;
}
public
void
setjFeature
(
String
jFeature
)
{
this
.
jFeature
=
jFeature
;
}
public
String
getjNextStep
()
{
return
jNextStep
;
}
public
void
setjNextStep
(
String
jNextStep
)
{
this
.
jNextStep
=
jNextStep
;
}
public
String
getjReply
()
{
return
jReply
;
}
public
void
setjReply
(
String
jReply
)
{
this
.
jReply
=
jReply
;
}
public
String
getjAuxiliaryPriority
()
{
return
jAuxiliaryPriority
;
}
public
void
setjAuxiliaryPriority
(
String
jAuxiliaryPriority
)
{
this
.
jAuxiliaryPriority
=
jAuxiliaryPriority
;
}
public
int
getjStatus
()
{
return
jStatus
;
}
public
void
setCurPremise
(
String
curPremise
)
{
this
.
curPremise
=
curPremise
;
}
public
String
getHisPremise
()
{
return
hisPremise
;
}
public
void
setHisPremise
(
String
hisPremise
)
{
this
.
hisPremise
=
hisPremise
;
}
public
String
getReply
()
{
return
reply
;
}
public
void
setReply
(
String
reply
)
{
this
.
reply
=
reply
;
}
public
String
getAuxiliaryPriority
()
{
return
auxiliaryPriority
;
}
public
String
getStatus
()
{
return
status
;
}
public
String
getNextStepStatus
()
{
return
nextStepStatus
;
}
public
String
getUpdateKnowledge
()
{
public
String
getUpdateKnowledge
()
{
return
updateKnowledge
;
return
updateKnowledge
;
}
}
...
@@ -80,14 +172,15 @@ public class JConfig {
...
@@ -80,14 +172,15 @@ public class JConfig {
private
String
updateKnowledge
=
""
;
private
String
updateKnowledge
=
""
;
private
String
nextStepStatus
=
"return"
;
private
String
nextStepStatus
=
"return"
;
Map
<
String
,
String
>
statusMap
=
new
HashMap
<
String
,
String
>()
{
static
Map
<
String
,
String
>
statusMap
=
new
HashMap
<
String
,
String
>()
{
{
{
put
(
"return"
,
"return"
);
put
(
"return"
,
"return"
);
put
(
"return-1"
,
"back"
);
put
(
"return-1"
,
"back"
);
put
(
"return-0"
,
"stay"
);
put
(
"return-0"
,
"stay"
);
put
(
"active"
,
"activate"
);
put
(
"activ
at
e"
,
"activate"
);
}
}
};
};
static
int
querySkipCount
=
10
;
public
void
setStatus
(
String
status
)
{
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
this
.
status
=
status
;
...
@@ -252,7 +345,7 @@ public class JConfig {
...
@@ -252,7 +345,7 @@ public class JConfig {
data
.
put
(
"historyPremiseList"
,
hisPremiseList
);
data
.
put
(
"historyPremiseList"
,
hisPremiseList
);
//添加下一步状态
//添加下一步状态
data
.
put
(
"nextStepStatus"
,
statusMap
.
get
(
nextStepStatus
));
//添加configName
//添加configName
data
.
put
(
"configName"
,
configName
);
data
.
put
(
"configName"
,
configName
);
...
@@ -270,8 +363,15 @@ public class JConfig {
...
@@ -270,8 +363,15 @@ public class JConfig {
pair
=
feat
.
substring
(
0
,
feat
.
length
()
-
1
).
split
(
"\\("
,
2
);
pair
=
feat
.
substring
(
0
,
feat
.
length
()
-
1
).
split
(
"\\("
,
2
);
postURL
=
pair
[
1
];
postURL
=
pair
[
1
];
postType
=
pair
[
0
].
split
(
"::"
)[
1
];
postType
=
pair
[
0
].
split
(
"::"
)[
1
];
}
else
if
(
feat
.
equals
(
"return-0"
)){
nextStepStatus
=
"return-0"
;
}
else
if
(
feat
.
equals
(
"activate"
)){
nextStepStatus
=
"activate"
;
}
}
}
}
data
.
put
(
"nextStepStatus"
,
statusMap
.
get
(
nextStepStatus
));
//添加post参数
//添加post参数
data
.
put
(
"doPost"
,
doPost
);
data
.
put
(
"doPost"
,
doPost
);
data
.
put
(
"postURL"
,
postURL
);
data
.
put
(
"postURL"
,
postURL
);
...
@@ -319,4 +419,37 @@ public class JConfig {
...
@@ -319,4 +419,37 @@ public class JConfig {
return
text
;
return
text
;
}
}
public
Object
clone
()
{
Object
o
=
null
;
try
{
o
=
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
){
System
.
out
.
println
(
e
.
toString
());
}
return
o
;
}
public
static
JConfig
activateCopy
(
JConfig
jConfig
){
JConfig
jConfig2
=
(
JConfig
)
jConfig
.
clone
();
jConfig2
.
setReply
(
jConfig2
.
getReply
()
+
",{临时变量2-2}"
);
jConfig2
.
setUpdateKnowledge
(
jConfig2
.
getUpdateKnowledge
()
+
"-<-process-nextStep:var={临时变量1-2}"
);
jConfig2
.
setStatus
(
"sleeping"
);
jConfig2
.
setConfigName
(
"queryskip"
+
String
.
valueOf
(
querySkipCount
));
querySkipCount
++;
jConfig2
.
setjStatus
(
1
);
jConfig2
.
setAuxiliaryPriority
(
"2"
);
return
jConfig2
;
}
public
static
JConfig
simpleCopy
(
JConfig
jConfig
){
JConfig
jConfig2
=
(
JConfig
)
jConfig
.
clone
();
return
jConfig2
;
}
}
}
src/gameDesign/CharacterConstructor.java
View file @
d70969e1
...
@@ -10,11 +10,14 @@ import java.util.*;
...
@@ -10,11 +10,14 @@ import java.util.*;
public
class
CharacterConstructor
extends
ElementConstructor
{
public
class
CharacterConstructor
extends
ElementConstructor
{
public
CharacterConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
public
CharacterConstructor
(
SqlHelper
helper
,
int
botId
,
int
skipCount
,
String
botAccount
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
botAccount
=
botAccount
;
this
.
exceptRelation
=
exceptRelation
;
this
.
exceptRelation
=
exceptRelation
;
this
.
skipCount
=
skipCount
;
this
.
POS
=
POS
;
}
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
...
@@ -50,7 +53,11 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -50,7 +53,11 @@ public class CharacterConstructor extends ElementConstructor {
for
(
JSONObject
character
:
allNPC
.
toJavaList
(
JSONObject
.
class
))
{
for
(
JSONObject
character
:
allNPC
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
character
.
get
(
"name"
);
name
=
(
String
)
character
.
get
(
"name"
);
if
(!
name
.
equals
(
""
))
POS
.
append
(
"="
+
name
+
"|人名\r\n"
);
className
=
(
String
)
character
.
get
(
"class"
);
className
=
(
String
)
character
.
get
(
"class"
);
if
(!
className
.
equals
(
""
))
POS
.
append
(
"="
+
className
+
"|人名\r\n"
);
if
(!
classSet
.
contains
(
className
))
{
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
classSet
.
add
(
className
);
...
@@ -64,6 +71,8 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -64,6 +71,8 @@ public class CharacterConstructor extends ElementConstructor {
keywords
.
append
(
"+"
+
repValue
);
keywords
.
append
(
"+"
+
repValue
);
while
(
attrIter
.
hasNext
())
{
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrName
=
attrIter
.
next
();
if
(!
attrName
.
equals
(
""
))
POS
.
append
(
"="
+
attrName
+
"|名词\r\n"
);
attrValue
=
attribute
.
get
(
attrName
);
attrValue
=
attribute
.
get
(
attrName
);
}
}
...
@@ -75,17 +84,25 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -75,17 +84,25 @@ public class CharacterConstructor extends ElementConstructor {
for
(
String
conditionName
:
relateConditions
)
{
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAttrByNPCName:"
+
conditionName
"match,return-0"
,
"
【{智能助手-2}】
{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAttrByNPCName:"
+
conditionName
);
);
jConfig
.
setAuxiliaryPriority
(
"1"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
//根据根据NPC类别和地点属性查询所有NPC实例
//根据根据NPC类别和地点属性查询所有NPC实例
for
(
String
conditionName
:
relateConditions
)
{
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAroundNpcByClassName:"
+
conditionName
"match,return-0"
,
"
【{智能助手-2}】
{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAroundNpcByClassName:"
+
conditionName
);
);
jConfig
.
setAuxiliaryPriority
(
"1"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
operationStatus
=
0
;
operationStatus
=
0
;
...
...
src/gameDesign/ElementConstructor.java
View file @
d70969e1
...
@@ -16,11 +16,12 @@ public class ElementConstructor {
...
@@ -16,11 +16,12 @@ public class ElementConstructor {
int
operationStatus
=
1
;
int
operationStatus
=
1
;
int
skipCount
=
0
;
SqlHelper
helper
=
null
;
SqlHelper
helper
=
null
;
HashSet
<
String
>
exceptRelation
=
null
;
HashSet
<
String
>
exceptRelation
=
null
;
JConfig
jConfig
=
null
;
JConfig
jConfig
=
null
;
String
CHITCHAT_URL
=
"http:192.168.1.178:1111/test"
;
String
CHITCHAT_URL
=
"http:192.168.1.178:1111/test"
;
String
userName
;
String
botAccount
;
...
@@ -32,6 +33,7 @@ public class ElementConstructor {
...
@@ -32,6 +33,7 @@ public class ElementConstructor {
StringBuffer
configText
=
new
StringBuffer
();
StringBuffer
configText
=
new
StringBuffer
();
Map
<
String
,
String
>
varInitialMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
varInitialMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
conditionDescription
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
conditionDescription
=
new
HashMap
<
String
,
String
>();
StringBuffer
POS
=
new
StringBuffer
();
public
String
getMessage
()
{
return
message
;
}
public
String
getMessage
()
{
return
message
;
}
...
@@ -57,7 +59,7 @@ public class ElementConstructor {
...
@@ -57,7 +59,7 @@ public class ElementConstructor {
}
}
public
void
ElementConstructor
(
String
userName
)
{
public
void
ElementConstructor
(
String
userName
)
{
this
.
userName
=
userName
;
this
.
botAccount
=
botAccount
;
}
}
public
String
getConfigText
()
{
public
String
getConfigText
()
{
...
...
src/gameDesign/GlobalVariableConstructor.java
View file @
d70969e1
...
@@ -12,11 +12,14 @@ import java.util.Map;
...
@@ -12,11 +12,14 @@ import java.util.Map;
public
class
GlobalVariableConstructor
extends
ElementConstructor
{
public
class
GlobalVariableConstructor
extends
ElementConstructor
{
public
GlobalVariableConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
public
GlobalVariableConstructor
(
SqlHelper
helper
,
int
botId
,
int
skipCount
,
String
botAccount
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
botAccount
=
botAccount
;
this
.
exceptRelation
=
exceptRelation
;
this
.
exceptRelation
=
exceptRelation
;
this
.
skipCount
=
skipCount
;
this
.
POS
=
POS
;
}
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
...
@@ -34,7 +37,7 @@ public class GlobalVariableConstructor extends ElementConstructor {
...
@@ -34,7 +37,7 @@ public class GlobalVariableConstructor extends ElementConstructor {
while
(
attrIter
.
hasNext
())
{
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrName
=
attrIter
.
next
();
attrValue
=
attribute
.
get
(
attrName
);
attrValue
=
attribute
.
get
(
attrName
);
varInitialMap
.
put
(
category
+
"_"
+
attrName
,
attrValue
);
varInitialMap
.
put
(
attrName
,
attrValue
);
}
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
...
src/gameDesign/ItemConstructor.java
View file @
d70969e1
...
@@ -11,11 +11,15 @@ import java.util.*;
...
@@ -11,11 +11,15 @@ import java.util.*;
public
class
ItemConstructor
extends
ElementConstructor
{
public
class
ItemConstructor
extends
ElementConstructor
{
public
ItemConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
public
ItemConstructor
(
SqlHelper
helper
,
int
botId
,
int
skipCount
,
String
botAccount
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
botAccount
=
botAccount
;
this
.
exceptRelation
=
exceptRelation
;
this
.
exceptRelation
=
exceptRelation
;
this
.
skipCount
=
skipCount
;
this
.
POS
=
POS
;
}
}
...
@@ -46,7 +50,11 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -46,7 +50,11 @@ public class ItemConstructor extends ElementConstructor {
for
(
JSONObject
good
:
goods
.
toJavaList
(
JSONObject
.
class
))
{
for
(
JSONObject
good
:
goods
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
good
.
get
(
"name"
);
name
=
(
String
)
good
.
get
(
"name"
);
if
(!
name
.
equals
(
""
))
POS
.
append
(
"="
+
name
+
"|名词\r\n"
);
className
=
(
String
)
good
.
get
(
"class"
);
className
=
(
String
)
good
.
get
(
"class"
);
if
(!
className
.
equals
(
""
))
POS
.
append
(
"="
+
className
+
"|名词\r\n"
);
if
(!
classSet
.
contains
(
className
))
{
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
classSet
.
add
(
className
);
...
@@ -58,6 +66,9 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -58,6 +66,9 @@ public class ItemConstructor extends ElementConstructor {
attrIter
=
attribute
.
keySet
().
iterator
();
attrIter
=
attribute
.
keySet
().
iterator
();
while
(
attrIter
.
hasNext
())
{
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrName
=
attrIter
.
next
();
if
(!
attrName
.
equals
(
""
))
POS
.
append
(
"="
+
attrName
+
"|名词\r\n"
);
attrValue
=
attribute
.
get
(
attrName
);
attrValue
=
attribute
.
get
(
attrName
);
keywords
.
append
(
"+"
+
name
+
":"
+
attrName
);
keywords
.
append
(
"+"
+
name
+
":"
+
attrName
);
...
@@ -71,10 +82,11 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -71,10 +82,11 @@ public class ItemConstructor extends ElementConstructor {
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"match,return-0"
,
"{goods_query-2}"
,
"
【{智能助手-2}】
{goods_query-2}"
,
" "
,
" "
,
"goods_query:queryAttrByGoodsName:"
+
conditionName
"goods_query:queryAttrByGoodsName:"
+
conditionName
);
);
jConfig
.
setAuxiliaryPriority
(
"1"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
@@ -83,10 +95,11 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -83,10 +95,11 @@ public class ItemConstructor extends ElementConstructor {
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"match,return-0"
,
"{goods_query-2}"
,
"
【{智能助手-2}】
{goods_query-2}"
,
" "
,
" "
,
"goods_query:queryAroundGoodsByClassName:"
+
conditionName
"goods_query:queryAroundGoodsByClassName:"
+
conditionName
);
);
jConfig
.
setAuxiliaryPriority
(
"1"
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
...
src/gameDesign/MapConstructor.java
View file @
d70969e1
This diff is collapsed.
Click to expand it.
src/gameDesign/PlotConstructor.java
View file @
d70969e1
This diff is collapsed.
Click to expand it.
src/processing/ChatCacheController.java
View file @
d70969e1
...
@@ -19,7 +19,7 @@ import java.util.Map;
...
@@ -19,7 +19,7 @@ import java.util.Map;
public
class
ChatCacheController
{
public
class
ChatCacheController
{
public
static
long
TIME_OUT
=
5
000
;
public
static
long
TIME_OUT
=
300
000
;
private
static
String
CHAT_CACHE_DIR
=
"ChatCache"
;
private
static
String
CHAT_CACHE_DIR
=
"ChatCache"
;
...
@@ -189,8 +189,8 @@ public class ChatCacheController {
...
@@ -189,8 +189,8 @@ 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
(
"开始游戏"
)
||
if
(
receiveParamters
.
containsKey
(
"
start_options"
)
&&
(
receiveParamters
.
get
(
"start_options
"
)[
0
].
contains
(
"开始游戏"
)
||
receiveParamters
.
get
(
"
yaobuyao"
)[
0
].
contains
(
"继续游戏"
)||
receiveParamters
.
get
(
"yaobuyao"
)[
0
].
contains
(
"开始
"
)))
{
receiveParamters
.
get
(
"
start_options"
)[
0
].
contains
(
"继续游戏"
)||
receiveParamters
.
get
(
"start_options"
)[
0
].
contains
(
"继续
"
)))
{
chatCache
=
loadChatCache
(
chatKey
,
context
,
userinfo
,
loadCacheStatus
);
chatCache
=
loadChatCache
(
chatKey
,
context
,
userinfo
,
loadCacheStatus
);
}
else
{
}
else
{
chatCache
=
new
ChatCache
(
userinfo
);
chatCache
=
new
ChatCache
(
userinfo
);
...
...
src/processing/QuestionMatcher.java
View file @
d70969e1
...
@@ -336,8 +336,15 @@ public class QuestionMatcher {
...
@@ -336,8 +336,15 @@ public class QuestionMatcher {
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"
)){
}
else
if
(
actionName
.
startsWith
(
"isNeighbour"
)){
//keyword = gameEnv.isNeighbour(historyInfoPoint.get("site"), actionName.split(":")[1]);
String
opPair
[]
=
actionName
.
split
(
":"
);
if
(!
curInfoPoint
.
containsKey
(
opPair
[
1
])
||
curInfoPoint
.
get
(
opPair
[
1
]).
equals
(
"unknown"
)){
keyword
=
"not_exist"
;
}
else
{
logWriter
.
record
(
"isNeighbour("
+
historyInfoPoint
.
get
(
"site"
)
+
","
+
curInfoPoint
.
get
(
opPair
[
1
]).
split
(
":"
)[
1
]
+
")"
,
1
);
keyword
=
String
.
valueOf
(
gameEnv
.
isNeighbour
(
historyInfoPoint
.
get
(
"site"
),
curInfoPoint
.
get
(
opPair
[
1
]).
split
(
":"
)[
1
]));
logWriter
.
record
(
"返回:"
+
keyword
,
1
);
}
}
else
{
}
else
{
keyword
=
infoPoint
.
get
(
actionName
);
keyword
=
infoPoint
.
get
(
actionName
);
...
@@ -735,7 +742,10 @@ public class QuestionMatcher {
...
@@ -735,7 +742,10 @@ public class QuestionMatcher {
//停留
//停留
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"return-0"
))
{
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"return-0"
))
{
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
1
]);
if
(
activeList
.
length
>
0
)
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
1
]);
else
ans
.
setNext
(
"nextStep= "
);
//激活
//激活
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
))
{
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
))
{
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
...
@@ -759,13 +769,19 @@ public class QuestionMatcher {
...
@@ -759,13 +769,19 @@ public class QuestionMatcher {
//用正则表达式将回答中的变量模板{conditionName-2}替换成后台存储的变量值
//用正则表达式将回答中的变量模板{conditionName-2}替换成后台存储的变量值
String
keyword
;
reply
=
ans
.
getAnswer
();
reply
=
ans
.
getAnswer
();
Matcher
m
=
replacePattern
.
matcher
(
reply
);
Matcher
m
=
replacePattern
.
matcher
(
reply
);
while
(
m
.
find
())
{
while
(
m
.
find
())
{
variable
=
m
.
group
(
1
).
substring
(
1
,
m
.
group
(
1
).
length
()
-
3
);
variable
=
m
.
group
(
1
).
substring
(
1
,
m
.
group
(
1
).
length
()
-
3
);
if
(
m
.
group
(
1
).
endsWith
(
"-1}"
))
{
if
(
m
.
group
(
1
).
endsWith
(
"-1}"
))
{
if
(
curInfoPoint
.
get
(
variable
)
!=
null
&&
!
curInfoPoint
.
get
(
variable
).
equals
(
""
))
if
(
curInfoPoint
.
get
(
variable
)
!=
null
&&
!
curInfoPoint
.
get
(
variable
).
equals
(
""
))
{
reply
=
reply
.
replace
(
"{"
+
variable
+
"-1}"
,
curInfoPoint
.
get
(
variable
));
keyword
=
curInfoPoint
.
get
(
variable
);
if
(
keyword
.
contains
(
":"
))
keyword
=
keyword
.
split
(
":"
)[
1
];
reply
=
reply
.
replace
(
"{"
+
variable
+
"-1}"
,
keyword
);
}
}
else
if
(
m
.
group
(
1
).
endsWith
(
"-2}"
))
{
}
else
if
(
m
.
group
(
1
).
endsWith
(
"-2}"
))
{
if
(
historyInfoPoint
.
get
(
variable
)
!=
null
)
if
(
historyInfoPoint
.
get
(
variable
)
!=
null
)
if
(
historyInfoPoint
.
get
(
variable
).
equals
(
"do_reset"
)){
if
(
historyInfoPoint
.
get
(
variable
).
equals
(
"do_reset"
)){
...
...
src/processing/WorldController.java
View file @
d70969e1
...
@@ -130,28 +130,69 @@ public class WorldController {
...
@@ -130,28 +130,69 @@ public class WorldController {
}
}
break
;
break
;
case
"queryCanGoBySite"
:
case
"queryCanGoBySite"
:
if
(!
currentInfoPoint
.
containsKey
(
valuePair
[
1
]))
{
returnStr
=
"不可到达"
;
break
;
}
sites
=
gameEnv
.
queryCanGoBySite
(
historyInfoPoint
.
get
(
"site"
));
sites
=
gameEnv
.
queryCanGoBySite
(
historyInfoPoint
.
get
(
"site"
));
if
(
sites
==
null
||
sites
.
size
()
==
0
)
if
(
sites
==
null
)
{
returnStr
=
"没什么地方可去的,继续玩吧"
;
returnStr
=
"没什么地方可去的,继续玩吧"
;
else
{
}
else
if
(
sites
.
size
()
==
0
){
returnStr
=
"没什么地方可去的,继续玩吧"
;
}
else
{
returnStr
=
"可以去"
;
returnStr
=
"可以去"
;
if
(
sites
.
size
()
>
0
)
{
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
returnStr
+=
"、"
+
site
;
System
.
out
.
println
(
"returnStr"
+
returnStr
);
}
else
{
}
else
{
returnStr
=
"没什么地方可去的,继续玩吧"
;
returnStr
=
"没什么地方可去的,继续玩吧"
;
}
}
}
}
break
;
break
;
case
"queryPathBySite"
:
case
"queryHowToPathBySite"
:
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
if
(!
currentInfoPoint
.
containsKey
(
valuePair
[
1
]))
{
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"不可到达"
;
break
;
}
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
)[
1
]);
if
(
sites
==
null
)
{
returnStr
=
"不可到达"
;
}
else
if
(
sites
.
size
()
==
0
){
returnStr
=
"就在附近哦"
;
returnStr
=
"就在附近哦"
;
else
{
}
else
{
returnStr
=
"通过"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
returnStr
+=
"可以到达"
;
}
else
{
returnStr
=
"就在附近哦"
;
}
}
break
;
case
"queryToDoPathBySite"
:
if
(!
currentInfoPoint
.
containsKey
(
valuePair
[
1
]))
{
returnStr
=
"不可到达"
;
break
;
}
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
)[
1
]);
if
(
sites
==
null
)
{
returnStr
=
"不可到达"
;
}
else
if
(
sites
.
size
()
==
0
){
returnStr
=
"就在附近哦"
;
}
else
{
returnStr
=
"通过"
;
returnStr
=
"通过"
;
if
(
sites
.
size
()
>
0
)
{
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
returnStr
+=
"、"
+
site
;
returnStr
+=
"可以到达"
;
}
else
{
}
else
{
returnStr
=
"就在附近哦"
;
returnStr
=
"就在附近哦"
;
}
}
...
...
src/servlet/GameDesignServlet.java
View file @
d70969e1
...
@@ -35,15 +35,23 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -35,15 +35,23 @@ public class GameDesignServlet extends HttpServlet {
}
}
};
};
//每个condition的三元组两端需要补充的关键词,比如npc名字、npc属性等
HashMap
<
String
,
HashSet
<
String
>>
relationKeywords
=
new
HashMap
<
String
,
HashSet
<
String
>>();
//特定的relation的三元组不会被添加到relationKeywords
HashSet
<
String
>
exceptRelation
=
new
HashSet
<
String
>();
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
//所有需要修改的词性
StringBuffer
POS
=
new
StringBuffer
();
//每个condition的三元组两端需要补充的关键词,比如npc名字、npc属性等
HashMap
<
String
,
HashSet
<
String
>>
relationKeywords
=
new
HashMap
<
String
,
HashSet
<
String
>>();
//特定的relation的三元组不会被添加到relationKeywords
HashSet
<
String
>
exceptRelation
=
new
HashSet
<
String
>();
Integer
botId
,
projectId
,
dataId
,
returnStatus
=
1
;
Integer
botId
,
projectId
,
dataId
,
returnStatus
=
1
;
String
botAccount
=
null
,
moduleName
,
userName
,
moduleName2
,
returnMessage
=
"Success"
;
String
botAccount
=
null
,
userName
,
moduleName2
,
returnMessage
=
"Success"
;
ServletContext
context
=
this
.
getServletContext
();
ServletContext
context
=
this
.
getServletContext
();
JSONObject
json
=
null
,
root
=
null
;
JSONObject
json
=
null
,
root
=
null
;
Boolean
flag
;
Boolean
flag
;
...
@@ -95,37 +103,38 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -95,37 +103,38 @@ public class GameDesignServlet extends HttpServlet {
}
}
Iterator
<
String
>
moduleIter
=
gameElements
.
keySet
().
iterator
();
StringBuffer
mergedConfigText
=
new
StringBuffer
();
StringBuffer
mergedConfigText
=
new
StringBuffer
();
while
(
moduleIter
.
hasNext
())
{
int
skipCount
=
0
;
String
moduleList
[]
=
{
"map"
,
"goods"
,
"globalVariable"
,
"npc"
,
"plots"
};
for
(
String
moduleName:
moduleList
){
moduleName
=
moduleIter
.
next
();
switch
(
moduleName
)
{
switch
(
moduleName
)
{
case
"map"
:
case
"map"
:
moduleName2
=
"地图"
;
moduleName2
=
"地图"
;
constructor
=
new
MapConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
=
new
MapConstructor
(
helper
,
botId
,
skipCount
,
botAccount
,
exceptRelation
,
POS
);
constructor
.
construct
(
gameElements
,
userinfo
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"plots"
:
case
"plots"
:
moduleName2
=
"剧情"
;
moduleName2
=
"剧情"
;
constructor
=
new
PlotConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
=
new
PlotConstructor
(
helper
,
botId
,
skipCount
,
botAccount
,
exceptRelation
,
POS
);
constructor
.
construct
(
gameElements
,
userinfo
);
constructor
.
construct
(
gameElements
,
userinfo
);
root
=
((
PlotConstructor
)
constructor
).
getId2j
().
get
((
String
)
gameElements
.
get
(
"start"
));
root
=
((
PlotConstructor
)
constructor
).
getId2j
().
get
((
String
)
gameElements
.
get
(
"start"
));
break
;
break
;
case
"goods"
:
case
"goods"
:
moduleName2
=
"物品"
;
moduleName2
=
"物品"
;
constructor
=
new
ItemConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
=
new
ItemConstructor
(
helper
,
botId
,
skipCount
,
botAccount
,
exceptRelation
,
POS
);
constructor
.
construct
(
gameElements
,
userinfo
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"globalVaria
lb
e"
:
case
"globalVaria
bl
e"
:
moduleName2
=
"全局变量"
;
moduleName2
=
"全局变量"
;
constructor
=
new
GlobalVariableConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
=
new
GlobalVariableConstructor
(
helper
,
botId
,
skipCount
,
botAccount
,
exceptRelation
,
POS
);
constructor
.
construct
(
gameElements
,
userinfo
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"npc"
:
case
"npc"
:
moduleName2
=
"NPC"
;
moduleName2
=
"NPC"
;
constructor
=
new
CharacterConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
=
new
CharacterConstructor
(
helper
,
botId
,
skipCount
,
botAccount
,
exceptRelation
,
POS
);
constructor
.
construct
(
gameElements
,
userinfo
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
default
:
default
:
...
@@ -166,7 +175,7 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -166,7 +175,7 @@ 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
);
String
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
);
String
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
,
relationKeywords
,
exceptRelation
,
POS
);
if
(!
postResult
.
equals
(
"success"
)){
if
(!
postResult
.
equals
(
"success"
)){
returnStatus
=
0
;
returnStatus
=
0
;
...
@@ -221,22 +230,29 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -221,22 +230,29 @@ public class GameDesignServlet extends HttpServlet {
return
deleteConfigFlag
&&
deleteVariableFlag
;
return
deleteConfigFlag
&&
deleteVariableFlag
;
}
}
public
String
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
){
public
String
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
,
HashMap
<
String
,
HashSet
<
String
>>
relationKeywords
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
){
String
startCondition
;
String
startCondition
,
POS2
=
""
;
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
();
System
.
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"
,
"start_options"
);
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
actionPostData
.
put
(
"botName"
,
botName
);
actionPostData
.
put
(
"botName"
,
botName
);
actionPostData
.
put
(
"botId"
,
(
Integer
)
gameElements
.
get
(
"botId"
));
actionPostData
.
put
(
"botId"
,
(
Integer
)
gameElements
.
get
(
"botId"
));
actionPostData
.
put
(
"type"
,
"game_plot_init"
);
actionPostData
.
put
(
"type"
,
"game_plot_init"
);
actionPostData
.
put
(
"welcome"
,
(
String
)
gameElements
.
get
(
"plotStartText"
)
);
actionPostData
.
put
(
"welcome"
,
"欢迎来到"
+
(
String
)
gameElements
.
get
(
"botName"
)
+
",请说开始游戏或者继续游戏"
);
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
if
(
gameElements
.
containsKey
(
"POS"
))
POS2
=
(
String
)
gameElements
.
get
(
"POS"
);
actionPostData
.
put
(
"POS"
,
POS
.
toString
()
+
POS2
);
System
.
out
.
println
(
actionPostData
.
toJSONString
());
System
.
out
.
println
(
actionPostData
.
toJSONString
());
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
...
...
src/servlet/GetAnswerServlet.java
View file @
d70969e1
...
@@ -35,7 +35,7 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -35,7 +35,7 @@ public class GetAnswerServlet extends HttpServlet {
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
,
chatKey
=
""
;
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
,
chatKey
=
""
;
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
].
split
(
"
-
"
)[
0
];
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
].
split
(
"
@
"
)[
0
];
receiveParamters
.
get
(
"chat_key"
)[
0
]
=
chatKey
;
receiveParamters
.
get
(
"chat_key"
)[
0
]
=
chatKey
;
OutputStream
out
=
response
.
getOutputStream
();
OutputStream
out
=
response
.
getOutputStream
();
...
...
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