테이블 수정
리더보드 테이블 설정을 수정하는 API입니다.
URL 확인
이 API는 service-api.playnanoo.com 도메인을 사용합니다.
API 정보
- URL:
https://service-api.playnanoo.com/leaderboard/v20240301/table/edit - Method:
PUT - 인증 필요: 예
DeviceInfo 상속
이 API의 Req 클래스는 DeviceInfo를 상속받습니다. DeviceInfo의 모든 속성이 자동으로 포함됩니다.
요청 파라미터
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| uid | string | 필수 | 테이블 코드 |
| record_type | string | 필수 | 기록 타입 ("highscore", "lowscore", "sum", "last") |
| record_sort_type | string | 필수 | 정렬 타입 ("asc", "desc") |
| record_priority | string | 필수 | 기록 우선순위 ("Y" 또는 "N") |
응답 데이터
Res 클래스
| 필드 | 타입 | 설명 |
|---|---|---|
| Status | string | 처리 상태 |
Unity C# 구현
BaseResponse 클래스
모든 API 응답의 기본 클래스입니다.
public class BaseResponse
{
public string ErrorCode;
public string Message;
public string WithdrawalKey;
public string BlockKey;
}
필드 설명:
ErrorCode: 에러 코드Message: 에러 메시지WithdrawalKey: 탈퇴 유예 상태인 경우 복구에 필요한 키 (탈퇴 유예 중인 계정만 제공)BlockKey: 차단된 계정인 경우 제공되는 키 (차단된 계정만 제공)
Enum 정의
public enum RecordType
{
LOWSCORE,
HIGHSCORE,
SUM,
LAST
}
public enum SortType
{
DESC,
ASC
}
테이블 수정 클래스
using System;
using System.Collections;
using UnityEngine.Networking;
public class TableEdit
{
static string path = "https://service-api.playnanoo.com/leaderboard/v20240301/table/edit";
[Serializable]
public class Req : DeviceInfo
{
public string uid;
public string record_type;
public string record_sort_type;
public string record_priority;
public IEnumerator Send(
string table_code,
RecordType recordType,
SortType recordSortType,
bool recordPriority,
Action<Res> onSuccess,
Action<BaseResponse> onError)
{
if (!string.IsNullOrEmpty(table_code)) this.uid = table_code;
this.record_type = GetRecordType(recordType);
this.record_sort_type = GetSortType(recordSortType);
this.record_priority = recordPriority ? "Y" : "N";
yield return HttpClient.Send<Req, Res>(
UnityWebRequest.kHttpVerbPUT,
path,
requireToken: true,
body: this,
onSuccess: onSuccess,
onError: onError
);
}
// 공통 Common 함수로 만들어 두세요.
private string GetRecordType(RecordType value)
{
return value switch
{
RecordType.LOWSCORE => "lowscore",
RecordType.SUM => "sum",
RecordType.LAST => "last",
_ => "highscore",
};
}
private string GetSortType(SortType value)
{
if (value == SortType.ASC)
{
return "asc";
}
return "desc";
}
}
[Serializable]
public class Res : BaseResponse
{
public string Status;
}
}
사용 예제
public void EditLeaderboardTable()
{
TableEdit.Req req = new TableEdit.Req();
StartCoroutine(req.Send(
table_code: "my_leaderboard_table",
recordType: RecordType.LOWSCORE, // 낮은 점수가 더 좋은 경우
recordSortType: SortType.ASC, // 오름차순 정렬
recordPriority: true,
onSuccess: res =>
{
Debug.Log("테이블 수정 성공");
Debug.Log($"상태: {res.Status}");
},
onError: error =>
{
Debug.LogError($"테이블 수정 실패: [{error.ErrorCode}] {error.Message}");
}
));
}
기록 타입
- highscore: 가장 높은 점수만 유지
- lowscore: 가장 낮은 점수만 유지 (레이스 게임 등에 적합)
- sum: 모든 점수를 합산
- last: 가장 최근 점수로 갱신
정렬 타입
- desc: 내림차순 정렬 (높은 점수가 상위)
- asc: 오름차순 정렬 (낮은 점수가 상위)
테이블 수정 주의사항
테이블 설정을 변경하면 기존 순위 계산 방식이 변경될 수 있습니다. 플레이어들이 이미 기록한 점수에 영향을 줄 수 있으므로 신중하게 변경하세요.