Skip to content

Commit 83da461

Browse files
committed
fix: pokemon background db support
1 parent 1930643 commit 83da461

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

packages/types/lib/server.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface DbContext {
4848
hasShowcaseType: boolean
4949
hasStationedGmax: boolean
5050
hasBattlePokemonStats: boolean
51+
hasPokemonBackground: boolean
5152
hasPokemonShinyStats?: boolean
5253
connection?: number
5354
}

server/src/models/Pokemon.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,16 @@ class Pokemon extends Model {
132132
static async getAll(perms, args, ctx) {
133133
const { iv: ivs, pvp, areaRestrictions } = perms
134134
const { onlyIvOr, onlyHundoIv, onlyZeroIv, onlyAreas = [] } = args.filters
135-
const { hasSize, hasHeight, isMad, mem, secret, httpAuth, pvpV2 } = ctx
135+
const {
136+
hasSize,
137+
hasHeight,
138+
hasPokemonBackground,
139+
isMad,
140+
mem,
141+
secret,
142+
httpAuth,
143+
pvpV2,
144+
} = ctx
136145
const { filterMap, globalFilter } = this.getFilters(perms, args, ctx)
137146

138147
let queryPvp = config
@@ -175,7 +184,14 @@ class Pokemon extends Model {
175184
if (isMad) {
176185
Pokemon.getMadSql(query)
177186
} else {
178-
query.select(['*', hasSize && !hasHeight ? 'size AS height' : 'size'])
187+
const selectColumns = [
188+
'*',
189+
hasSize && !hasHeight ? 'size AS height' : 'size',
190+
]
191+
if (hasPokemonBackground) {
192+
selectColumns.push('background')
193+
}
194+
query.select(selectColumns)
179195
}
180196
query.where(
181197
isMad ? 'disappear_time' : 'expire_timestamp',

server/src/services/DbManager.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,16 @@ class DbManager extends Logger {
131131
* @returns {Promise<import("@rm/types").DbContext>}
132132
*/
133133
static async schemaCheck(schema) {
134-
const [isMad, pvpV2, hasSize, hasHeight] = await schema('pokemon')
135-
.columnInfo()
136-
.then((columns) => [
137-
'cp_multiplier' in columns,
138-
'pvp' in columns,
139-
'size' in columns,
140-
'height' in columns,
141-
])
134+
const [isMad, pvpV2, hasSize, hasHeight, hasPokemonBackground] =
135+
await schema('pokemon')
136+
.columnInfo()
137+
.then((columns) => [
138+
'cp_multiplier' in columns,
139+
'pvp' in columns,
140+
'size' in columns,
141+
'height' in columns,
142+
'background' in columns,
143+
])
142144
const [
143145
hasRewardAmount,
144146
hasPowerUp,
@@ -220,6 +222,7 @@ class DbManager extends Logger {
220222
hasBattlePokemonStats,
221223
hasShortcode,
222224
hasPokemonShinyStats,
225+
hasPokemonBackground,
223226
}
224227
}
225228

@@ -237,7 +240,6 @@ class DbManager extends Logger {
237240
: {
238241
mem: this.endpoints[i].endpoint,
239242
secret: this.endpoints[i].secret,
240-
// Add support for HTTP authentication
241243
httpAuth: this.endpoints[i].httpAuth,
242244
pvpV2: true,
243245
}

0 commit comments

Comments
 (0)