From b45687cc6702d68c9ec047af2adcd03df999988e Mon Sep 17 00:00:00 2001 From: Torrin Leonard <82110564+torrinworx@users.noreply.github.com> Date: Thu, 10 Mar 2022 12:05:05 -0500 Subject: [PATCH 1/3] Patching Logic methods --- __init__.py | 17 -------- main/DNA_Generator.py | 2 +- main/Logic.py | 96 +++++++++++++++++++++++++++++-------------- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/__init__.py b/__init__.py index e0c01c7..992bfd4 100644 --- a/__init__.py +++ b/__init__.py @@ -35,7 +35,6 @@ else: Batch_Refactorer, \ get_combinations - # User input Property Group: class BMNFTS_PGT_MyProperties(bpy.types.PropertyGroup): @@ -345,19 +344,6 @@ class BMNFTS_PT_Documentation(bpy.types.Panel): row.operator("wm.url_open", text="Documentation", icon='URL').url = "https://github.com/torrinworx/Blend_My_NFTs" -# Logic Panel: -class BMNFTS_PT_LOGIC_Panel(bpy.types.Panel): - bl_label = "Logic" - bl_idname = "BMNFTS_PT_LOGIC_Panel" - bl_space_type = 'VIEW_3D' - bl_region_type = 'UI' - bl_category = 'Blend_My_NFTs' - - def draw(self, context): - layout = self.layout - scene = context.scene - mytool = scene.my_tool - # # Materials Panel: # # class BMNFTS_PT_MATERIALS_Panel(bpy.types.Panel): @@ -388,7 +374,6 @@ class BMNFTS_PT_LOGIC_Panel(bpy.types.Panel): # row = layout.row() # row.prop(mytool, "apiKey") - def redraw_panel(): try: bpy.utils.unregister_class(BMNFTS_PT_CreateData) @@ -406,8 +391,6 @@ classes = ( BMNFTS_PT_Documentation, # Other panels: - - BMNFTS_PT_LOGIC_Panel, # BMNFTS_PT_MATERIALS_Panel, # BMNFTS_PT_API_Panel, diff --git a/main/DNA_Generator.py b/main/DNA_Generator.py index 7e73967..11e5068 100644 --- a/main/DNA_Generator.py +++ b/main/DNA_Generator.py @@ -294,7 +294,7 @@ def generateNFT_DNA(nftName, maxNFTs, nftsPerBatch, save_path, logicFile, enable dnaStrList = [] for i in listOptionVariant: - randomVariantNum = random.choices(i, k = 1) + randomVariantNum = random.choices(i, k=1) str1 = ''.join(str(e) for e in randomVariantNum) dnaStrList.append(str1) diff --git a/main/Logic.py b/main/Logic.py index 79502ef..ad01903 100644 --- a/main/Logic.py +++ b/main/Logic.py @@ -7,33 +7,31 @@ import sys import json import random import importlib +import collections from . import metaData importlib.reload(metaData) - removeList = [".gitignore", ".DS_Store"] def isAttorVar(hierarchy, items_List): - items_returned = {} - + items_returned = collections.defaultdict(list) for i in items_List: for j in hierarchy: if i == j: # If i is an Attribute, add all i Variants to dictionary. items_returned[i] = list(hierarchy[j].keys()) items_returned[i].append("Empty") - for h in hierarchy[j]: - if h == i: # If i is a Variant, add i Variant and i's Attribute to dictionary. - items_returned[j] = [h] + if i in list(hierarchy[j].keys()): + items_returned[j].append(i) # Check if all variants in an attribute were included, if so, add "Empty" variant. for i in items_returned: if list(items_returned[i]) == list(hierarchy[i].keys()): items_returned[i].append("Empty") - return items_returned + return dict(items_returned) def getAttIndex(hierarchy, attribute): attList = list(hierarchy.keys()) @@ -55,39 +53,77 @@ def items_to_num(hierarchy, items_List): for j in items_List[i]: variant_num_list.append(getVarNum(j)) - num_List[getAttIndex(hierarchy, i)] = variant_num_list - - + num_List[i] = variant_num_list return num_List +def rar_selectVar(hierarchy, items_List, deconstructed_DNA): + + for attribute in items_List: + + a_attribute_index = getAttIndex(hierarchy, attribute) + + selected_variants = items_List[attribute] + hierarchy_selected_variants = list(hierarchy[attribute]) + + left_over_variants = [x for x in hierarchy_selected_variants if x not in selected_variants] + print(left_over_variants) + + if not left_over_variants: + deconstructed_DNA[int(a_attribute_index)] = "0" + else: + number_List_Of_i = [] + rarity_List_Of_i = [] + ifZeroBool = None + variantNum = None + + for a in left_over_variants: + number = a.split("_")[1] + rarity = a.split("_")[2] + + number_List_Of_i.append(int(number)) + rarity_List_Of_i.append(float(rarity)) + + for x in rarity_List_Of_i: + if x == 0: + ifZeroBool = True + elif x != 0: + ifZeroBool = False + + if ifZeroBool: + variantNum = random.choices(number_List_Of_i, k=1) + + if not ifZeroBool: + variantNum = random.choices(number_List_Of_i, weights=rarity_List_Of_i, k=1) + + deconstructed_DNA[int(a_attribute_index)] = str(variantNum[0]) + + return deconstructed_DNA + def logicafyDNAList(DNAList, hierarchy, logicFile): logicFile = json.load(open(logicFile)) - LogicDNAList_deconstructed = [] + items_List1 = [] + items_List2 = [] + + for a in logicFile: + items_List1 = isAttorVar(hierarchy, logicFile[a]["Items-1"]) + items_List2 = isAttorVar(hierarchy, logicFile[a]["Items-2"]) + + # Convert String Attributes to DNA Index number, and String Variants to Order number. Variant == 0 if Empty given. + num_List1 = items_to_num(hierarchy, items_List1) + num_List2 = items_to_num(hierarchy, items_List2) for a in DNAList: deconstructed_DNA = a.split("-") for b in logicFile: - items_List1 = isAttorVar(hierarchy, logicFile[b]["Items-1"]) - items_List2 = isAttorVar(hierarchy, logicFile[b]["Items-2"]) - - print(items_List1) - print(items_List2) - - # Convert String Attributes to DNA Index number, and String Variants to Order number. Variant == 0 if Empty given. - num_List1 = items_to_num(hierarchy, items_List1) - # ^cannot go with: - num_List2 = items_to_num(hierarchy, items_List2) - if logicFile[b]["Rule"] == "Never with": - rand_bool = random.getrandbits(1) == 0 - if rand_bool == 0: - for c in num_List2: - deconstructed_DNA[c] = '0' + rand_bool = bool(random.getrandbits(1)) - if rand_bool == 1: - for c in num_List1: - deconstructed_DNA[c] = '0' + if rand_bool: + deconstructed_DNA = rar_selectVar(hierarchy, items_List2, deconstructed_DNA) + + if not rand_bool: + deconstructed_DNA = rar_selectVar(hierarchy, items_List1, deconstructed_DNA) if logicFile[b]["Rule"] == "Only with": for c in list(num_List2.keys()): @@ -98,9 +134,9 @@ def logicafyDNAList(DNAList, hierarchy, logicFile): LogicDNAList_deconstructed.append(deconstructed_DNA) LogicDNAList = [] + for a in LogicDNAList_deconstructed: reconstructed_DNA = "" - print(a) for b in a: num = "-" + str(b) reconstructed_DNA += num From 685e1fa7023394fff701434d66f15e2c90f8545b Mon Sep 17 00:00:00 2001 From: Torrin Leonard <82110564+torrinworx@users.noreply.github.com> Date: Thu, 10 Mar 2022 12:40:52 -0500 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 420e478..f5676e4 100644 --- a/README.md +++ b/README.md @@ -548,7 +548,7 @@ Blend_My_NFTs can only provide this information in the templates, you will have The list of meta data standard sources used to create the templates: - `Cardano CIP25` --> https://cips.cardano.org/cips/cip25/ -- `Solana Metaplex` --> https://docs.metaplex.com/nft-standard +- `Solana Metaplex` --> https://docs.metaplex.com/token-metadata/specification - `ERC721` --> https://docs.opensea.io/docs/metadata-standards - `ERC1155` --> To be created... From 41f4eee5e40bcdefb648620a68f353ae20f9a4b8 Mon Sep 17 00:00:00 2001 From: Torrin Leonard <82110564+torrinworx@users.noreply.github.com> Date: Thu, 10 Mar 2022 14:02:24 -0500 Subject: [PATCH 3/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f5676e4..79a152f 100644 --- a/README.md +++ b/README.md @@ -550,7 +550,6 @@ The list of meta data standard sources used to create the templates: - `Cardano CIP25` --> https://cips.cardano.org/cips/cip25/ - `Solana Metaplex` --> https://docs.metaplex.com/token-metadata/specification - `ERC721` --> https://docs.opensea.io/docs/metadata-standards -- `ERC1155` --> To be created... The Blend_My_NFTs code implementation for the above standards can be found in `main>metaData.py`.