import { ACTIVITY_TYPE } from '../../consts';
import { ActivityModel, ActivityModelType } from '../../db/Activity';
import { ActivityRefreshTaskModel, ActivityRefreshTaskModelType } from '../../db/ActivityRefreshTask';
import { ActivityRefreshTaskPointModel, ActivityRefreshTaskPointModelType } from '../../db/ActivityRefreshTaskPoint';
import { RefreshTaskData } from '../../domain/activityField/refreshTaskField';
import { getRoleCreateTime, getServerCreateTime } from '../redisService';
import { getActivitiesByType, getActivityById } from './activityService';

/**
   * 玩家玩家活动数据
   *
   * @param {number} serverId 区Id
   * @param {number} activityId 活动Id
   * @param {string} roleId 角色Id
   *
   */
export async function getPlayerRefreshTaskData(activityId: number, serverId: number, roleId: string) {
    let activityData = await getActivityById(activityId);
    let createTime = await getRoleCreateTime(roleId);
    let serverTime = await getServerCreateTime(serverId);
    let playerData = new RefreshTaskData(activityData, createTime, serverTime);
    let playerRecords: ActivityRefreshTaskModelType[] = await ActivityRefreshTaskModel.findData(serverId, activityId, roleId, playerData.roundIndex);
    let pointRecordData: ActivityRefreshTaskPointModelType = await ActivityRefreshTaskPointModel.findData(serverId, activityId, roleId);
    playerData.setPlayerRecords(playerRecords, pointRecordData);
    return playerData;
}


