|
|
@ -243,6 +243,11 @@ public class ScreenService implements IScreenService{ |
|
|
|
|
|
|
|
gameStatusVo.setGameStatus(gameRecord.getGameStatus()); |
|
|
|
|
|
|
|
GameUserJoinExample gameuserJoinExample = new GameUserJoinExample(); |
|
|
|
gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord()); |
|
|
|
List<GameUserJoin> userJoins = gameUserJoinDao.selectByExample(gameuserJoinExample); |
|
|
|
gameStatusVo.setTotalMembers(userJoins.size()); |
|
|
|
|
|
|
|
switch (gameStatusVo.getGameStatus()){ |
|
|
|
case 0: |
|
|
|
break; |
|
|
@ -294,10 +299,9 @@ public class ScreenService implements IScreenService{ |
|
|
|
} |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
// List<ClientDto.RedisUser> userJoins = sendMsg.getAllScore(gameRecord);
|
|
|
|
GameUserJoinExample gameuserJoinExample = new GameUserJoinExample(); |
|
|
|
gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord()); |
|
|
|
List<GameUserJoin> userJoins = gameUserJoinDao.selectByExample(gameuserJoinExample); |
|
|
|
// GameUserJoinExample gameuserJoinExample = new GameUserJoinExample();
|
|
|
|
// gameuserJoinExample.createCriteria().andRecordIdEqualTo(memberRecord.getMemberRecord());
|
|
|
|
// List<GameUserJoin> userJoins = gameUserJoinDao.selectByExample(gameuserJoinExample);
|
|
|
|
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData(); |
|
|
|
if(CollectionUtil.isNotEmpty(userJoins)){ |
|
|
|
completedData = getCompletedData(userJoins); |
|
|
@ -316,7 +320,7 @@ public class ScreenService implements IScreenService{ |
|
|
|
* 再玩一次 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String startAgain(QueryDto<ScreenDto.MemberRecord> params) { |
|
|
|
public String startAgain(QueryDto<ScreenDto.MemberRecord> params) throws Exception { |
|
|
|
ScreenDto.MemberRecord memberRecord = params.getParam(); |
|
|
|
GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(memberRecord.getMemberRecord()); |
|
|
|
if(ObjectUtil.isNull(gameRecord)){ |
|
|
@ -330,17 +334,6 @@ public class ScreenService implements IScreenService{ |
|
|
|
if(ObjectUtil.isNull(gameType)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
|
} |
|
|
|
// //添加一场新的游戏记录
|
|
|
|
// GameRecord gameRecordNew = new GameRecord();
|
|
|
|
// gameRecordNew.setId(snowflake.nextId());
|
|
|
|
// gameRecordNew.setUserPayId(gameUserPay.getId());
|
|
|
|
// gameRecordNew.setUrl(WebConstant.TEST_URL_GAME + gameRecordNew.getId() + File.separator + gameType.getScreenUrl());
|
|
|
|
// gameRecordNew.setQrCodeUrl(WebConstant.TEST_URL_GAME + gameRecordNew.getId() + File.separator + gameType.getClientUrl());
|
|
|
|
// gameRecordDao.insertSelective(gameRecordNew);
|
|
|
|
// //修改购买的游戏的使用次数
|
|
|
|
// gameUserPay.setUsedCount(gameUserPay.getUsedCount() + 1);
|
|
|
|
// gameUserPayDao.updateByPrimaryKeySelective(gameUserPay);
|
|
|
|
|
|
|
|
|
|
|
|
if(gameUserPay.getUsedCount() >= gameUserPay.getTotalCount()){ |
|
|
|
throw new BaseException(CodeEnum. GAME_NOT_TIMES); |
|
|
@ -357,6 +350,23 @@ public class ScreenService implements IScreenService{ |
|
|
|
//修改购买的游戏的使用次数
|
|
|
|
gameUserPay.setUsedCount(gameUserPay.getUsedCount() + 1); |
|
|
|
gameUserPayDao.updateByPrimaryKeySelective(gameUserPay); |
|
|
|
|
|
|
|
// //给所有人发送消息发送消息
|
|
|
|
// ChromeMessageDto chromeMessageDto = new ChromeMessageDto(gameRecord.getUrl(),gameRecord.getId(),memberGame.getProjectId());
|
|
|
|
// BaseMessageDto.MessageUser messageUser = null;
|
|
|
|
// List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>();
|
|
|
|
// //获取项目下所有成员
|
|
|
|
// List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberGame.getProjectId());
|
|
|
|
// if(CollectionUtil.isNotEmpty(memberIdList)){
|
|
|
|
// for(Long memberId:memberIdList){
|
|
|
|
// messageUser = new BaseMessageDto.MessageUser();
|
|
|
|
// messageUser.setUserId(memberId);
|
|
|
|
// messageUserList.add(messageUser);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// chromeMessageDto.setReceivers(messageUserList);
|
|
|
|
// messageService.sendGameMessageWithGetUrl(chromeMessageDto);
|
|
|
|
|
|
|
|
}else { |
|
|
|
throw new BaseException(CodeEnum.GAME_NO_END); |
|
|
|
} |
|
|
@ -466,7 +476,11 @@ public class ScreenService implements IScreenService{ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 开始游戏 |
|
|
|
* @param start |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ScreenVo.StartGame startGame(ScreenDto.Start start) { |
|
|
|
long current = System.currentTimeMillis(); |
|
|
@ -552,8 +566,10 @@ public class ScreenService implements IScreenService{ |
|
|
|
}); |
|
|
|
|
|
|
|
long endTime = gameRecord.getEndTime() - System.currentTimeMillis(); |
|
|
|
System.out.println("游戏结束"); |
|
|
|
sendMsg.sendMsg(executor, endTime > 0 ? endTime : 0, ()->{ |
|
|
|
try { |
|
|
|
System.out.println("-----游戏结束"); |
|
|
|
sendMsg.sendStatus(gameRecord, userJoins, GameConstant.GAME_COMPLETED); |
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|