Skip to content

Commit

Permalink
fix json
Browse files Browse the repository at this point in the history
  • Loading branch information
bupt1987 committed Jul 1, 2016
1 parent a61e508 commit 0169bf2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Player extends BasePlayer {

private UserInfo userInfo;
private BasePosition oldPosition;
private Map<Integer, Integer> actionJson = new HashMap<>();
private Map<String, Integer> actionJson = new HashMap<>();

static {
levelExperience.put(1, 100);
Expand All @@ -42,8 +42,8 @@ public void init(UserInfo userInfo) {

actionJson = BaseJson.JsonToObject(userInfo.getActions(), Map.class);

for (Map.Entry<Integer, Integer> entry : actionJson.entrySet()) {
AttackAction attackAction = (AttackAction) ActionManager.getAction(entry.getKey());
for (Map.Entry<String, Integer> entry : actionJson.entrySet()) {
AttackAction attackAction = (AttackAction) ActionManager.getAction(Integer.parseInt(entry.getKey()));
attackAction.setLevel(entry.getValue());
this.addAction(attackAction);
}
Expand All @@ -64,7 +64,7 @@ private void upLevel(int level) {
IBaseAction action = entry.getValue();
if (action instanceof AttackAction) {
((AttackAction) action).setLevel(level);
actionJson.put(action.getId(), level);
actionJson.put(Integer.toString(action.getId()), level);
}
userInfo.setActions(BaseJson.ObjectToJson(actionJson));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public IBaseModel findByUid(int uid) {
}

public static String getDefaultActions() {
Map<Integer, Integer> actions = new HashMap<Integer, Integer>();
actions.put(AttackAction.ID, 1);
Map<String, Integer> actions = new HashMap<>();
actions.put(Integer.toString(AttackAction.ID), 1);
return BaseJson.ObjectToJson(actions);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/jgframework.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ service.threadCount=0
service.heartbeatTime=300000
#socket or websocket
service.mode=websocket
service.maxLoginUser=0
service.maxLoginUser=2

#auth
auth.port=18080
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var socket, sercret;
var socket, secret;
var sended = 0;
var player = null;
var pk_player_me_id = "";
Expand All @@ -7,7 +7,7 @@ var auth_url = "http://localhost:18080";

function initSocket(rs) {
sended = 0;
sercret = rs.result.sercret;
secret = rs.result.secret;
if (!window.WebSocket) {
window.WebSocket = window.MozWebSocket;
}
Expand All @@ -16,7 +16,7 @@ function initSocket(rs) {
open : function(event) {
$("#responseText").val("");
socket.send("init", {
sercret : sercret
secret : secret
});
},
close : function(event) {
Expand Down Expand Up @@ -202,4 +202,4 @@ $("#duel").click(function() {
socket.send("duel", {
uid : uid
});
});
});
5 changes: 2 additions & 3 deletions src/test/java/client/TestQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public static void main(String[] args) {
// queue.remove(list.get(i));
// }

int size = list.size();
for (int i = 0; i < size; i++) {
queue.remove(list.get(i));
for (BaseQueueElement<Integer> aList : list) {
queue.remove(aList);
}

// for (int i = 0; i < 10000000; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/client/TestRegist.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
public class TestRegist {

public static void main(String[] args) throws Exception {
for (int i = 10000; i <= 100000; i++) {
HashMap<String, Object> params = new HashMap<String, Object>();
for (int i = 10000; i <= 11000; i++) {
HashMap<String, Object> params = new HashMap<>();
params.put("username", "test" + i);
params.put("password", "123456");
params.put("nickname", "测试" + i + "号");
Expand Down

0 comments on commit 0169bf2

Please sign in to comment.