更新
This commit is contained in:
@@ -10,13 +10,13 @@ const playerTaskSchema = new Schema({
|
||||
assignedTime: { type: Date, required: true },
|
||||
expireTime: { type: Date, required: true },
|
||||
status: { type: Number, required: true, default: 0 }, // 0: Active, 1: Completed, 2: Expired, 3: Claimed
|
||||
progress: { type: Number, required: true, default: 0 }
|
||||
progress: { type: Number, required: true, default: 0 },
|
||||
});
|
||||
|
||||
const playerTaskDataSchema = new Schema({
|
||||
userId: { type: String, required: true, index: true },
|
||||
tasks: [playerTaskSchema],
|
||||
lastDailyTaskAssigned: { type: Date, default: null }
|
||||
lastDailyTaskAssigned: { type: Date, default: null },
|
||||
});
|
||||
|
||||
playerTaskDataSchema.methods.toObj = function () {
|
||||
@@ -39,7 +39,7 @@ exports.getAllTaskConfigs = async () => {
|
||||
|
||||
// Get task configuration by ID
|
||||
exports.getTaskConfigById = async (taskId) => {
|
||||
return taskConfigurations.find(task => task.id === taskId);
|
||||
return taskConfigurations.find((task) => task.id === taskId);
|
||||
};
|
||||
|
||||
// Get player tasks
|
||||
@@ -50,7 +50,7 @@ exports.getPlayerTasks = async (userId) => {
|
||||
playerTaskData = new PlayerTaskData({
|
||||
userId: userId,
|
||||
tasks: [],
|
||||
lastDailyTaskAssigned: null
|
||||
lastDailyTaskAssigned: null,
|
||||
});
|
||||
await playerTaskData.save();
|
||||
}
|
||||
@@ -80,15 +80,17 @@ exports.savePlayerTasks = async (playerTaskData) => {
|
||||
exports.initializeTaskConfig = (configPath) => {
|
||||
try {
|
||||
if (fs.existsSync(configPath)) {
|
||||
const configFile = fs.readFileSync(configPath, 'utf8');
|
||||
const configFile = fs.readFileSync(configPath, "utf8");
|
||||
taskConfigurations = JSON.parse(configFile);
|
||||
console.log(`Loaded ${taskConfigurations.length} task configurations`);
|
||||
} else {
|
||||
console.log("Task configuration file not found, using empty configuration");
|
||||
console.log(
|
||||
"Task configuration file not found, using empty configuration"
|
||||
);
|
||||
taskConfigurations = [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error initializing task configuration:", e);
|
||||
taskConfigurations = [];
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user