WorldSimulation / plugins /CharacterCreationPlugin.py
yingqianjiang-lingoace
Update
4e30523
raw
history blame
1.11 kB
import random
from Character import Character
from utils import get_random_name
class CharacterCreationPlugin:
def __init__(self, special_constitution_ratio=None, spiritual_roots_ratio=None):
self.special_constitution_ratio = special_constitution_ratio
self.spiritual_roots_ratio = spiritual_roots_ratio
def create_character(self):
# 根据 special_constitution_ratio 随机确定这个角色拥有哪些特殊体质
special_constitution = [1 if random.random() < ratio else 0 for ratio in self.special_constitution_ratio]
# 根据 spiritual_roots_ratio 随机确定这个角色拥有哪些灵根
spiritual_roots = [1 if random.random() < ratio else 0 for ratio in self.spiritual_roots_ratio]
character = Character(get_random_name(), random.choice(["男", "女"]), special_constitution, spiritual_roots)
return character
def set_parameters(self, special_constitution_ratio, spiritual_roots_ratio):
self.special_constitution_ratio = special_constitution_ratio
self.spiritual_roots_ratio = spiritual_roots_ratio