Implemented houses
This commit is contained in:
@@ -6,6 +6,8 @@ import CharacterTrait from "../../models/falukant/type/character_trait.js";
|
||||
import PromotionalGift from "../../models/falukant/type/promotional_gift.js";
|
||||
import PromotionalGiftCharacterTrait from "../../models/falukant/predefine/promotional_gift_character_trait.js";
|
||||
import PromotionalGiftMood from "../../models/falukant/predefine/promotional_gift_mood.js";
|
||||
import HouseType from '../../models/falukant/type/house.js';
|
||||
import TitleOfNobility from "../../models/falukant/type/title_of_nobility.js";
|
||||
|
||||
export const initializeFalukantTypes = async () => {
|
||||
await initializeFalukantTypeRegions();
|
||||
@@ -14,6 +16,7 @@ export const initializeFalukantTypes = async () => {
|
||||
await initializeFalukantCharacterTraits();
|
||||
await initializeFalukantPromotionalGifts();
|
||||
await initializePromotionalGiftMoodLinks();
|
||||
await initializeFalukantHouseTypes();
|
||||
};
|
||||
|
||||
const regionTypes = [];
|
||||
@@ -204,6 +207,52 @@ const promotionalGiftMoodLinks = [
|
||||
{ gift: "Horse", mood: "nervous", suitability: 4 },
|
||||
];
|
||||
|
||||
const houseTypes = [
|
||||
{ labelTr: 'Unter der Brücke', abbr: 'under_bridge', cost: 10, position: 1, minimumTitle: 'noncivil' },
|
||||
{ labelTr: 'Strohhütte', abbr: 'straw_hut', cost: 20, position: 2, minimumTitle: 'noncivil' },
|
||||
{ labelTr: 'Holzhaus', abbr: 'wooden_house', cost: 50, position: 3, minimumTitle: 'civil' },
|
||||
{ labelTr: 'Hinterhofzimmer', abbr: 'backyard_room', cost: 5, position: 4, minimumTitle: 'civil' },
|
||||
{ labelTr: 'Kleines Familienhaus', abbr: 'family_house', cost: 100, position: 5, minimumTitle: 'sir' },
|
||||
{ labelTr: 'Stadthaus', abbr: 'townhouse', cost: 200, position: 6, minimumTitle: 'townlord' },
|
||||
{ labelTr: 'Villa', abbr: 'villa', cost: 500, position: 7, minimumTitle: 'knight' },
|
||||
{ labelTr: 'Herrenhaus', abbr: 'mansion', cost: 1000, position: 8, minimumTitle: 'ruler' },
|
||||
{ labelTr: 'Schloss', abbr: 'castle', cost: 5000, position: 9, minimumTitle: 'prince-regent' },
|
||||
];
|
||||
|
||||
{
|
||||
const giftNames = promotionalGifts.map(g => g.name);
|
||||
const traitNames = characterTraits.map(t => t.name);
|
||||
|
||||
giftNames.forEach(giftName => {
|
||||
traitNames.forEach(traitName => {
|
||||
if (!promotionalGiftTraitLinks.some(l => l.gift === giftName && l.trait === traitName)) {
|
||||
promotionalGiftTraitLinks.push({
|
||||
gift: giftName,
|
||||
trait: traitName,
|
||||
suitability: Math.floor(Math.random() * 5) + 1,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const giftNames = promotionalGifts.map(g => g.name);
|
||||
const moodNames = moods.map(m => m.name);
|
||||
|
||||
giftNames.forEach(giftName => {
|
||||
moodNames.forEach(moodName => {
|
||||
if (!promotionalGiftMoodLinks.some(l => l.gift === giftName && l.mood === moodName)) {
|
||||
promotionalGiftMoodLinks.push({
|
||||
gift: giftName,
|
||||
mood: moodName,
|
||||
suitability: Math.floor(Math.random() * 5) + 1,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const initializeFalukantTypeRegions = async () => {
|
||||
for (const regionType of regionTypeTrs) {
|
||||
const [regionTypeRecord] = await RegionType.findOrCreate({
|
||||
@@ -303,6 +352,8 @@ export const initializePromotionalGiftTraitLinks = async () => {
|
||||
},
|
||||
defaults: {
|
||||
suitability: link.suitability,
|
||||
gift_id: gift.id,
|
||||
trait_id: trait.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -316,15 +367,27 @@ export const initializePromotionalGiftMoodLinks = async () => {
|
||||
console.error(`Gift or Mood not found for: ${link.gift}, ${link.mood}`);
|
||||
continue;
|
||||
}
|
||||
await PromotionalGiftMood.findOrCreate({
|
||||
where: {
|
||||
gift_id: gift.id,
|
||||
mood_id: mood.id,
|
||||
},
|
||||
defaults: {
|
||||
suitability: link.suitability,
|
||||
},
|
||||
|
||||
await PromotionalGiftMood.create({
|
||||
gift_id: gift.id,
|
||||
mood_id: mood.id,
|
||||
suitability: link.suitability,
|
||||
}).catch(err => {
|
||||
if (err.name !== 'SequelizeUniqueConstraintError') throw err;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const initializeFalukantHouseTypes = async () => {
|
||||
for (const ht of houseTypes) {
|
||||
const [record, created] = await HouseType.findOrCreate({
|
||||
where: { labelTr: ht.abbr },
|
||||
defaults: {
|
||||
cost: ht.cost,
|
||||
imageUrl: null,
|
||||
position: ht.position,
|
||||
minimumNobleTitle: await TitleOfNobility.findOne({ where: { labelTr: ht.minimumTitle } }).then(title => title.id),
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user