任务奖励
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const TasksModel = require("./tasks.model.js");
|
||||
|
||||
const UserModel = require("../users/users.model.js");
|
||||
// Task status constants
|
||||
const TASK_STATUS = {
|
||||
ACTIVE: 0,
|
||||
@@ -86,7 +86,6 @@ exports.updateTaskProgress = async (playerTask, taskConfig, increment = 1) => {
|
||||
exports.giveTaskReward = async (userId, taskConfig) => {
|
||||
// In a real implementation, this would integrate with the rewards system
|
||||
// For now, we'll just log the reward information
|
||||
console.log(`Giving reward to user ${userId} for task ${taskConfig.id}`);
|
||||
|
||||
for (let i = 0; i < taskConfig.rewardTypes.length; i++) {
|
||||
const rewardType = taskConfig.rewardTypes[i];
|
||||
@@ -94,8 +93,11 @@ exports.giveTaskReward = async (userId, taskConfig) => {
|
||||
|
||||
switch (rewardType) {
|
||||
case TASK_REWARD_TYPES.COINS:
|
||||
console.log(`Rewarding ${rewardNum} coins to user ${userId}`);
|
||||
// Here we would call the rewards system to give coins to the user
|
||||
const user = await UserModel.getById(userId);
|
||||
user.coins += rewardNum;
|
||||
|
||||
await user.save();
|
||||
break;
|
||||
default:
|
||||
console.log(`Unknown reward type: ${rewardType}`);
|
||||
|
||||
Reference in New Issue
Block a user