将地图的尺寸和障碍物数量存入Record数据库
This commit is contained in:
parent
291b176aee
commit
5d28c29f41
|
@ -3,13 +3,13 @@ package com.kob.backend.consumer;
|
||||||
// WebSocket用于前后端通信
|
// WebSocket用于前后端通信
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.kob.backend.config.MapSizeConfig;
|
||||||
import com.kob.backend.consumer.utils.Game;
|
import com.kob.backend.consumer.utils.Game;
|
||||||
import com.kob.backend.consumer.utils.JwtAuthenticationUtil;
|
import com.kob.backend.consumer.utils.JwtAuthenticationUtil;
|
||||||
import com.kob.backend.mapper.BotMapper;
|
import com.kob.backend.mapper.BotMapper;
|
||||||
import com.kob.backend.mapper.RecordMapper;
|
import com.kob.backend.mapper.RecordMapper;
|
||||||
import com.kob.backend.mapper.UserMapper;
|
import com.kob.backend.mapper.UserMapper;
|
||||||
import com.kob.backend.pojo.Bot;
|
import com.kob.backend.pojo.Bot;
|
||||||
import com.kob.backend.pojo.Record;
|
|
||||||
import com.kob.backend.pojo.User;
|
import com.kob.backend.pojo.User;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -119,9 +119,9 @@ public class WebSocketServer {
|
||||||
|
|
||||||
// 匹配成功时,创建联机地图
|
// 匹配成功时,创建联机地图
|
||||||
Game game = new Game(
|
Game game = new Game(
|
||||||
13,
|
MapSizeConfig.rows,
|
||||||
14,
|
MapSizeConfig.cols,
|
||||||
20,
|
MapSizeConfig.inner_walls_count,
|
||||||
a.getId(),
|
a.getId(),
|
||||||
botA,
|
botA,
|
||||||
b.getId(),
|
b.getId(),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kob.backend.consumer.utils;
|
package com.kob.backend.consumer.utils;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.kob.backend.config.MapSizeConfig;
|
||||||
import com.kob.backend.consumer.WebSocketServer;
|
import com.kob.backend.consumer.WebSocketServer;
|
||||||
import com.kob.backend.pojo.Bot;
|
import com.kob.backend.pojo.Bot;
|
||||||
import com.kob.backend.pojo.Record;
|
import com.kob.backend.pojo.Record;
|
||||||
|
@ -392,6 +393,9 @@ public class Game extends Thread {
|
||||||
playerA.getStepsString(),
|
playerA.getStepsString(),
|
||||||
playerB.getStepsString(),
|
playerB.getStepsString(),
|
||||||
getGameMapString(),
|
getGameMapString(),
|
||||||
|
MapSizeConfig.rows,
|
||||||
|
MapSizeConfig.cols,
|
||||||
|
MapSizeConfig.inner_walls_count,
|
||||||
loser,
|
loser,
|
||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,6 +27,9 @@ public class Record {
|
||||||
private String aSteps;
|
private String aSteps;
|
||||||
private String bSteps;
|
private String bSteps;
|
||||||
private String map;
|
private String map;
|
||||||
|
private Integer mapRows;
|
||||||
|
private Integer mapCols;
|
||||||
|
private Integer innerWallsCount;
|
||||||
private String loser;
|
private String loser;
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
|
||||||
|
|
Loading…
Reference in New Issue