From a41fb9aa3ac421a0155be5ef7fb7e5ad0d0e1f86 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:23:49 +0800 Subject: [PATCH] update activity cfg --- docs/api.md | 2 + initdatas/activity_info.json | 126 ++++++++++++++++++---------- src/controllers/sign.controller.ts | 8 ++ src/controllers/tasks.controller.ts | 5 +- src/models/ScoreRecord.ts | 1 + src/tasks/ShareCode.ts | 7 +- 6 files changed, 101 insertions(+), 48 deletions(-) diff --git a/docs/api.md b/docs/api.md index 4a8427f..29ff8ac 100644 --- a/docs/api.md +++ b/docs/api.md @@ -310,6 +310,8 @@ body: "scoreTotal": 200, // 总积分 "rankTotal": "-", "invite": "邀请人address", + "inviteCount": 0, // 我邀请的用户总数 + "inviteScore": 0, // 我邀请用户总数获得的分数 "code": "自己的邀请码" } ``` diff --git a/initdatas/activity_info.json b/initdatas/activity_info.json index 42e4a39..6bb2046 100644 --- a/initdatas/activity_info.json +++ b/initdatas/activity_info.json @@ -6,18 +6,18 @@ "tasks": [{ "id": "e2yhq2lj30vwcpedv7p", "task": "TwitterConnect", - "title": "Connect Twitter", + "title": "", "type": 1, "desc": "", - "score": 100, + "score": 0, "category": "", - "autoclaim": true, + "autoclaim": false, "cfg": {"icon": "twitter"}, "params": {} }, { "id": "e2fclylj30vwcpe0szl", "task": "TwitterFollow", - "title": "Follow Twitter", + "title": "", "type": 1, "desc": "Follow Counter Fire’s official X account", "category": "Social Tasks", @@ -29,7 +29,7 @@ }, { "id": "e2feyflj30vwcpe0sjy", "task": "TwitterFollow", - "title": "Follow Twitter", + "title": "", "type": 1, "desc": "", "category": "Social Tasks", @@ -41,23 +41,35 @@ }, { "id": "e2fuah0j30vwcpe0my7", "task": "TwitterRetweet", - "title": "ReTwitter", - "type": 2, - "desc": "", + "title": "", + "type": 1, + "desc": "Show your friends Counter Fire.", "category": "Social Tasks", - "score": 100, + "score": 150, "autoclaim": false, "pretasks": ["e2yhq2lj30vwcpedv7p"], - "cfg": {"icon": "twitter"}, + "cfg": {"icon": "twitter", "content": "Just joined Counter Fire! 🎮 Excited about the endless opportunities ahead. 🔥 Let's team up and conquer together! Come in with me #CounterFire #GamingAdventures"}, + "params": {"time": 6, "failRate": 60} + }, { + "id": "e2fuah0j30vwcpe1my7", + "task": "TwitterRetweet", + "title": "", + "type": 1, + "desc": "Click Verify button and retweet on the tweet", + "category": "Social Tasks", + "score": 200, + "autoclaim": false, + "pretasks": ["e2yhq2lj30vwcpedv7p"], + "cfg": {"icon": "twitter", "content": "输入框自动生成,活动开始时添加内容)"}, "params": {"time": 6, "failRate": 60} }, { "id": "e2far3lj30vwcpe0mh7", "task": "DiscordConnect", - "title": "Connect Discord", + "title": "", "type": 1, "desc": "", "category": "", - "score": 100, + "score": 0, "autoclaim": false, "pretasks": [], "cfg": {"icon": "discord"}, @@ -65,8 +77,8 @@ }, { "id": "e2far3lj30vwcpe0mf8", "task": "DiscordJoin", - "title": "Join Discord", - "type": 2, + "title": "", + "type": 1, "desc": "Join Counter Fire’s official Discord server", "category": "Social Tasks", "score": 100, @@ -78,10 +90,10 @@ "id": "e2fak2lj30vwcpe0awc", "task": "DiscordRole", "title": "Discord Role", - "type": 2, - "desc": "", + "type": 1, + "desc": "Get a role in Counter Fire’s official Discord ", "category": "Social Tasks", - "score": 100, + "score": 200, "autoclaim": false, "pretasks": ["e2far3lj30vwcpe0mf8"], "cfg": {"icon": "discord"}, @@ -89,7 +101,7 @@ }, { "id": "e2feyflj30vwcpe0sjx", "task": "YoutubeFollow", - "title": "Follow Youtube", + "title": "", "type": 1, "desc": "Follow Counter Fire’s official YTB account", "category": "Social Tasks", @@ -101,43 +113,43 @@ }, { "id": "e2feyflj30vwcpe0sjz", "task": "YoutubePost", - "title": "Post Youtube", + "title": "", "type": 1, "desc": "Post a video introducing @_CounterFire", "category": "Social Tasks", - "score": 100, + "score": 500, "autoclaim": false, "pretasks": [], "cfg": {"icon": "youtube"}, "params": {"time": 6, "failRate": 60} }, { - "id": "e2f7fplj30vwcpe0l98", - "task": "OkxLogin", - "title": "okx wallet login", + "id": "e2fuah0j30vwcpe2my7", + "task": "TwitterRetweet", + "title": "", + "type": 2, + "desc": "Showcase your performance in Counter Fire to your friends!", + "category": "Social Tasks", + "score": 300, + "autoclaim": false, + "pretasks": ["e2yhq2lj30vwcpedv7p"], + "cfg": {"icon": "twitter", "content": "Just scored xx Flame on @_CounterFire! 🔥 Join me in the action-packed fun and let's play to earn! #GamingAdventures #CounterFire"}, + "params": {"time": 6, "failRate": 60} + }, { + "id": "e2fuah0j30vwcpe2my7", + "task": "TwitterRetweet", + "title": "", "type": 1, - "desc": "", - "category": "Special Quests", + "desc": "Post to confess your 💕 for @_CounterFire", + "category": "Referral to Earn", "score": 100, "autoclaim": false, - "pretasks": [], - "cfg": {"account": "okx", "icon": "okx"}, - "params": {} - }, { - "id": "e2f7fplj30vwcpe0l96", - "task": "DailyCheckIn", - "title": "daily checkin", - "type": 2, - "desc": "", - "category": "Special Quests", - "score": 20, - "autoclaim": false, - "pretasks": [], - "cfg": {"score": [0, 15, 20, 20, 40, 40, 60]}, - "params": {"days": 1, "score": [0, 15, 20, 20, 40, 40, 60]} + "pretasks": ["e2yhq2lj30vwcpedv7p"], + "cfg": {"icon": "twitter", "content": "Just scored xx Flame on @_CounterFire! 🔥 Join me in the action-packed fun and let's play to earn! #GamingAdventures #CounterFire"}, + "params": {"time": 6, "failRate": 60} }, { "id": "e2f7fplj30vwcpe0l97", "task": "DailyCheckIn", - "title": "daily checkin", + "title": "", "type": 1, "desc": "Check-in for 3 consecutive days.", "category": "Referral to Earn", @@ -146,16 +158,42 @@ "pretasks": [], "cfg": {}, "params": {"days": 3} + }, { + "id": "e2f7fplj30vwcpe0l98", + "task": "OkxLogin", + "title": "", + "type": 1, + "desc": "Sign in via OKX Wallet.", + "category": "Referral to Earn", + "score": 300, + "autoclaim": false, + "pretasks": [], + "cfg": {"account": "okx", "icon": "okx"}, + "params": {} + }, { + "id": "e2f7fplj30vwcpe0l96", + "task": "DailyCheckIn", + "title": "", + "type": 2, + "desc": "Daily check-in! Score more Flames with 7 days of consecutive check-ins. Ignite it now!", + "category": "Social Tasks", + "score": 20, + "autoclaim": false, + "pretasks": [], + "cfg": {"score": [0, 15, 20, 20, 40, 40, 60]}, + "params": {"days": 1, "score": [0, 15, 20, 20, 40, 40, 60]} }, { "id": "e2f7t4lj30vwcpe0ldr", "task": "ShareCode", + "title": "", + "desc": "Click here if your are referred by a friend!", "type": 1, - "show": false, + "show": true, "autoclaim": false, "pretasks": [], "cfg": {}, - "score": 100, - "params": {"score": [100, 20]} + "score": 500, + "params": {"score": [500]} }, { "id": "e2f7t4lj31vwcpe0ldr", "task": "BurnNft", diff --git a/src/controllers/sign.controller.ts b/src/controllers/sign.controller.ts index 5a2a1b7..55d785f 100644 --- a/src/controllers/sign.controller.ts +++ b/src/controllers/sign.controller.ts @@ -4,6 +4,7 @@ import { role, router } from 'decorators/router' import logger from 'logger/logger' import { ActivityUser } from 'models/ActivityUser' import {DEFAULT_EXPIRED, NonceRecord} from 'models/NonceRecord' +import { ScoreRecord } from 'models/ScoreRecord' import { LoginRecordQueue } from 'queue/loginrecord.queue' import { RedisClient } from 'redis/RedisClient' import { queryCheckInList } from 'services/chain.svr' @@ -94,6 +95,11 @@ class SignController extends BaseController { invite = inviteUser.address } } + const records = await ScoreRecord.find({ user: user.id, activity: user.activity, scoreType: 'invite' }) + let score = 0; + for (let record of records) { + score += record.score; + } let result = { address: user.address, boost: user.boost || 1, @@ -106,6 +112,8 @@ class SignController extends BaseController { scoreTotal: totalScore ? parseInt(totalScore+'') : 0, rankTotal: totalRank ? totalRank : '-', invite, + inviteCount: records.length, + inviteScore: score, code: user.inviteCode, } return result; diff --git a/src/controllers/tasks.controller.ts b/src/controllers/tasks.controller.ts index 05ad4cd..c3a3a03 100644 --- a/src/controllers/tasks.controller.ts +++ b/src/controllers/tasks.controller.ts @@ -89,8 +89,9 @@ export default class TasksController extends BaseController { if (cfg.pretasks && cfg.pretasks.length > 0) { for (let preTask of cfg.pretasks) { let preTaskData = user.taskProgress.find((t: TaskStatus) => { - if (preTask.type === TaskTypeEnum.DAILY) { - return t.id === `${preTask}:${formatDate(new Date())}` + if (preTask.type === TaskTypeEnum.DAILY) { + //这种情况下只要完成一次就算完成了 + return t.id.indexOf(preTask) > -1 } return t.id === preTask }); diff --git a/src/models/ScoreRecord.ts b/src/models/ScoreRecord.ts index 893fb59..54dc398 100644 --- a/src/models/ScoreRecord.ts +++ b/src/models/ScoreRecord.ts @@ -6,6 +6,7 @@ import { BaseModule } from './Base' @dbconn() @index({ user: 1 }, { unique: false }) @index({ activity: 1 }, { unique: false }) +@index({user: 1, activity: 1, type: 1}, { unique: false }) @modelOptions({ schemaOptions: { collection: 'score_record', timestamps: true }, options: { allowMixed: Severity.ALLOW } }) class ScoreRecordClass extends BaseModule { @prop({ required: true}) diff --git a/src/tasks/ShareCode.ts b/src/tasks/ShareCode.ts index 583a5ec..433effe 100644 --- a/src/tasks/ShareCode.ts +++ b/src/tasks/ShareCode.ts @@ -29,8 +29,11 @@ export default class ShareCode extends ITask { static show: boolean = false async execute(data: any) { - let {task} = data + let { task } = data let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id) + if (!this.params.user.inviteUser) { + throw new Error('not finished') + } let scores = cfg.params.score; task.status = TaskStatusEnum.SUCCESS task.timeFinish = Date.now() @@ -52,6 +55,6 @@ export default class ShareCode extends ITask { await super.claimReward(task); let cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === task.id) let scores = cfg.params.score; - await updateInviteScore(this.params.user, scores, 0, task.task) + await updateInviteScore(this.params.user, scores, 0, "invite") } } \ No newline at end of file