|
|
@ -48,6 +48,8 @@ public class ScreenService implements IScreenService{ |
|
|
|
@Autowired |
|
|
|
private GameRecordDao gameRecordDao; |
|
|
|
@Autowired |
|
|
|
private GameGroupDao gameGroupDao; |
|
|
|
@Autowired |
|
|
|
private GameActivityRuleDao activityRuleDao; |
|
|
|
@Autowired |
|
|
|
private GameActivityPrizeDao activityPrizeDao; |
|
|
@ -111,7 +113,18 @@ public class ScreenService implements IScreenService{ |
|
|
|
gameRecord.setUrl(WebConstant.TEST_URL_GAME + gameType.getScreenUrl() + "?id="+gameRecord.getId()); |
|
|
|
gameRecord.setQrCodeUrl(WebConstant.TEST_URL_GAME + gameRecord.getId() + File.separator + gameType.getClientUrl()); |
|
|
|
gameRecordDao.insertSelective(gameRecord); |
|
|
|
//4、 判断是否有分组
|
|
|
|
//4、 判断是否有分组,如果是分组游戏,添加两条分组信息
|
|
|
|
if(gameType.getIsGroup() == 1){ |
|
|
|
GameGroup gameGroupBlue = new GameGroup(); |
|
|
|
gameGroupBlue.setId(snowflake.nextId()); |
|
|
|
gameGroupBlue.setRecordId(gameRecord.getId()); |
|
|
|
gameGroupBlue.setName("蓝队"); |
|
|
|
GameGroup gameGroupRed = new GameGroup(); |
|
|
|
gameGroupRed.setId(snowflake.nextId()); |
|
|
|
gameGroupRed.setRecordId(gameRecord.getId()); |
|
|
|
gameGroupRed.setName("红队"); |
|
|
|
} |
|
|
|
|
|
|
|
//5、查询该游戏的规则
|
|
|
|
List<String> ruleList = getGameActivityRule(gameType.getId()); |
|
|
|
//6、返回
|
|
|
@ -170,9 +183,23 @@ public class ScreenService implements IScreenService{ |
|
|
|
gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord()); |
|
|
|
totalUsers = gameUserJoinDao.countByExample(gameuserJoinExample); |
|
|
|
} |
|
|
|
|
|
|
|
//总人数
|
|
|
|
gameInfoVo.setTotalMembers(totalUsers == null ? 0 : totalUsers.intValue()); |
|
|
|
|
|
|
|
//获取分组信息
|
|
|
|
GameGroupExample gameGroupExample = new GameGroupExample(); |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameGroupList)){ |
|
|
|
List<ScreenVo.Group> groups = new ArrayList<>(); |
|
|
|
for(GameGroup gameGroup:gameGroupList){ |
|
|
|
ScreenVo.Group group = new ScreenVo.Group(); |
|
|
|
group.setGroupId(gameGroup.getId()); |
|
|
|
group.setGroupName(gameGroup.getName()); |
|
|
|
groups.add(group); |
|
|
|
} |
|
|
|
gameInfoVo.setGroups(groups); |
|
|
|
} |
|
|
|
|
|
|
|
switch (gameInfoVo.getGameStatus()){ |
|
|
|
case 0: |
|
|
@ -214,6 +241,8 @@ public class ScreenService implements IScreenService{ |
|
|
|
return gameInfoVo; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取游戏状态 |
|
|
|
*/ |
|
|
@ -270,6 +299,28 @@ public class ScreenService implements IScreenService{ |
|
|
|
return gameStatusVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 结束时查询胜利组的信息(总分数,总次数,平均以及前十名) |
|
|
|
*/ |
|
|
|
private ScreenVo.CompletedData getCompletedDataByWin(Long gameRecordId) { |
|
|
|
//1、分别查询redis内每个队伍的总分,
|
|
|
|
//2、查询获胜队伍的信息
|
|
|
|
|
|
|
|
//3、redis内没有则查询数据库
|
|
|
|
//查询分组信息
|
|
|
|
GameGroupExample gameGroupExample = new GameGroupExample(); |
|
|
|
gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecordId); |
|
|
|
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample); |
|
|
|
if(CollectionUtil.isNotEmpty(gameGroupList)){ |
|
|
|
//分别查找两个队伍的总分
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//4、分别查询每个队伍的总分
|
|
|
|
//5、获取获胜队伍的信息
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询总分数,总次数,平均以及前十名 |
|
|
|
* @param gameRecordId |
|
|
|