Skip to content

Commit

Permalink
fix: pass through quality for giveItem (#1044)
Browse files Browse the repository at this point in the history
Co-authored-by: takaro-ci-bot[bot] <138661031+takaro-ci-bot[bot]@users.noreply.github.com>
  • Loading branch information
niekcandaele and takaro-ci-bot[bot] authored Jun 18, 2024
1 parent 9b5da9a commit 91da346
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/app-api/src/controllers/GameServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class GiveItemInputDTO extends TakaroDTO<GiveItemInputDTO> {

@IsNumber({ allowNaN: false, allowInfinity: false })
amount: number;
@IsNumber({ allowNaN: false, allowInfinity: false })
quality: number;
}

Expand Down Expand Up @@ -465,7 +466,7 @@ export class GameServerController {
})
async giveItem(@Req() req: AuthenticatedRequest, @Params() params: PogParam, @Body() data: GiveItemInputDTO) {
const service = new GameServerService(req.domainId);
const result = await service.giveItem(params.gameServerId, params.playerId, data.name, data.amount);
const result = await service.giveItem(params.gameServerId, params.playerId, data.name, data.amount, data.quality);
return apiResponse(result);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app-api/src/service/GameServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,10 @@ export class GameServerService extends TakaroService<
const gameInstance = await this.getGame(gameServerId);
return gameInstance.listBans();
}
async giveItem(gameServerId: string, playerId: string, item: string, amount: number) {
async giveItem(gameServerId: string, playerId: string, item: string, amount: number, quality: number) {
const gameInstance = await this.getGame(gameServerId);
const pog = await this.pogService.getPog(playerId, gameServerId);
return gameInstance.giveItem(pog, item, amount);
return gameInstance.giveItem(pog, item, amount, quality);
}

async getPlayers(gameServerId: string) {
Expand Down
6 changes: 6 additions & 0 deletions packages/lib-apiclient/src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,12 @@ export interface GiveItemInputDTO {
* @memberof GiveItemInputDTO
*/
amount: number;
/**
*
* @type {number}
* @memberof GiveItemInputDTO
*/
quality: number;
}
/**
*
Expand Down
4 changes: 2 additions & 2 deletions packages/lib-gameserver/src/gameservers/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export class Mock implements IGameServer {
return this.requestFromServer('listBans');
}

async giveItem(player: IPlayerReferenceDTO, item: string, amount: number): Promise<void> {
return this.requestFromServer('giveItem', player, item, amount);
async giveItem(player: IPlayerReferenceDTO, item: string, amount: number, quality: number): Promise<void> {
return this.requestFromServer('giveItem', player, item, amount, quality);
}

async listItems(): Promise<IItemDTO[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-gameserver/src/interfaces/GameServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface IGameServer {
getPlayerLocation(player: IPlayerReferenceDTO): Promise<IPosition | null>;
getPlayerInventory(player: IPlayerReferenceDTO): Promise<IItemDTO[]>;

giveItem(player: IPlayerReferenceDTO, item: string, amount: number): Promise<void>;
giveItem(player: IPlayerReferenceDTO, item: string, amount: number, quality: number): Promise<void>;
listItems(): Promise<IItemDTO[]>;

executeConsoleCommand(rawCommand: string): Promise<CommandOutput>;
Expand Down

Large diffs are not rendered by default.

0 comments on commit 91da346

Please sign in to comment.