完善地图
parent
d6cd2edb89
commit
d1600d94a9
|
@ -49,6 +49,18 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String FIGHT_GROUPID = "GROUPID";
|
||||
|
||||
/**
|
||||
* 需要推进的任务id
|
||||
* sub_key
|
||||
*/
|
||||
public static final String NEED_MISSION_ID = "NEED_MISSION_ID";
|
||||
|
||||
/**
|
||||
* 需要销毁的事件点id
|
||||
* sub_key
|
||||
*/
|
||||
public static final String NEED_DESORY_ID = "NEED_DESORY_ID";
|
||||
|
||||
/**
|
||||
* 过期事件
|
||||
*/
|
||||
|
|
|
@ -458,7 +458,7 @@ public class MapLogic {
|
|||
String key = RedisKey.getKey(RedisKey.FIGHT, user.getId() , false);
|
||||
Map<Object , Object> valueMap = RedisUtil.getInstence().hmget(key);
|
||||
CommonProto.Drop.Builder dropBuilder = null;
|
||||
if (valueMap == null) {
|
||||
if (valueMap == null || valueMap.isEmpty()) {
|
||||
dropBuilder = ItemUtil.drop(user, sOptionConfig.getReward(), 1, 1);
|
||||
}
|
||||
List<CommonProto.EventBehaviorValues> eventBehaviorValuesList = new ArrayList<>();
|
||||
|
@ -732,9 +732,17 @@ public class MapLogic {
|
|||
String fightReadyKey = RedisKey.getKey(RedisKey.FIGHT_READY, Integer.toString(uid), false);
|
||||
String fightReady = (String) RedisUtil.getInstence().get(fightReadyKey);
|
||||
int groupId;
|
||||
String missionId = "0", destroyId = "0";
|
||||
if (fightReady != null) {
|
||||
String[] split = fightReady.split("#");
|
||||
RedisUtil.getInstence().del(fightReadyKey);
|
||||
groupId = Integer.parseInt(fightReady);
|
||||
groupId = Integer.parseInt(split[0]);
|
||||
if (split.length > 1) {
|
||||
missionId = split[1];
|
||||
}
|
||||
if (split.length > 2) {
|
||||
destroyId = split[2];
|
||||
}
|
||||
} else {
|
||||
int[] option = sEventPointConfig.getOption();
|
||||
if (option == null) {
|
||||
|
@ -745,7 +753,7 @@ public class MapLogic {
|
|||
groupId = option[0];
|
||||
}
|
||||
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
|
||||
BehaviorUtil.getFightInfo(user, groupId, fightStartResponse);
|
||||
BehaviorUtil.getFightInfo(user, groupId, fightStartResponse, missionId, destroyId);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
|
||||
}
|
||||
|
||||
|
@ -805,7 +813,7 @@ public class MapLogic {
|
|||
return;
|
||||
}else if(resultCode == 0){
|
||||
// 失败处理
|
||||
resetMapInfo(user,true);
|
||||
resetMapInfo(user,false);
|
||||
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
||||
FightInfoProto.FightEndResponse fightEndResponse = FightInfoProto.FightEndResponse
|
||||
.newBuilder()
|
||||
|
@ -831,6 +839,14 @@ public class MapLogic {
|
|||
.setResult(resultCode)
|
||||
.addAllRemainHpList(remainHp)
|
||||
.build();
|
||||
int missionId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_MISSION_ID));
|
||||
int destoryId = Integer.parseInt((String)valueMap.get(RedisKey.NEED_DESORY_ID));
|
||||
if (missionId != 0) {
|
||||
BehaviorUtil.updateMission(user, missionId, null);
|
||||
}
|
||||
if (destoryId != 0) {
|
||||
BehaviorUtil.distoryPoint(user, destoryId);
|
||||
}
|
||||
updateMapMission(user.getMapManager(),EventType.fightEvent,0,monsterGroupId);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse, true);
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ import com.ljsd.jieling.logic.dao.Equip;
|
|||
import com.ljsd.jieling.logic.dao.Item;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TemporaryItems {
|
||||
|
||||
public Map<Integer, Item> items = new HashMap<>();
|
||||
|
||||
public Map<Integer, Equip> equips = new HashMap<>();
|
||||
public Set<Equip> equips = new HashSet<>();
|
||||
|
||||
}
|
||||
|
|
|
@ -69,9 +69,9 @@ public class BehaviorUtil {
|
|||
}
|
||||
|
||||
|
||||
public static void fightReady(String uid, int groupId) {
|
||||
public static void fightReady(String uid, String readyInfo) {
|
||||
String key = RedisKey.getKey(RedisKey.FIGHT_READY, uid, false);
|
||||
RedisUtil.getInstence().set(key, Integer.toString(groupId), RedisKey.EXPIRE_TIME);
|
||||
RedisUtil.getInstence().set(key, readyInfo, RedisKey.EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ public class BehaviorUtil {
|
|||
* @param fightStartRespons
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons) throws Exception {
|
||||
public static void getFightInfo(User user, int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String missionId, String destoryId) throws Exception {
|
||||
MapManager mapManager = user.getMapManager();
|
||||
|
||||
int teamId = mapManager.getTeamId();
|
||||
|
@ -137,6 +137,8 @@ public class BehaviorUtil {
|
|||
fightInfo.put(RedisKey.FIGHT_MONSTERS, JsonFormat.printToString(monsterGroupList.get(0)));//暂时没考虑多拨怪
|
||||
fightInfo.put(RedisKey.FIGHT_SEED,Integer.toString(seed));
|
||||
fightInfo.put(RedisKey.FIGHT_GROUPID, Integer.toString(groupId));
|
||||
fightInfo.put(RedisKey.NEED_MISSION_ID, missionId);
|
||||
fightInfo.put(RedisKey.NEED_DESORY_ID, destoryId);
|
||||
RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME);
|
||||
|
||||
|
||||
|
@ -157,7 +159,9 @@ public class BehaviorUtil {
|
|||
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
|
||||
for (Mission missions : checkMissionReturn.missions) {
|
||||
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(missions);
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
if (eventUpdateResponse != null) {
|
||||
eventUpdateResponse.addMission(missionProto);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@ public class FightAndDestroyPointBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
BehaviorUtil.fightReady(user.getId(), behaviorTypeValues[0][1]);
|
||||
String readyInfo = Integer.toString(behaviorTypeValues[0][1]) + "#" + Integer.toString(behaviorTypeValues[0][0]) + "#" + behaviorTypeValues[0][2];
|
||||
BehaviorUtil.fightReady(user.getId(), readyInfo);
|
||||
// 放在战斗胜利后
|
||||
// BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
// BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][2]);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class FightBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.fightReady(user.getId(), behaviorTypeValues[0][0]);
|
||||
BehaviorUtil.fightReady(user.getId(), Integer.toString(behaviorTypeValues[0][0]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class CBean2Proto {
|
|||
for (Item item : temporaryItems.items.values()) {
|
||||
drop.addItemlist(getItem(item));
|
||||
}
|
||||
for (Equip equip : temporaryItems.equips.values()) {
|
||||
for (Equip equip : temporaryItems.equips) {
|
||||
drop.addEquipId(getEquipProto(equip));
|
||||
}
|
||||
return drop.build();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.util;
|
||||
|
||||
import com.ljsd.jieling.config.SEquipConfig;
|
||||
import com.ljsd.jieling.config.SItem;
|
||||
import com.ljsd.jieling.config.SRewardGroup;
|
||||
import com.ljsd.jieling.config.SRewardItem;
|
||||
|
@ -13,10 +14,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
|
@ -91,12 +89,12 @@ public class ItemUtil {
|
|||
}
|
||||
useRandomItem(user,randomMap);
|
||||
if (isMapping == 1) {
|
||||
addItemToTemporaryBag(user,itemMap,dropBuilder);
|
||||
addItemToTemporaryBag(user, itemMap, equipMap, dropBuilder);
|
||||
} else {
|
||||
addItem(user,itemMap,dropBuilder);
|
||||
addEquip(user,equipMap,dropBuilder);
|
||||
}
|
||||
addCard(user,cardMap,dropBuilder);
|
||||
addEquip(user,equipMap,dropBuilder);
|
||||
return dropBuilder;
|
||||
}
|
||||
private static void selectItemArr(int[][] itemArr, Map<Integer, Integer> cardMap, Map<Integer, Integer>
|
||||
|
@ -272,8 +270,9 @@ public class ItemUtil {
|
|||
* @param itemMap
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void addItemToTemporaryBag(User user, Map<Integer, Integer> itemMap,CommonProto.Drop.Builder dropBuilder) throws Exception {
|
||||
List<CommonProto.Item> itemProtoList = new CopyOnWriteArrayList<>();
|
||||
public static void addItemToTemporaryBag(User user, Map<Integer, Integer> itemMap, Map<Integer, Integer> equipMap, CommonProto.Drop.Builder dropBuilder) throws Exception {
|
||||
List<CommonProto.Item> itemProtoList = new ArrayList<>();
|
||||
List<CommonProto.Equip> equipProtoList = new ArrayList<>();
|
||||
MapManager mapManager = user.getMapManager();
|
||||
TemporaryItems temporaryItems = mapManager.getTemporaryItems();
|
||||
if (temporaryItems == null) {
|
||||
|
@ -281,8 +280,8 @@ public class ItemUtil {
|
|||
}
|
||||
Map<Integer, Item> items = temporaryItems.items;
|
||||
for (Map.Entry<Integer, Integer> entry : itemMap.entrySet()) {
|
||||
SItem sItem = SItem.getsItemMap().get (entry.getKey());
|
||||
if (sItem == null){
|
||||
SItem sItem = SItem.getsItemMap().get(entry.getKey());
|
||||
if (sItem == null) {
|
||||
continue;
|
||||
}
|
||||
Item item = items.get(entry.getKey());
|
||||
|
@ -294,9 +293,20 @@ public class ItemUtil {
|
|||
}
|
||||
itemProtoList.add(CBean2Proto.getItem(item));
|
||||
}
|
||||
Set<Equip> equips = temporaryItems.equips;
|
||||
for (Map.Entry<Integer, Integer> entry : equipMap.entrySet()) {
|
||||
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(entry.getKey());
|
||||
if (sEquipConfig == null) {
|
||||
continue;
|
||||
}
|
||||
Equip equip = new Equip(user.getId(), entry.getKey());
|
||||
equips.add(equip);
|
||||
equipProtoList.add(CBean2Proto.getEquipProto(equip));
|
||||
}
|
||||
mapManager.setTemporaryItems(temporaryItems);
|
||||
if (dropBuilder != null) {
|
||||
dropBuilder.addAllItemlist(itemProtoList);
|
||||
dropBuilder.addAllEquipId(equipProtoList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +318,7 @@ public class ItemUtil {
|
|||
*/
|
||||
public static void addTemporaryItemToBag(User user, TemporaryItems temporaryItems) throws Exception {
|
||||
Map<Integer, Item> items = temporaryItems.items;
|
||||
Map<Integer, Equip> equips = temporaryItems.equips;
|
||||
Set<Equip> equips = temporaryItems.equips;
|
||||
if (items.isEmpty() && equips.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -331,6 +341,16 @@ public class ItemUtil {
|
|||
itemMap.put(entry.getKey(), item) ;
|
||||
}
|
||||
user.getItemManager().setItemMap(itemMap);
|
||||
for (Equip equip : equips) {
|
||||
SItem sItem = SItem.getsItemMap().get (equip.getEquipId());
|
||||
if (sItem == null){
|
||||
continue;
|
||||
}
|
||||
if (sItem.getIsSave() != 1) {
|
||||
continue;
|
||||
}
|
||||
user.getEquipManager().addEquip(equip);
|
||||
}
|
||||
user.getMapManager().setTemporaryItems(null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue