package com.qiwu.chatbotbackend.entity; import com.qiwu.chatbotbackend.GameEnvironment.GameEnv; import org.springframework.beans.factory.DisposableBean; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class ChatCache implements DisposableBean { public String ENV_ERROR = "游戏平台初始化失败"; // private String chatKey = "不知道"; private String userKey = ""; private String randKey = ""; private String botAccount = ""; private Map infoPoint = null; private GameEnv gameEnv = null; private Boolean gameStart = false; private Boolean reload = false; public String getBotAccount() { return botAccount; } public void setBotAccount(String botAccount) { this.botAccount = botAccount; } public String getUserKey() { return userKey; } public void setUserKey(String userKey) { this.userKey = userKey; } public String getRandKey() { return randKey; } public void setRandKey(String randKey) { this.randKey = randKey; } public Map getInfoPoint() { return infoPoint; } public void setInfoPoint(Map infoPoint) { this.infoPoint = infoPoint; } public boolean isGameStart() { return gameStart; } public void setGameStart(boolean gameStart) { this.gameStart = gameStart; } public Boolean getReload() { return reload; } public void setReload(Boolean reload) { this.reload = reload; } public GameEnv getGameEnv() { return gameEnv; } public void setGameEnv(GameEnv gameEnv) { this.gameEnv = gameEnv; } public ChatCache(String userKey, String randKey, GameEnv gameEnv, Map infoPoint) { this.userKey = userKey; this.randKey = randKey; this.gameEnv = gameEnv; this.infoPoint = infoPoint; } @Override public void destroy() throws IOException { } public ChatCache(UserInfo userInfo, String userKey, String randKey) throws Exception { try { gameEnv = new GameEnv(userInfo.botAccount); } catch (Exception e) { System.out.println(ENV_ERROR); infoPoint.put("error_message", ENV_ERROR); e.printStackTrace(); } String k; this.botAccount = userInfo.botAccount; infoPoint = new HashMap(); Iterator iit = userInfo.varInitialMap.keySet().iterator(); while (iit.hasNext()) { k = iit.next(); infoPoint.put(k, userInfo.varInitialMap.get(k)); } infoPoint.put("lastUpdateTime", String.valueOf(System.currentTimeMillis())); this.randKey = randKey; this.userKey = userKey; } public ChatCache(String userKey, String randKey) { this.userKey = userKey; this.randKey = randKey; } }