value] = self::getDescription($case); } return $options; } /** * 获取任务状态的描述 * * @param TASK_STATUS $status * @return string */ public static function getDescription(self $status): string { return match($status) { self::NOT_ACCEPTED => '未接取', self::IN_PROGRESS => '进行中', self::COMPLETED => '已完成', self::REWARDED => '已领取奖励', self::FAILED => '已失败', self::EXPIRED => '已过期', }; } /** * 获取任务状态的颜色 * * @param TASK_STATUS $status * @return string */ public static function getColor(self $status): string { return match($status) { self::NOT_ACCEPTED => 'gray', self::IN_PROGRESS => 'blue', self::COMPLETED => 'green', self::REWARDED => 'purple', self::FAILED => 'red', self::EXPIRED => 'orange', }; } /** * 检查任务是否可以接取 * * @param TASK_STATUS $status * @return bool */ public static function canAccept(self $status): bool { return $status === self::NOT_ACCEPTED; } /** * 检查任务是否可以放弃 * * @param TASK_STATUS $status * @return bool */ public static function canAbandon(self $status): bool { return $status === self::IN_PROGRESS; } /** * 检查任务是否可以完成 * * @param TASK_STATUS $status * @return bool */ public static function canComplete(self $status): bool { return $status === self::IN_PROGRESS; } /** * 检查任务是否可以领取奖励 * * @param TASK_STATUS $status * @return bool */ public static function canClaimReward(self $status): bool { return $status === self::COMPLETED; } }