判断道具
parent
f7d3b64b61
commit
0d7f123a01
|
@ -1,15 +1,11 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.config.SItem;
|
||||
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 EatBuffBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
@ -19,14 +15,10 @@ public class EatBuffBehavior extends BaseBehavior {
|
|||
|
||||
@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]);
|
||||
boolean isEnough = ItemUtil.itemCost(user, behaviorTypeValues);
|
||||
if (!isEnough) {
|
||||
return isEnough;
|
||||
}
|
||||
Map<Integer, Integer> useItems = new HashMap<>();
|
||||
useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]);
|
||||
ItemUtil.useItem(user, useItems);
|
||||
return isEnough;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,10 @@ public class ScoutBehavior extends BaseBehavior {
|
|||
|
||||
@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]);
|
||||
boolean isEnough = ItemUtil.itemCost(user, behaviorTypeValues);
|
||||
if (!isEnough) {
|
||||
return isEnough;
|
||||
}
|
||||
Map<Integer, Integer> useItems = new HashMap<>();
|
||||
useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]);
|
||||
ItemUtil.useItem(user, useItems);
|
||||
return isEnough;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
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;
|
||||
|
@ -8,7 +7,6 @@ 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
|
||||
|
@ -20,14 +18,10 @@ public class UseItemAndDestroyBehavior extends BaseBehavior {
|
|||
|
||||
@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]);
|
||||
boolean isEnough = ItemUtil.itemCost(user, behaviorTypeValues);
|
||||
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);
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.config.SItem;
|
||||
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 UseItemBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
@ -19,14 +15,10 @@ public class UseItemBehavior extends BaseBehavior {
|
|||
|
||||
@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]);
|
||||
boolean isEnough = ItemUtil.itemCost(user, behaviorTypeValues);
|
||||
if (!isEnough) {
|
||||
return isEnough;
|
||||
}
|
||||
Map<Integer, Integer> useItems = new HashMap<>();
|
||||
useItems.put(behaviorTypeValues[0][0], behaviorTypeValues[0][1]);
|
||||
ItemUtil.useItem(user, useItems);
|
||||
return isEnough;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue