Skip to content

Commit

Permalink
Merge pull request #2804 from WhatIsACore/master
Browse files Browse the repository at this point in the history
Prevent out of bounds drag drop exploit
  • Loading branch information
sylvainpolletvillard authored Feb 8, 2025
2 parents c49aba2 + 70edb1b commit 9ba0447
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/rooms/commands/game-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import {
PORTAL_CAROUSEL_BASE_DURATION,
PortalCarouselStages,
StageDuration,
SynergyTriggers
SynergyTriggers,
BOARD_WIDTH,
BOARD_SIDE_HEIGHT
} from "../../types/Config"
import { Effect } from "../../types/enum/Effect"
import { BattleResult, GamePhaseState, Team } from "../../types/enum/Game"
Expand Down Expand Up @@ -232,8 +234,17 @@ export class OnDragDropCommand extends Command<
if (player) {
message.updateItems = false
const pokemon = player.board.get(detail.id)
if (pokemon) {
const { x, y } = detail
const { x, y } = detail

if (
pokemon &&
x != null &&
x >= 0 &&
x < BOARD_WIDTH &&
y != null &&
y >= 0 &&
y < BOARD_SIDE_HEIGHT
) {
const dropOnBench = y == 0
const dropFromBench = isOnBench(pokemon)

Expand Down
1 change: 1 addition & 0 deletions app/types/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const SCOPE_LENS_MANA = 15
export const ARMOR_FACTOR = 0.1
export const BOARD_WIDTH = 8
export const BOARD_HEIGHT = 6
export const BOARD_SIDE_HEIGHT = 4 // 0 = bench

export const RarityHpCost: { [key in Rarity]: number } = Object.freeze({
[Rarity.COMMON]: 1,
Expand Down

0 comments on commit 9ba0447

Please sign in to comment.