summaryrefslogtreecommitdiff
path: root/sassbot/modules/artifact2-0
diff options
context:
space:
mode:
Diffstat (limited to 'sassbot/modules/artifact2-0')
-rw-r--r--sassbot/modules/artifact2-0/Combat.py160
-rw-r--r--sassbot/modules/artifact2-0/Enemy.py78
-rw-r--r--sassbot/modules/artifact2-0/Items.py211
-rw-r--r--sassbot/modules/artifact2-0/LevelUp.py38
-rw-r--r--sassbot/modules/artifact2-0/PlayerAdventuring.py1
-rw-r--r--sassbot/modules/artifact2-0/PlayerCreate.py68
-rw-r--r--sassbot/modules/artifact2-0/PlayerDeath.py34
-rw-r--r--sassbot/modules/artifact2-0/PlayerStats.py47
-rw-r--r--sassbot/modules/artifact2-0/Resting.py201
-rw-r--r--sassbot/modules/artifact2-0/__init__.py0
10 files changed, 838 insertions, 0 deletions
diff --git a/sassbot/modules/artifact2-0/Combat.py b/sassbot/modules/artifact2-0/Combat.py
new file mode 100644
index 0000000..155f4c8
--- /dev/null
+++ b/sassbot/modules/artifact2-0/Combat.py
@@ -0,0 +1,160 @@
+#Python modules
+import MySQLdb
+import math
+import re
+import sys
+import random
+
+#Artifact Modules
+sys.path.insert(0, '/home/bouncer/sassbot/modules/artifact2-0/')
+import PlayerStats
+import Items
+import Enemy
+import PlayerDeath
+
+def PlayerInCombat(phenny, parameters, playerStats, strCmd1, strCmd2):
+ enemyStats={}
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ playerStats = PlayerStats.RefreshStats(phenny, parameters)
+ enemyStats = Enemy.GetStats(phenny, parameters, enemyStats)
+ strAttackLog = '\x0399'
+
+ # Attack
+ if strCmd1 == 'a' or strCmd1 == 'attack':
+ # Players attack
+ strAttackLog = strAttackLog + PerformAttack(phenny, playerStats, enemyStats, parameters)
+
+ if enemyStats['HP'] < 1:
+ strAttackLog = strAttackLog + "The \03" + str(enemyStats['EnemyColor']) + enemyStats['EnemyName'] + "\0399 falls to the floor. "
+ c.execute("UPDATE `Players` SET `State`='Rest', `RestedHeal`=0, `ChallengeRating`=`ChallengeRating`+0.1 WHERE `Nick`=%s;",(parameters["Nick"]));db.commit();
+
+ if random.randint(1, 3) == 1 and enemyStats['Class'] == 'Minor':
+ # Equipment Drop
+ itemGen = Items.GenerateEquipment(phenny, parameters, "0:0:0:0:0")
+ Items.AddToInventory(phenny, parameters, itemGen)
+ strAttackLog = strAttackLog + "You obtained a " + itemGen['RarityColor'] + " " + itemGen['EquipmentName'] + "\x0399. "
+
+ # Rare drops
+ elif enemyStats['Class'] == 'Rare':
+ #
+ # REQUIRES REWRITE
+ #
+ if enemyStats['Unlock'] == 'Chaos':
+ c.execute("SELECT `EquipmentName`, `EquipmentSlot`, `EquipmentType`, `HandsReq`, `Locked`, `Scaling`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor`, `Requirement` FROM `Items_Master` WHERE `Requirement`='Chaos'")
+ sqlItem = c.fetchone()
+ c.execute("INSERT INTO `Items_PlayerInventory` (`Nick`,`Equipped`,`EquipmentColor`,`EquipmentName`,`EquipmentSlot`,`EquipmentType`,`Permanent`,`Scaling`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", (parameters['Nick'], 0, 06, sqlItem['EquipmentName'], sqlItem['EquipmentSlot'],
+ sqlItem['EquipmentType'], 0, sqlItem['Scaling'],
+ sqlItem['HandsReq'], sqlItem['Strength'], sqlItem['Dexterity'],
+ sqlItem['Constitution'], sqlItem['Intelligence'], sqlItem['Dodge'],
+ sqlItem['Crit'], sqlItem['Armor']));
+ db.commit();
+ #TEMP FIX - add a better solution to clearing the enemies
+ c.execute("DELETE FROM `CombatEnemy` WHERE `Nick`=%s", (parameters["Nick"]));db.commit();
+ return "\x0399You acquire a \x0306Shard of Chaos\x0399 from the remains of the enemy."
+
+ # LootDrop
+ if random.randint(1, 1) == 1:
+ strItemName, intItemPotency = Items.CreateItem(phenny, enemyStats, playerStats, parameters)
+ strAttackLog = strAttackLog + "You got " + str(intItemPotency) + " " + strItemName + ". "
+ c.execute("UPDATE `Players` SET `Currency`=`Currency`+%s WHERE `Nick`=%s;",(intItemPotency, parameters["Nick"]));db.commit();
+
+ c.execute("DELETE FROM `CombatEnemy` WHERE `Nick`=%s", (parameters["Nick"]));
+ db.commit();
+ # Attempt to restock shop
+ if random.randint(1, 2) == 1:
+ strAttackLog = strAttackLog + "The shop has been restocked. "
+ c.execute("DELETE FROM `PlayerShop` WHERE `Nick`=%s", (parameters["Nick"]));db.commit();
+
+ intItemsAdded = 0
+ intItemsToAdd = random.randint(2,4)
+
+ while intItemsAdded < intItemsToAdd:
+ Items.AddToShop(phenny, parameters, Items.GenerateEquipment(phenny, parameters, '0:0:0:0:1'))
+ intItemsAdded += 1
+
+ #Unlock boss items
+ if enemyStats['Unlock'] is not 'Default' and enemyStats['Class'] is 'Boss':
+ c.execute("SELECT COUNT(`Requirement`) AS `Requirement` FROM `Items_PlayerPool` INNER JOIN `Items_Master` ON `Items_PlayerPool`.`EquipmentName` = `Items_Master`.`EquipmentName` WHERE `Nick`=%s and `Requirement`=%s",(parameters['Nick'], enemyStats['Unlock']))
+ sqlUnlockCheck = c.fetchone()
+ if str(sqlUnlockCheck['Requirement']) == '0':
+ UnlockItems(phenny, parameters, str(enemyStats['Unlock']))
+ return "Additional items will now begin appearing"
+
+ playerStats = PlayerStats.RefreshStats(phenny, parameters)
+ if playerStats['ChallengeRating'] == int(math.ceil(playerStats['ChallengeRating'] / 1) * 1):
+ c.execute("UPDATE `Players` SET `AttributePoints`=2 WHERE `Nick`=%s;", (parameters["Nick"]));db.commit();
+ strAttackLog = strAttackLog + "You have gained 2 attribute points"
+ else:
+ # Enemys attack
+ strAttackLog = strAttackLog + PerformAttack(phenny, enemyStats, playerStats, parameters)
+
+ if playerStats['HP'] <= 0:
+ strAttackLog = strAttackLog + "You died. "
+ PlayerDeath.CharacterDeath(phenny, playerStats, parameters)
+
+ return "\0399" + strAttackLog
+
+ # flee
+ elif strCmd1.lower() == 'f' or strCmd1.lower() == 'flee':
+ if random.randint(1, 3) == 1:
+ return FleeCombat(phenny, parameters)
+ else:
+ return "You failed to escape. " + PerformAttack(phenny, enemyStats, playerStats, parameters)
+ if playerStats['HP'] <= 0:
+ PlayerDeath.CharacterDeath(phenny, playerStats, parameters)
+ return "You were struck down as you attempted to flee. You died."
+
+ # Admin commands
+ elif strCmd1.lower() == 'admin' and input.admin:
+ return PerformAttack(phenny, playerStats, enemyStats, parameters["Nick"])
+ else:
+ return "\0399Available commands: (a)ttack, (f)lee"
+
+
+def PerformAttack(phenny, attackerStats, defenderStats, parameters):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ # determine if attacker hits
+ if random.randint(0, 100) < int(defenderStats['DodgePercentage']):
+ db.close()
+ if attackerStats['UnitType'] == 'Player':
+ return "You miss. "
+ elif attackerStats['UnitType'] == 'Enemy':
+ return "You dodge the \03" + str(attackerStats['EnemyColor']) + attackerStats['EnemyName'] + "\0399's attack. "
+
+ if random.randint(0,100) < int(defenderStats['BlockPercentage']):
+ db.close()
+ if attackerStats['UnitType'] == 'Player':
+ return "The enemy blocks your attack. "
+ elif attackerStats['UnitType'] == 'Enemy':
+ return "You block the \03" + str(attackerStats['EnemyColor']) + attackerStats['EnemyName'] + "\0399's attack. "
+
+ #Calculate total damage caused
+ intAttackerDamage = int(float(attackerStats['Strength']) + random.uniform(float(attackerStats['Strength']) * -0.2,float(attackerStats['Strength']) * 0.2))
+
+ #Apply Armor reduction
+ intAttackerDamage = int(math.ceil(intAttackerDamage - (intAttackerDamage * defenderStats['ArmorPercentage'] / 100.0)))
+
+ # Determine if the attacker is going to crit
+ strCrit = 'did'
+ if random.randint(0, 100) < attackerStats['CritPercentage']:
+ intAttackerDamage = intAttackerDamage * 2
+ strCrit = 'CRIT'
+
+ # Update defender health
+ defenderStats['HP'] = defenderStats['HP'] - intAttackerDamage
+ if defenderStats['UnitType'] == 'Enemy':
+ c.execute("UPDATE `CombatEnemy` SET `HP`=%s WHERE `Nick`=%s;", (defenderStats['HP'], parameters['Nick']));db.commit();
+ elif defenderStats['UnitType'] == 'Player':
+ c.execute("UPDATE `Players` SET `HP`=%s WHERE `Nick`=%s;", (defenderStats['HP'], parameters['Nick']));db.commit();
+
+ db.close()
+
+ if attackerStats['UnitType'] == 'Player':
+ return "You " + strCrit + " " + str(intAttackerDamage) + " damage. "
+ elif attackerStats['UnitType'] == 'Enemy':
+ return "The \03" + str(attackerStats['EnemyColor']) + attackerStats[
+ 'EnemyName'] + "\0399 " + strCrit + " " + str(intAttackerDamage) + " damage. " \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/Enemy.py b/sassbot/modules/artifact2-0/Enemy.py
new file mode 100644
index 0000000..1d55941
--- /dev/null
+++ b/sassbot/modules/artifact2-0/Enemy.py
@@ -0,0 +1,78 @@
+import MySQLdb
+import math
+import random
+
+def Create(phenny, enemyStats, playerStats, parameters):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ # Update player state for combat
+ c.execute("UPDATE `Players` SET `State`='Combat' WHERE `Nick`=%s;", (parameters['Nick']));db.commit();
+
+ if playerStats['ChallengeRating'] == int(math.ceil(playerStats['ChallengeRating'] / 4) * 4):
+ # Get total unluck enemy weighting
+ c.execute("SELECT SUM(`EnemyWeight`) AS `EnemyWeight` FROM `GenEnemy` WHERE `Locked`=0 AND `Class`='Boss'")
+ intTotalWeight = random.randint(1, int(c.fetchone()['EnemyWeight']))
+
+ #Get Boss
+ c.execute("SELECT `EnemyColor`, `EnemyName`, `Season`, `Class`, `Unlock`, `HP`, `Locked`, `EnemyWeight`, `ChallengeRating`, `GoldCarried`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit` "+
+ "FROM `GenEnemy` WHERE `Locked`=0 AND `Class`='Boss'")
+ else:
+ # Get total unluck enemy weighting
+ c.execute("SELECT SUM(`EnemyWeight`) AS `EnemyWeight` FROM `GenEnemy` WHERE `Locked`=0 AND `Class`='Rare' OR `Locked`=0 AND `Class`='Minor'")
+ intTotalWeight = random.randint(1, int(c.fetchone()['EnemyWeight']))
+
+ #Get enemy
+ c.execute("SELECT `EnemyColor`, `EnemyName`, `Season`, `Class`, `Unlock`, `HP`, `Locked`, `EnemyWeight`, `ChallengeRating`, `GoldCarried`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit` "+
+ "FROM `GenEnemy` WHERE `Locked`=0 AND `Class`='Rare' OR "+
+ "`Locked`=0 AND `Class`='Minor'")
+ enemyStats = c.fetchone()
+
+ while True:
+ intTotalWeight = intTotalWeight - enemyStats['EnemyWeight']
+ if intTotalWeight <= 0:
+ break
+ else:
+ enemyStats = c.fetchone()
+
+ #Apply challenge rating modifier to enemy
+ intChallengeModifier = 2
+ enemyStats['HP'] = int(math.ceil(enemyStats['HP'] * playerStats['ChallengeRating']/intChallengeModifier))
+ enemyStats['GoldCarried'] = int(math.ceil(enemyStats['GoldCarried'] * playerStats['ChallengeRating']/intChallengeModifier))
+ enemyStats['Strength'] = int(math.ceil(enemyStats['Strength'] * playerStats['ChallengeRating']/intChallengeModifier))
+ enemyStats['Dexterity'] = int(math.ceil(enemyStats['Dexterity'] * playerStats['ChallengeRating']/intChallengeModifier))
+ enemyStats['Constitution'] = int(math.ceil(enemyStats['Constitution'] * playerStats['ChallengeRating']/intChallengeModifier))
+ enemyStats['Intelligence'] = int(math.ceil(enemyStats['Intelligence'] * playerStats['ChallengeRating']/intChallengeModifier))
+
+ #Create entity in database
+ c.execute("INSERT INTO CombatEnemy(`EnemyColor`,`EnemyName`,`Season`,`Class`,`Nick`,`HP`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`GoldCarried`,`Unlock`) VALUES ('"+
+ str(enemyStats['EnemyColor'])+"','"+str(enemyStats['EnemyName'])+"','"+str(enemyStats['Season'])+"','"+str(enemyStats['Class'])+"','"+parameters['Nick']+"','"+str(enemyStats['HP'])+"','"+str(enemyStats['Strength'])+"','"+str(enemyStats['Dexterity'])+"','"+str(enemyStats['Constitution'])+"','"+str(enemyStats['Intelligence'])+"','"+str(enemyStats['GoldCarried'])+"','"+str(enemyStats['Unlock'])+"')");db.commit();
+
+ #Cleanup
+ db.close()
+ return enemyStats
+
+def GetStats(phenny, parameters, enemyStats):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ c.execute("SELECT `EnemyColor`,`EnemyName`, `Class`, `Season`, `Unlock`,`HP`,`GoldCarried`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`GoldCarried`, `Dodge`, `Crit` FROM `CombatEnemy` WHERE `Nick`=%s",parameters['Nick'])
+ sqlEnemy = c.fetchone()
+ enemyStats['EnemyColor'] = sqlEnemy['EnemyColor']
+ enemyStats['EnemyName'] = sqlEnemy['EnemyName']
+ enemyStats['Class'] = sqlEnemy['Class']
+ enemyStats['Season'] = sqlEnemy['Season']
+ enemyStats['Unlock'] = sqlEnemy['Unlock']
+ enemyStats['HP'] = sqlEnemy['HP']
+ enemyStats['GoldCarried'] = sqlEnemy['GoldCarried']
+ enemyStats['Strength'] = sqlEnemy['Strength']
+ enemyStats['Dexterity'] = sqlEnemy['Dexterity']
+ enemyStats['Constitution'] = sqlEnemy['Constitution']
+ enemyStats['Intelligence'] = sqlEnemy['Intelligence']
+ enemyStats['DodgePercentage'] = sqlEnemy['Dodge']
+ enemyStats['CritPercentage'] = sqlEnemy['Crit']
+ enemyStats['ArmorPercentage'] = 0
+ enemyStats['UnitType'] = 'Enemy'
+ enemyStats['BlockPercentage'] = 0
+ db.close()
+
+ return enemyStats \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/Items.py b/sassbot/modules/artifact2-0/Items.py
new file mode 100644
index 0000000..7841d7d
--- /dev/null
+++ b/sassbot/modules/artifact2-0/Items.py
@@ -0,0 +1,211 @@
+import MySQLdb
+import random
+
+def GenerateEquipment(phenny, parameters, itemCode):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ intIteration=0
+ itemName=strRaritySpacing='';
+
+
+ itemCode = itemCode.split(':')
+
+ #Generate Rarity
+ itemGenRarity = CreateEquipmentRarity(phenny, parameters, itemCode[0])
+
+ #Generate Item
+ itemGenEquipment = CreateEquipmentName(phenny, parameters, itemCode[1])
+ itemGenEquipment['FabledPrefix'] = ''
+
+ #Generate Enchantment
+ itemGenEnchantment = CreateEquipmentEnchantment(phenny, parameters, itemCode[2], int(itemGenRarity["ID"]))
+
+ #Generate Element
+ itemGenElement = CreateEquipmentElement(phenny, parameters, itemCode[3], int(itemGenRarity["ID"]))
+
+ #Attempt creating an Artifact
+ itemGenEquipment = CreateEquipmentArtifact(phenny, parameters, itemGenEquipment, itemCode[4])
+
+ strRaritySpacing = "" if len(itemGenRarity['RarityName']) == 0 else " "
+
+
+
+ itemGen={}
+ itemGen['RarityColor'] = "\x03"+itemGenRarity['RarityColor']
+ itemGen['EquipmentName'] = (itemGenEquipment['FabledPrefix'] +
+ itemGenRarity['RarityName'] +
+ strRaritySpacing +
+ ("" if itemGenElement == {} else itemGenElement['EffectName'] + " ") +
+ itemGenEquipment['EquipmentName'] + " " +
+ ("" if itemGenEnchantment == {} else itemGenEnchantment['Name'] + " "))
+
+ itemGen['EquipmentSlot'] = itemGenEquipment['EquipmentSlot']
+ itemGen['EquipmentType'] = itemGenEquipment['EquipmentType']
+ itemGen['HandsReq'] = itemGenEquipment['HandsReq']
+ itemGen['Strength'] = itemGenEquipment['Strength']
+ itemGen['Dexterity'] = itemGenEquipment['Dexterity']
+ itemGen['Constitution'] = itemGenEquipment['Constitution']
+ itemGen['Intelligence'] = itemGenEquipment['Intelligence']
+ itemGen['Dodge'] = itemGenEquipment['Dodge']
+ itemGen['Crit'] = itemGenEquipment['Crit']
+ itemGen['Armor'] = itemGenEquipment['Armor']
+ itemGen['Precision'] = itemGenEquipment['Precision']
+ itemGen['Resistance'] = itemGenEquipment['Resistance']
+ itemGen['Luck'] = itemGenEquipment['Luck']
+ itemGen['Block'] = itemGenEquipment['Block']
+ itemGen['Permanent'] = itemGenEquipment['Permanent']
+
+ itemGen['Cost'] = (itemGenEquipment['Cost'] +
+ (0 if itemGenElement == {} else itemGenElement['Cost']) +
+ (0 if itemGenEnchantment == {} else itemGenEnchantment['Cost']) +
+ (0 if itemGenRarity == {} else itemGenRarity['RarityCost']))
+
+ return itemGen
+
+def CreateEquipmentName(phenny, parameters, itemCode):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ itemGenEquipment = {}
+
+
+ #Item by ID
+ if int(itemCode) is not 0:
+ c.execute("SELECT `EquipmentName`,`EquipmentSlot`,`EquipmentType`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`,`Precision`,`Resistance`,`Luck`,`Block` FROM `Items_Master` WHERE `ID` = " + str(itemCode))
+ itemGenEquipment = c.fetchone()
+
+ #Item by Random
+ elif int(itemCode) is 0:
+ #UPDATE: Should be able to generate an available weapon with just one query
+ # Pick random item that is available to the player
+ c.execute("SELECT `Items_PlayerPool`.`Nick`, `Items_PlayerPool`.`EquipmentName`, `Items_Master`.`Locked` FROM `Items_PlayerPool` INNER JOIN `Items_Master` ON `Items_PlayerPool`.`EquipmentName` = `Items_Master`.`EquipmentName` WHERE `Nick`=%s AND `Locked`=0 ORDER BY RAND() LIMIT 1",parameters['Nick'])
+ sqlItemPlayer = c.fetchone()
+
+ # Get information from randomly picked weapon
+ c.execute("SELECT `EquipmentName`, `EquipmentSlot`, `EquipmentType`, `HandsReq`, `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor`, `Precision`, `Resistance`, `Luck`, `Block` FROM `Items_Master` WHERE `EquipmentName`=%s",sqlItemPlayer['EquipmentName'])
+ itemGenEquipment = c.fetchone()
+
+ itemGenEquipment['Permanent'] = 0
+ itemGenEquipment['Cost'] = 100
+ return itemGenEquipment
+
+def CreateEquipmentElement(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)
+
+ 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()
+
+ itemGenElement['Cost'] = 200
+ return itemGenElement
+
+def CreateEquipmentRarity(phenny, parameters, itemCode):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ itemGenRarity = {}
+ if int(itemCode) is not 0:
+ c.execute("SELECT `ID`,`RarityName`,`RarityColor`,`RarityModifier`,`RarityChance`,`RarityCost` FROM `GenRarity` WHERE `ID` = " + str(itemCode))
+ itemGenRarity = c.fetchone()
+ elif int(itemCode) is 0:
+ # Obtain sum of all rarities
+ c.execute("SELECT SUM(`RarityChance`) AS RarityTotal FROM `GenRarity`")
+ intRarityTotal = c.fetchone()['RarityTotal']
+
+ # Variable declaration
+ intIteration = 0
+ intRandom = random.randint(1, intRarityTotal)
+
+ while True:
+ intIteration = intIteration + 1
+
+ # Obtain Rarity in order of lowest to highest with each iteration
+ c.execute("SELECT `ID`,`RarityName`,`RarityColor`,`RarityModifier`,`RarityChance`,`RarityCost` FROM `GenRarity` WHERE `ID` = " + str(intIteration))
+ itemGenRarity = c.fetchone()
+
+ # Subtract the current iterations rarity from the random roll
+ # If intRandom becomes negative, our item rarity has been found. End the loop.
+ intRandom = intRandom - itemGenRarity['RarityChance']
+ if intRandom <= 0:
+ break
+ return itemGenRarity
+ db.close()
+
+def CreateEquipmentEnchantment(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)
+
+ 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()
+
+ itemGenEnchantment['Cost'] = 200
+ return itemGenEnchantment
+
+def CreateEquipmentArtifact(phenny, parameters, itemGenEquipment, itemCode):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ # Gen for Artifact item:
+ # 0 - Will attempt to add an artifact randomly and not exceed the standard limit
+ if random.randint(1, 100) == 1 and int(itemCode) == 0:
+ if itemGenEquipment['EquipmentType'] == 'Armor' or itemGenEquipment['EquipmentType'] == 'Weapon':
+ c.execute("SELECT COUNT(`Permanent`) AS `Artifacts` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `Permanent`=1;",parameters['Nick'])
+ sqlCountArtifacts = c.fetchone()
+ if sqlCountArtifacts['Artifacts'] < 2:
+ itemGenEquipment['FabledPrefix'] = 'Fabled '
+ itemGenEquipment['Permanent'] = 1
+ # 1 - Will not generate item as an artifact
+ elif int(itemCode) == 1:
+ itemGenEquipment['FabledPrefix'] = ''
+
+ # 2 - Will force the item to become an artifact and exceed the limit of 2 artifacts
+ elif int(itemCode) == 2:
+ if itemGenEquipment['EquipmentType'] == 'Armor' or itemGenEquipment['EquipmentType'] == 'Weapon':
+ c.execute("SELECT COUNT(`Permanent`) AS `Artifacts` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `Permanent`=1;",parameters['Nick'])
+ sqlCountArtifacts = c.fetchone()
+ itemGenEquipment['FabledPrefix'] = 'Fabled '
+ itemGenEquipment['Permanent'] = 1
+ return itemGenEquipment
+
+def CreateItem(phenny, enemyStats, playerStats, parameters):
+ import random
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ # Get random element
+ c.execute("SELECT `LootName`,`ItemType`,`Potency` FROM `GenLoot` WHERE `Locked`=0 ORDER BY RAND() LIMIT 1")
+ sqlRarity = c.fetchone()
+ strLootName = sqlRarity['LootName']
+ strItemType = sqlRarity['ItemType']
+ intPotency = sqlRarity['Potency']
+
+ if strItemType == 'Quantity':
+ intPotency = enemyStats['GoldCarried'] + int(
+ random.uniform(float(enemyStats['GoldCarried']) * -0.3, float(enemyStats['GoldCarried']) * 0.3))
+
+ db.close()
+ return strLootName, intPotency
+
+def AddToShop(phenny, parameters, item):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ c.execute("""INSERT INTO `PlayerShop` (`Nick`,`Cost`,`Equipped`,`EquipmentColor`,`EquipmentName`,`EquipmentSlot`,`EquipmentType`,`Permanent`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);""", (parameters['Nick'], item['Cost'], 0, item['RarityColor'], item['EquipmentName'], item['EquipmentSlot'], item['EquipmentType'],item['Permanent'], item['HandsReq'], item['Strength'], item['Dexterity'], item['Constitution'], item['Intelligence'], item['Dodge'], item['Crit'], item['Armor']));db.commit();
+ return
+
+def AddToInventory(phenny, parameters, item):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ c.execute("""INSERT INTO `Items_PlayerInventory` (`EquipmentColor`,`EquipmentName`,`EquipmentSlot`,`EquipmentType`,`Permanent`,`HandsReq`,`Equipped`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`,`Nick`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);""", (item['RarityColor'], item['EquipmentName'], item['EquipmentSlot'], item['EquipmentType'],item['Permanent'], item['HandsReq'], 0, item['Strength'], item['Dexterity'], item['Constitution'], item['Intelligence'], item['Dodge'], item['Crit'], item['Armor'],parameters['Nick']));db.commit();
+ return \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/LevelUp.py b/sassbot/modules/artifact2-0/LevelUp.py
new file mode 100644
index 0000000..74e0acf
--- /dev/null
+++ b/sassbot/modules/artifact2-0/LevelUp.py
@@ -0,0 +1,38 @@
+import MySQLdb
+import sys
+sys.path.insert(0, '/home/bouncer/sassbot/modules/artifact2-0/')
+import PlayerStats
+
+def LevelUpAttributes(phenny, parameters, strCmd1, strCmd2):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ #In the event no valid value is given, assume the points to assign will be 1
+ try:
+ strCmd2 = int(strCmd2)
+ except ValueError:
+ strCmd2 = 1
+
+ #Get players attribute points
+ c.execute("SELECT `AttributePoints` FROM `Players` WHERE `Nick`=%s;", (parameters["Nick"]))
+ sqlAttibutes = c.fetchone()
+
+ #Prevent over-allocation
+ if int(strCmd2) > sqlAttibutes['AttributePoints']:
+ return "You cannot apply more points than you have."
+
+ #Attribute allocation
+ else:
+ if strCmd1.lower() == 's':
+ c.execute("UPDATE `Players` SET `Strength`=`Strength`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit();
+ elif strCmd1.lower() == 'd':
+ c.execute("UPDATE `Players` SET `Dexterity`=`Dexterity`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit();
+ elif strCmd1.lower() == 'c':
+ c.execute("UPDATE `Players` SET `Constitution`=`Constitution`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit();
+ elif strCmd1.lower() == 'i':
+ c.execute("UPDATE `Players` SET `Intelligence`=`Intelligence`+%s, `AttributePoints`=`AttributePoints`-%s WHERE `Nick`=%s;",(strCmd2, strCmd2, parameters["Nick"]));db.commit();
+
+ playerStats = PlayerStats.RefreshStats(phenny, parameters)
+
+ c.execute("UPDATE `Players` SET `HP`=%s WHERE `Nick`=%s;", (playerStats['MaxHP'], parameters["Nick"]));db.commit();
+ return "\0399Attribute Points: " + str(playerStats['AttributePoints']) + " (S)tr:" + str(playerStats['Strength']) + " (D)ex:" + str(playerStats['Dexterity']) + " (C)on:" + str(playerStats['Constitution']) + " (I)nt:" + str(playerStats['Intelligence']) \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/PlayerAdventuring.py b/sassbot/modules/artifact2-0/PlayerAdventuring.py
new file mode 100644
index 0000000..f0f05c9
--- /dev/null
+++ b/sassbot/modules/artifact2-0/PlayerAdventuring.py
@@ -0,0 +1 @@
+# Embedded file name: /home/bouncer/sassbot/modules/artifact2-0/PlayerAdventuring.py \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/PlayerCreate.py b/sassbot/modules/artifact2-0/PlayerCreate.py
new file mode 100644
index 0000000..6a30d6c
--- /dev/null
+++ b/sassbot/modules/artifact2-0/PlayerCreate.py
@@ -0,0 +1,68 @@
+# Embedded file name: /home/bouncer/sassbot/modules/artifact2-0/PlayerCreate.py
+import PlayerStats
+import MySQLdb
+
+def PickCharacterClan(phenny, parameters, strCmd1):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ if strCmd1 is '':
+ return '\x0399Name your Clan.'
+ elif len(strCmd1) < 3:
+ return 'Your Clan name must be at least three characters.'
+ else:
+ c.execute('INSERT INTO `Players` (`Nick`,`ClanName`,`State`) VALUES (%s,%s,%s);', (parameters['Nick'], strCmd1, 'CreationName'))
+ db.commit()
+ return '\x0399The adventure for the ' + strCmd1 + ' clan begins.'
+
+
+def PickCharacterName(phenny, parameters, playerStats, strCmd1):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ if strCmd1 is '':
+ return 'Give yourself a name.'
+ elif len(strCmd1) < 3:
+ return 'Your name must be at least three characters.'
+ else:
+ c.execute('UPDATE `Players` SET `CharacterName`=%s, `Alive`=1, `State`=%s WHERE `Nick`=%s;', (strCmd1, 'CreationRace', parameters['Nick']))
+ db.commit()
+ c.execute('SELECT COUNT(`Requirement`) AS `Requirement` FROM `Items_PlayerPool` INNER JOIN `Items_Master` ON `Items_PlayerPool`.`EquipmentName` = `Items_Master`.`EquipmentName` WHERE `Nick`=%s and `Requirement`=%s', (parameters['Nick'], 'Default'))
+ sqlUnlockCheck = c.fetchone()
+ if str(sqlUnlockCheck['Requirement']) == '0':
+ UnlockItems(phenny, parameters, 'Default')
+ return 'You are ' + strCmd1 + ' ' + playerStats['ClanName'] + '. Pick a race: (H)uman, (O)rc, (E)lf, (D)warf, (L)izardman'
+
+
+def PickCharacterRace(phenny, parameters, playerStats, strCmd1):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ strRaceSelected = None
+ if strCmd1.lower() == 'h':
+ strRaceSelected = 'Human'
+ elif strCmd1.lower() == 'o':
+ strRaceSelected = 'Orc'
+ elif strCmd1.lower() == 'e':
+ strRaceSelected = 'Elf'
+ elif strCmd1.lower() == 'd':
+ strRaceSelected = 'Dwarf'
+ elif strCmd1.lower() == 'l':
+ strRaceSelected = 'Lizardman'
+ else:
+ return 'Pick a race: (H)uman, (O)rc, (E)lf, (D)warf, (L)izardman'
+ if strRaceSelected is not None:
+ c.execute('SELECT `Strength`, `Dexterity`, `Constitution`, `Intelligence`, `Dodge`, `Crit`, `Armor` FROM `LK_Races` WHERE `Race` = %s;', strRaceSelected)
+ sqlRaceStats = c.fetchone()
+ c.execute("UPDATE `Players` SET `Strength`=%s, `Dexterity`=%s, `Constitution`=%s, `Intelligence`=%s, `Dodge`=%s, `Crit`=%s, `Armor`=%s, `State`='Rest' WHERE `Nick`=%s;", (sqlRaceStats['Strength'],
+ sqlRaceStats['Dexterity'],
+ sqlRaceStats['Constitution'],
+ sqlRaceStats['Intelligence'],
+ sqlRaceStats['Dodge'],
+ sqlRaceStats['Crit'],
+ sqlRaceStats['Armor'],
+ parameters['Nick']))
+ db.commit()
+ playerStats = PlayerStats.RefreshStats(phenny, parameters)
+ c.execute('UPDATE `Players` SET `HP`=%s WHERE `Nick`=%s;', (playerStats['MaxHP'], parameters['Nick']))
+ db.commit()
+ return playerStats['CharacterName'] + ' ' + playerStats['ClanName'] + ' the ' + strRaceSelected + ' begins their adventure'
+ else:
+ return \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/PlayerDeath.py b/sassbot/modules/artifact2-0/PlayerDeath.py
new file mode 100644
index 0000000..9c3df41
--- /dev/null
+++ b/sassbot/modules/artifact2-0/PlayerDeath.py
@@ -0,0 +1,34 @@
+import time
+import MySQLdb
+
+
+def CharacterDeath(phenny, playerStats, parameters):
+ db = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ dbIRC = MySQLdb.connect(host="localhost", user=phenny.config.mysql_username, passwd=phenny.config.mysql_password,db='IRC')
+ cIRC = dbIRC.cursor(MySQLdb.cursors.DictCursor)
+
+ # Collect total items lost on death
+ c.execute("SELECT COUNT(`EquipmentName`) AS EquipmentName FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `Permanent`=0;",parameters['Nick'])
+ sqlEquipmentCount = c.fetchone()['EquipmentName']
+
+ # Create death entry
+ cIRC.execute("INSERT INTO `ArtifactsGraveyard` (`Nick`,`CharacterName`,`ClanName`,`ItemsLost`,`ChallengeRating`,`VersionDied`) VALUES (%s,%s,%s,%s,%s,%s);",(parameters['Nick'], playerStats['CharacterName'], playerStats['ClanName'], sqlEquipmentCount,playerStats['ChallengeRating'], '1.3.1'));dbIRC.commit();
+
+ # Delete players Inventory
+ c.execute("DELETE FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `Permanent`=0;", (str(parameters['Nick'])));db.commit();
+
+ # Delete players opponent
+ c.execute("DELETE FROM `CombatEnemy` WHERE `Nick`=%s;", (str(parameters['Nick'])));db.commit();
+
+ # Delete players shop
+ c.execute("DELETE FROM `PlayerShop` WHERE `Nick`=%s;", (str(parameters['Nick'])));db.commit();
+
+ # Update player record for new character
+ c.execute("UPDATE `Players` SET `State`='CreationName', `Alive`=0, `RestedHeal`=0, `HP`=1, `AttributePoints`=0, `Strength`=8, `Dexterity`=8, `Constitution`=8, `Intelligence`=8, `ChallengeRating`=1, `XP`=0, `XPToLevel`=200 WHERE `Nick`=%s;",(parameters['Nick']));db.commit();
+
+ # Lose gold on death
+ c.execute("UPDATE `Players` SET `Currency`=`Currency`/2 WHERE `Nick`=%s;", (parameters['Nick']));db.commit();
+
+ dbIRC.close()
+ db.close() \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/PlayerStats.py b/sassbot/modules/artifact2-0/PlayerStats.py
new file mode 100644
index 0000000..39c919e
--- /dev/null
+++ b/sassbot/modules/artifact2-0/PlayerStats.py
@@ -0,0 +1,47 @@
+# Embedded file name: /home/bouncer/sassbot/modules/artifact2-0/PlayerStats.py
+import sys
+import math
+import MySQLdb
+sys.path.insert(0, '/home/bouncer/sassbot/modules/artifact2-0/')
+import Calculate
+
+def PrintStats(phenny, input, parameters):
+ playerStats = {}
+ playerStats = RefreshStats(phenny, parameters)
+ return '\x0399' + playerStats['CharacterName'] + ' ' + playerStats['ClanName'] + ' has ' + str(playerStats['HP']) + '/' + str(playerStats['MaxHP']) + ' HP, ' + str(playerStats['Strength']) + ' STR, ' + str(playerStats['Dexterity']) + ' DEX, ' + str(playerStats['Constitution']) + ' CON, ' + str(playerStats['Intelligence']) + ' INT and you have ' + str(playerStats['Currency']) + ' gold. Challenge rating: ' + str(playerStats['ChallengeRating']) + '. ' + str(playerStats['DodgePercentage']) + '% Dodge, ' + str(playerStats['CritPercentage']) + '% Crit, ' + str(playerStats['ArmorPercentage']) + '% Armor, ' + str(playerStats['PrecisionPercentage']) + '% Precision, ' + str(playerStats['ResistancePercentage']) + '% Resistance, ' + str(playerStats['Luck']) + ' Luck, ' + str(playerStats['BlockPercentage']) + '% Block'
+
+
+def RefreshStats(phenny, parameters):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+ c.execute('SELECT `Nick`,`ClanName`,`Currency`,`State`,`CharacterName`,`Alive`,`ChallengeRating`,`RestedHeal`,`HP`,`AttributePoints`,`Strength`,`Dexterity`,`Constitution`,`Intelligence` FROM `Players` WHERE `Nick` = %s;', parameters['Nick'])
+ sqlPlayerBase = c.fetchone()
+ c.execute('SELECT `Nick`, SUM(`HandsReq`) AS HandsReq, SUM(`Strength`) AS Strength, SUM(`Dexterity`) AS Dexterity, SUM(`Constitution`) AS Constitution, SUM(`Intelligence`) AS Intelligence, SUM(`Crit`) AS Crit, SUM(`Dodge`) AS Dodge, SUM(`Armor`) AS Armor,SUM(`Precision`) AS `Precision`,SUM(`Resistance`) AS Resistance,SUM(`Luck`) AS Luck,SUM(`Block`) AS Block from \n (\n select `Nick`,0 AS `HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Crit`,`Dodge`,`Armor`, `Precision`, `Resistance`, `Luck`, `Block` from `Players` \n union all \n select `Nick`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Crit`,`Dodge`,`Armor`, `Precision`, `Resistance`, `Luck`, `Block` from `Items_PlayerInventory` where `Equipped`=1 ) x \n WHERE `Nick`=%s group by `Nick`', parameters['Nick'])
+ sqlPlayerStats = c.fetchone()
+ playerStats = {}
+ if c.rowcount:
+ playerStats['Nick'] = sqlPlayerBase['Nick']
+ playerStats['Currency'] = sqlPlayerBase['Currency']
+ playerStats['ClanName'] = sqlPlayerBase['ClanName']
+ playerStats['CharacterName'] = sqlPlayerBase['CharacterName']
+ playerStats['State'] = sqlPlayerBase['State']
+ playerStats['Alive'] = sqlPlayerBase['Alive']
+ playerStats['ChallengeRating'] = sqlPlayerBase['ChallengeRating']
+ playerStats['RestedHeal'] = sqlPlayerBase['RestedHeal']
+ playerStats['HP'] = sqlPlayerBase['HP']
+ playerStats['MaxHP'] = int(math.ceil((float(sqlPlayerStats['Constitution']) + float(sqlPlayerStats['Constitution']) / 1.75) * 2))
+ playerStats['AttributePoints'] = sqlPlayerBase['AttributePoints']
+ playerStats['HandsReq'] = sqlPlayerStats['HandsReq']
+ playerStats['UnitType'] = 'Player'
+ playerStats['Strength'] = sqlPlayerStats['Strength']
+ playerStats['Dexterity'] = sqlPlayerStats['Dexterity']
+ playerStats['Constitution'] = sqlPlayerStats['Constitution']
+ playerStats['Intelligence'] = sqlPlayerStats['Intelligence']
+ playerStats['DodgePercentage'] = Calculate.DiminishingReturns(sqlPlayerStats['Dodge'] + int(math.ceil(sqlPlayerStats['Dexterity'] / 2)), 25, 15)
+ playerStats['CritPercentage'] = Calculate.DiminishingReturns(sqlPlayerStats['Crit'] + int(math.ceil(sqlPlayerStats['Dexterity'] / 2)), 25, 15)
+ playerStats['ArmorPercentage'] = Calculate.DiminishingReturns(sqlPlayerStats['Armor'], 25, 0)
+ playerStats['PrecisionPercentage'] = Calculate.DiminishingReturns(sqlPlayerStats['Precision'], 25, 0)
+ playerStats['ResistancePercentage'] = Calculate.DiminishingReturns(sqlPlayerStats['Resistance'], 25, 0)
+ playerStats['Luck'] = sqlPlayerStats['Luck']
+ playerStats['BlockPercentage'] = sqlPlayerStats['Block']
+ return playerStats \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/Resting.py b/sassbot/modules/artifact2-0/Resting.py
new file mode 100644
index 0000000..b495587
--- /dev/null
+++ b/sassbot/modules/artifact2-0/Resting.py
@@ -0,0 +1,201 @@
+#Python modules
+import MySQLdb
+import math
+import re
+import sys
+
+#Artifact Modules
+sys.path.insert(0, '/home/bouncer/sassbot/modules/artifact2-0/')
+import PlayerStats
+import Enemy
+
+def PlayerResting(phenny, parameters, playerStats, strCmd1, strCmd2):
+ db = MySQLdb.connect(host='localhost', user=phenny.config.mysql_username, passwd=phenny.config.mysql_password, db=parameters['LiveDB'])
+ c = db.cursor(MySQLdb.cursors.DictCursor)
+
+ # Inventory
+ if strCmd1.lower() == 'i' or strCmd1.lower() == 'inventory':
+ try:
+ strCmd2 = int(strCmd2)
+ except ValueError:
+ strCmd2 = 1
+
+ c.execute("SELECT COUNT(ID) AS `ID` FROM `Items_PlayerInventory` WHERE `Nick`=%s", (parameters["Nick"]))
+ sqlSumResult = c.fetchone()
+ intTotalPages = int(math.ceil(float(sqlSumResult["ID"]) / float(5)))
+
+ c.execute("SELECT `ID`,`Equipped`,`EquipmentColor`,`EquipmentName`,`HandsReq` FROM `Items_PlayerInventory` WHERE `Nick` = %s LIMIT 5 OFFSET %s;",(parameters["Nick"], (int(strCmd2) * 5) - 5))
+ sqlItem = c.fetchall()
+
+ if int(strCmd2) > 0 and int(strCmd2) <= intTotalPages:
+ phenny.write(('NOTICE', parameters["Nick"]), "Page " + str(strCmd2) + " of " + str(intTotalPages) + ". ( http://lexicade.uk/artifact.php?nick=" + parameters["Nick"] + " )")
+ for row in sqlItem:
+ strEquipped = 'Equipped ' if str(row["Equipped"]) == '1' else 'Unequipped'
+ strHands = "--" if str(row["HandsReq"]) == '0' else str(row["HandsReq"]) + "H"
+
+ phenny.write(('NOTICE', parameters["Nick"]),str(row["ID"]) + " " + strEquipped + " " + strHands + "\x03" + str(row["EquipmentColor"]) + " " + str(row["EquipmentName"]) + "\0399")
+
+ # Equip
+ elif strCmd1.lower() == 'e' or strCmd1.lower() == 'equip':
+ if playerStats['State'] == 'Rest':
+ # Check to unequip
+ if strCmd2 == 'u' or strCmd2 == 'unequip':
+ c.execute("UPDATE `Items_PlayerInventory` SET `Equipped`=0 WHERE `Nick`=%s;", (parameters["Nick"]));db.commit();
+ return "All items have been unequipped."
+
+ # Check to see if an ID was supplied
+ elif re.match("^[0-9]+$", strCmd2):
+ c.execute("SELECT `ID`,`Nick`,`EquipmentColor`,`EquipmentSlot`,`EquipmentType`,`EquipmentName`,`Equipped`,`HandsReq` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `ID`=%s",(parameters["Nick"], strCmd2))
+ sqlItem = c.fetchone()
+ if sqlItem is not None:
+ EquipmentID = sqlItem['ID']
+ EquipmentNick = sqlItem['Nick']
+ EquipmentSlot = sqlItem['EquipmentSlot']
+ EquipmentType = sqlItem['EquipmentType']
+ EquipmentName = sqlItem['EquipmentName']
+ EquipmentColor = sqlItem['EquipmentColor']
+ EquipmentEquipped = sqlItem['Equipped']
+ EquipmentHandsReq = sqlItem['HandsReq']
+
+ # If selected item is weapon
+ if EquipmentType == 'Weapon':
+
+ c.execute("SELECT sum(`HandsReq`) AS `HandsReq` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `EquipmentType`='Weapon' AND `Equipped`=1",(parameters["Nick"]))
+ sqlHandsUsed = c.fetchone()
+ if sqlHandsUsed["HandsReq"] is None:
+ intHandsUsed = 0
+ else:
+ intHandsUsed = sqlHandsUsed["HandsReq"]
+
+ if int(intHandsUsed) + EquipmentHandsReq <= 2 and EquipmentEquipped == 0:
+ c.execute("UPDATE `Items_PlayerInventory` SET `Equipped`=1 WHERE `ID`=%s and `Nick`=%s;",(strCmd2, parameters["Nick"]));db.commit();
+ return "\0399Equipping your \03" + str(EquipmentColor) + EquipmentName + "\0399."
+ elif EquipmentEquipped == 1:
+ c.execute("UPDATE `Items_PlayerInventory` SET `Equipped`=0 WHERE `ID`=%s and `Nick`=%s;",(strCmd2, parameters["Nick"]));db.commit();
+ return "\0399Unequipping your \03" + str(EquipmentColor) + EquipmentName + "\0399."
+ else:
+ return "You can only wield one two-handed weapon, or two one-handed weapons."
+
+ # If selected item is Armor
+ elif EquipmentType == 'Armor':
+ c.execute("SELECT `ID`,`EquipmentType`,`EquipmentSlot` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `EquipmentType`='Armor' AND `EquipmentSlot`=%s AND `Equipped`=1 GROUP BY `EquipmentType`",(parameters["Nick"], EquipmentSlot))
+ sqlArmor = c.fetchone()
+ if sqlArmor is None:
+ c.execute("UPDATE `Items_PlayerInventory` SET `Equipped`=1 WHERE `ID`=%s and `Nick`=%s;",(strCmd2, parameters["Nick"]));db.commit();
+ return "\0399Equipping your \03" + str(EquipmentColor) + EquipmentName + "\0399."
+
+ elif sqlArmor['ID'] == EquipmentID:
+ strArmorID = sqlArmor['ID']
+ strArmorType = sqlArmor['EquipmentType']
+ strArmorHands = sqlArmor['EquipmentSlot']
+ c.execute("UPDATE `Items_PlayerInventory` SET `Equipped`=0 WHERE `ID`=%s and `Nick`=%s;",(strCmd2, parameters["Nick"]));db.commit();
+ return "\0399Unequipping your \03" + str(EquipmentColor) + EquipmentName + "\0399."
+
+ else:
+ return "\0399You already have an item in this slot."
+
+ # All other checks failed, print help message
+ else:
+ return "Available commands: e (u)nequip all, e <ID to equip/unequip>"
+ else:
+ return "You must rest before changing your equipment."
+
+ # Destroy
+ elif strCmd1.lower() == 'd' or strCmd1.lower() == 'destroy':
+ if re.match("^[0-9]+$", strCmd2):
+ c.execute("SELECT `ID`,`Nick`,`EquipmentColor`,`EquipmentSlot`,`EquipmentType`,`EquipmentName`,`Equipped`,`HandsReq` FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `ID`=%s",(parameters["Nick"], strCmd2))
+ sqlItem = c.fetchone()
+ itemName = sqlItem['EquipmentName']
+ itemColor = sqlItem['EquipmentColor']
+ if sqlItem is not None:
+ c.execute("DELETE FROM `Items_PlayerInventory` WHERE `Nick`=%s AND `ID`=%s",(parameters["Nick"], strCmd2));db.commit();
+ return "Your \x03" + str(itemColor) + itemName + "\x0399 has been destroyed."
+
+ # Battle
+ elif strCmd1.lower() == 'b' or strCmd1.lower() == 'battle':
+ enemyStats = {}
+ if playerStats['ChallengeRating'] == int(math.ceil(playerStats['ChallengeRating'] / 4) * 4):
+ enemyStats = Enemy.Create(phenny, enemyStats, playerStats, parameters)
+ return "\0399Your fighting has caught the attention of the \03" + str(enemyStats['EnemyColor'])+enemyStats['EnemyName'] + "\0399."
+ else:
+ enemyStats = Enemy.Create(phenny, enemyStats, playerStats, parameters)
+ return "\0399You've been attacked by \03" + str(enemyStats['EnemyColor']) + enemyStats['EnemyName'] + "\0399."
+
+ # Character
+ elif strCmd1.lower() == 'c' or strCmd1.lower() == 'character':
+ PlayerStats.RefreshStats(phenny, parameters)
+ return PlayerStats.PrintStats(phenny, input, parameters)
+
+ # Shop
+ elif strCmd1.lower() == 's' or strCmd1.lower() == 'shop':
+ if strCmd2 is '':
+ c.execute("SELECT `ID`,`Cost`,`EquipmentColor`,`EquipmentName` FROM `PlayerShop` WHERE `Nick`=%s",parameters["Nick"])
+ sqlShopItem = c.fetchone()
+ while sqlShopItem is not None:
+ phenny.write(('NOTICE', parameters["Nick"]), str(sqlShopItem['ID']) + " \03" + sqlShopItem['EquipmentColor'] + sqlShopItem['EquipmentName'] + "\0399 " + str(sqlShopItem['Cost']) + " gold")
+ # phenny.reply("\03"+sqlShopItem['EquipmentColor']+sqlShopItem['EquipmentName']+"\0399 "+str(sqlShopItem['Cost'])+" gold")
+ sqlShopItem = c.fetchone()
+ else:
+ c.execute("SELECT `ID`,`Cost` FROM `PlayerShop` WHERE `ID`=%s and `Nick`=%s",(strCmd2, parameters["Nick"]))
+ sqlItemBought = c.fetchone()
+ if sqlItemBought is None:
+ return "\0399The shopkeep doesn't know what item you ask for."
+
+ elif playerStats['Currency'] < sqlItemBought['Cost']:
+ return "You cannot afford this item."
+
+ else:
+
+
+
+ c.execute("SELECT `Nick`,`Cost`,`EquipmentColor`,`EquipmentName`,`EquipmentSlot`,`EquipmentType`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`, `Precision`, `Resistance`, `Luck`, `Block` FROM `PlayerShop` WHERE `ID`=%s",strCmd2)
+ sqlItemBought = c.fetchone()
+ c.execute("INSERT INTO `Items_PlayerInventory` (`Nick`,`Equipped`,`EquipmentColor`,`EquipmentName`,`EquipmentSlot`,`EquipmentType`,`HandsReq`,`Strength`,`Dexterity`,`Constitution`,`Intelligence`,`Dodge`,`Crit`,`Armor`, `Precision`, `Resistance`, `Luck`, `Block`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);", (
+ parameters["Nick"], 0, sqlItemBought['EquipmentColor'], sqlItemBought['EquipmentName'],sqlItemBought['EquipmentSlot'], sqlItemBought['EquipmentType'],
+ sqlItemBought['HandsReq'], sqlItemBought['Strength'], sqlItemBought['Dexterity'],sqlItemBought['Constitution'], sqlItemBought['Intelligence'],
+ sqlItemBought['Dodge'], sqlItemBought['Crit'],sqlItemBought['Armor'],sqlItemBought['Precision'],sqlItemBought['Resistance'],sqlItemBought['Luck'],sqlItemBought['Block']));db.commit();
+ c.execute("DELETE FROM `PlayerShop` WHERE `Nick`=%s and `ID`=%s",(str(parameters["Nick"]), strCmd2));db.commit();
+ c.execute("UPDATE `Players` SET `Currency`=`Currency`-%s WHERE `Nick`=%s;",(sqlItemBought['Cost'], parameters["Nick"]));db.commit();
+ return "\0399The \03" + sqlItemBought['EquipmentColor'] + sqlItemBought['EquipmentName'] + "\0399 has been added to your inventory."
+
+ # Heal
+ elif strCmd1.lower() == 'r' or strCmd1.lower() == 'rest':
+ playerStats = PlayerStats.RefreshStats(phenny, parameters)
+ intHPGained = int(math.ceil(playerStats['MaxHP'] / 2))
+
+ if playerStats['RestedHeal'] == 0:
+ if playerStats['HP'] >= playerStats['MaxHP']:
+ return "\0399You rest. You are already at max HP."
+
+ elif intHPGained + playerStats['HP'] > playerStats['MaxHP']:
+ intHPGained = playerStats['MaxHP']
+ c.execute("UPDATE `Players` SET `HP`=%s, `RestedHeal`=1 WHERE `Nick`=%s;",(intHPGained, parameters["Nick"]));db.commit();
+ return "\0399You rest and your wounds heal completely."
+
+ elif playerStats['HP'] < playerStats['MaxHP']:
+ c.execute("UPDATE `Players` SET `HP`=`HP`+%s, `RestedHeal`=1 WHERE `Nick`=%s;",(intHPGained, parameters["Nick"]));db.commit();
+ return "\0399You rest and you recover " + str(intHPGained) + " HP."
+ else:
+ return "\0399You rest."
+
+ # DEBUG - CREATE WEAPON
+ elif strCmd1.lower() == 'z':
+ itemCode = input.group(2)[2:].split(':')
+ #phenny.say(str(itemCode[0])+str(itemCode[1])+str(itemCode[2])+str(itemCode[3]))
+ return GenerateItem.CreateItem(phenny, parameters, itemCode)
+
+ # Version
+ elif strCmd1.lower() == 'v' or strCmd1.lower() == 'version':
+ return "Version 1.3 - Notes can be found at: http://www.lexicade.uk/dev.php?view=patchnotes"
+
+ # Admin commands
+ elif strCmd1.lower() == 'genitem' and input.admin:
+ GenEquipment(phenny, itemGenEquipment, parameters, 'Items_PlayerPool')
+
+ # Death
+ elif strCmd1.lower() == 'suicide':
+ CharacterDeath(phenny, playerStats, parameters)
+ return "You committed suicide."
+
+ else:
+ return "\0399Available commands: (i)nventory, (e)quip, (b)attle, (c)haracter, (s)hop, (r)est, (v)ersion, (d)estroy." \ No newline at end of file
diff --git a/sassbot/modules/artifact2-0/__init__.py b/sassbot/modules/artifact2-0/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sassbot/modules/artifact2-0/__init__.py