kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Patching Logic methods
rodzic
8f6e8405c8
commit
b45687cc67
17
__init__.py
17
__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,
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue