import { GameInfo, GoodInfo } from "./UserM";
import WsM from "./WsM";

export class ClaimSpinResult {
  changeSpin: number;
  currentSpin: number;
}

export class GameSpinResult {
  spinId: string; // 转盘id
  spinPog: number; // 基础值
  rankPog: number; // 排行加成值
  ranKAddition: number; // 排行加成比例
  gamePassPog: number; // 通行证加成值
  gamePassAddition: number; // 通行证加成比例
  totalPog: number; // 总值
  currentSpin: number;
  goodList: GoodInfo[];
}

export class CritRewardResult {
  critPog: number;
  goodList: GoodInfo[];
}
export default class GameM {
  async claimGamePassGift(gameId: number, giftId: number) {
    let result = await WsM.ins.syncRequest(24007, {
      gameId: gameId,
      giftId: giftId,
    });
    return result;
  }
  async bindGame(gameId: number, input: string) {
    let result = await WsM.ins.syncRequest(24002, {
      gameId: gameId,
      wallet: input,
    });
    return result;
  }

  async LinkGameConfirm(
    gameId: number,
    userId: string,
    userName: string,
    wallet: string
  ) {
    let result = await WsM.ins.syncRequest(24003, {
      gameId: gameId,
      gameUser: {
        userId: userId,
        userName: userName,
        wallet: wallet,
      },
    });
    return result;
  }

  async getCritReward(gameId: number, spinId: string) {
    let result = await WsM.ins.syncRequest(24006, {
      gameId: gameId,
      id: spinId,
    });
    return result;
  }
  async gameSpin(gameId: number): Promise<GameSpinResult> {
    let result = await WsM.ins.syncRequest(24005, { gameId: gameId });
    return result;
  }
  async claimSpinTimes(
    gameId: number,
    taskId: number
  ): Promise<ClaimSpinResult> {
    let result = await WsM.ins.syncRequest(24004, {
      gameId: gameId,
      taskId: taskId,
    });
    return result;
  }
  private static _ins: GameM;
  public static get ins(): GameM {
    return (GameM._ins ??= new GameM());
  }

  // public async getGameList(): Promise<any> {
  //   let result = await WsM.ins.syncRequest(24001, {});
  //   return result;
  // }

  public async getGameDetailInfo(gameId: number): Promise<GameInfo> {
    let result = await WsM.ins.syncRequest(24001, { gameId: gameId });
    return result;
  }
}
