盲盒抽獎游戲系統(tǒng)開發(fā)(開發(fā)案例)丨NFT盲盒抽獎游戲系統(tǒng)開發(fā)規(guī)則玩法/方案項(xiàng)目/源碼
企業(yè)以互聯(lián)網(wǎng)為依托,通過運(yùn)用大數(shù)據(jù)、人工智能等先進(jìn)技術(shù)手段,對商品的生產(chǎn)、流通與銷售過程進(jìn)行升級改造,進(jìn)而重塑業(yè)態(tài)結(jié)構(gòu)與生態(tài)圈,并對線上服務(wù)、線下體驗(yàn)以及現(xiàn)代物流進(jìn)行深度融合的零售新模式。
New retail refers to the upgrading and transformation of the production,circulation and sales process of commodities based on the Internet and through the use of advanced technologies such as Big data and artificial intelligence,進(jìn)而重塑業(yè)態(tài)結(jié)構(gòu)與生態(tài)圈,并對線上服務(wù)、線下體驗(yàn)以及現(xiàn)代物流進(jìn)行深度融合的零售新模式。
pub fun get_rand_nft(item_prob:{String:UFix64}):String{
let prob_list=item_prob.values
let nft_list=item_prob.keys
//step 1,build area
let ratio:UFix64=1000.0
var nft_area_list:[UFix64]=[0.0]
var prob_sum:UFix64=0.0
for item in prob_list{
prob_sum=prob_sum+item*ratio
nft_area_list.append(prob_sum)
}
//step 2,get index
let big_int=unsafeRandom()//UInt64,can't run in playground,need testnet or emu
//let big_int:UInt64=999923
let base_mod=UInt64(ratio)//same to ratio
let rand_index=UInt32(big_int%base_mod)
var item_index=0
for item in nft_area_list{
if 0.0==item{
continue
}
if UFix64(rand_index)<item{
break
}
item_index=item_index+1
}
let rand_nft=nft_list[item_index]
return rand_nft
}