feat(divination): 重构手动起卦教程,支持三硬币交互选择
This commit is contained in:
@@ -54,7 +54,6 @@ class DivinationRunAggregate {
|
||||
const DivinationRunAggregate({
|
||||
required this.derived,
|
||||
required this.signLevel,
|
||||
required this.summary,
|
||||
required this.conclusion,
|
||||
required this.focusPoints,
|
||||
required this.advice,
|
||||
@@ -64,7 +63,6 @@ class DivinationRunAggregate {
|
||||
|
||||
final DerivedDivinationData derived;
|
||||
final String signLevel;
|
||||
final String summary;
|
||||
final List<String> conclusion;
|
||||
final List<String> focusPoints;
|
||||
final List<String> advice;
|
||||
@@ -82,8 +80,9 @@ class DivinationRunAggregate {
|
||||
lowerName: derived.lowerName,
|
||||
signType: signLevel,
|
||||
keywords: keywords.join('、'),
|
||||
focusPoints: focusPoints,
|
||||
conclusion: _asBullet(conclusion),
|
||||
analysis: summary.isEmpty ? answer : '$summary\n\n$answer',
|
||||
analysis: answer,
|
||||
suggestion: _asBullet(advice),
|
||||
ganzhi: GanzhiData(
|
||||
yearGanZhi: derived.ganzhi.yearGanZhi,
|
||||
|
||||
@@ -22,6 +22,7 @@ class DivinationParams {
|
||||
required this.divinationTime,
|
||||
required this.coinBalance,
|
||||
required this.userId,
|
||||
this.allowVibration = true,
|
||||
});
|
||||
|
||||
final DivinationMethod method;
|
||||
@@ -30,6 +31,7 @@ class DivinationParams {
|
||||
final DateTime divinationTime;
|
||||
final int coinBalance;
|
||||
final String userId;
|
||||
final bool allowVibration;
|
||||
|
||||
DivinationParams copyWith({
|
||||
DivinationMethod? method,
|
||||
@@ -38,6 +40,7 @@ class DivinationParams {
|
||||
DateTime? divinationTime,
|
||||
int? coinBalance,
|
||||
String? userId,
|
||||
bool? allowVibration,
|
||||
}) {
|
||||
return DivinationParams(
|
||||
method: method ?? this.method,
|
||||
@@ -46,6 +49,7 @@ class DivinationParams {
|
||||
divinationTime: divinationTime ?? this.divinationTime,
|
||||
coinBalance: coinBalance ?? this.coinBalance,
|
||||
userId: userId ?? this.userId,
|
||||
allowVibration: allowVibration ?? this.allowVibration,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class DivinationResultData {
|
||||
required this.lowerName,
|
||||
required this.signType,
|
||||
required this.keywords,
|
||||
required this.focusPoints,
|
||||
required this.conclusion,
|
||||
required this.analysis,
|
||||
required this.suggestion,
|
||||
@@ -29,6 +30,7 @@ class DivinationResultData {
|
||||
final String lowerName;
|
||||
final String signType;
|
||||
final String keywords;
|
||||
final List<String> focusPoints;
|
||||
final String conclusion;
|
||||
final String analysis;
|
||||
final String suggestion;
|
||||
@@ -50,6 +52,7 @@ class DivinationResultData {
|
||||
'lowerName': lowerName,
|
||||
'signType': signType,
|
||||
'keywords': keywords,
|
||||
'focusPoints': focusPoints,
|
||||
'conclusion': conclusion,
|
||||
'analysis': analysis,
|
||||
'suggestion': suggestion,
|
||||
@@ -86,6 +89,7 @@ class DivinationResultData {
|
||||
lowerName: _requiredString(json, 'lowerName'),
|
||||
signType: _requiredString(json, 'signType'),
|
||||
keywords: _requiredString(json, 'keywords'),
|
||||
focusPoints: _requiredStringList(json, 'focusPoints'),
|
||||
conclusion: _requiredString(json, 'conclusion'),
|
||||
analysis: _requiredString(json, 'analysis'),
|
||||
suggestion: _requiredString(json, 'suggestion'),
|
||||
@@ -113,6 +117,21 @@ class DivinationResultData {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> _requiredStringList(Map<String, dynamic> json, String key) {
|
||||
final raw = json[key];
|
||||
if (raw is! List<dynamic>) {
|
||||
throw FormatException('Invalid $key payload');
|
||||
}
|
||||
return raw
|
||||
.map((item) {
|
||||
if (item is! String) {
|
||||
throw FormatException('Invalid $key item payload');
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
class GanzhiData {
|
||||
const GanzhiData({
|
||||
required this.yearGanZhi,
|
||||
|
||||
Reference in New Issue
Block a user