Exemplo n.º 1
0
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")
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
async def rpgstart():

    for filename in os.listdir("rpg_files/players/"):
        try:

            stats = nacistSouborHrace(filename)
            stats.state = "idle"
            ulozitSouborHrace(stats, filename)
        except:
            pass
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
async def inventory(ctx):
    zprava = ""
    stats = nacistSouborHrace(ctx.author.id)
    if stats.inventory == []:
        await ctx.send('Inventář je prázdný')
    else:
        for item in stats.inventory:
            if hasattr(item, 'amount'):
                zprava += item.name + " - " + str(item.amount) + "     "
            else:
                zprava += item.name + "     "
        await ctx.send(zprava)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
async def exploreLocation(ctx, location, timeinsecs=600):
    stats = nacistSouborHrace(ctx.author.id)

    if stats.state == "idle":
        locations = loadmonsters("rpg_files/data/locations")

        for misto in range(len(locations)):
            if location == locations[misto].name.lower():
                await ctx.channel.send("Exploring " + location)

                await changestate(ctx, "busy")

                if timeinsecs > 600:
                    timeinsecs = 600
                    await ctx.send(
                        "Maximální doba průzkumu je 10 minut a byla proto zkrácena"
                    )
                await asyncio.sleep(timeinsecs)

                expIncrease = math.ceil(
                    (locations[0].expFactor * timeinsecs)**1.1 *
                    (random.random() + 0.5))
                goldIncrease = math.ceil(
                    (locations[0].goldFactor * timeinsecs)**1.1 *
                    (random.random() + 0.5))

                expGain(expIncrease, ctx.author.id)
                goldGain(goldIncrease, ctx.author.id)

                await ctx.channel.send("Finished exploring " + location +
                                       ", rewards: " + str(goldIncrease) +
                                       " gold, " + str(expIncrease) + " exp.")
                stats = nacistSouborHrace(ctx.author.id)
                await changestate(ctx, "idle")
    else:
        await ctx.send('Teď nemůžeš explorovat')
Exemplo n.º 8
0
async def onevonemebro(ctx, target):
    attacker = []
    attacker.append(ctx.author)
    guild = ctx.guild
    defender = []
    defender = ((discord.utils.get(guild.members,
                                   id=int(
                                       target.replace(">", "").replace(
                                           "<",
                                           "").replace("!",
                                                       "").replace("@", "")))))
    oznaceny = defender.id
    defender = nacistSouborHrace(oznaceny)

    await fight(ctx, attacker, defender)
Exemplo n.º 9
0
async def randomfight(ctx):

    stats = nacistSouborHrace(ctx.author.id)
    lvl = stats.level
    enemy = nahodnyVyberSoupere(lvl)
    vyhra = await fight(ctx, [ctx.author], enemy)
    if vyhra:
        await ctx.send("Získáváš " + str(enemy.experience) + " zkušeností a " +
                       str(enemy.gold) + " zlaťáků")

        await rollItem(ctx, ctx.author, enemy)
        await matDrop(ctx, stats, enemy)
        expGain(enemy.experience, ctx.author.id)

        goldGain(enemy.gold, ctx.author.id)
Exemplo n.º 10
0
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í!')
Exemplo n.º 11
0
async def clearInventory(ctx):
    stats = nacistSouborHrace(ctx.author.id)
    stats.inventory.clear()

    ulozitSouborHrace(stats, ctx.author.id)
Exemplo n.º 12
0
async def inspectItem(ctx, pos: int):
    stats = nacistSouborHrace(ctx.author.id)
    zprava = inspect(stats.inventory[pos])
    await ctx.send(zprava)
Exemplo n.º 13
0
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)
Exemplo n.º 14
0
async def stats(ctx):

    try:
        stats = nacistSouborHrace(ctx.author.id)
    except:
        await ctx.send('Hráč nenalezen. Založ si postavu')
    vybava = {}

    for slot, item in stats.equipment.items():
        if not (item == None) and not (slot == "Hands"):
            vybava[slot] = item.name
        elif slot == "Hands":
            vybava["Left hand"] = item["Left"].name
            vybava["Right hand"] = item["Right"].name

    statbonus = {
        'attack': 0,
        'defense': 0,
        'dexterity': 0,
        'intelligence': 0,
        'luck': 0
    }
    for slot, item in stats.equipment.items():
        if not (item == None) and not (slot == "Hands"):

            statbonus['attack'] += item.attack
            statbonus['defense'] += item.defense
            statbonus['dexterity'] += item.dexterity
            statbonus['intelligence'] += item.intelligence
            statbonus['luck'] += item.luck
        elif slot == "Hands":
            statbonus['attack'] += item["Right"].attack
            statbonus['defense'] += item["Right"].defense
            statbonus['dexterity'] += item["Right"].dexterity
            statbonus['intelligence'] += item["Right"].intelligence
            statbonus['luck'] += item["Right"].luck
            statbonus['attack'] += item["Left"].attack
            statbonus['defense'] += item["Left"].defense
            statbonus['dexterity'] += item["Left"].dexterity
            statbonus['intelligence'] += item["Left"].intelligence
            statbonus['luck'] += item["Left"].luck

    attstr = str(stats.attack) + "(+" + str(statbonus['attack']) + ")"
    defstr = str(stats.defense) + "(+" + str(statbonus['defense']) + ")"
    dexstr = str(stats.dexterity) + "(+" + str(statbonus['dexterity']) + ")"
    intstr = str(stats.intelligence) + "(+" + str(
        statbonus['intelligence']) + ")"
    lucstr = str(stats.luck) + "(+" + str(statbonus['luck']) + ")"

    zprava = ("Staty tvé postavy: \nLevel: " + str(stats.level) +
              "\nAttack: " + attstr + "\t\tDefense: " + defstr +
              "\t\tDexterity: " + dexstr + "\t\tIntellifence: " + intstr +
              "\t\tLuck: " + lucstr + "\n\nEquipment:\n\n")

    for slot, item in vybava.items():
        zprava += (str(slot) + "   " + str(item) + "\n")

    zprava += ("XP:" + str(stats.experience) + "\t\t\t\tXP to next level: " +
               str(xpToLevel[stats.level] - stats.experience) +
               "\t\t\t\tGold: " + str(stats.gold))
    if stats.sp > 0:
        zprava += "\n\n You have unspent skill points: " + str(stats.sp)

    await ctx.channel.send(zprava)
Exemplo n.º 15
0
def goldGain(gold, id):
    player_id = str(id)
    stats = nacistSouborHrace(player_id)
    stats.gold += gold
    ulozitSouborHrace(stats, player_id)
Exemplo n.º 16
0
def expGain(exp, id):
  
    player_id = str(id)
    stats = nacistSouborHrace(player_id)
    stats.experience += exp
    ulozitSouborHrace(stats, player_id)
Exemplo n.º 17
0
async def fight(ctx, group, opponent):
    kesmazani_id = 0
    stats = []  #list hráčů
    hitrate = []  #přesnosti hráčů
    hitratesprisery = []  #přesnosti nepřítele
    for x in range(len(group)):
        #načte označené hráče, jejich staty a zvýší je o equipy
        stats.append(nacistSouborHrace(group[x].id))

        if not (await checkState(ctx, stats[x].state)):
            return
        await changestate(ctx, "busy")
        addequipbonus(stats[x])

    for x in range(len(stats)):
        #určí přesnosti
        hitrate.append(80 + (stats[x].dexterity / opponent.dexterity))
        hitratesprisery.append(80 + (opponent.dexterity / stats[x].dexterity))
    await ctx.send("You've encountered " + str(opponent.name) + "!")
    isPartyAlive = True
    while (opponent.hp > 0) and (isPartyAlive):

        zprava = ""
        for x in range(len(stats)):
            if (random.randint(0, 100) < hitrate[x]):
                damage = calculateDamage(stats[x], opponent)
                opponent.hp -= (damage[0])
                if damage[1]:
                    zprava += stats[x].name + " útočí! Kritický zásah! " + str(
                        damage[0]
                    ) + " poškození!     " + opponent.name + ": " + str(
                        opponent.hp) + " HP\n"
                else:
                    zprava += stats[x].name + " útočí! " + str(
                        damage[0]
                    ) + " poškození!     " + opponent.name + ": " + str(
                        opponent.hp) + " HP\n"
            else:
                zprava += stats[x].name + " se netrefil!/a\n"
        target = random.randint(0, len(stats) - 1)
        if (random.randint(0, 100) < hitratesprisery[target]):
            damage = calculateDamage(opponent, stats[target])
            stats[target].hp -= damage[0]
            if damage[1]:
                zprava += opponent.name + " útočí! Kritický zásah! " + str(
                    damage[0]
                ) + " poškození!      " + stats[target].name + ": " + str(
                    stats[target].hp) + " HP\n"
            else:
                zprava += opponent.name + " útočí! " + str(
                    damage[0]
                ) + " poškození!      " + stats[target].name + ": " + str(
                    stats[target].hp) + " HP\n"
        else:
            zprava += opponent.name + " se netrefil/a!\n"
        #zprava += (stats.name +": "+str(stats.hp) + " HP\n"+prisera.name +": "+str(prisera.hp)+" HP\n")
        aliveMembers = 0

        if kesmazani_id == 0:
            msg = await ctx.send(zprava)

        else:
            await msg.edit(content=zprava)
        kesmazani_id = ctx.channel.last_message_id
        for x in range(len(stats)):

            if stats[x].hp > 0:
                aliveMembers += 1
        #určení výsledku bitvy a pauza
        if aliveMembers == 0 and opponent.hp > 0:
            isPartyAlive = False
            await ctx.send("Skupina Prohrává!\n")
            await changestate(ctx, "dead")
            return False

        elif aliveMembers == 0 and opponent.hp <= 0:
            await ctx.send('Remíza, nedostáváš žádnou odměnu')
            await changestate(ctx, "dead")
            return False

        elif opponent.hp <= 0:
            await ctx.send(opponent.name + " byl/a poražen/a!")
            await changestate(ctx, "idle")
            return True

        await asyncio.sleep(3)