Entkopple Partnersuche vom Altersabstand und entferne garantierte Schwangerschaften
All checks were successful
Deploy to production / deploy (push) Successful in 2m41s
All checks were successful
Deploy to production / deploy (push) Successful in 2m41s
This commit is contained in:
20
backend/utils/falukant/partnerCandidates.js
Normal file
20
backend/utils/falukant/partnerCandidates.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Op, Sequelize } from 'sequelize';
|
||||
|
||||
// One calendar day is one game year. Only the minimum age restricts age;
|
||||
// neither the age difference nor the date the character was created matters.
|
||||
export function buildPartnerCandidateQuery({ characterId, gender, regionId, titleId, minimumAge, now = new Date() }) {
|
||||
const minimumAgeCutoff = new Date(now);
|
||||
minimumAgeCutoff.setHours(0, 0, 0, 0);
|
||||
minimumAgeCutoff.setDate(minimumAgeCutoff.getDate() - minimumAge + 1);
|
||||
return {
|
||||
where: {
|
||||
id: { [Op.ne]: characterId },
|
||||
gender: { [Op.ne]: gender },
|
||||
regionId,
|
||||
birthdate: { [Op.lt]: minimumAgeCutoff },
|
||||
titleOfNobility: { [Op.between]: [titleId - 1, titleId + 1] },
|
||||
},
|
||||
order: Sequelize.literal('random()'),
|
||||
limit: 5,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user