-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
127 lines (107 loc) · 5.24 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from discord.ext import commands
import discord
from time import time
from random import
import openpyxl
import pandas as pd
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
global pasttime
pasttime = dict()
@bot.command(name="강화")
async def 강화(ctx, *args):
if args == ():
await ctx.send("강화 순위 - 강화 순위를 확인합니다\n강화 [이름] - [이름]의 레벨을 올립니다 (1~9레벨이 증가하며 파괴확률이 존재합니다)")
elif args == ('순위',):
levrank = []
userrank = []
ds = pd.read_excel('D:\강화\data.xlsx', sheet_name='Sheet1')
df = pd.DataFrame(ds)
df = df.sort_values(by='Level', ascending=False)
df.to_excel("data.xlsx", index=False)
wb=None
ws=None
wb = openpyxl.load_workbook('data.xlsx')
ws = wb.active
for i in range (2, len(ws['B'])+2):
if i != len(ws['B'])+1:
levrank.append(int(ws['B'+str(i)].value))
for v in range (2, len(ws['A'])+2):
if v != len(ws['A'])+1:
userrank.append(str(ws['A'+str(v)].value))
rankst = userrank[0] + ", " + str(levrank[0]) + ".lev"
ranknd = userrank[1] + ", " + str(levrank[1]) + ".lev"
rankth = userrank[2] + ", " + str(levrank[2]) + ".lev"
rankfo = userrank[3] + ", " + str(levrank[3]) + ".lev"
rankfi = userrank[4] + ", " + str(levrank[4]) + ".lev"
ranksi = userrank[5] + ", " + str(levrank[5]) + ".lev"
rankse = userrank[6] + ", " + str(levrank[6]) + ".lev"
rankei = userrank[7] + ", " + str(levrank[7]) + ".lev"
rankni = userrank[8] + ", " + str(levrank[8]) + ".lev"
rankte = userrank[9] + ", " + str(levrank[9]) + ".lev"
await ctx.send("1위: " + str(rankst) + "\n2위: " + str(ranknd) + "\n3위: " + str(rankth) + "\n4위: " + str(rankfo) + "\n5위: " + str(rankfi) + "\n6위: " + str(ranksi) + "\n7위: " + str(rankse) + "\n8위: " + str(rankei) + "\n9위: " + str(rankni) + "\n10위: " + str(rankte))
else:
if len(str(args)) < 20:
if ctx.author.id not in pasttime:
pasttime[ctx.author.id] = time()
else:
past = pasttime[ctx.author.id]
if time() - past < 60:
em = discord.Embed(title=f"아직 강화를 진행할 수 없습니다! " + str(round((float(60) - (float(time()) - float(past))), 2)) + " 초 이후에 다시 시도해주세요.", color=15158332)
await ctx.send(embed=em)
return
pasttime[ctx.author.id] = time()
wb = openpyxl.load_workbook('data.xlsx')
ws = wb.active
argt = str(args)[2:]
argtr = argt.find("'")
argf = argt[:argtr]
for i in range (2, len(ws['A'])+2):
if i != len(ws['A'])+1:
if str(ws['A'+str(i)].value) == str(argf):
lev = int(ws['B'+str(i)].value)
break
else:
lev = 0
break
randf = uniform(95.0-(lev*0.613), 99.9)
randtw = randrange(0, 100)
if randtw < randf:
an = True
else:
an = False
if an == True:
rand = randrange(1,10)
if i != len(ws['A'])+1:
await ctx.send(str(argf) + " 를 " + str(round(randf, 2)) + "%의 확률로 강화에 성공하였습니다\n" + str(argf) + " 의 레벨 " + str(lev) + "->" + str(int(lev) + int(rand)))
lev = lev + rand
ws['B'+str(i)] = lev
wb.save('data.xlsx')
else:
ws['A'+str(i)] = str(argf)
ws['B'+str(i)] = rand
wb.save('data.xlsx')
await ctx.send(str(argf) + " 를 " + str(round(randf, 2)) + "%의 확률로 강화에 성공하였습니다\n" + str(argf) + " 의 레벨 " + str(rand))
else:
rand = randrange(1, 15)
if i != len(ws['A'])+1:
randt = uniform(95.0-(lev*0.05), 99.9)
if randt > randtw:
await ctx.send(str(argf) + " 가 " + str(100-round(randt, 2)) + "%의 확률로 파괴되었습니다\n" + str(argf) + " 의 레벨 " + str(lev) + "->0")
ws.delete_rows(i)
wb.save('data.xlsx')
else:
await ctx.send(str(argf) + " 가 " + str(100-round(randf, 2)) + "%의 확률로 강화에 실패하였습니다\n" + str(argf) + " 의 레벨 " + str(lev) + "->" + str(int(lev) - int(rand)))
lev = lev - rand
ws['B'+str(i)] = lev
wb.save('data.xlsx')
else:
await ctx.send(str(argf) + " 가 " + str(100-round(randf, 2)) + "%의 확률로 강화에 실패하였습니다\n" + str(argf) + "가 존재하지 않아 0레벨로 설정되었습니다")
else:
await ctx.send("이름이 너무 깁니다")
bot.run('TOKEN')