Spaces:
Runtime error
Runtime error
File size: 1,106 Bytes
bcf0302 4e30523 bcf0302 4e30523 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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 |