Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
7.4 kB
2
Indexable
Never
import discord
import random
import asyncio
import time
from discord.ext import commands, tasks

done = {
    'done1' : False,
    'done2' : False
}

senjata = {
    'knife' :8,

    'vandal' : 17,
    'odin' : 18,
    'phantom' : 15,

    'ak47' : 17,
    'm4a1' : 16,
    'sniper' : 20,

    'flick' : 20,
    'randomshoot' : 18,
    'rungun' : 21,

    'nvrtx' : 26,
    'intelxe' : 23,
    'amdrx' : 25,

    'piano' : 23,
    'viola' : 26,
    'gitar' : 25,

    'capterica' : 29,
    'ironman' : 32,
    'hawkeye' : 27,

    'michael' : 10,
    'franklin' : 11,
    'trevor' : 12,

    'jogging' : 5,
    'sprinting' : 7,
    'walking' : 4,

    'avengers' : 99,

    'healthpack' : 50
}

karakter = {
    'budy' : ['knife', 'vandal', 'ak47', 'flick', 'nvrtx', 'piano', 'capterica', 'michael', 'jogging', 'avengers', 'healthpack'],
    'roshe' : ['knife', 'odin', 'm4a1', 'randomshoot', 'intelxe', 'viola', 'ironman', 'franklin', 'sprinting', 'avengers', 'healthpack'],
    'kubis' : ['knife', 'phantom', 'sniper', 'rungun', 'amdrx', 'gitar', 'hawkeye', 'trevor', 'walking', 'avengers', 'healthpack']
}

player1 = {
    'plr' : 'nama',
    'plr_char' : 'karakter',
    'plr_health' : 200
}

player2 = {
    'plr' : 'nama',
    'plr_char' : 'karakter',
    'plr_health' : 200
}

async def startduel(ctx, args):
    await ctx.send('memulai inisialisasi game duel')
    await ctx.send('silahkan tulis, oi duel join1 atau, oi duel join2')

async def assign_player1(ctx):
    if ctx.message.author == player2['plr']:
        await ctx.send('udah jadi player1 oi')
    else:
        player1['plr'] = ctx.message.author
        await ctx.send('player 1 confirmed')

    if player1['plr'] != 'nama' and player2['plr'] != 'nama':
            await ctx.send('pilih karakter pake, oi duel pilih (karakter), ada budy, roshe, dan kubis')

async def assign_player2(ctx):
    if ctx.message.author == player1['plr']:
        await ctx.send('udah jadi player2 oi')
    else:
        player2['plr'] = ctx.message.author
        await ctx.send('player 2 confirmed')

    if player1['plr'] != 'nama' and player2['plr'] != 'nama':
            await ctx.send('pilih karakter pake oi duel pilih (karakter), ada budy, roshe, dan kubis')

async def assign_char(ctx, args):
    if not args:
        await ctx.send("tulis karakternya oi, ada budy, roshe, dan kubis")

    if len(args) > 1:
        if ctx.message.author == player1['plr']:
            player1['plr_char'] = args[1]

        if ctx.message.author == player2['plr']:
            player2['plr_char'] = args[1]

    if player1['plr_char'] != 'karakter' and player2['plr_char'] != 'karakter':
            await confirm(ctx)

health1 = player1['plr_health']
health2 = player2['plr_health']

async def confirm(ctx):
    embed = discord.Embed(title="Status game", description="", color=0x13d9e7)
    embed.add_field(name='Player 1: {}'.format(player1['plr']), value='Karakter: {}, nyawa: {}'.format(player1['plr_char'], health1), inline=False)
    embed.add_field(name='Player 2: {}'.format(player2['plr']), value='Karakter: {}, nyawa: {}'.format(player2['plr_char'], health2), inline=False)
    await ctx.send(embed=embed)

    done['done1'] = False
    done['done2'] = False

    await game(ctx)

char1_weapon = 0
char2_weapon = 0

async def game(ctx):
    global char1_weapon, char2_weapon

