45behaivor
parent
10dfabfd50
commit
5ce990e6ff
|
@ -106,6 +106,7 @@ public class EventType {
|
|||
public static final int fourtyTwo = 42;
|
||||
public static final int fourtyThree = 43;
|
||||
public static final int fourtyFour = 44;
|
||||
public static final int fourtyfive = 45;
|
||||
|
||||
|
||||
public static final int updatePonintEvent = 1;
|
||||
|
|
|
@ -16,10 +16,7 @@ import com.ljsd.jieling.logic.dao.PlayerManager;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
|
@ -110,6 +107,8 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private Map<Integer,Integer> towerReceivedReward = new HashMap<>();
|
||||
|
||||
private Map<Integer, Map<Integer,Integer>> monsterTempSkill = new HashMap<>();
|
||||
|
||||
public MapManager() {
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
}
|
||||
|
@ -652,6 +651,20 @@ public class MapManager extends MongoBase {
|
|||
towerReceivedReward.put(tower,1);
|
||||
}
|
||||
|
||||
public Map<Integer, Map<Integer,Integer>> getMonsterTempSkill() {
|
||||
return monsterTempSkill;
|
||||
}
|
||||
public void updateMonsterTempSkill(int monsterGroupId,int skillId,int count){
|
||||
if(monsterTempSkill.get(monsterGroupId)==null){
|
||||
monsterTempSkill.put(monsterGroupId,new HashMap<>());
|
||||
}
|
||||
monsterTempSkill.get(monsterGroupId).put(skillId,count);
|
||||
updateString("monsterTempSkill." + monsterGroupId +"." + skillId, count);
|
||||
}
|
||||
public void removeMonsterTempSkill(){
|
||||
monsterTempSkill = new HashMap<>();
|
||||
updateString("monsterTempSkill",monsterTempSkill);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -129,6 +129,21 @@ public class BehaviorUtil {
|
|||
RedisUtil.getInstence().set(key, readyInfo, RedisKey.EXPIRE_TIME);
|
||||
}
|
||||
|
||||
|
||||
private static List<CommonProto.FightTeamInfo> addGroupSkills(String skills,List<CommonProto.FightTeamInfo> monsterGroupList){
|
||||
List<CommonProto.FightTeamInfo> monsterGroupListResult = new ArrayList<>(monsterGroupList.size());
|
||||
for(CommonProto.FightTeamInfo fightTeamInfo : monsterGroupList){
|
||||
List<CommonProto.FightUnitInfo> fightUnitInfos = new ArrayList<>(fightTeamInfo.getFightUnitListList().size());
|
||||
for(CommonProto.FightUnitInfo fightUnitInfo :fightTeamInfo.getFightUnitListList()){
|
||||
fightUnitInfos.add(fightUnitInfo.toBuilder()
|
||||
.setUnitSkillIds(fightUnitInfo.getUnitSkillIds() + skills)
|
||||
.build());
|
||||
}
|
||||
monsterGroupListResult.add(CommonProto.FightTeamInfo.newBuilder().addAllFightUnitList(fightUnitInfos).build());
|
||||
}
|
||||
return monsterGroupListResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取战斗数据
|
||||
* @param user
|
||||
|
@ -145,9 +160,18 @@ public class BehaviorUtil {
|
|||
fightData.setHeroFightInfos(fightTeamInfo);
|
||||
//monster
|
||||
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
|
||||
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_1);
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList1 = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_2);
|
||||
List<CommonProto.FightTeamInfo> monsterGroupList2 = getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_3);
|
||||
for(Map.Entry<Integer,Map<Integer,Integer>> entry :mapManager.getMonsterTempSkill().entrySet()){
|
||||
if(groupId!=entry.getKey()){
|
||||
continue;
|
||||
}
|
||||
for(Map.Entry<Integer,Integer> skill:entry.getValue().entrySet()){
|
||||
monsterGroupList = addGroupSkills(skill.getKey().toString()+"#",monsterGroupList);
|
||||
}
|
||||
}
|
||||
fightData.addAllMonsterList(monsterGroupList).addAllMonsterList(monsterGroupList1).addAllMonsterList(monsterGroupList2);
|
||||
//设置战斗随机种子
|
||||
int seed = (int)(System.currentTimeMillis()/1000);
|
||||
|
@ -172,10 +196,6 @@ public class BehaviorUtil {
|
|||
fightInfo.put(RedisKey.NEED_VICTORY_AFTER, pointId);
|
||||
RedisUtil.getInstence().hmset(key, fightInfo, RedisKey.EXPIRE_TIME);
|
||||
|
||||
|
||||
// ISession session = OnlineUserManager.getSessionByUid(Integer.parseInt(user.getId()));
|
||||
// MapLogic.getInstance().endFight(session,"", MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
|
||||
import com.ljsd.jieling.handler.map.EventType;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FourtyFiveBehavior extends BaseBehavior {
|
||||
@Override
|
||||
public int getBehaviorType() {
|
||||
return EventType.fourtyfive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
||||
String readyInfo = behaviorTypeValues[0][1] + "#" + Integer.toString(optionId);
|
||||
BehaviorUtil.fightReady(user.getId(), readyInfo);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isFightBehavior() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||
if(behaviorTypeValues[0][0]==1){
|
||||
user.getMapManager().removeMonsterTempSkill();
|
||||
}
|
||||
for(Integer group:behaviorTypeValues[1]){
|
||||
for(Integer skill:behaviorTypeValues[2]){
|
||||
user.getMapManager().updateMonsterTempSkill(group,skill,1);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue