async def spendSP(ctx, stat, num: int): if stat.lower() in [ 'attack', 'defense', 'luck', 'dexterity', 'intelligence', 'hp' ]: stats = nacistSouborHrace(ctx.author.id) if stats.sp >= num: zvyseni = getattr(stats, stat) if stat.lower() == 'hp': zvyseni += num * 10 else: zvyseni += num stats.sp -= num setattr(stats, stat, zvyseni) await ctx.channel.send("Stat" + str(stat) + " zvýšen o " + str(num)) ulozitSouborHrace(stats, ctx.author.id) else: await ctx.channel.send("Insufficient SP") elif (num < 1 or num > 500): await ctx.channel.send("Zadej číslo mezi 1 a 500") else: await ctx.channel.send("This stat cannot be increased by spending SP")
async def swapEquip(ctx, inventoryItem: int, slot: str): stats = nacistSouborHrace(ctx.author.id) if slot in stats.inventory[inventoryItem][slot]: pomocna = stats.equipment[slot] stats.equipment[slot] = stats.inventory[inventoryItem] stats.inventory[inventoryItem] = pomocna ulozitSouborHrace(stats, ctx.author.id)
async def rpgstart(): for filename in os.listdir("rpg_files/players/"): try: stats = nacistSouborHrace(filename) stats.state = "idle" ulozitSouborHrace(stats, filename) except: pass
async def rollItem(ctx, player, prisera): stats = nacistSouborHrace(player.id) if not prisera.drops == None: if random.randint(0, 100) < prisera.drops["chance"]: prisera.drops["item"] = itemrarity(prisera.drops["item"]) stats.inventory.append(prisera.drops["item"]) await ctx.send('Hráč ' + player.name + (' Získal ') + prisera.drops["item"].name + "! Vzácnost: " + str(prisera.drops["item"].rarity)) ulozitSouborHrace(stats, player.id)
async def matDrop(ctx, hrac, nepritel): chance = nepritel.level roll = random.randint(0, 100) if chance > roll: await addToInventory(ctx, hrac, "Magic dust") if round(math.log(chance, 2)) > roll: await addToInventory(ctx, hrac, "Magic shard") if round(math.log(chance, 3)) > roll: await addToInventory(ctx, hrac, "Magic crystal") dir(hrac) ulozitSouborHrace(hrac, ctx.author.id)
async def levelup(ctx): zprava = "" stats = nacistSouborHrace(ctx.author.id) if (xpToLevel[stats.level] - stats.experience) > 0: await ctx.send('Nedostatek zkušeností') while ((xpToLevel[stats.level] - stats.experience) <= 0): stats.experience -= xpToLevel[stats.level] stats.level += 1 stats.sp += 5 ulozitSouborHrace(stats, ctx.author.id) zprava += "Level up! SP: " + str(stats.sp) + ", Level: " + str( stats.level) + "\n" "" await ctx.channel.send(zprava)
async def upgradeEquip(ctx, slot): upgradeReq = { "dustRequirement": [1, 2, 3, 5, 7, 9, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "shardRequirement": [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0], "crystalRequirement": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4] } stats = nacistSouborHrace(ctx.author.id) mats = [0, 0, 0] toUpgrade = "" if slot.lower() == "left hand": toUpgrade = stats.equipment["Hands"]["Left"] elif slot.lower() == "right hand": toUpgrade = stats.equipment["Hands"]["Right"] else: toUpgrade = stats.equipment[slot] for item in range(len(stats.inventory)): mats[0] = saveToMats(stats, "Magic dust", item) mats[1] = saveToMats(stats, "Magic shard", item) mats[2] = saveToMats(stats, "Magic crystal", item) if (mats[0] >= upgradeReq["dustRequirement"][toUpgrade.upgrade]) and ( mats[1] >= upgradeReq["shardRequirement"][toUpgrade.upgrade] ) and (mats[2] >= upgradeReq["crystalRequirement"][toUpgrade.upgrade]): for item in range(len(stats.inventory)): removeMats(stats, "Magic dust", item, upgradeReq, toUpgrade) removeMats(stats, "Magic shard", item, upgradeReq, toUpgrade) removeMats(stats, "Magic crystal", item, upgradeReq, toUpgrade) toUpgrade = upgradeStats(toUpgrade) ulozitSouborHrace(stats, ctx.author.id) await ctx.send('Vybavení bylo vylepšeno!') else: await ctx.send('Nemáš dostatek materiálu na vylepšení!')
def expGain(exp, id): player_id = str(id) stats = nacistSouborHrace(player_id) stats.experience += exp ulozitSouborHrace(stats, player_id)
def goldGain(gold, id): player_id = str(id) stats = nacistSouborHrace(player_id) stats.gold += gold ulozitSouborHrace(stats, player_id)
async def clearInventory(ctx): stats = nacistSouborHrace(ctx.author.id) stats.inventory.clear() ulozitSouborHrace(stats, ctx.author.id)
async def rename(ctx, newname): stats = nacistSouborHrace(ctx.author.id) stats.name = newname ulozitSouborHrace(stats, ctx.author.id) await ctx.send("Tvá postava byla přejmenována na " + stats.name)