Example #1
0
    def generate(template=None, template_attr={}):
        spawn_obj = Spawn(template, template_attr)
        template = spawn_obj.template

        spawn_obj.ARG_TYPES = [Mob]
        spawn_obj._mob_args = Arguments(
            {
                "mob_location": None,
                "repeat_key": None,
                "repeat_location": None,
                "template_attr": template_attr,
            }
        )
        # the number of repetitions for Action if any
        spawn_obj._repeat_args = Arguments(
            {"repeat_key": None, "repeat_count": None, "repeat_dir": None}
        )

        # change default arguments for ARG_TYPE classes using the template_objects.
        for j, templ in enumerate(template):
            for i, t in enumerate(templ):
                if type(t) != str:
                    if callable(getattr(t, "add_generate_args", None)):
                        t.add_generate_args(index=i, templ_index=j)

        # Append the ARG_TYPE object with arguments, to generate the action tree
        spawn_obj.args = [Mob(**spawn_obj._mob_args)]

        # Repeat is optional, only add if default values were updated
        if spawn_obj._repeat_args.values_updated:
            spawn_obj.ARG_TYPES.append(Repeat)
            spawn_obj.args.append(Repeat(**spawn_obj._repeat_args))

        return spawn_obj
Example #2
0
    def generate(template=None, template_attr={}):
        copy_obj = Copy(template, template_attr)
        template = copy_obj.template

        copy_obj.ARG_TYPES = []
        copy_obj._no_children = False  # no ARG_TYPE if _no_children is True

        copy_obj._block_obj_args = Arguments(
            {
                "block_object_type": Object,
                "block_object_attributes": None,
                "block_object_location": False,
                "no_child": False,
                "repeat_key": None,
                "repeat_location": None,
                "coref_type": None,
                "template_attr": template_attr,
            }
        )
        copy_obj._location_args = Arguments(
            {
                "location_type": "ANY",
                "relative_direction": False,
                "steps": None,
                "repeat_key": None,
                "template_attr": template_attr,
            }
        )
        # the number of repetitions for Action if any
        copy_obj._repeat_args = Arguments(
            {"repeat_key": None, "repeat_count": None, "repeat_dir": None}
        )

        # change default arguments for ARG_TYPE classes using the template_objects.
        for j, templ in enumerate(template):
            for i, t in enumerate(templ):
                if type(t) != str:
                    if callable(getattr(t, "add_generate_args", None)):
                        t.add_generate_args(index=i, templ_index=j)

        # Append the ARG_TYPE object with arguments, to generate the action tree
        copy_obj.args = []
        if copy_obj._no_children:
            return copy_obj

        if copy_obj._block_obj_args.values_updated:
            copy_obj.ARG_TYPES.append(BlockObject)
            copy_obj.args.append(BlockObject(**copy_obj._block_obj_args))

        # Location is optional, only add if the default arguments were changed.
        if copy_obj._location_args.values_updated:
            copy_obj.ARG_TYPES.append(Location)
            copy_obj.args.append(Location(**copy_obj._location_args))

        # Repeat is optional, only add if default values were updated
        if copy_obj._repeat_args.values_updated:
            copy_obj.ARG_TYPES.append(Repeat)
            copy_obj.args.append(Repeat(**copy_obj._repeat_args))

        return copy_obj
Example #3
0
    def generate(template=None, template_attr={}):
        dig_obj = Dig(template, template_attr)
        template = dig_obj.template

        dig_obj.ARG_TYPES = []
        dig_obj._no_children = False  # no ARG_TYPE if _no_children is True
        dig_obj.schematic = {}
        dig_obj._location_args = Arguments(
            {
                "location_type": "ANY",
                "relative_direction": False,
                "steps": None,
                "repeat_key": None,
                "coref_resolve": None,
                "template_attr": template_attr,
            }
        )
        dig_obj._condition_args = Arguments({"condition_type": None, "block_type": None})
        # the number of repetitions for Action if any
        dig_obj._repeat_args = Arguments(
            {"repeat_key": None, "repeat_count": None, "repeat_dir": None}
        )

        # change default arguments for ARG_TYPE classes using the template_objects.
        for j, templ in enumerate(template):
            for i, t in enumerate(templ):
                if type(t) != str:
                    if callable(getattr(t, "add_generate_args", None)):
                        t.add_generate_args(index=i, templ_index=j)

        # Append the ARG_TYPE object with arguments, to generate the action tree
        dig_obj.args = []
        if dig_obj._no_children:
            return dig_obj

        # Location is optional, only add if the default arguments were changed.
        if dig_obj._location_args.values_updated:
            dig_obj.ARG_TYPES.append(Location)
            dig_obj.args.append(Location(**dig_obj._location_args))

        # StopCondition is optional, only add if the default arguments were changed.
        if dig_obj._condition_args.values_updated:
            dig_obj.ARG_TYPES.append(StopCondition)
            dig_obj.args.append(StopCondition(**dig_obj._condition_args))

        # Repeat is optional, only add if default values were updated
        if dig_obj._repeat_args.values_updated:
            dig_obj.ARG_TYPES.append(Repeat)
            dig_obj.args.append(Repeat(**dig_obj._repeat_args))

        return dig_obj
Example #4
0
    def generate(cls, template=None, template_attr={}):
        build_obj = Build(template, template_attr)
        template = build_obj.template

        build_obj.ARG_TYPES = []
        build_obj._no_children = False  # no ARG_TYPE if _no_children is True
        build_obj._schematics_args = Arguments(
            {
                "only_block_type": False,
                "block_type": False,
                "schematic_attributes": False,
                "schematic_type": None,
                "abstract_size": None,
                "colour": None,
                "repeat_key": None,
                "repeat_dir": None,
                "template_attr": template_attr,
                "multiple_schematics": False,
            }
        )
        build_obj._location_args = Arguments(
            {
                "location_type": "ANY",
                "relative_direction": False,
                "steps": None,
                "repeat_key": None,
                "coref_resolve": None,
                "template_attr": template_attr,
            }
        )

        # the number of repetitions for Action if any
        build_obj._repeat_args = Arguments(
            {"repeat_key": None, "repeat_count": None, "repeat_dir": None}
        )

        # change default arguments for ARG_TYPE classes using the template_objects.
        for j, templ in enumerate(template):
            for i, t in enumerate(templ):
                if type(t) != str:
                    if callable(getattr(t, "add_generate_args", None)):
                        t.add_generate_args(index=i, templ_index=j)

        # Append the ARG_TYPE object with arguments, to generate the action tree
        build_obj.args = []

        if build_obj._schematics_args.values_updated or not build_obj._no_children:
            build_obj.ARG_TYPES.append(Schematic)
            build_obj.args.append(Schematic(**build_obj._schematics_args))

        # Location is optional, only add if the default arguments were changed.
        if build_obj._location_args.values_updated:
            build_obj.ARG_TYPES.append(Location)
            build_obj.args.append(Location(**build_obj._location_args))

        # Repeat is optional, only add if default values were updated
        if build_obj._repeat_args.values_updated:
            build_obj.ARG_TYPES.append(Repeat)
            build_obj.args.append(Repeat(**build_obj._repeat_args))

        return build_obj