From a2b21dff76b66b0f73d49b9f1b8bee94f2e7fe17 Mon Sep 17 00:00:00 2001 From: Jason Le Long Date: Thu, 8 Mar 2018 13:57:31 +0000 Subject: Equipment rolls working as desired --- sassbot/modules/artifact2-0/EquipmentCreate.py | 55 ++++++++++++++++---------- sassbot/modules/artifact2.py | 44 +++++++++++---------- 2 files changed, 59 insertions(+), 40 deletions(-) (limited to 'sassbot/modules') diff --git a/sassbot/modules/artifact2-0/EquipmentCreate.py b/sassbot/modules/artifact2-0/EquipmentCreate.py index e1520d7..c7f1c8c 100644 --- a/sassbot/modules/artifact2-0/EquipmentCreate.py +++ b/sassbot/modules/artifact2-0/EquipmentCreate.py @@ -14,19 +14,28 @@ def GenerateItem(phenny, parameters, itemCode): itemGenEquipment = CreateItemName(phenny, parameters, itemCode[1]) #Generate Enchantment - itemGenEnchantment = CreateItemEnchantment(phenny, parameters, itemCode[2]) + itemGenEnchantment = CreateItemEnchantment(phenny, parameters, itemCode[2], int(itemGenRarity["ID"])) #Generate Element - itemGenElement = CreateItemElement(phenny, parameters, itemCode[3]) + itemGenElement = CreateItemElement(phenny, parameters, itemCode[3], int(itemGenRarity["ID"])) #Attempt creating an Artifact itemGenEquipment = CreateItemArtifact(phenny, parameters, itemGenEquipment, itemCode[4]) strRaritySpacing = "" if len(itemGenRarity['RarityName']) == 0 else " " + + + itemGen={} - itemGen['EquipmentName'] = "\x03"+itemGenRarity['RarityColor'] + itemGenEquipment['FabledPrefix'] + itemGenRarity['RarityName'] + strRaritySpacing + itemGenElement['EffectName'] + " " + itemGenEquipment['EquipmentName'] + " " + itemGenEnchantment['Name']+"\x0399" - #itemGen['EquipmentName'] + itemGen['EquipmentName'] = ("\x03"+itemGenRarity['RarityColor'] + + itemGenEquipment['FabledPrefix'] + + itemGenRarity['RarityName'] + + strRaritySpacing + + ("" if itemGenElement == {} else itemGenElement['EffectName'] + " ") + + itemGenEquipment['EquipmentName'] + " " + + ("" if itemGenEnchantment == {} else itemGenEnchantment['Name'] + " ") + + "\x0399") #itemGen['EquipmentSlot'] #itemGen['EquipmentType'] #itemGen['HandsReq'] @@ -68,16 +77,19 @@ def CreateItemName(phenny, parameters, itemCode): itemGenEquipment['Permanent'] = 0 return itemGenEquipment -def CreateItemElement(phenny, parameters, itemCode): +def CreateItemElement(phenny, parameters, itemCode, RarityID): db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB']) c = db.cursor(MySQLdb.cursors.DictCursor) - itemGenElement = {} - if int(itemCode) is not 0: - c.execute("SELECT `EffectName`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor` FROM `GenElement` WHERE `ID` = %s",itemCode) - itemGenElement = c.fetchone() - elif int(itemCode) is 0: - c.execute("SELECT `EffectName`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor` FROM `GenElement` ORDER BY RAND() LIMIT 1") - itemGenElement = c.fetchone() + + if random.randint(1, 3) is 1 or RarityID <= 3: + itemGenElement = {} + else: + if int(itemCode) is not 0: + c.execute("SELECT `EffectName`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor` FROM `GenElement` WHERE `ID` = %s",itemCode) + itemGenElement = c.fetchone() + elif int(itemCode) is 0: + c.execute("SELECT `EffectName`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor` FROM `GenElement` ORDER BY RAND() LIMIT 1") + itemGenElement = c.fetchone() return itemGenElement def CreateItemRarity(phenny, parameters, itemCode): @@ -111,16 +123,19 @@ def CreateItemRarity(phenny, parameters, itemCode): return itemGenRarity db.close() -def CreateItemEnchantment(phenny, parameters, itemCode): +def CreateItemEnchantment(phenny, parameters, itemCode, RarityID): db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB']) c = db.cursor(MySQLdb.cursors.DictCursor) - itemGenElement = {} - if int(itemCode) is not 0: - c.execute("SELECT `Name`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`, `Crit`, `Armor` FROM `GenEnchantment` WHERE `ID` = %s", str(itemCode)) - itemGenEnchantment = c.fetchone() - elif int(itemCode) is 0: - c.execute("SELECT `Name`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`, `Crit`, `Armor` FROM `GenEnchantment` ORDER BY RAND() LIMIT 1") - itemGenEnchantment = c.fetchone() + + if random.randint(1, 3) is 1 or RarityID <= 2: + itemGenEnchantment = {} + else: + if int(itemCode) is not 0: + c.execute("SELECT `Name`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`, `Crit`, `Armor` FROM `GenEnchantment` WHERE `ID` = %s", str(itemCode)) + itemGenEnchantment = c.fetchone() + elif int(itemCode) is 0: + c.execute("SELECT `Name`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`, `Crit`, `Armor` FROM `GenEnchantment` ORDER BY RAND() LIMIT 1") + itemGenEnchantment = c.fetchone() return itemGenEnchantment def CreateItemArtifact(phenny, parameters, itemGenEquipment, itemCode): diff --git a/sassbot/modules/artifact2.py b/sassbot/modules/artifact2.py index bddd968..04c3db2 100644 --- a/sassbot/modules/artifact2.py +++ b/sassbot/modules/artifact2.py @@ -26,26 +26,30 @@ def adventurersinc(phenny, input): parameters['LiveDB'] = 'Artifact2.0' parameters['LiveVersion'] = '2.0' parameters['Nick'] = input.nick - - - #Actions based on player state - if strPlayerState == "newchar": - phenny.say("New Character") - - elif strPlayerState == "rest": - phenny.say("Resting") - - elif strPlayerState == "adventuring": - phenny.say("Exploring") - - elif strPlayerState == "combat": - phenny.say("Combat") - - elif strPlayerState == "debug": - itemCode = input.group(2).split(':') - #phenny.say(str(input.group(2))) - NewItem = EquipmentCreate.GenerateItem(phenny, parameters, itemCode) - phenny.say(NewItem["EquipmentName"]) + + if strCmd1 == "git": + phenny.say("Artifact v2 git: http://www.blatech.co.uk/JasonFS/Artifact-v2") + elif strCmd1 == "version": + phenny.say("Artifact v2 - alpha 0.0") + else: + #Actions based on player state + if strPlayerState == "newchar": + phenny.say("New Character") + + elif strPlayerState == "rest": + phenny.say("Resting") + + elif strPlayerState == "adventuring": + phenny.say("Exploring") + + elif strPlayerState == "combat": + phenny.say("Combat") + + elif strPlayerState == "debug": + itemCode = input.group(2).split(':') + #phenny.say(str(input.group(2))) + NewItem = EquipmentCreate.GenerateItem(phenny, parameters, itemCode) + phenny.say(NewItem["EquipmentName"]) adventurersinc.commands = ['a'] adventurersinc.priority = 'high' -- cgit v1.2.3