dnd5-scripts/generate_npc/backgrounds.py
2026-06-17 22:32:48 +03:00

390 lines
32 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# backgrounds.py
import random
from typing import Optional
import skills as sk
import languages as lang
# ─── Инструменты ─────────────────────────────────────────────────────────────
alchemists_supplies = "Alchemist's supplies"
brewers_supplies = "Brewer's supplies"
calligraphers_supplies= "Calligrapher's supplies"
carpenters_tools = "Carpenter's tools"
cartographers_tools = "Cartographer's tools"
cobblers_tools = "Cobbler's tools"
cooks_utensils = "Cook's utensils"
glassblowers_tools = "Glassblower's tools"
jewelers_tools = "Jeweler's tools"
leatherworkers_tools = "Leatherworker's tools"
masons_tools = "Mason's tools"
painters_tools = "Painter's tools"
potters_tools = "Potter's tools"
smiths_tools = "Smith's tools"
tinkers_tools = "Tinker's tools"
weavers_tools = "Weaver's tools"
woodcarvers_tools = "Woodcarver's tools"
barber_tools = "Barber's Tools" # Добавил (хоумбрю)
artisans_tools = [
alchemists_supplies, brewers_supplies, calligraphers_supplies, carpenters_tools,
cartographers_tools, cobblers_tools, cooks_utensils, glassblowers_tools,
jewelers_tools, leatherworkers_tools, masons_tools, painters_tools,
potters_tools, smiths_tools, tinkers_tools, weavers_tools, woodcarvers_tools,
]
dice_set = "Dice set"
dragonchess_set = "Dragonchess set"
playing_card_set = "Playing card set"
three_dragon_ante= "Three-Dragon Ante set"
gaming_sets = [dice_set, dragonchess_set, playing_card_set, three_dragon_ante]
disguise_kit = "Disguise kit"
forgery_kit = "Forgery kit"
herbalism_kit = "Herbalism kit"
navigators_tools = "Navigator's tools"
poisoners_kit = "Poisoner's kit"
thieves_tools = "Thieves' tools"
vehicles_land = "Vehicles (Land)"
vehicles_water = "Vehicles (Water)"
bagpipes = "Bagpipes"
drum = "Drum"
dulcimer = "Dulcimer"
flute = "Flute"
lute = "Lute"
lyre = "Lyre"
horn = "Horn"
pan_flute = "Pan flute"
shawm = "Shawm"
viol = "Viol"
musical_instruments = [bagpipes, drum, dulcimer, flute, lute, lyre, horn, pan_flute, shawm, viol]
all_tools = artisans_tools + gaming_sets + musical_instruments + [
disguise_kit, forgery_kit, herbalism_kit, navigators_tools,
poisoners_kit, thieves_tools, vehicles_land, vehicles_water,
]
# Сокращения для языков
_living_exc = lang.living_languages_except_common
_dead = lang.dead_languages
# ─── Группы профессий ────────────────────────────────────────────────────────
maritime_professions = {
"Моряк": {"skills":[sk.athletics, sk.perception], "tools":[navigators_tools], "languages":[_living_exc], "chance":35},
"Рыбак": {"skills":[sk.survival, sk.animal_handling],"tools":["Fishing tackle"], "languages":[_living_exc], "chance":25},
"Пират": {"skills":[sk.athletics, sk.perception], "tools":[vehicles_water, navigators_tools],"languages":[], "chance":10},
"Гребец": {"skills":[sk.athletics, sk.survival], "tools":[vehicles_water], "languages":[_living_exc], "chance":10},
"Боцман": {"skills":[sk.intimidation, sk.athletics], "tools":[vehicles_water, navigators_tools],"languages":[_living_exc], "chance":5},
"Штурман": {"skills":[sk.arcana, sk.perception], "tools":[navigators_tools, cartographers_tools],"languages":[_living_exc],"chance":3},
"Канонир": {"skills":[sk.athletics, sk.investigation],"tools":[smiths_tools], "languages":[_living_exc], "chance":3},
"Кок корабля": {"skills":[sk.insight, sk.performance], "tools":[cooks_utensils], "languages":[_living_exc], "chance":3},
"Кладовщик корабля": {"skills":[sk.investigation, sk.perception],"tools":[vehicles_water], "languages":[_living_exc], "chance":2},
"Лоцман": {"skills":[sk.perception, sk.survival], "tools":[navigators_tools], "languages":[_living_exc], "chance":2},
"Канатчик": {"skills":[sk.athletics, sk.sleight_of_hand],"tools":[weavers_tools], "languages":[_living_exc], "chance":1},
"Оружейник корабля": {"skills":[sk.athletics, sk.investigation],"tools":[smiths_tools], "languages":[_living_exc], "chance":1},
}
agrarian_professions = {
"Фермер": {"skills":[sk.animal_handling, sk.nature], "tools":[brewers_supplies, carpenters_tools, cobblers_tools, cooks_utensils, leatherworkers_tools, masons_tools], "languages":[_living_exc], "chance":25},
"Пастух": {"skills":[sk.animal_handling, sk.nature], "tools":[musical_instruments], "languages":[_living_exc], "chance":15},
"Земледелец": {"skills":[sk.athletics, sk.nature], "tools":[], "languages":[_living_exc], "chance":10},
"Охотник": {"skills":[sk.stealth, sk.survival], "tools":["Animal traps"], "languages":[_living_exc], "chance":10},
"Овчар": {"skills":[sk.animal_handling, sk.survival],"tools":[barber_tools], "languages":[_living_exc], "chance":5},
"Скотник": {"skills":[sk.animal_handling, sk.survival],"tools":[barber_tools, leatherworkers_tools], "languages":[_living_exc], "chance":5},
"Свинопас": {"skills":[sk.animal_handling, sk.nature], "tools":[musical_instruments], "languages":[_living_exc], "chance":5},
"Мельник": {"skills":[sk.athletics, sk.investigation],"tools":[cooks_utensils], "languages":[_living_exc], "chance":4},
"Птицевод": {"skills":[sk.animal_handling, sk.survival],"tools":[woodcarvers_tools], "languages":[_living_exc], "chance":3},
"Заводчик лошадей": {"skills":[sk.animal_handling, sk.persuasion],"tools":[musical_instruments, calligraphers_supplies], "languages":[_living_exc], "chance":3},
"Садовник": {"skills":[sk.nature, sk.survival], "tools":[herbalism_kit], "languages":[_living_exc], "chance":3},
"Пчеловод": {"skills":[sk.animal_handling, sk.survival],"tools":[woodcarvers_tools, cooks_utensils], "languages":[_living_exc], "chance":2},
"Сыровар": {"skills":[sk.animal_handling, sk.investigation],"tools":[cooks_utensils], "languages":[_living_exc], "chance":2},
"Винодел": {"skills":[sk.nature, sk.persuasion], "tools":[brewers_supplies], "languages":[_living_exc], "chance":2},
"Молочник": {"skills":[sk.animal_handling, sk.athletics],"tools":[cooks_utensils], "languages":[_living_exc], "chance":2},
"Зверолов": {"skills":[sk.stealth, sk.survival], "tools":["Animal traps"], "languages":[_living_exc], "chance":2},
}
artisan_professions = {
"Кузнец": {"skills":[sk.athletics, sk.insight], "tools":[smiths_tools], "languages":[_living_exc], "chance":12},
"Кожевенник": {"skills":[sk.survival, sk.investigation], "tools":[leatherworkers_tools],"languages":[_living_exc], "chance":9},
"Ткач": {"skills":[sk.insight, sk.investigation], "tools":[weavers_tools], "languages":[_living_exc], "chance":9},
"Пекарь": {"skills":[sk.insight, sk.investigation], "tools":[cooks_utensils], "languages":[_living_exc], "chance":8},
"Мясник": {"skills":[sk.athletics, sk.survival], "tools":[cooks_utensils], "languages":[_living_exc], "chance":8},
"Сапожник": {"skills":[sk.investigation, sk.perception], "tools":[cobblers_tools], "languages":[_living_exc], "chance":6},
"Повар": {"skills":[sk.insight, sk.performance], "tools":[cooks_utensils], "languages":[_living_exc], "chance":7},
"Столяр": {"skills":[sk.athletics, sk.perception], "tools":[carpenters_tools], "languages":[_living_exc], "chance":5},
"Резчик по дереву": {"skills":[sk.athletics, sk.perception], "tools":[woodcarvers_tools], "languages":[_living_exc], "chance":5},
"Каменотес": {"skills":[sk.athletics, sk.investigation], "tools":[masons_tools], "languages":[_living_exc], "chance":5},
"Гончар": {"skills":[sk.investigation, sk.performance],"tools":[potters_tools], "languages":[_living_exc], "chance":5},
"Булочник": {"skills":[sk.insight, sk.performance], "tools":[cooks_utensils], "languages":[_living_exc], "chance":4},
"Бондарь": {"skills":[sk.athletics, sk.investigation], "tools":[woodcarvers_tools], "languages":[_living_exc], "chance":4},
"Пивовар": {"skills":[sk.investigation, sk.insight], "tools":[brewers_supplies], "languages":[_living_exc], "chance":4},
"Кирпичник": {"skills":[sk.athletics, sk.investigation], "tools":[masons_tools], "languages":[_living_exc], "chance":3},
"Кондитер": {"skills":[sk.insight, sk.investigation], "tools":[cooks_utensils], "languages":[_living_exc], "chance":2},
"Изготовитель свечей":{"skills":[sk.investigation, sk.insight], "tools":[cooks_utensils], "languages":[_living_exc], "chance":2},
"Механик": {"skills":[sk.investigation, sk.sleight_of_hand],"tools":[tinkers_tools], "languages":[_living_exc], "chance":2},
"Стеклодув": {"skills":[sk.investigation, sk.perception], "tools":[glassblowers_tools], "languages":[_living_exc], "chance":1},
"Часовщик": {"skills":[sk.investigation, sk.perception], "tools":[tinkers_tools], "languages":[_living_exc], "chance":1},
"Ювелир": {"skills":[sk.insight, sk.investigation], "tools":[jewelers_tools], "languages":[_living_exc], "chance":1},
"Ткач ковров": {"skills":[sk.insight, sk.perception], "tools":[weavers_tools], "languages":[_living_exc], "chance":1},
"Лудильщик": {"skills":[sk.survival, sk.investigation], "tools":[tinkers_tools], "languages":[_living_exc], "chance":1},
}
performing_arts_professions = {
"Музыкант": {"skills":[sk.performance, sk.perception], "tools":[musical_instruments], "languages":[_living_exc], "chance":21},
"Актер театра": {"skills":[sk.performance, sk.deception], "tools":[musical_instruments, weavers_tools], "languages":[_living_exc], "chance":15},
"Певец": {"skills":[sk.performance, sk.persuasion], "tools":[], "languages":[_living_exc], "chance":15},
"Танцор": {"skills":[sk.acrobatics, sk.performance], "tools":[], "languages":[_living_exc], "chance":10},
"Художник": {"skills":[sk.performance, sk.investigation],"tools":[painters_tools], "languages":[_living_exc], "chance":6},
"Поэт": {"skills":[sk.performance, sk.persuasion], "tools":[], "languages":[_living_exc], "chance":6},
"Жонглер": {"skills":[sk.sleight_of_hand, sk.performance],"tools":[], "languages":[_living_exc], "chance":4},
"Фокусник": {"skills":[sk.sleight_of_hand, sk.performance],"tools":[woodcarvers_tools], "languages":[_living_exc], "chance":4},
"Кукловод": {"skills":[sk.performance, sk.sleight_of_hand],"tools":[weavers_tools], "languages":[_living_exc], "chance":3},
"Скульптор": {"skills":[sk.perception, sk.performance], "tools":[painters_tools], "languages":[_living_exc], "chance":3},
"Бард": {"skills":[sk.performance, sk.history], "tools":[musical_instruments], "languages":[_living_exc], "chance":3},
"Оркестровый музыкант":{"skills":[sk.performance, sk.insight], "tools":[musical_instruments], "languages":[_living_exc], "chance":2},
"Трубач": {"skills":[sk.performance, sk.athletics], "tools":[horn], "languages":[_living_exc], "chance":2},
"Лютнист": {"skills":[sk.performance, sk.perception], "tools":[lute], "languages":[_living_exc], "chance":2},
"Гармонист": {"skills":[sk.performance, sk.sleight_of_hand],"tools":["Harmonica"], "languages":[_living_exc], "chance":2},
"Писатель (драматург)":{"skills":[sk.history, sk.performance], "tools":[calligraphers_supplies], "languages":[_living_exc], "chance":2},
}
military_professions = {
"Легкий пехотинец": {"skills":[sk.athletics, sk.perception], "tools":[gaming_sets], "languages":[_living_exc], "chance":15},
"Тяжелый пехотинец": {"skills":[sk.athletics, sk.intimidation], "tools":[gaming_sets], "languages":[_living_exc], "chance":10},
"Стражник": {"skills":[sk.athletics, sk.perception], "tools":[gaming_sets], "languages":[_living_exc], "chance":10},
"Ополченец": {"skills":[sk.athletics, sk.perception], "tools":[], "languages":[_living_exc], "chance":10},
"Лучник": {"skills":[sk.perception, sk.survival], "tools":[gaming_sets], "languages":[_living_exc], "chance":10},
"Копейщик": {"skills":[sk.athletics, sk.survival], "tools":[gaming_sets], "languages":[_living_exc], "chance":8},
"Кавалерист": {"skills":[sk.athletics, sk.animal_handling],"tools":[gaming_sets], "languages":[_living_exc], "chance":5},
"Гарнизонный солдат":{"skills":[sk.athletics, sk.insight], "tools":[gaming_sets], "languages":[_living_exc], "chance":5},
"Наемник": {"skills":[sk.athletics, sk.survival], "tools":[], "languages":[_living_exc], "chance":5},
"Рекрут": {"skills":[sk.athletics, sk.survival], "tools":[gaming_sets], "languages":[_living_exc], "chance":4},
"Телохранитель": {"skills":[sk.athletics, sk.insight], "tools":[], "languages":[_living_exc], "chance":3},
"Разведчик": {"skills":[sk.stealth, sk.survival], "tools":[cartographers_tools], "languages":[_living_exc], "chance":3},
"Оруженосец": {"skills":[sk.athletics, sk.perception], "tools":[smiths_tools, leatherworkers_tools, weavers_tools, gaming_sets], "languages":[_living_exc], "chance":3},
"Баллистик": {"skills":[sk.investigation, sk.athletics],"tools":[smiths_tools], "languages":[_living_exc], "chance":2},
"Фортификатор": {"skills":[sk.investigation, sk.perception],"tools":[masons_tools], "languages":[_living_exc], "chance":2},
"Гладиатор": {"skills":[sk.athletics, sk.intimidation], "tools":[], "languages":[_living_exc], "chance":2},
"Осадный инженер": {"skills":[sk.investigation, sk.survival], "tools":[carpenters_tools], "languages":[_living_exc], "chance":2},
"Морской пехотинец": {"skills":[sk.athletics, sk.perception], "tools":[navigators_tools], "languages":[_living_exc], "chance":2},
"Катапультир": {"skills":[sk.athletics, sk.survival], "tools":[masons_tools], "languages":[_living_exc], "chance":2},
"Шпион": {"skills":[sk.stealth, sk.deception], "tools":[disguise_kit, thieves_tools], "languages":[_living_exc], "chance":1},
}
criminal_professions = {
"Карманник": {"skills":[sk.sleight_of_hand, sk.stealth],"tools":[thieves_tools], "languages":[_living_exc], "chance":20},
"Мошенник": {"skills":[sk.deception, sk.persuasion], "tools":[gaming_sets], "languages":[_living_exc], "chance":15},
"Домушник": {"skills":[sk.stealth, sk.perception], "tools":[thieves_tools], "languages":[_living_exc], "chance":15},
"Контрабандист": {"skills":[sk.stealth, sk.deception], "tools":[vehicles_land, vehicles_water, thieves_tools, disguise_kit, forgery_kit], "languages":[_living_exc], "chance":10},
"Карточный шулер": {"skills":[sk.sleight_of_hand, sk.deception],"tools":[playing_card_set], "languages":[_living_exc], "chance":8},
"Скупщик краденого": {"skills":[sk.insight, sk.persuasion], "tools":[disguise_kit], "languages":[_living_exc], "chance":7},
"Медвежатник": {"skills":[sk.sleight_of_hand, sk.stealth],"tools":[thieves_tools], "languages":[_living_exc], "chance":5},
"Скотокрад": {"skills":[sk.stealth, sk.survival], "tools":[], "languages":[_living_exc], "chance":5},
"Грабитель повозок": {"skills":[sk.athletics, sk.stealth], "tools":[], "languages":[_living_exc], "chance":4},
"Угонщик повозок": {"skills":[sk.stealth, sk.sleight_of_hand],"tools":[vehicles_land], "languages":[_living_exc], "chance":3},
"Фальшивомонетчик": {"skills":[sk.deception, sk.investigation],"tools":[forgery_kit], "languages":[_living_exc], "chance":3},
"Рекетир": {"skills":[sk.intimidation, sk.athletics],"tools":[], "languages":[_living_exc], "chance":2},
"Подделыватель документов":{"skills":[sk.investigation, sk.sleight_of_hand],"tools":[forgery_kit],"languages":[_living_exc],"chance":2},
"Похититель скота": {"skills":[sk.survival, sk.stealth], "tools":[], "languages":[_living_exc], "chance":2},
"Ассасин": {"skills":[sk.stealth, sk.deception], "tools":[poisoners_kit, disguise_kit, forgery_kit], "languages":[_living_exc], "chance":1},
"Наёмный убийца": {"skills":[sk.stealth, sk.intimidation], "tools":[poisoners_kit, disguise_kit, forgery_kit], "languages":[_living_exc], "chance":1},
"Поджигатель": {"skills":[sk.stealth, sk.intimidation], "tools":[alchemists_supplies], "languages":[_living_exc], "chance":1},
"Похититель": {"skills":[sk.stealth, sk.deception], "tools":[disguise_kit, thieves_tools, forgery_kit], "languages":[_living_exc], "chance":1},
}
academic_professions = {
"Писарь": {"skills":[sk.history, sk.investigation], "tools":[calligraphers_supplies], "languages":[_living_exc], "chance":15},
"Учитель": {"skills":[sk.persuasion, sk.insight], "tools":[all_tools], "languages":[_living_exc], "chance":15},
"Аколит": {"skills":[sk.religion, sk.insight], "tools":[calligraphers_supplies], "languages":[_living_exc], "chance":12},
"Ученый": {"skills":[sk.history, sk.arcana], "tools":[calligraphers_supplies, cartographers_tools, alchemists_supplies], "languages":[_living_exc, _dead], "chance":9},
"Алхимик": {"skills":[sk.arcana, sk.investigation], "tools":[alchemists_supplies], "languages":[_living_exc], "chance":8},
"Инженер": {"skills":[sk.investigation, sk.perception],"tools":[tinkers_tools], "languages":[_living_exc], "chance":8},
"Профессор": {"skills":[sk.history, sk.persuasion], "tools":[], "languages":[_living_exc, _dead], "chance":7},
"Историк": {"skills":[sk.history, sk.insight], "tools":[], "languages":[_living_exc, _dead], "chance":4},
"Библиотекарь":{"skills":[sk.history, sk.investigation],"tools":[], "languages":[_living_exc, _dead], "chance":4},
"Картограф": {"skills":[sk.investigation, sk.perception],"tools":[cartographers_tools], "languages":[_living_exc], "chance":3},
"Археолог": {"skills":[sk.history, sk.investigation], "tools":[cartographers_tools], "languages":[_living_exc, _dead], "chance":3},
"Лингвист": {"skills":[sk.history, sk.insight], "tools":[], "languages":[_living_exc, _dead], "chance":2},
"Математик": {"skills":[sk.investigation, sk.insight], "tools":[], "languages":[_living_exc], "chance":2},
"Философ": {"skills":[sk.religion, sk.insight], "tools":[], "languages":[_living_exc], "chance":2},
"Исследователь":{"skills":[sk.nature, sk.survival], "tools":[herbalism_kit], "languages":[_living_exc, _dead], "chance":2},
"Географ": {"skills":[sk.nature, sk.history], "tools":[cartographers_tools], "languages":[_living_exc], "chance":2},
"Астроном": {"skills":[sk.arcana, sk.perception], "tools":[navigators_tools], "languages":[_living_exc], "chance":2},
}
urban_professions = {
"Извозчик": {"skills":[sk.animal_handling, sk.perception],"tools":[vehicles_land], "languages":[_living_exc], "chance":20},
"Грузчик": {"skills":[sk.athletics, sk.survival], "tools":[], "languages":[_living_exc], "chance":17},
"Цирюльник": {"skills":[sk.medicine, sk.performance], "tools":[barber_tools], "languages":[_living_exc], "chance":10},
"Трактирщик": {"skills":[sk.persuasion, sk.insight], "tools":[brewers_supplies], "languages":[_living_exc], "chance":10},
"Гонец": {"skills":[sk.acrobatics, sk.athletics], "tools":[], "languages":[_living_exc], "chance":8},
"Фонарщик": {"skills":[sk.athletics, sk.perception], "tools":[], "languages":[_living_exc], "chance":5},
"Почтальон": {"skills":[sk.athletics, sk.perception], "tools":[], "languages":[_living_exc], "chance":5},
"Пожарный": {"skills":[sk.athletics, sk.perception], "tools":[], "languages":[_living_exc], "chance":4},
"Тюремщик": {"skills":[sk.intimidation, sk.insight], "tools":[], "languages":[_living_exc], "chance":3},
"Садовник городской":{"skills":[sk.nature, sk.survival], "tools":[herbalism_kit], "languages":[_living_exc], "chance":3},
}
mercantile_professions = {
"Продавец фруктов и овощей":{"skills":[sk.nature, sk.persuasion], "tools":[], "languages":[_living_exc], "chance":15},
"Продавец тканей": {"skills":[sk.insight, sk.performance], "tools":[weavers_tools], "languages":[_living_exc], "chance":12},
"Продавец лошадей": {"skills":[sk.animal_handling, sk.persuasion],"tools":[], "languages":[_living_exc], "chance":10},
"Караванщик": {"skills":[sk.animal_handling, sk.perception],"tools":[vehicles_land], "languages":[_living_exc], "chance":10},
"Продавец оружия": {"skills":[sk.persuasion, sk.investigation],"tools":[smiths_tools], "languages":[_living_exc], "chance":10},
"Продавец ювелирных изделий":{"skills":[sk.persuasion, sk.insight], "tools":[jewelers_tools], "languages":[_living_exc], "chance":8},
"Продавец вина": {"skills":[sk.persuasion, sk.insight], "tools":[brewers_supplies], "languages":[_living_exc], "chance":8},
"Продавец мебели": {"skills":[sk.persuasion, sk.investigation],"tools":[carpenters_tools], "languages":[_living_exc], "chance":7},
"Аптекарь": {"skills":[sk.medicine, sk.arcana], "tools":[herbalism_kit], "languages":[_living_exc], "chance":6},
"Продавец книг": {"skills":[sk.history, sk.investigation], "tools":[], "languages":[_living_exc], "chance":5},
"Продавец рыбы": {"skills":[sk.survival, sk.athletics], "tools":["Fishing tackle"], "languages":[_living_exc], "chance":5},
"Торговец кожаными изделиями":{"skills":[sk.investigation, sk.insight], "tools":[leatherworkers_tools], "languages":[_living_exc], "chance":4},
"Торговец тканями": {"skills":[sk.insight, sk.persuasion], "tools":[weavers_tools], "languages":[_living_exc], "chance":3},
"Караванный охранник": {"skills":[sk.athletics, sk.perception], "tools":[gaming_sets], "languages":[_living_exc], "chance":2},
"Гильдейский казначей": {"skills":[sk.investigation, sk.insight], "tools":[calligraphers_supplies], "languages":[_living_exc], "chance":1},
"Продавец пряностей": {"skills":[sk.insight, sk.persuasion], "tools":[], "languages":[_living_exc], "chance":1},
}
construction_professions = {
"Строитель": {"skills":[sk.athletics, sk.perception], "tools":[carpenters_tools], "languages":[_living_exc], "chance":42},
"Каменщик": {"skills":[sk.athletics, sk.investigation],"tools":[masons_tools], "languages":[_living_exc], "chance":25},
"Архитектор": {"skills":[sk.investigation, sk.insight], "tools":[masons_tools], "languages":[_living_exc], "chance":12},
"Маляр": {"skills":[sk.investigation, sk.performance],"tools":[painters_tools], "languages":[_living_exc], "chance":4},
"Плотник": {"skills":[sk.athletics, sk.perception], "tools":[carpenters_tools], "languages":[_living_exc], "chance":9},
"Кровельщик": {"skills":[sk.athletics, sk.perception], "tools":["roofersTools"], "languages":[_living_exc], "chance":2},
"Реставратор": {"skills":[sk.insight, sk.investigation], "tools":["restorationTools"], "languages":[_living_exc], "chance":6},
}
medical_professions = {
"Врач": {"skills":[sk.medicine, sk.perception], "tools":["Medical instruments"], "languages":[_living_exc], "chance":52},
"Травник": {"skills":[sk.nature, sk.medicine], "tools":[herbalism_kit], "languages":[_living_exc], "chance":21},
"Хирург": {"skills":[sk.medicine, sk.investigation],"tools":["Healer's kit"], "languages":[_living_exc], "chance":14},
"Акушер": {"skills":[sk.medicine, sk.insight], "tools":["Medical instruments"], "languages":[_living_exc], "chance":8},
"Корабельный врач":{"skills":[sk.medicine, sk.perception], "tools":["Medical instruments"], "languages":[_living_exc], "chance":5},
}
religious_professions = {
"Священник": {"skills":[sk.religion, sk.persuasion], "tools":[calligraphers_supplies], "languages":[_living_exc, _dead], "prerequisite_classes":["Cleric","Paladin"], "chance":30},
"Аколит": {"skills":[sk.religion, sk.insight], "tools":[], "languages":[_living_exc, _dead], "prerequisite_classes":["Cleric","Paladin"], "chance":20},
"Монах": {"skills":[sk.religion, sk.acrobatics], "tools":[herbalism_kit], "languages":[_living_exc, _dead], "prerequisite_classes":["Cleric","Paladin"], "chance":15},
"Храмовый целитель":{"skills":[sk.medicine, sk.religion], "tools":["Healer's kit"], "languages":[_living_exc], "prerequisite_classes":["Cleric","Paladin"], "chance":15},
"Певчий в храме": {"skills":[sk.performance, sk.religion], "tools":[musical_instruments], "languages":[_living_exc], "chance":9},
"Церковный учитель":{"skills":[sk.religion, sk.persuasion], "tools":[all_tools], "languages":[_living_exc], "prerequisite_classes":["Cleric","Paladin"], "chance":7},
"Церковный писарь":{"skills":[sk.history, sk.investigation],"tools":[calligraphers_supplies], "languages":[_living_exc], "chance":4},
}
BACKGROUNDS = {
"agrarianProfessions": {"list": agrarian_professions, "chance": 30.00},
"militaryProfessions": {"list": military_professions, "chance": 20.00},
"maritimeProfessions": {"list": maritime_professions, "chance": 6.00},
"artisanProfessions": {"list": artisan_professions, "chance": 10.00},
"urbanProfessions": {"list": urban_professions, "chance": 8.00},
"criminalProfessions": {"list": criminal_professions, "chance": 6.00},
"mercantileProfessions": {"list": mercantile_professions, "chance": 5.00},
"religiousProfessions": {"list": religious_professions, "chance": 5.00},
"medicalProfessions": {"list": medical_professions, "chance": 3.00},
"constructionProfessions": {"list": construction_professions, "chance": 3.00},
"academicProfessions": {"list": academic_professions, "chance": 2.00},
"performingArtsProfessions":{"list": performing_arts_professions,"chance": 2.00},
}
# ─── Вспомогательные функции ─────────────────────────────────────────────────
def _get_random_item_with_chance(items: list[dict]) -> dict:
total = sum(item["chance"] for item in items)
r = random.random() * total
cumulative = 0.0
for item in items:
cumulative += item["chance"]
if r <= cumulative:
return item
return items[-1]
def _flatten(obj) -> list:
"""Рекурсивно разворачивает вложенные списки."""
if isinstance(obj, list):
result = []
for item in obj:
result.extend(_flatten(item))
return result
return [obj]
def _select_random_elements(array, count: int, exclude: list = None) -> list:
if exclude is None:
exclude = []
if not array:
return []
flat = list(dict.fromkeys(_flatten(array))) # уникальные, порядок сохранён
available = [el for el in flat if el not in exclude]
if not available:
return []
random.shuffle(available)
return available[:min(count, len(available))]
def _select_from_two_arrays(arr1, arr2, exclude_languages: list = None) -> dict:
if exclude_languages is None:
exclude_languages = []
tools: list = []
langs: list = []
if arr1 and arr2:
tools = _select_random_elements(arr1, 1)
langs = _select_random_elements(arr2, 1, exclude_languages)
elif arr1:
tools = _select_random_elements(arr1, 2)
elif arr2:
langs = _select_random_elements(arr2, 2, exclude_languages)
return {"tools": tools, "languages": langs}
def get_background(character_class: str, known_languages_from_race: list = None) -> dict:
"""Выбирает случайный бэкграунд с учётом класса и уже известных языков расы."""
if known_languages_from_race is None:
known_languages_from_race = []
while True:
# Шаг 1: группа бэкграундов
group_items = [{"name": k, **v} for k, v in BACKGROUNDS.items()]
selected_group = _get_random_item_with_chance(group_items)
# Шаг 2: профессия внутри группы
prof_items = [{"name": k, **v} for k, v in selected_group["list"].items()]
prof = _get_random_item_with_chance(prof_items)
# Шаг 3: проверка prerequisite_classes
prereqs = prof.get("prerequisite_classes", [])
if prereqs and character_class not in prereqs:
continue # не подходит — перебираем
# Шаг 4: скиллы / инструменты / языки
selected_skills = _select_random_elements(prof["skills"], 2)
selected_tl = _select_from_two_arrays(
prof.get("tools", []),
prof.get("languages", []),
known_languages_from_race,
)
return {
"name": prof["name"],
"skills": selected_skills,
"tools": selected_tl["tools"],
"languages": selected_tl["languages"],
}
def get_class_skills_with_background(character_class: str, background: dict) -> list[str]:
"""Выбирает скиллы класса, исключая уже взятые из бэкграунда."""
from skills import CHARACTER_CLASS_SKILLS, get_random_skills
bg_skills = background["skills"]
# Получаем список скиллов для класса персонажа
skills_list, count = CHARACTER_CLASS_SKILLS[character_class.lower()]
# Убираем из списка скиллов класса те, что уже выбраны через бекграунд
filtered = [s for s in skills_list if s not in bg_skills]
return get_random_skills(filtered, count)