#    char1_weapon = random.sample(karakter[player1['plr_char']], 2)
#    char2_weapon = random.sample(karakter[player2['plr_char']], 2)

    char1_weapon = random.choices(karakter[player1['plr_char']], weights=(80, 60, 50, 50, 40, 40, 20, 70, 90, 5, 10), k=2)
    char2_weapon = random.choices(karakter[player2['plr_char']], weights=(80, 60, 50, 50, 40, 40, 20, 70, 90, 5, 10), k=2)

    await ctx.send('Player 1 = {} dan {}'.format(char1_weapon[0], char1_weapon[1]))
    await ctx.send('Player 2 = {} dan {}'.format(char2_weapon[0], char2_weapon[1]))

    await ctx.send('silahkan melancarkan serangan, bisa pake, oi duel pake (attack), attack sesuai yang tertera')

async def sorterer(ctx, args):
    if ctx.message.author == player1['plr']:

        await attack1(args)

        if health2 < 0:
            await ctx.send('Player 1 menang')
            await reset()
        else:
            await ctx.send('Nyawa Player 2: {}'.format(health2))
            done['done1'] = True

        if done['done1'] == True and done['done2'] == True:
            await confirm(ctx)
            done['done1'] = False
            done['done2'] = False

    elif ctx.message.author == player2['plr']:

        await attack2(args)

        if health1 < 0:
            await ctx.send('Player 2 menang')
            await reset()
        else:
            await ctx.send('Nyawa Player 1: {}'.format(health1))
            done['done2'] = True

        if done['done1'] == True and done['done2'] == True:
            await confirm(ctx)
            done['done1'] = False
            done['done2'] = False

async def attack1(args):
    global char1_weapon, health1, health2

    dmg = senjata[args[1]]

    if args[1] in char1_weapon:
        if args[1] == 'healthpack':
            health1 += senjata['healthpack']
        else:
            health2 -= dmg

async def attack2(args):
    global char2_weapon, health1, health2

    dmg = senjata[args[1]]

    if args[1] in char2_weapon:
        if args[1] == 'healthpack':
            health2 += senjata['healthpack']
        else:
            health1 -= dmg

async def reset():
    player1['plr'] = 'nama'
    player1['plr_char'] = 'karakter'
    player1['plr_health'] = 200

    player2['plr'] = 'nama'
    player2['plr_char'] = 'karakter'
    player2['plr_health'] = 200

    done['done1'] = False
    done['done2'] = False

async def dmg_list(ctx):
    embed = discord.Embed()
    embed.add_field(name="knife", value="8", inline=True)
    embed.add_field(name="valorant", value="Vandal {}, Odin {}, Phantom {}".format(senjata['vandal'], senjata['odin'], senjata['phantom']), inline=True)
    embed.add_field(name="csgo", value="AK47 {}, M4A1 {}, Sniper {}".format(senjata['ak47'], senjata['m4a1'], senjata['sniper']), inline=True)
    embed.add_field(name="shooting", value="Flick {}, Random Shoot {}, Run n Gun {}".format(senjata['flick'], senjata['randomshoot'], senjata['rungun']), inline=True)
    embed.add_field(name="gpu", value="NVRTX {}, IntelXe {}, AMDRX {}".format(senjata['nvrtx'], senjata['intelxe'], senjata['amdrx']), inline=True)
    embed.add_field(name="music", value="Piano {}, Viola {}, Gitar {}".format(senjata['piano'], senjata['viola'], senjata['gitar']), inline=True)
    embed.add_field(name="hero", value="Capterica {}, IronMan {}, Hawkeye {}".format(senjata['capterica'], senjata['ironman'], senjata['hawkeye']), inline=True)
    embed.add_field(name="gta", value="Michael {}, Franklin {}, Trevor {}".format(senjata['michael'], senjata['franklin'], senjata['trevor']), inline=True)
    embed.add_field(name="olahraga", value="Jogging {}, Sprinting {}, Walking {}".format(senjata['jogging'], senjata['sprinting'], senjata['walking']), inline=True)
    embed.add_field(name="avengers", value="99", inline=True)
    await ctx.send(embed=embed)