def mutate(self, info, **kwargs): custom_set_id = kwargs.get("custom_set_id") with session_scope() as db_session: old_custom_set = db_session.query(ModelCustomSet).get( custom_set_id) custom_set = get_or_create_custom_set(None, db_session) custom_set.name = (_( "%(old_name)s copy", old_name=old_custom_set.name)[:MAX_NAME_LENGTH] if old_custom_set.name else _("Copy")) custom_set.level = old_custom_set.level custom_set.parent_custom_set_id = old_custom_set.uuid for stat in base_stat_list + scrolled_stat_list: setattr(custom_set.stats, stat, getattr(old_custom_set.stats, stat)) for old_equipped_item in old_custom_set.equipped_items: equipped_item = ModelEquippedItem( custom_set_id=custom_set.uuid, item_slot_id=old_equipped_item.item_slot_id, item_id=old_equipped_item.item_id, weapon_element_mage=old_equipped_item.weapon_element_mage, ) db_session.add(equipped_item) db_session.flush() for old_exo in old_equipped_item.exos: exo = ModelEquippedItemExo( stat=old_exo.stat, value=old_exo.value, equipped_item_id=equipped_item.uuid, ) db_session.add(exo) return CopyCustomSet(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") stats = kwargs.get("stats") custom_set = get_or_create_custom_set(custom_set_id, db_session) edit_custom_set_stats(custom_set, stats) return EditCustomSetStats(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") set_id = kwargs.get("set_id") custom_set = get_or_create_custom_set(custom_set_id, db_session) set_obj = db_session.query(ModelSet).get(set_id) custom_set.equip_set(set_obj, db_session) return EquipSet(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") item_slot_id = kwargs.get("item_slot_id") item_id = kwargs.get("item_id") custom_set = get_or_create_custom_set(custom_set_id, db_session) custom_set.equip_item(item_id, item_slot_id, db_session) return UpdateCustomSetItem(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") name = kwargs.get("name") level = kwargs.get("level") custom_set = get_or_create_custom_set(custom_set_id, db_session) edit_custom_set_metadata(custom_set, name, level) return EditCustomSetMetadata(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") item_ids = kwargs.get("item_ids") custom_set = get_or_create_custom_set(custom_set_id, db_session) items = db_session.query(ModelItem).filter( ModelItem.uuid.in_(item_ids)) custom_set.equip_items(items, db_session) return EquipMultipleItems(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") name = kwargs.get("name") level = kwargs.get("level") if len(name) > MAX_NAME_LENGTH: raise GraphQLError(_("The set name is too long.")) if level < 1 or level > 200: raise GraphQLError(_("Invalid set level (must be 1-200).")) custom_set = get_or_create_custom_set(custom_set_id, db_session) custom_set.name = name custom_set.level = level return EditCustomSetMetadata(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set_id = kwargs.get("custom_set_id") stats = kwargs.get("stats") for base_stat in base_stat_list: if stats[base_stat] < 0 or stats[base_stat] > 999: raise GraphQLError(_("Invalid stat value.")) for scrolled_stat in scrolled_stat_list: if stats[scrolled_stat] < 0 or stats[scrolled_stat] > 100: raise GraphQLError(_("Invalid stat value.")) custom_set = get_or_create_custom_set(custom_set_id, db_session) for stat in base_stat_list + scrolled_stat_list: setattr(custom_set.stats, stat, stats[stat]) return EditCustomSetStats(custom_set=custom_set)
def mutate(self, info, **kwargs): item_objs = kwargs.get("items") stats = kwargs.get("stats") name = kwargs.get("name") level = kwargs.get("level") with session_scope() as db_session: custom_set = get_or_create_custom_set(None, db_session) edit_custom_set_stats(custom_set, stats) edit_custom_set_metadata(custom_set, name, level) items = [{ "item": db.session.query(ModelItem).filter( ModelItem.uuid == item_obj.id).one(), "ap_exo": item_obj.ap_exo, "mp_exo": item_obj.mp_exo, "range_exo": item_obj.range_exo, } for item_obj in item_objs] custom_set.equip_items(items, db_session) return ImportCustomSet(custom_set=custom_set)
def mutate(self, info, **kwargs): with session_scope() as db_session: custom_set = get_or_create_custom_set(None, db_session) return CreateCustomSet(custom_set=custom_set)