Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #13

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions docs/spec/CodeCharacter-API.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ paths:
in: query
name: size
description: Size of the page
- schema:
$ref: '#/components/schemas/TierType'
in: query
name: tier
description: Leaderboard Tier
description: Get PvP leaderboard
parameters: []

Expand Down Expand Up @@ -1659,23 +1664,31 @@ paths:
components:
schemas:
UserMatchStats:
title: UserMatchStats
title: UserMatchStat
type: array
description: User Match Stats array model
items:
anyOf:
- $ref: '#/components/schemas/UserMatchStat'
required:
- stat

UserMatchStat:
title: UserMatchStat
type: object
description: User Match Stats model
description: User Match Stat model
properties:
avgAtk:
type: number
default: 0
dc_wins:
type: number
default: 0
coins:
type: number
default: 0
required:
- avgAtk
- dc_wins
- coins

PasswordLoginRequest:
title: PasswordLoginRequest
type: object
Expand Down Expand Up @@ -2596,6 +2609,7 @@ components:
- DAILYCHALLENGE
- PVP
- SELFPVP
- AUTOPVP
description: Match Mode
Verdict:
type: string
Expand Down
10 changes: 9 additions & 1 deletion packages/client/src/apis/LeaderboardApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface GetLeaderboardRequest {
export interface GetPvPLeaderboardRequest {
page?: number;
size?: number;
tier?: TierType;
}

/**
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface LeaderboardApiInterface {
* @summary Get PvP leaderboard
* @param {number} [page] Index of the page
* @param {number} [size] Size of the page
* @param {TierType} [tier] Leaderboard Tier
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof LeaderboardApiInterface
Expand All @@ -84,6 +86,7 @@ export interface LeaderboardApiInterface {
getPvPLeaderboard(
page?: number,
size?: number,
tier?: TierType,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<PvPLeaderBoardResponse>>;
}
Expand Down Expand Up @@ -175,6 +178,10 @@ export class LeaderboardApi
queryParameters['size'] = requestParameters.size;
}

if (requestParameters.tier !== undefined) {
queryParameters['tier'] = requestParameters.tier;
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
Expand Down Expand Up @@ -205,10 +212,11 @@ export class LeaderboardApi
async getPvPLeaderboard(
page?: number,
size?: number,
tier?: TierType,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<PvPLeaderBoardResponse>> {
const response = await this.getPvPLeaderboardRaw(
{ page: page, size: size },
{ page: page, size: size, tier: tier },
initOverrides,
);
return await response.value();
Expand Down
14 changes: 7 additions & 7 deletions packages/client/src/apis/StatsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* CodeCharacter API
* Specification of the CodeCharacter API
*
* The version of the OpenAPI document: 2023.0.1
* The version of the OpenAPI document: 2024.0.1
* Contact: delta@nitt.edu
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -13,7 +13,7 @@
*/

import * as runtime from '../runtime';
import type { UserMatchStats } from '../models';
import type { UserMatchStatsInner } from '../models';

/**
* StatsApi - interface
Expand All @@ -31,15 +31,15 @@ export interface StatsApiInterface {
*/
getStatsRaw(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<Array<UserMatchStats>>>;
): Promise<runtime.ApiResponse<Array<Array<UserMatchStatsInner>>>>;

/**
* Gets all statistics for the current user
* Get all General Stats for current user and top user
*/
getStats(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<UserMatchStats>>;
): Promise<Array<Array<UserMatchStatsInner>>>;
}

/**
Expand All @@ -52,7 +52,7 @@ export class StatsApi extends runtime.BaseAPI implements StatsApiInterface {
*/
async getStatsRaw(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<Array<UserMatchStats>>> {
): Promise<runtime.ApiResponse<Array<Array<UserMatchStatsInner>>>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};
Expand All @@ -75,7 +75,7 @@ export class StatsApi extends runtime.BaseAPI implements StatsApiInterface {
initOverrides,
);

return new runtime.JSONApiResponse(response);
return new runtime.JSONApiResponse<any>(response);
}

/**
Expand All @@ -84,7 +84,7 @@ export class StatsApi extends runtime.BaseAPI implements StatsApiInterface {
*/
async getStats(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<UserMatchStats>> {
): Promise<Array<Array<UserMatchStatsInner>>> {
const response = await this.getStatsRaw(initOverrides);
return await response.value();
}
Expand Down
38 changes: 32 additions & 6 deletions packages/client/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ export const MatchMode = {
Dailychallenge: 'DAILYCHALLENGE',
Pvp: 'PVP',
Selfpvp: 'SELFPVP',
Autopvp: 'AUTOPVP',
} as const;
export type MatchMode = (typeof MatchMode)[keyof typeof MatchMode];

Expand Down Expand Up @@ -1376,27 +1377,52 @@ export interface UpdatePasswordRequest {
passwordConfirmation: string;
}
/**
* User Match Stats model
* User Match Stat model
* @export
* @interface UserMatchStats
* @interface UserMatchStat
*/
export interface UserMatchStats {
export interface UserMatchStat {
/**
*
* @type {number}
* @memberof UserMatchStats
* @memberof UserMatchStat
*/
avgAtk: number;
/**
*
* @type {number}
* @memberof UserMatchStats
* @memberof UserMatchStat
*/
dcWins: number;
/**
*
* @type {number}
* @memberof UserMatchStats
* @memberof UserMatchStat
*/
coins: number;
}
/**
*
* @export
* @interface UserMatchStatsInner
*/
export interface UserMatchStatsInner {
/**
*
* @type {number}
* @memberof UserMatchStatsInner
*/
avgAtk: number;
/**
*
* @type {number}
* @memberof UserMatchStatsInner
*/
dcWins: number;
/**
*
* @type {number}
* @memberof UserMatchStatsInner
*/
coins: number;
}
Expand Down
25 changes: 21 additions & 4 deletions packages/renderer/src/RendererComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Renderer } from './Renderer';

const RendererLayer = createComponent(React, 'cc-renderer', Renderer);

const StatsText = () => {
const StatsText = ({ shouldShowStats }: { shouldShowStats: boolean }) => {
const [turns, setTurns] = React.useState(0);
const [coins, setCoins] = React.useState(0);
const [destruction, setDestruction] = React.useState(0);
Expand Down Expand Up @@ -51,7 +51,7 @@ const StatsText = () => {
events.once(RendererEvents.CHANGE_DESTRUCTION, onDestructionUpdated);
}, [destruction]);

return (
return shouldShowStats ? (
<p
style={{
textAlign: 'right',
Expand All @@ -67,10 +67,27 @@ const StatsText = () => {
<br />
Destruction : {String(destruction.toFixed(2)).padStart(6, '\xa0')} %
</p>
) : (
<p
style={{
textAlign: 'right',
color: 'white',
fontFamily: 'Poppins',
fontSize: '1rem',
padding: '1rem',
}}
>
Turn : {String(turns).padStart(8, '\xa0')}
<br />
</p>
);
};

export default function RendererComponent(): JSX.Element {
export default function RendererComponent({
shouldShowStats,
}: {
shouldShowStats?: boolean;
}): JSX.Element {
const [isPaused, setPaused] = React.useState(false);
const [isFullscreen, setFullscreen] = React.useState(false);

Expand Down Expand Up @@ -166,7 +183,7 @@ export default function RendererComponent(): JSX.Element {
)}
</Button>
</ButtonGroup>
<StatsText />
<StatsText shouldShowStats={shouldShowStats ?? true} />
</ButtonToolbar>
<RendererLayer />
</>
Expand Down
Loading
Loading