88 lines
2.0 KiB
Dart
88 lines
2.0 KiB
Dart
enum DivinationMethod { manual, auto }
|
|
|
|
enum QuestionType {
|
|
career,
|
|
love,
|
|
wealth,
|
|
fortune,
|
|
dream,
|
|
health,
|
|
study,
|
|
search,
|
|
other,
|
|
}
|
|
|
|
enum YaoType { undetermined, youngYang, youngYin, oldYang, oldYin }
|
|
|
|
class DivinationParams {
|
|
const DivinationParams({
|
|
required this.method,
|
|
required this.questionType,
|
|
required this.question,
|
|
required this.divinationTime,
|
|
required this.coinBalance,
|
|
required this.userId,
|
|
});
|
|
|
|
final DivinationMethod method;
|
|
final QuestionType questionType;
|
|
final String question;
|
|
final DateTime divinationTime;
|
|
final int coinBalance;
|
|
final String userId;
|
|
|
|
DivinationParams copyWith({
|
|
DivinationMethod? method,
|
|
QuestionType? questionType,
|
|
String? question,
|
|
DateTime? divinationTime,
|
|
int? coinBalance,
|
|
String? userId,
|
|
}) {
|
|
return DivinationParams(
|
|
method: method ?? this.method,
|
|
questionType: questionType ?? this.questionType,
|
|
question: question ?? this.question,
|
|
divinationTime: divinationTime ?? this.divinationTime,
|
|
coinBalance: coinBalance ?? this.coinBalance,
|
|
userId: userId ?? this.userId,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toPayload() {
|
|
return <String, dynamic>{
|
|
'method': method.name,
|
|
'questionType': questionType.name,
|
|
'question': question,
|
|
'divinationTime': divinationTime.toIso8601String(),
|
|
'coinBalance': coinBalance,
|
|
'userId': userId,
|
|
};
|
|
}
|
|
|
|
String toBinary(List<YaoType> yaoStates) {
|
|
return yaoStates
|
|
.map(
|
|
(v) => switch (v) {
|
|
YaoType.youngYang || YaoType.oldYang => '1',
|
|
_ => '0',
|
|
},
|
|
)
|
|
.join();
|
|
}
|
|
|
|
String toChangedBinary(List<YaoType> yaoStates) {
|
|
return yaoStates
|
|
.map(
|
|
(v) => switch (v) {
|
|
YaoType.youngYang => '1',
|
|
YaoType.youngYin => '0',
|
|
YaoType.oldYang => '0',
|
|
YaoType.oldYin => '1',
|
|
YaoType.undetermined => '0',
|
|
},
|
|
)
|
|
.join();
|
|
}
|
|
}
|