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
1e2dc2d2
Commit
1e2dc2d2
authored
Dec 15, 2018
by
李进峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add nickname bug repair
parent
15fa3483
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
12 deletions
+56
-12
GameEnv.java
src/GameEnvironment/GameEnv.java
+32
-8
GoodsInstance.java
src/GameEnvironment/bean/GoodsInstance.java
+9
-2
NpcInstance.java
src/GameEnvironment/bean/NpcInstance.java
+15
-2
No files found.
src/GameEnvironment/GameEnv.java
View file @
1e2dc2d2
...
@@ -153,9 +153,15 @@ public class GameEnv implements Serializable{
...
@@ -153,9 +153,15 @@ public class GameEnv implements Serializable{
npcNames
.
put
(
instanceKey
,
(
String
)
instanceAttrMap
.
get
(
"name"
));
npcNames
.
put
(
instanceKey
,
(
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
npcInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
npcInstance
.
setNickname
((
List
<
String
>)
instanceAttrMap
.
get
(
"nickname"
));
List
<
Attr
>
npcInstanceAttrs
=
new
ArrayList
<
Attr
>();
List
<
Attr
>
npcInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(!
instanceAttrKey
.
equals
(
"name"
)&&!
instanceAttrKey
.
equals
(
"intro"
)&&!
instanceAttrKey
.
equals
(
"placeId"
)&&!
instanceAttrKey
.
equals
(
"placeName"
)&&!
instanceAttrKey
.
equals
(
"class"
))
{
if
(!
instanceAttrKey
.
equals
(
"name"
)
&&!
instanceAttrKey
.
equals
(
"intro"
)
&&!
instanceAttrKey
.
equals
(
"placeId"
)
&&!
instanceAttrKey
.
equals
(
"placeName"
)
&&!
instanceAttrKey
.
equals
(
"class"
)
&&!
instanceAttrKey
.
equals
(
"nickname"
))
{
Attr
attr
=
new
Attr
();
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
...
@@ -169,13 +175,15 @@ public class GameEnv implements Serializable{
...
@@ -169,13 +175,15 @@ public class GameEnv implements Serializable{
Place
place
=
null
;
Place
place
=
null
;
if
(
instanceAttrMap
.
get
(
"placeId"
)!=
null
)
{
if
(
instanceAttrMap
.
get
(
"placeId"
)!=
null
)
{
Map
<
String
,
Object
>
placeMap
=
(
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)));
Map
<
String
,
Object
>
placeMap
=
(
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)));
place
=
placeIndex
.
get
(
placeMap
.
get
(
"name"
));
if
(
placeMap
!=
null
)
{
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
place
=
placeIndex
.
get
(
placeMap
.
get
(
"name"
));
if
(
npcInstances
==
null
)
{
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
npcInstances
=
new
ArrayList
<
NpcInstance
>();
if
(
npcInstances
==
null
)
{
npcInstances
=
new
ArrayList
<
NpcInstance
>();
}
npcInstances
.
add
(
npcInstance
);
place
.
setNpcInstances
(
npcInstances
);
}
}
npcInstances
.
add
(
npcInstance
);
place
.
setNpcInstances
(
npcInstances
);
}
}
List
<
NpcInstance
>
npcInstanceClass
=
npcClass
.
getNpcInstances
();
List
<
NpcInstance
>
npcInstanceClass
=
npcClass
.
getNpcInstances
();
if
(
npcInstanceClass
==
null
)
{
if
(
npcInstanceClass
==
null
)
{
...
@@ -220,9 +228,14 @@ public class GameEnv implements Serializable{
...
@@ -220,9 +228,14 @@ public class GameEnv implements Serializable{
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
goodsInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
goodsInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
goodsInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
goodsInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
goodsInstance
.
setNickname
((
List
<
String
>)
instanceAttrMap
.
get
(
"nickname"
));
List
<
Attr
>
goodsInstanceAttrs
=
new
ArrayList
<
Attr
>();
List
<
Attr
>
goodsInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(
instanceAttrKey
!=
"placeId"
&&
instanceAttrKey
!=
"npcId"
&&
instanceAttrKey
!=
"name"
&&
instanceAttrKey
!=
"intro"
)
{
if
(
instanceAttrKey
!=
"placeId"
&&
instanceAttrKey
!=
"npcId"
&&
instanceAttrKey
!=
"name"
&&
instanceAttrKey
!=
"intro"
&&
instanceAttrKey
!=
"nickname"
)
{
Attr
attr
=
new
Attr
();
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
...
@@ -363,6 +376,17 @@ public class GameEnv implements Serializable{
...
@@ -363,6 +376,17 @@ public class GameEnv implements Serializable{
}
}
}
}
// 通过别名查询当前地点最近的npc
public
String
getNpcNameByNickname
(
String
curPlaceName
,
String
nickname
)
{
List
<
NpcInstance
>
npcInstances
=
this
.
placeIndex
.
get
(
curPlaceName
).
getNpcInstances
();
for
(
int
i
=
0
;
i
<
npcInstances
.
size
();
i
++)
{
NpcInstance
npcInstance
=
npcInstances
.
get
(
i
);
if
(
npcInstance
.
getNickname
().
indexOf
(
nickname
)>=
0
)
{
return
npcInstance
.
getName
();
}
}
return
nickname
;
}
// 两点之间的路径 // 使用广度优先算法单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。只有状态为2的时候使用
// 两点之间的路径 // 使用广度优先算法单源最短路的SPFA算法的全称是:Shortest Path Faster Algorithm。只有状态为2的时候使用
public
List
<
String
>
getAllPath
(
String
placeA
,
String
placeB
){
public
List
<
String
>
getAllPath
(
String
placeA
,
String
placeB
){
List
<
String
>
paths
=
new
ArrayList
<
String
>();
List
<
String
>
paths
=
new
ArrayList
<
String
>();
...
...
src/GameEnvironment/bean/GoodsInstance.java
View file @
1e2dc2d2
...
@@ -5,6 +5,7 @@ import java.util.List;
...
@@ -5,6 +5,7 @@ import java.util.List;
public
class
GoodsInstance
extends
SuperClass
implements
Serializable
{
public
class
GoodsInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
String
>
nickname
;
private
Place
place
;
private
Place
place
;
private
NpcInstance
npc
;
private
NpcInstance
npc
;
public
Place
getPlace
()
{
public
Place
getPlace
()
{
...
@@ -19,7 +20,13 @@ public class GoodsInstance extends SuperClass implements Serializable{
...
@@ -19,7 +20,13 @@ public class GoodsInstance extends SuperClass implements Serializable{
public
void
setNpc
(
NpcInstance
npc
)
{
public
void
setNpc
(
NpcInstance
npc
)
{
this
.
npc
=
npc
;
this
.
npc
=
npc
;
}
}
@Override
public
List
<
String
>
getNickname
()
{
return
nickname
;
}
public
void
setNickname
(
List
<
String
>
nickname
)
{
this
.
nickname
=
nickname
;
}
@Override
public
String
toString
()
{
public
String
toString
()
{
String
placeName
=
""
;
String
placeName
=
""
;
if
(
place
!=
null
)
{
if
(
place
!=
null
)
{
...
@@ -29,7 +36,7 @@ public class GoodsInstance extends SuperClass implements Serializable{
...
@@ -29,7 +36,7 @@ public class GoodsInstance extends SuperClass implements Serializable{
if
(
npc
!=
null
)
{
if
(
npc
!=
null
)
{
npcName
=
npc
.
getName
();
npcName
=
npc
.
getName
();
}
}
return
super
.
toString
()+
"GoodsInstance [placeName="
+
placeName
+
", npcName="
+
npcName
+
"]"
;
return
super
.
toString
()+
"GoodsInstance [placeName="
+
placeName
+
", npcName="
+
npcName
+
",nickname="
+
nickname
+
"]"
;
}
}
}
}
src/GameEnvironment/bean/NpcInstance.java
View file @
1e2dc2d2
...
@@ -5,21 +5,34 @@ import java.util.List;
...
@@ -5,21 +5,34 @@ import java.util.List;
public
class
NpcInstance
extends
SuperClass
implements
Serializable
{
public
class
NpcInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
String
>
nickname
;
private
Place
place
;
private
Place
place
;
private
List
<
GoodsInstance
>
goodsInstances
;
private
List
<
GoodsInstance
>
goodsInstances
;
public
List
<
String
>
getNickname
()
{
return
nickname
;
}
public
void
setNickname
(
List
<
String
>
nickname
)
{
this
.
nickname
=
nickname
;
}
public
Place
getPlace
()
{
public
Place
getPlace
()
{
return
place
;
return
place
;
}
}
public
void
setPlace
(
Place
place
)
{
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
this
.
place
=
place
;
}
}
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
return
goodsInstances
;
}
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
this
.
goodsInstances
=
goodsInstances
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
String
placeName
=
""
;
String
placeName
=
""
;
if
(
place
!=
null
)
{
if
(
place
!=
null
)
{
...
@@ -29,7 +42,7 @@ public class NpcInstance extends SuperClass implements Serializable{
...
@@ -29,7 +42,7 @@ public class NpcInstance extends SuperClass implements Serializable{
if
(
goodsInstances
!=
null
)
{
if
(
goodsInstances
!=
null
)
{
goodsInstancesSize
=
goodsInstances
.
size
();
goodsInstancesSize
=
goodsInstances
.
size
();
}
}
return
super
.
toString
()+
"NpcInstance [placeName="
+
placeName
+
", goodsInstancesSize="
+
goodsInstancesSize
+
"]"
;
return
super
.
toString
()+
"NpcInstance [placeName="
+
placeName
+
", goodsInstancesSize="
+
goodsInstancesSize
+
",nickname="
+
nickname
+
"]"
;
}
}
}
}
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