Merge branch 'master' of 60.1.1.230:backend/jieling_server
commit
7684ffe7e0
|
@ -41,6 +41,10 @@ public class EventType {
|
||||||
* 行为参数:任务id
|
* 行为参数:任务id
|
||||||
* 14 完成任务往下推一步并消耗物品,不摧毁事件点
|
* 14 完成任务往下推一步并消耗物品,不摧毁事件点
|
||||||
* 行为参数:物品id#物品数量#任务id
|
* 行为参数:物品id#物品数量#任务id
|
||||||
|
* 15 销毁事件点
|
||||||
|
* 行为参数:事件点id
|
||||||
|
* 16 消耗道具并销毁事件点
|
||||||
|
* 行为参数:道具id#num#事件点id
|
||||||
*/
|
*/
|
||||||
public static final int fight = 1;
|
public static final int fight = 1;
|
||||||
public static final int useItem = 2;
|
public static final int useItem = 2;
|
||||||
|
@ -54,4 +58,6 @@ public class EventType {
|
||||||
public static final int openMission = 11;
|
public static final int openMission = 11;
|
||||||
public static final int finishMission = 13;
|
public static final int finishMission = 13;
|
||||||
public static final int useItemMission = 14;
|
public static final int useItemMission = 14;
|
||||||
|
public static final int destroyPoint = 15;
|
||||||
|
public static final int useItemAndDestroy = 16;
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,6 @@ public class MapLogic {
|
||||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 1 完成事件点,即进度100%
|
|
||||||
nextPoint = getNextPoint(user, mapManager, jumpTypeValues, sOptionAddConditions);
|
nextPoint = getNextPoint(user, mapManager, jumpTypeValues, sOptionAddConditions);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -417,6 +416,7 @@ public class MapLogic {
|
||||||
private int getNextPoint(User user, MapManager mapManager, int[][] jumpTypeValues, SOptionAddCondition sOptionAddConditions) {
|
private int getNextPoint(User user, MapManager mapManager, int[][] jumpTypeValues, SOptionAddCondition sOptionAddConditions) {
|
||||||
int nextPoint = 0;
|
int nextPoint = 0;
|
||||||
switch (sOptionAddConditions.getType()) {
|
switch (sOptionAddConditions.getType()) {
|
||||||
|
// 1 完成事件点,即进度100%
|
||||||
case 1:{
|
case 1:{
|
||||||
int doneEvent = sOptionAddConditions.getValues()[0][0];
|
int doneEvent = sOptionAddConditions.getValues()[0][0];
|
||||||
for (Cell cell1 : mapManager.getMapInfo().values()) {
|
for (Cell cell1 : mapManager.getMapInfo().values()) {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.ljsd.jieling.handler.map.behavior;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.map.Cell;
|
||||||
|
import com.ljsd.jieling.handler.map.EventType;
|
||||||
|
import com.ljsd.jieling.logic.dao.User;
|
||||||
|
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DestroyPointBehavior extends BaseBehavior {
|
||||||
|
@Override
|
||||||
|
public int getBehaviorType() {
|
||||||
|
return EventType.destroyPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
|
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
|
||||||
|
mapInfo.remove(user.getMapManager().getCurXY());
|
||||||
|
user.getMapManager().setMapInfo(mapInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.ljsd.jieling.handler.map.behavior;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.config.SItem;
|
||||||
|
import com.ljsd.jieling.handler.map.Cell;
|
||||||
|
import com.ljsd.jieling.handler.map.EventType;
|
||||||
|
import com.ljsd.jieling.logic.dao.User;
|
||||||
|
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||||
|
import com.ljsd.jieling.util.ItemUtil;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class UseItemAndDestroyBehavior extends BaseBehavior {
|
||||||
|
@Override
|
||||||
|
public int getBehaviorType() {
|
||||||
|
return EventType.useItemAndDestroy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||||
|
SItem sItem = SItem.getsItemMap().get(behaviorTypeValues[0][0]);
|
||||||
|
boolean isEnough = ItemUtil.checkCost(user, sItem, behaviorTypeValues[0][1]);
|
||||||
|
if (!isEnough) {
|
||||||
|
return isEnough;
|
||||||
|
}
|
||||||
|
Map<Integer, Integer> useItems = new HashMap<>();
|
||||||
|
useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]);
|
||||||
|
ItemUtil.useItem(user, useItems);
|
||||||
|
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
|
||||||
|
mapInfo.remove(user.getMapManager().getCurXY());
|
||||||
|
user.getMapManager().setMapInfo(mapInfo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import java.util.Map;
|
||||||
public class UseItemBehavior extends BaseBehavior {
|
public class UseItemBehavior extends BaseBehavior {
|
||||||
@Override
|
@Override
|
||||||
public int getBehaviorType() {
|
public int getBehaviorType() {
|
||||||
return EventType.eatBuff;
|
return EventType.useItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue