Spiel erweitert
This commit is contained in:
@@ -65,6 +65,26 @@ import PromotionalGiftLog from './falukant/log/promotional_gift.js';
|
||||
import HouseType from './falukant/type/house.js';
|
||||
import BuyableHouse from './falukant/data/buyable_house.js';
|
||||
import UserHouse from './falukant/data/user_house.js';
|
||||
import PartyType from './falukant/type/party.js';
|
||||
import Party from './falukant/data/party.js';
|
||||
import MusicType from './falukant/type/music.js';
|
||||
import BanquetteType from './falukant/type/banquette.js';
|
||||
import PartyInvitedNobility from './falukant/data/partyInvitedNobility.js';
|
||||
import ChildRelation from './falukant/data/child_relation.js';
|
||||
import Learning from './falukant/data/learning.js';
|
||||
import LearnRecipient from './falukant/type/learn_recipient.js';
|
||||
import Credit from './falukant/data/credit.js';
|
||||
import DebtorsPrism from './falukant/data/debtors_prism.js';
|
||||
import HealthActivity from './falukant/log/health_activity.js';
|
||||
import Election from './falukant/data/election.js';
|
||||
import ElectionResult from './falukant/data/election_result.js';
|
||||
import Candidate from './falukant/data/candidate.js';
|
||||
import Vote from './falukant/data/vote.js';
|
||||
import PoliticalOfficeType from './falukant/type/political_office_type.js';
|
||||
import PoliticalOffice from './falukant/data/political_office.js';
|
||||
import PoliticalOfficeBenefit from './falukant/predefine/political_office_benefit.js';
|
||||
import PoliticalOfficeBenefitType from './falukant/type/political_office_benefit_type.js';
|
||||
import PoliticalOfficeRequirement from './falukant/predefine/political_office_prerequisite.js';
|
||||
|
||||
export default function setupAssociations() {
|
||||
// UserParam related associations
|
||||
@@ -275,7 +295,7 @@ export default function setupAssociations() {
|
||||
|
||||
BuyableStock.belongsTo(FalukantStockType, { foreignKey: 'stockTypeId', as: 'stockType' });
|
||||
FalukantStockType.hasMany(BuyableStock, { foreignKey: 'stockTypeId', as: 'buyableStocks' });
|
||||
|
||||
|
||||
Director.belongsTo(FalukantUser, { foreignKey: 'employerUserId', as: 'user' });
|
||||
FalukantUser.hasMany(Director, { foreignKey: 'employerUserId', as: 'directors' });
|
||||
|
||||
@@ -315,31 +335,31 @@ export default function setupAssociations() {
|
||||
Notification.belongsTo(FalukantUser, { foreignKey: 'userId', as: 'user' });
|
||||
FalukantUser.hasMany(Notification, { foreignKey: 'userId', as: 'notifications' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, {foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'requesterCharacterId', as: 'requesterCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'requesterCharacterId', as: 'initiatedProposals' });
|
||||
|
||||
MarriageProposal.belongsTo(FalukantCharacter, {foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, {foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, {through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, {through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
|
||||
Mood.hasMany(FalukantCharacter, {foreignKey: 'mood_id', as: 'moods'});
|
||||
FalukantCharacter.belongsTo(Mood, {foreignKey: 'mood_id', as: 'mood'});
|
||||
|
||||
PromotionalGift.belongsToMany(CharacterTrait, {through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits',});
|
||||
CharacterTrait.belongsToMany(PromotionalGift, {through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts',});
|
||||
MarriageProposal.belongsTo(FalukantCharacter, { foreignKey: 'proposedCharacterId', as: 'proposedCharacter', });
|
||||
FalukantCharacter.hasMany(MarriageProposal, { foreignKey: 'proposedCharacterId', as: 'receivedProposals' });
|
||||
|
||||
PromotionalGift.belongsToMany(Mood, {through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods',});
|
||||
Mood.belongsToMany(PromotionalGift, {through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts',});
|
||||
FalukantCharacter.belongsToMany(CharacterTrait, { through: FalukantCharacterTrait, foreignKey: 'character_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(FalukantCharacter, { through: FalukantCharacterTrait, foreignKey: 'trait_id', as: 'characters', });
|
||||
|
||||
Mood.hasMany(FalukantCharacter, { foreignKey: 'mood_id', as: 'moods' });
|
||||
FalukantCharacter.belongsTo(Mood, { foreignKey: 'mood_id', as: 'mood' });
|
||||
|
||||
PromotionalGift.belongsToMany(CharacterTrait, { through: PromotionalGiftCharacterTrait, foreignKey: 'gift_id', as: 'traits', });
|
||||
CharacterTrait.belongsToMany(PromotionalGift, { through: PromotionalGiftCharacterTrait, foreignKey: 'trait_id', as: 'gifts', });
|
||||
|
||||
PromotionalGift.belongsToMany(Mood, { through: PromotionalGiftMood, foreignKey: 'gift_id', as: 'moods', });
|
||||
Mood.belongsToMany(PromotionalGift, { through: PromotionalGiftMood, foreignKey: 'mood_id', as: 'gifts', });
|
||||
|
||||
Relationship.belongsTo(RelationshipType, { foreignKey: 'relationshipTypeId', as: 'relationshipType' });
|
||||
RelationshipType.hasMany(Relationship, { foreignKey: 'relationshipTypeId', as: 'relationships' });
|
||||
|
||||
Relationship.belongsTo(FalukantCharacter, {foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, {foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, {foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, {foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character1Id', as: 'character1', });
|
||||
Relationship.belongsTo(FalukantCharacter, { foreignKey: 'character2Id', as: 'character2', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character1Id', as: 'relationshipsAsCharacter1', });
|
||||
FalukantCharacter.hasMany(Relationship, { foreignKey: 'character2Id', as: 'relationshipsAsCharacter2', });
|
||||
|
||||
PromotionalGiftLog.belongsTo(PromotionalGift, { foreignKey: 'giftId', as: 'gift' });
|
||||
PromotionalGift.hasMany(PromotionalGiftLog, { foreignKey: 'giftId', as: 'logs' });
|
||||
@@ -367,4 +387,262 @@ export default function setupAssociations() {
|
||||
|
||||
TitleOfNobility.hasMany(HouseType, { foreignKey: 'minimumNobleTitle', as: 'houseTypes' });
|
||||
HouseType.belongsTo(TitleOfNobility, { foreignKey: 'minimumNobleTitle', as: 'titleOfNobility' });
|
||||
|
||||
PartyType.hasMany(Party, { foreignKey: 'partyTypeId', as: 'parties' });
|
||||
Party.belongsTo(PartyType, { foreignKey: 'partyTypeId', as: 'partyType' });
|
||||
|
||||
MusicType.hasMany(Party, { foreignKey: 'musicTypeId', as: 'parties' });
|
||||
Party.belongsTo(MusicType, { foreignKey: 'musicTypeId', as: 'musicType' });
|
||||
|
||||
BanquetteType.hasMany(Party, { foreignKey: 'banquetteTypeId', as: 'parties' });
|
||||
Party.belongsTo(BanquetteType, { foreignKey: 'banquetteTypeId', as: 'banquetteType' });
|
||||
|
||||
FalukantUser.hasMany(Party, { foreignKey: 'falukantUserId', as: 'parties' });
|
||||
Party.belongsTo(FalukantUser, { foreignKey: 'falukantUserId', as: 'partyUser' });
|
||||
|
||||
Party.belongsToMany(TitleOfNobility, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'party_id',
|
||||
otherKey: 'title_of_nobility_id',
|
||||
as: 'invitedNobilities',
|
||||
});
|
||||
TitleOfNobility.belongsToMany(Party, {
|
||||
through: PartyInvitedNobility,
|
||||
foreignKey: 'title_of_nobility_id',
|
||||
otherKey: 'party_id',
|
||||
as: 'partiesInvitedTo',
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'father'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'fatherCharacterId',
|
||||
as: 'childrenFather'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'mother'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'motherCharacterId',
|
||||
as: 'childrenMother'
|
||||
});
|
||||
|
||||
ChildRelation.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'child'
|
||||
});
|
||||
FalukantCharacter.hasMany(ChildRelation, {
|
||||
foreignKey: 'childCharacterId',
|
||||
as: 'parentRelations'
|
||||
});
|
||||
|
||||
Learning.belongsTo(LearnRecipient, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'recipient'
|
||||
}
|
||||
);
|
||||
|
||||
LearnRecipient.hasMany(Learning, {
|
||||
foreignKey: 'learningRecipientId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantUser, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learner'
|
||||
}
|
||||
);
|
||||
|
||||
FalukantUser.hasMany(Learning, {
|
||||
foreignKey: 'associatedFalukantUserId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(ProductType, {
|
||||
foreignKey: 'productId',
|
||||
as: 'productType'
|
||||
});
|
||||
|
||||
ProductType.hasMany(Learning, {
|
||||
foreignKey: 'productId',
|
||||
as: 'learnings'
|
||||
});
|
||||
|
||||
Learning.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningCharacter'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(Learning, {
|
||||
foreignKey: 'associatedLearningCharacterId',
|
||||
as: 'learningsCharacter'
|
||||
});
|
||||
|
||||
FalukantUser.hasMany(Credit, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'credits'
|
||||
});
|
||||
Credit.belongsTo(FalukantUser, {
|
||||
foreignKey: 'falukantUserId',
|
||||
as: 'user'
|
||||
});
|
||||
|
||||
FalukantCharacter.hasMany(DebtorsPrism, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'debtorsPrisms'
|
||||
});
|
||||
DebtorsPrism.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
|
||||
HealthActivity.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(HealthActivity, {
|
||||
foreignKey: 'character_id',
|
||||
as: 'healthActivities'
|
||||
});
|
||||
|
||||
// — Political Offices —
|
||||
|
||||
// predefine requirements for office
|
||||
PoliticalOfficeRequirement.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficeRequirement, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'requirements'
|
||||
});
|
||||
|
||||
// predefine benefits for office
|
||||
PoliticalOfficeBenefit.belongsTo(
|
||||
PoliticalOfficeBenefitType,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinition' }
|
||||
);
|
||||
PoliticalOfficeBenefitType.hasMany(
|
||||
PoliticalOfficeBenefit,
|
||||
{ foreignKey: 'benefitTypeId', as: 'benefitDefinitions' }
|
||||
);
|
||||
|
||||
// tie benefits back to office type
|
||||
PoliticalOfficeBenefit.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOfficeBenefit, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'benefits'
|
||||
});
|
||||
|
||||
// actual office holdings
|
||||
PoliticalOffice.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'type'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
PoliticalOffice.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'holder'
|
||||
});
|
||||
FalukantCharacter.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'heldOffices'
|
||||
});
|
||||
|
||||
// elections
|
||||
Election.belongsTo(PoliticalOfficeType, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'officeType'
|
||||
});
|
||||
PoliticalOfficeType.hasMany(Election, {
|
||||
foreignKey: 'officeTypeId',
|
||||
as: 'elections'
|
||||
});
|
||||
|
||||
// candidates in an election
|
||||
Candidate.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(Candidate, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'candidates'
|
||||
});
|
||||
|
||||
Candidate.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'character'
|
||||
});
|
||||
FalukantCharacter.hasMany(Candidate, {
|
||||
foreignKey: 'characterId',
|
||||
as: 'candidacies'
|
||||
});
|
||||
|
||||
// votes cast
|
||||
Vote.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(Vote, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
Vote.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
});
|
||||
Candidate.hasMany(Vote, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'votes'
|
||||
});
|
||||
|
||||
Vote.belongsTo(FalukantCharacter, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'voter'
|
||||
});
|
||||
FalukantCharacter.hasMany(Vote, {
|
||||
foreignKey: 'voterCharacterId',
|
||||
as: 'votesCast'
|
||||
});
|
||||
|
||||
// election results
|
||||
ElectionResult.belongsTo(Election, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'election'
|
||||
});
|
||||
Election.hasMany(ElectionResult, {
|
||||
foreignKey: 'electionId',
|
||||
as: 'results'
|
||||
});
|
||||
|
||||
ElectionResult.belongsTo(Candidate, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'candidate'
|
||||
});
|
||||
Candidate.hasMany(ElectionResult, {
|
||||
foreignKey: 'candidateId',
|
||||
as: 'results'
|
||||
});
|
||||
|
||||
PoliticalOffice.belongsTo(RegionData, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'region'
|
||||
});
|
||||
RegionData.hasMany(PoliticalOffice, {
|
||||
foreignKey: 'regionId',
|
||||
as: 'offices'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user