Ejemplo n.º 1
0
 def from_data(cls, file: File, data: Dict[str, Any],
               game_contents: GameContents) -> 'Element':
     e = game_contents.get_element(data['id'])
     e.file = file
     e.label = get(data, 'label')
     e.description = get(data, 'description')
     e.animation_frames = get(data, 'animFrames', 0, int)
     e.icon = get(data, 'icon')
     e.lifetime = get(data, 'lifetime', 0.0, float)
     e.decay_to = game_contents.get_element(get(data, 'decayTo', None))
     e.is_aspect = get(data, 'isAspect', False, to_bool)
     e.unique = get(data, 'unique', False, to_bool)
     e.uniqueness_group = get(data, 'uniquenessgroup')
     e.aspects = [
         ElementAspect(element=e,
                       aspect=game_contents.get_element(aspect_id),
                       quantity=int(quantity))
         for aspect_id, quantity in get(data, 'aspects', {}).items()
     ]
     e.induces = [
         ElementLinkedRecipeDetails.from_data(v, game_contents)
         for v in get(data, 'induces', [])
     ]
     e.child_slots = [
         ElementSlotSpecification.from_data(v, game_contents)
         for v in get(data, 'slots', [])
     ]
     e.x_triggers = [
         ElementXTrigger(trigger=game_contents.get_element(trigger_id),
                         result=game_contents.get_element(result_id))
         for trigger_id, result_id in get(data, 'xtriggers', {}).items()
     ]
     e.no_art_needed = get(data, 'noartneeded', False, to_bool)
     e.comments = get(data, 'comments', None)
     return e
Ejemplo n.º 2
0
 def from_data(cls, file: File, data: Dict[str, Any],
               translations: Dict[str, Dict[str, Any]],
               game_contents: GameContents) -> 'Deck':
     d = game_contents.get_deck(data['id'])
     d.file = file
     d._cards = [
         DeckCard(element=game_contents.get_element(c))
         for c in get(data, 'spec', [])
     ]
     d.default_card = game_contents.get_element(
         get(data, 'defaultcard', None))
     d.reset_on_exhaustion = get(data, 'resetonexhaustion', False, to_bool)
     d.label = get(data, 'label', None, translations=translations)
     d.description = get(data,
                         'description',
                         None,
                         translations=translations)
     d.all_draw_messages = [
         DeckDrawMessage(element=game_contents.get_element(element_id),
                         message=message + cls._get_draw_message_loc(
                             translations, element_id))
         for element_id, message in get(data, 'drawmessages', {}).items()
     ] + [
         DeckDrawMessage(element=game_contents.get_element(element_id),
                         message=message + cls._get_draw_message_loc(
                             translations, element_id),
                         default=True) for element_id, message in get(
                             data, 'defaultdrawmessages', {}).items()
     ]
     d.comments = get(data, 'comments', None)
     return d
 def from_data(cls, data: Dict[str, Any],
               translations: Dict[str, Dict[str, Any]],
               game_contents: GameContents) -> 'SlotSpecification':
     s = cls()
     s.element = game_contents.get_element(data['id'])
     s.label = get(data,
                   'label',
                   s.element.element_id,
                   translations=translations)
     s.description = get(data, 'description', '', translations=translations)
     s.required = [
         SlotSpecificationItem(
             element=game_contents.get_element(element_id),
             quantity=quantity)
         for element_id, quantity in get(data, 'required', {}).items()
     ]
     s.forbidden = [
         SlotSpecificationItem(
             element=game_contents.get_element(element_id),
             quantity=quantity)
         for element_id, quantity in get(data, 'forbidden', {}).items()
     ]
     s.greedy = get(data, 'greedy', False, to_bool)
     s.consumes = get(data, 'consumes', False, to_bool)
     s.no_animation = get(data, 'noanim', False, to_bool)
     s.for_verb = game_contents.get_verb(get(data, 'actionId', None))
     return s
Ejemplo n.º 4
0
 def from_data(cls, val: List[Dict[str, str]], game_contents: GameContents):
     return [
         MutationEffect(
             filter_on_aspect=game_contents.get_element(
                 v['filterOnAspectId']),
             mutate_aspect=game_contents.get_element(v['mutateAspectId']),
             mutation_level=int(v['mutationLevel']),
             additive=get(v, 'additive', False, to_bool)) for v in val
     ]
 def from_data(
     cls, val: Union[str, Dict[str, str]], game_contents: GameContents
 ) -> List['LinkedRecipeChallengeRequirement']:
     return [
         cls(element=game_contents.get_element(element_id),
             convention=convention)
         for element_id, convention in val.items()
     ] if isinstance(val, dict) else [
         cls(element=game_contents.get_element(val), convention='base')
     ]
Ejemplo n.º 6
0
 def from_data(cls, val: Dict[str, str], game_contents: GameContents):
     return [
         cls(
             element=game_contents.get_element(element_id),
             quantity=int(quantity)
         )
         for element_id, quantity in val.items()
     ]
Ejemplo n.º 7
0
 def from_data(cls, file: File, data: Dict[str, Any],
               translations: Dict[str, Dict[str, Any]],
               game_contents: GameContents) -> 'Element':
     e = game_contents.get_element(data['id'])
     e.file = file
     e.label = get(data, 'label', translations=translations)
     e.description = get(data, 'description', translations=translations)
     e.animation_frames = get(data, 'animFrames', 0, int)
     e.icon = get(data, 'icon')
     e.lifetime = get(data, 'lifetime', 0.0, float)
     e.decay_to = game_contents.get_element(get(data, 'decayTo', None))
     e.is_aspect = get(data, 'isAspect', False, to_bool)
     e.unique = get(data, 'unique', False, to_bool)
     e.uniqueness_group = get(data, 'uniquenessgroup')
     e.aspects = [
         ElementAspect(element=e,
                       aspect=game_contents.get_element(aspect_id),
                       quantity=int(quantity))
         for aspect_id, quantity in get(data, 'aspects', {}).items()
     ]
     e.induces = [
         ElementLinkedRecipeDetails.from_data(
             v, ElementLinkedRecipeDetailsChallengeRequirement,
             game_contents) for v in get(data, 'induces', [])
     ]
     e.child_slots = [
         ElementSlotSpecification.from_data(
             v, {
                 c: c_transformation["slots"][i]
                 for c, c_transformation in translations.items()
                 if "slots" in c_transformation
             }, game_contents) for i, v in enumerate(get(data, 'slots', []))
     ]
     for trigger_id, result in get(data, 'xtriggers', {}).items():
         if isinstance(result, str):
             e.x_triggers.append(
                 ElementXTrigger(
                     trigger=game_contents.get_element(trigger_id),
                     result=game_contents.get_element(result)))
         else:
             for x_trigger_def in result:
                 e.x_triggers.append(
                     ElementXTrigger(
                         trigger=game_contents.get_element(trigger_id),
                         result=game_contents.get_element(
                             x_trigger_def['id']),
                         morph_effect=x_trigger_def.get('morpheffect'),
                         morph_effect_level=int(x_trigger_def['level'])
                         if 'level' in x_trigger_def else None,
                         morph_effect_chance=int(x_trigger_def['chance'])
                         if 'chance' in x_trigger_def else None,
                     ))
     e.is_hidden = get(data, 'isHidden', False, to_bool)
     e.no_art_needed = get(data, 'noartneeded', False, to_bool)
     e.resaturate = get(data, 'resaturate', False, to_bool)
     e.verb_icon = get(data, 'verbicon')
     e.comments = get(data, 'comments', None)
     return e