/** 加仇敌 */ public void addEnemy(int enemyId) { Enemy enemy = new Enemy(); enemy.setEnemyId(enemyId); enemy.setMyId(player.getId()); enemy.setAttackTime(TimeUtils.nowLong()); enemy.setReason( "用户:" + enemyId + " 于 " + TimeUtils.addSecond(enemy.getAttackTime(), 0) + " 攻击我!"); gameDao.getRelationDAO().addEnemy(enemy); emyMgr.put(enemyId, enemy); // 添加缓存 }
public boolean add2List(OnlineTime ot) { if (TimeUtils.isSameDay(date.getTime(), ot.getTimestamp().getTime())) { // 如果有当天数据 list.add(ot); return true; } else { return false; } }
/** 添加 好友申请 */ public TipUtil addFriend(int friendId) { TipUtil tip = new TipUtil(ProcotolType.FRIEND_RESP); if (I18nGreeting.LANLANGUAGE_TIPS == 1) { tip.setFailTip("Add failed."); } else { tip.setFailTip("添加失败"); } // logger.info("[addFriend]添加好友 : " + friendId); if (friMgr.get(friendId) == null) { // add friend type = 0 Friend friend = new Friend(); friend.setFriendId(friendId); friend.setMyId(player.getId()); friend.setType((byte) 2); friend.setAddTime(TimeUtils.nowLong()); gameDao.getRelationDAO().addFriend(friend); friend.setIsdel((byte) 0); friMgr.put(friendId, friend); // logger.info("[addFriend]" + MessageConst.FRIENT_ADD_S); tip.setSuccTip(MessageConst.FRIENT_ADD_S); List<Friend> roleLst = player.getRelationManager().myFriend(); // ArrayList<PlayerCache> roleLst1 = player.getRelationManager() // .randomOnlineUser((byte) 0); // **********rms RespModuleSet rms = new RespModuleSet(ProcotolType.FRIEND_RESP); // rms.addModule(friend); // for (Friend role : roleLst) { // rms.addModule(role); // } // for (PlayerCache role : roleLst1) { // rms.addModule(role); // } rms.addModule(friend); AndroidMessageSender.sendMessage(rms, player); // **********rms return tip; } else { Friend friend = friMgr.get(friendId); if (friend == null) { // logger.info("好友为空,添加失败"); if (I18nGreeting.LANLANGUAGE_TIPS == 1) { tip.setFailTip("Add failed.Friend doesn't exist. "); } else { tip.setFailTip("好友为空,添加失败"); } return tip; } else { // logger.info("[addFriend]" + MessageConst.FRIENTR_F1); friend.setTips(MessageConst.FRIENTR_F1, GameConst.GAME_RESP_FAIL); tip.setFailTip(MessageConst.FRIENTR_F1); return tip; } } }