初次提交
This commit is contained in:
parent
8012dca7bb
commit
203139a7eb
|
@ -56,10 +56,10 @@ public class ScenarioTaskServiceImpl extends
|
|||
public void start(Integer id, String roomId) {
|
||||
Scenario currentScenario = scenarioService.getScenarioById(id);
|
||||
//想定当前持续时间
|
||||
redisUtil.hset(roomId + "_" + id, "duringTime", 0);
|
||||
redisUtil.hset(roomId + "_" + id, "duringTime", "0");
|
||||
//想定当前状态
|
||||
redisUtil.hset(roomId + "_" + id, "states", "running");
|
||||
//想定物资信息
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|||
private final WebClient webClient = WebClient.create();
|
||||
@Resource
|
||||
private StatisticService statisticService;
|
||||
private final double fuelUseUpPerSecond = 0.1;
|
||||
private final static double fuelUseUpPerSecond = 0.1;
|
||||
private final static double medicalUseUpPerSecond = 0.1;
|
||||
private final static double ammunitionUsePerSecond = 0.1;
|
||||
|
||||
@Override
|
||||
public void handleMoveTask(ScenarioTask scenarioTask, Scenario currentScenario, String roomId,
|
||||
|
@ -136,6 +138,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|||
|
||||
@Override
|
||||
public void handleBattleTask(ScenarioTask task, Scenario scenario, String roomId) {
|
||||
StatisticBean statistic = getStatistic(task, scenario, roomId);
|
||||
int duringTime = getCurrentDuringTime(scenario, roomId);
|
||||
long seconds =
|
||||
duringTime - Duration.between(task.getStartTime(), scenario.getStartTime())
|
||||
.getSeconds();
|
||||
if (seconds > 0) {
|
||||
statistic.getMedical()
|
||||
.setCurrent(statistic.getMedical().getTotal() - seconds * medicalUseUpPerSecond);
|
||||
statistic.getAmmunition()
|
||||
.setCurrent(statistic.getAmmunition().getTotal() - seconds * ammunitionUsePerSecond);
|
||||
setStatistic(task, scenario, roomId, statistic);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -166,6 +182,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|||
StatisticBean bean) {
|
||||
redisUtil.hset(roomId + "_" + scenario.getId(),
|
||||
"resourceId_statistic_" + task.getResourceId(), bean);
|
||||
//推送到前端
|
||||
ResponseCmdInfo<Map<String, Object>> cmdInfo = new ResponseCmdInfo<>();
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
cmdInfo.setData(dataMap);
|
||||
dataMap.put("resourceId", task.getResourceId());
|
||||
dataMap.put("statistic", bean);
|
||||
Global.sendCmdInfoQueue.add(cmdInfo);
|
||||
}
|
||||
|
||||
private int getCurrentDuringTime(Scenario scenario, String roomId) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user