增加新行为 10

back_recharge
jiahuiwen 2019-05-31 16:58:40 +08:00
parent f768d3552f
commit d2107490de
2 changed files with 40 additions and 4 deletions

View File

@ -41,7 +41,10 @@ public class MapManager extends MongoBase {
private Map<String,Map<Integer, Integer>> heroAllAttributeMap = new HashMap<>(5); private Map<String,Map<Integer, Integer>> heroAllAttributeMap = new HashMap<>(5);
private MapMission mapMissionProgres; private MapMission mapMissionProgres;
private int energy;
private int monsterId;
private int monsterNum;
private int lastUpdateEnergyTime; private int lastUpdateEnergyTime;
@ -208,9 +211,22 @@ public class MapManager extends MongoBase {
this.lastUpdateEnergyTime = lastUpdateEnergyTime; this.lastUpdateEnergyTime = lastUpdateEnergyTime;
} }
public void setEnergy(int energy) { public void setMonsterId(int monsterId) {
updateString("energy", energy); updateString("monsterId", monsterId);
this.energy = energy; this.monsterId = monsterId;
}
public int getMonsterId() {
return monsterId;
}
public int getMonsterNum() {
return monsterNum;
}
public void setMonsterNum(int monsterNum) {
updateString("monsterNum", monsterNum);
this.monsterNum = monsterNum;
} }
public int getLastUpdateEnergyTime() { public int getLastUpdateEnergyTime() {

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.EventType; import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MapInfoProto; import com.ljsd.jieling.protocols.MapInfoProto;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -15,6 +16,25 @@ public class MonitorMissionBehavior 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 b = BehaviorUtil.updateMission(user, eventUpdateResponse); boolean b = BehaviorUtil.updateMission(user, eventUpdateResponse);
user.getMapManager().setMonsterId(behaviorTypeValues[0][0]);
for (int i = 1; i < behaviorTypeValues.length; i++) {
BehaviorUtil.addBehaviorInfo(behaviorTypeValues[i][3], user.getMapManager(), behaviorTypeValues[i][0], behaviorTypeValues[i][1], behaviorTypeValues[i][2]);
}
return b; return b;
} }
@Override
public boolean isFightBehavior() {
return true;
}
@Override
public boolean afterFight(User user, int[][] behaviorTypeValues, FightInfoProto.FightEndResponse.Builder fightEndResponse) throws Exception {
int monsterNum = user.getMapManager().getMonsterNum();
if (behaviorTypeValues[0][0] == user.getMapManager().getMonsterId() && monsterNum < behaviorTypeValues[0][1]) {
user.getMapManager().setMonsterNum(monsterNum + 1);
BehaviorUtil.updateMissionEndFight(user, fightEndResponse);
}
return true;
}
} }