修改开宝箱逻辑, 测试服不判断是否助力满
This commit is contained in:
parent
c63403a482
commit
c45c4c5bf4
@ -2,11 +2,11 @@
|
||||
{
|
||||
"type": 1,
|
||||
"name": "White List",
|
||||
"probability": 2
|
||||
"probability": 100
|
||||
},
|
||||
{
|
||||
"type": 2,
|
||||
"name": "NFT",
|
||||
"probability": 1
|
||||
"probability": 100
|
||||
}
|
||||
]
|
@ -338,18 +338,17 @@ class BoxController extends BaseController {
|
||||
const score = chest.scoreInit + chest.scoreBonus
|
||||
const dateTag = formatDate(new Date())
|
||||
let items: any[] = []
|
||||
if (!user.inWhiteList) {
|
||||
items = await generateChestBonus(chest)
|
||||
if (!chest.items) {
|
||||
chest.items = []
|
||||
}
|
||||
items.forEach(item => {
|
||||
chest.items.push(item.id)
|
||||
})
|
||||
if (items.find(item => item.type === 1)) {
|
||||
user.inWhiteList = true
|
||||
await user.save()
|
||||
}
|
||||
|
||||
items = await generateChestBonus(chest, user.inWhiteList)
|
||||
if (!chest.items) {
|
||||
chest.items = []
|
||||
}
|
||||
items.forEach(item => {
|
||||
chest.items.push(item.id)
|
||||
})
|
||||
if (items.find(item => item.type === 1)) {
|
||||
user.inWhiteList = true
|
||||
await user.save()
|
||||
}
|
||||
|
||||
await updateRankScore({
|
||||
|
@ -87,16 +87,19 @@ export const generateStepReward = (uid: string, activity: string, step: number)
|
||||
return { score, chests }
|
||||
}
|
||||
|
||||
export const generateChestBonus = async (chest: DocumentType<ActivityChestClass>) => {
|
||||
export const generateChestBonus = async (chest: DocumentType<ActivityChestClass>, hasWhite: boolean) => {
|
||||
let rewards = []
|
||||
// 如果宝箱的助力用户数量小于最大助力次数, 则不生成奖励
|
||||
if (chest.bonusUsers.length < chest.maxBounsCount) {
|
||||
if (process.env.NODE_ENV === 'production' && chest.bonusUsers.length < chest.maxBounsCount) {
|
||||
return []
|
||||
}
|
||||
let bonusItem
|
||||
for (let i = 0; i < chestBonusItems.length; i++) {
|
||||
let item = chestBonusItems[i]
|
||||
if (Math.random() < item.probability / 100) {
|
||||
if (item.type === 1 && hasWhite) {
|
||||
continue
|
||||
}
|
||||
bonusItem = item
|
||||
break
|
||||
}
|
||||
@ -116,4 +119,5 @@ export const generateChestBonus = async (chest: DocumentType<ActivityChestClass>
|
||||
desc: bonusItem.desc,
|
||||
amount: 1,
|
||||
})
|
||||
return rewards
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user