Python實現原神抽卡的方法

2022-09-22 00:36:09 字數 3863 閱讀 3915

目錄

import random

import sys

import tkinter as tk # 匯入乙個第三方庫,用於製作桌面軟體

import tkinter.font as tf

# 資料部分

r =

sr =

ssr =

ten_count = 0

ninety_count = 0

max_count = 0

person_up = "優菈"

data_up = "松籟響起之時"

all = [r, sr, ssr]

tag_id = "0"

# 單抽

def one():

_res = get()

count_flush(_res["level"], _res["thing"])

insert_text(conf=_res["level"], message=_res["thing"])

text.insert("end", "\n")

text.see("end")

# 十連抽

def ten():

text.tag_add('tag', "end")

text.tag_config('tag', foreground="white")

text.insert("end", "\nstart\n", 'tag')

for i in range(10):

one()

text.insert("end", f"\nend//\n", "tag")

text.see("end")

# 根據**出的物品index獲取物品等級

def found(index):

for i in all:

if pool[www.cppcns.comindex] in i["person"]:

return i

if p程式設計客棧ool[index] in i["data"]:

return i

# 每次抽卡後重新整理當前計數器

def count_flush(level, thing):

global ten_count

global ninety_count

global max_count

if level["name"] == "sr":

ten_count = 0

if level["name"] == "ssr":

ninety_count = 0

if level["name"] == "ssr" and ((thing in person_up) or (thing in data_up)):

aejhk max_count = 0

# 抽卡規則

def get():

global ten_count

global ninety_coun程式設計客棧t

global max_count

level = none

ten_count += 1

ninety_count += 1

max_count += 1

if ten_count == 10:

level = sr

if ninety_count == 90:

level = ssr

if level is sr or level is ssr:

index = random.randrange(len(level[what]))

thing = level[what][index]

if max_count != ninety_count and level is ssr:

level = ssr

thing = person_up if what == "person" else data_up

if max_count == 180:

level = ssr

thing = person_up if what == "person" else data_up

if level is none:

index = random.randrange(len(pool))

level = found(index)

thing = pool[index]

return

# 建立乙個主視窗 root

root = tk.tk()

# 設定視窗標題

root.title("原神模擬抽卡器")

# 設定單抽

image_one = tk.photoimage(file="單抽.png")

# 設定十連抽

image_ten = tk.photoimage(file="十連抽.png")

# 在視窗上建立乙個按鈕 button,用於單抽,它依賴於父視窗root

button_one = tk.button(root, text="單抽", image=image_one, command=one)

button_ten = tk.button(root, text="十連抽", image=image_ten, command=ten)

# 布局建立的按鈕,rou代表行,column代表列

button_one.grid(row=0, column=0)

button_ten.grid(row=0, column=1)

# 建立乙個文字框,用於列印**日誌

text = tk.text(root, bg="black")

# columnspan代表合併兩列

text.grid(row=1, columnspan=2)

# 新增日誌到text框

def insert_text(message, conf):

global tag_id

# 設定字型大小和顏色

ft = tf.font(family=conf["font"], size=conf["size"])

text.tag_add('tag'+tag_id, "end")

text.tag_config('tag'+tag_id, foreground=conf["color"], font=ft)

text.insert("end", message + "\n", "tag"+tag_id)

text.see("end")

tag_id = str(int(tag_id) + 1)

# mian函式,程式會執行這裡面的東西

if __name__ == '__main__':

# 修改為**抽**池

what = "角色"

if what == "角色":

what = "person"

if what == "**":

what = "data"

if what not in ["data", "person"]:

sys.exit(1)

# 把up角色和**加入池

ssr["data"].append(data_up)

ssr["person"].append(person_up)

# 合併在乙個總池,實現概率,可以通過演算法實現,難得弄..

pool = list()

for i in range(90):

pool.extend(r["data"])

for i in range(1aejhk0):

pool.extend(sr[what])

pool.extend(ssr[what])

# 執行視窗

root.mainloop()

本文標題: python實現原神抽卡的方法

本文位址:

原神面部陰影的實現 大概

參考 左右翻轉 float2 flipuv float2 1 i.uv.x,i.uv.y fixed4 lightmap fixed4 0 0,0 0 fixed4 lightmapl tex2d lightmap,i.uv fixed4 lightmapr tex2d lightmap,flipu...

Python實現曲線點抽稀演算法的示例

本文介紹了python實現曲線點抽稀演算法的示例,分享給大家,具體如下 目錄 正文 何為抽稀 在處理向量化資料時,記錄中往往會有很多重複資料,對進一步資料處理帶來諸多不便。多餘的資料一方面浪費了較多的儲存空間,另一方面造成所要表達的圖形不光滑或不符合標準。因此要通過某種規則,在保證向量曲線形狀不變的...

Python執行緒定時器Timer的實現原理解析

這篇文章主要介紹了python執行緒定時器timer實現原理解析!原理比較簡單,指定時間間隔後啟動執行緒,執行執行緒函式 匯入執行緒模組 import threading timer threading.timer interval,function,args none,kwargs none 引數...