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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
630 additions
and
115 deletions
+630
-115
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
+0
-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
+0
-0
PlotConstructor.java
src/gameDesign/PlotConstructor.java
+54
-3
ChatCacheController.java
src/processing/ChatCacheController.java
+29
-18
ConditionTableController.java
src/processing/ConditionTableController.java
+10
-3
MyFunc.java
src/processing/MyFunc.java
+2
-0
QuestionMatcher.java
src/processing/QuestionMatcher.java
+21
-10
UserInfoController.java
src/processing/UserInfoController.java
+13
-2
WorldController.java
src/processing/WorldController.java
+56
-11
GameDesignServlet.java
src/servlet/GameDesignServlet.java
+20
-25
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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
{
gameEnv
=
(
GameEnv
)
ObjectFileUtil
.
readObjectFromFile
(
String
.
format
(
ENV_PATH
,
key
));
File
file
=
new
File
(
String
.
format
(
ENV_PATH
,
key
));
if
(
file
.
exists
()){
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
){
chatCache
=
new
ChatCache
(
userinfo
);
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
);
}
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
))
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
configId
);
try
{
try
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
configId
);
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
);
originCondition
=
userinfo
.
id2condition
.
get
(
configId
);
}
else
{
originCondition
=
userinfo
.
name2condition
.
get
(
configIdStr
);
}
configId
=
originCondition
.
id
;
configStr
=
userinfo
.
id2config
.
get
(
configId
);
if
(
configStr
!=
null
)
{
originCondition
=
userinfo
.
id2condition
.
get
(
configId
);
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
]);
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"就在附近哦"
;
else
{
returnStr
=
"通过"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"就在附近哦"
;
}
}
break
;
break
;
}
}
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有"
;
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"啥都没有"
;
}
}
}
}
}
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,19 +195,10 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -191,19 +195,10 @@ public class GameDesignServlet extends HttpServlet {
PrintWriter
out
=
response
.
getWriter
();
out
.
append
(
responseJSONObject
.
toString
());
out
.
flush
();
try
{
PrintWriter
out
=
response
.
getWriter
();
out
.
append
(
responseJSONObject
.
toString
());
}
catch
(
IOException
e
)
{
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