将地图的尺寸和障碍物数量存入Record数据库

This commit is contained in:
flykhan 2023-03-10 17:03:36 +08:00
parent 291b176aee
commit 5d28c29f41
3 changed files with 11 additions and 4 deletions

View File

@ -3,13 +3,13 @@ package com.kob.backend.consumer;
// WebSocket用于前后端通信
import com.alibaba.fastjson2.JSONObject;
import com.kob.backend.config.MapSizeConfig;
import com.kob.backend.consumer.utils.Game;
import com.kob.backend.consumer.utils.JwtAuthenticationUtil;
import com.kob.backend.mapper.BotMapper;
import com.kob.backend.mapper.RecordMapper;
import com.kob.backend.mapper.UserMapper;
import com.kob.backend.pojo.Bot;
import com.kob.backend.pojo.Record;
import com.kob.backend.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -119,9 +119,9 @@ public class WebSocketServer {
// 匹配成功时,创建联机地图
Game game = new Game(
13,
14,
20,
MapSizeConfig.rows,
MapSizeConfig.cols,
MapSizeConfig.inner_walls_count,
a.getId(),
botA,
b.getId(),

View File

@ -1,6 +1,7 @@
package com.kob.backend.consumer.utils;
import com.alibaba.fastjson2.JSONObject;
import com.kob.backend.config.MapSizeConfig;
import com.kob.backend.consumer.WebSocketServer;
import com.kob.backend.pojo.Bot;
import com.kob.backend.pojo.Record;
@ -392,6 +393,9 @@ public class Game extends Thread {
playerA.getStepsString(),
playerB.getStepsString(),
getGameMapString(),
MapSizeConfig.rows,
MapSizeConfig.cols,
MapSizeConfig.inner_walls_count,
loser,
new Date()
);

View File

@ -27,6 +27,9 @@ public class Record {
private String aSteps;
private String bSteps;
private String map;
private Integer mapRows;
private Integer mapCols;
private Integer innerWallsCount;
private String loser;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")