package com.red.circle.other.app.inner.endpoint.game;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.game.GameLudoClientService;
import com.red.circle.other.inner.endpoint.game.api.GameLudoClientApi;
import com.red.circle.other.inner.model.cmd.game.GameLudoQryCmd;
import com.red.circle.other.inner.model.dto.game.GameLudoHistoryDTO;
import com.red.circle.other.inner.model.dto.game.GameLudoHistoryInfoDTO;
import com.red.circle.other.inner.model.dto.game.GameLudoPlayersDTO;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 飞行棋
 * @author zongpubin on 2024/1/26
 */
@Validated
@RestController
@RequestMapping(value = GameLudoClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GameLudoClientEndpoint implements GameLudoClientApi {

  private final GameLudoClientService gameLudoClientService;

  @Override
  public ResultResponse<List<GameLudoHistoryInfoDTO>> listGameLudoRun(GameLudoQryCmd query) {
    return ResultResponse.success(gameLudoClientService.listGameLudoRun(query));
  }

  @Override
  public ResultResponse<Void> dismiss(Long roomId) {
    gameLudoClientService.dismiss(roomId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<List<GameLudoHistoryDTO>> flowSelective(GameLudoQryCmd query) {
    return ResultResponse.success(gameLudoClientService.flowSelective(query));
  }

  @Override
  public ResultResponse<Map<Long, List<GameLudoPlayersDTO>>> mapLudoPlayersByGameId(
      Set<Long> gameIds) {
    return ResultResponse.success(gameLudoClientService.mapLudoPlayersByGameId(gameIds));
  }
}
