新行为 39 战斗,推任务,生成新的事件点。15 16修改
parent
0983abb99c
commit
17fdfbd6e4
|
@ -38,7 +38,7 @@ public class BehaviorUtil {
|
||||||
* @param user
|
* @param user
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void destoryPoint(User user, int mapId, int needDistoryPointId) throws Exception {
|
public static void destoryPoint(User user, int needDistoryPointId) throws Exception {
|
||||||
MapManager mapManager = user.getMapManager();
|
MapManager mapManager = user.getMapManager();
|
||||||
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
||||||
Set<Integer> needDelete = new HashSet<>();
|
Set<Integer> needDelete = new HashSet<>();
|
||||||
|
@ -53,6 +53,32 @@ public class BehaviorUtil {
|
||||||
mapManager.setMapInfo(mapInfo);
|
mapManager.setMapInfo(mapInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销毁多个事件点
|
||||||
|
* @param user
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void destoryPoints(User user, int[] needDistoryPointIds) throws Exception {
|
||||||
|
Set<Integer> set = new HashSet<>(needDistoryPointIds.length);
|
||||||
|
for (int i = 0; i < needDistoryPointIds.length; i++) {
|
||||||
|
set.add(needDistoryPointIds[i]);
|
||||||
|
}
|
||||||
|
MapManager mapManager = user.getMapManager();
|
||||||
|
Map<Integer, Cell> mapInfo = mapManager.getMapInfo();
|
||||||
|
Set<Integer> needDelete = new HashSet<>();
|
||||||
|
for (Map.Entry<Integer, Cell> entry : mapInfo.entrySet()) {
|
||||||
|
int pointId = entry.getValue().getPointId();
|
||||||
|
if (set.contains(pointId)) {
|
||||||
|
needDelete.add(entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Integer xy : needDelete) {
|
||||||
|
mapInfo.remove(xy);
|
||||||
|
}
|
||||||
|
mapManager.setMapInfo(mapInfo);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加新事件点
|
* 增加新事件点
|
||||||
* @param needDistoryPointId
|
* @param needDistoryPointId
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DestroyPointAndBehavior extends BaseBehavior {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||||
BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class DestroyPointBehavior extends BaseBehavior {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][0]);
|
BehaviorUtil.destoryPoints(user, behaviorTypeValues[0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class FightAndDestroyPointBehavior extends BaseBehavior {
|
||||||
@Override
|
@Override
|
||||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||||
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
|
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][2]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][2]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class FinsionMissionAndDestoryBehavior extends BaseBehavior{
|
||||||
@Override
|
@Override
|
||||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
||||||
BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
|
||||||
// 1#101011|101#13#18#101012|101#12#13#101009
|
// 1#101011|101#13#18#101012|101#12#13#101009
|
||||||
// BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
// BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||||
// 销毁事件点
|
// 销毁事件点
|
||||||
BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
// 开新事件
|
// 开新事件
|
||||||
for (int j = 1; j < behaviorTypeValues.length; j++) {
|
for (int j = 1; j < behaviorTypeValues.length; j++) {
|
||||||
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0], behaviorTypeValues[j][1], behaviorTypeValues[j][2]);
|
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0], behaviorTypeValues[j][1], behaviorTypeValues[j][2]);
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class ThirtyFiveBehavior extends BaseBehavior {
|
||||||
@Override
|
@Override
|
||||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][0]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][0]);
|
||||||
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
||||||
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class ThirtyFourBehavior extends BaseBehavior {
|
||||||
@Override
|
@Override
|
||||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][0]);
|
CombatLogic.getInstance().bufferAddByEatFoodOrEventTrigger(user.getMapManager(), behaviorTypeValues[0][0]);
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
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 ThirtyNineBehavior extends BaseBehavior {
|
||||||
|
@Override
|
||||||
|
public int getBehaviorType() {
|
||||||
|
return EventType.thirtyNine;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFightBehavior() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||||
|
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
|
||||||
|
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
||||||
|
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,7 @@ public class ThirtySexBehavior extends BaseBehavior{
|
||||||
return isEnough;
|
return isEnough;
|
||||||
}
|
}
|
||||||
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
BehaviorUtil.updateMission(user, eventUpdateResponse);
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][0]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ThirtyThreeBehavior extends BaseBehavior {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
||||||
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class ThirtyTwoBehavior extends BaseBehavior {
|
||||||
@Override
|
@Override
|
||||||
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
|
||||||
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
|
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
|
||||||
BehaviorUtil.destoryPoint(user, 0, behaviorTypeValues[0][1]);
|
BehaviorUtil.destoryPoint(user, behaviorTypeValues[0][1]);
|
||||||
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
for (int i = 1; i < behaviorTypeValues.length; i++) {
|
||||||
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
BehaviorUtil.addBehaviorInfo(user,behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@ public class UseItemAndDestroyBehavior extends BaseBehavior {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
public boolean process(int optionId, User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
boolean isEnough = ItemUtil.itemCost(user, behaviorTypeValues, BIReason.MAP_EVENT_CONSUME,getBehaviorType());
|
int[][] userItem = new int[behaviorTypeValues[0][0]][behaviorTypeValues[0][1]];
|
||||||
|
boolean isEnough = ItemUtil.itemCost(user, userItem, BIReason.MAP_EVENT_CONSUME,getBehaviorType());
|
||||||
if (!isEnough) {
|
if (!isEnough) {
|
||||||
return isEnough;
|
return isEnough;
|
||||||
}
|
}
|
||||||
BehaviorUtil.destoryPoint(user, user.getMapManager().getCurMapId(), behaviorTypeValues[0][2]);
|
BehaviorUtil.destoryPoints(user, behaviorTypeValues[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue