Skip to content

Commit 8b525ed

Browse files
authored
Merge pull request #68 from x-team/GAMESHQ_Tower_Hotfix
Gameshq tower hotfix
2 parents 6a2bfe0 + 7c876cc commit 8b525ed

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/models/TowerRoundAction.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,29 @@ export async function findAllActionsByRound(roundId: number, transaction: Transa
248248
});
249249
}
250250

251+
interface OptionalWhereParams {
252+
_towerRaiderId?: number;
253+
_towerFloorBattlefieldEnemyId?: number;
254+
_towerRoundId: number;
255+
}
256+
251257
export async function findRoundAction(
252258
{ raiderId = null, enemyId = null, roundId }: RoundActionKey,
253259
transaction?: Transaction
254260
) {
261+
let mutableWhereQuery: OptionalWhereParams = {
262+
_towerRoundId: roundId,
263+
};
264+
if (raiderId) {
265+
mutableWhereQuery['_towerRaiderId'] = raiderId;
266+
}
267+
268+
if (enemyId) {
269+
mutableWhereQuery['_towerFloorBattlefieldEnemyId'] = enemyId;
270+
}
271+
255272
return TowerRoundAction.findOne({
256-
where: {
257-
_towerRaiderId: raiderId ?? undefined,
258-
_towerFloorBattlefieldEnemyId: enemyId ?? undefined,
259-
_towerRoundId: roundId ?? undefined,
260-
},
273+
where: mutableWhereQuery as WhereOptions<TowerRoundActionAttributes>,
261274
transaction,
262275
});
263276
}

0 commit comments

Comments
 (0)