Skip to content

Commit

Permalink
资源文件更新到20220128
Browse files Browse the repository at this point in the history
优化了一些网络逻辑,修复了一个可能导致无法获取信息的问题
修复:未点击清除或直接退出侧边栏后,未提交的过滤选项不会回退而是保持退出前状态
添加了人物关于游戏版本的过滤和排序功能
  • Loading branch information
jay committed Jan 28, 2022
1 parent 7a6de0b commit c72c1dd
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 43 deletions.
Binary file modified assets/assets.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions lib/global/enum/game_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum GameVersion {
v1,
v2,
v3,
v4,
v5,
v6,
}
3 changes: 3 additions & 0 deletions lib/global/enum/sort_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum SortKey {
spd,
def,
res,
versionNum,
}

extension SortKeyExtension on SortKey {
Expand All @@ -31,6 +32,8 @@ extension SortKeyExtension on SortKey {
return "CUSTOM_STATS_DEF";
case SortKey.res:
return "CUSTOM_STATS_RES";
case SortKey.versionNum:
return "版本";
}
}
}
6 changes: 6 additions & 0 deletions lib/global/filters/person.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:feh_rebuilder/global/enum/move_type.dart';
import 'package:feh_rebuilder/global/enum/series.dart';
import 'package:feh_rebuilder/global/enum/game_version.dart';
import 'package:feh_rebuilder/global/enum/weapon_type.dart';
import 'package:feh_rebuilder/global/filters/filter.dart';
import 'package:feh_rebuilder/models/person/person.dart';
Expand All @@ -20,6 +21,7 @@ enum PersonFilterType {
weaponType,
series,
recentlyUpdated,
gameVersion,
}

class PersonFilter implements Filter<Person, PersonFilterType> {
Expand Down Expand Up @@ -94,6 +96,10 @@ class PersonFilter implements Filter<Person, PersonFilterType> {
_legendaryKind.contains(person.legendary?.element);
case PersonFilterType.recentlyUpdated:
return person.recentlyUpdate;
case PersonFilterType.gameVersion:
Set<int> _valid =
(valid as Set<GameVersion>).map((e) => e.index + 1).toSet();
return _valid.contains((person.versionNum! / 100).floor());
default:
throw "错误的过滤类型";
}
Expand Down
77 changes: 77 additions & 0 deletions lib/models/cloudObject/cloud_object.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// abstract class CloudObject {
// late String objectId;
// late DateTime createdAt;
// late DateTime updatedAt;
// ACL? acl;
// }

// class ACL {
// Iterable acls;
// ACL({
// required this.acls,
// }) {
// if (acls.isEmpty) {
// // 默认全部只读
// // acls = Iterable.generate(
// // 1,
// // (index) => AclItem(
// // object: "*",
// // permission: Permission(
// // read: false,
// // write: false,
// // ),
// // ),
// // );
// }
// }

// factory ACL.fromJson(Map<String, dynamic> json) {
// // json.forEach((key, value) {
// // AclItem.fromJson({key: value});
// // });
// return ACL(
// acls: Iterable.generate(
// json.length,
// (index) => AclItem.fromJson(
// json.entries.elementAt(index),
// ),
// ),
// );
// }

// // Map<String, dynamic> toJson() => Map.fromEntries(acls);
// }

// class AclItem {
// String object;
// Permission permission;
// AclItem({
// required this.object,
// required this.permission,
// });
// factory AclItem.fromJson(MapEntry<String, dynamic> json) => AclItem(
// object: json.key,
// permission: Permission.fromJson(json.value),
// );

// Map<String, dynamic> toJson() => {
// object: permission.toJson(),
// };
// }

// class Permission {
// bool read;
// bool write;

// Permission({
// required this.read,
// required this.write,
// });
// factory Permission.fromJson(Map<String, dynamic> json) =>
// Permission(read: json["read"], write: json["write"]);

// Map<String, dynamic> toJson() => {
// "read": read,
// "write": write,
// };
// }
4 changes: 4 additions & 0 deletions lib/models/person/json_person.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JsonPerson {
Dragonflowers? dragonflowers;
String? timestamp;
int? idNum;
int? versionNum;
int? sortValue;
int? origins;
int? weaponType;
Expand All @@ -38,6 +39,7 @@ class JsonPerson {
this.dragonflowers,
this.timestamp,
this.idNum,
this.versionNum,
this.sortValue,
this.origins,
this.weaponType,
Expand Down Expand Up @@ -67,6 +69,7 @@ class JsonPerson {
json['dragonflowers'] as Map<String, dynamic>),
timestamp: json['timestamp'] as String?,
idNum: json['id_num'] as int?,
versionNum: json['version_num'] as int?,
sortValue: json['sort_value'] as int?,
origins: json['origins'] as int?,
weaponType: json['weapon_type'] as int?,
Expand Down Expand Up @@ -96,6 +99,7 @@ class JsonPerson {
'dragonflowers': dragonflowers?.toJson(),
'timestamp': timestamp,
'id_num': idNum,
'version_num': versionNum,
'sort_value': sortValue,
'origins': origins,
'weapon_type': weaponType,
Expand Down
4 changes: 4 additions & 0 deletions lib/models/person/person.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Person extends JsonPerson {
Dragonflowers? dragonflowers,
String? timestamp,
int? idNum,
int? versionNum,
int? sortValue,
int? origins,
int? weaponType,
Expand Down Expand Up @@ -55,6 +56,7 @@ class Person extends JsonPerson {
dragonflowers: dragonflowers,
timestamp: timestamp,
idNum: idNum,
versionNum: versionNum,
sortValue: sortValue,
origins: origins,
weaponType: weaponType,
Expand Down Expand Up @@ -84,6 +86,7 @@ class Person extends JsonPerson {
json['dragonflowers'] as Map<String, dynamic>),
timestamp: json['timestamp'] as String?,
idNum: json['id_num'] as int?,
versionNum: json['version_num'] as int?,
sortValue: json['sort_value'] as int?,
origins: json['origins'] as int?,
weaponType: json['weapon_type'] as int?,
Expand Down Expand Up @@ -128,6 +131,7 @@ class Person extends JsonPerson {
'dragonflowers': dragonflowers?.toJson(),
'timestamp': timestamp,
'id_num': idNum,
'version_num': versionNum,
'sort_value': sortValue,
'origins': origins,
'weapon_type': weaponType,
Expand Down
47 changes: 34 additions & 13 deletions lib/pages/heroBuildShare/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,42 @@ class HeroBuild {
? null
: Skill.fromJson(Get.find<DataService>().skillBox.read(item))
];
Stats skillsStats = Stats(hp: 0, atk: 0, spd: 0, def: 0, res: 0);
for (var _skill in skills) {
if (_skill != null) {
skillsStats.add(_skill.stats);
// 目前仅对武器炼成后的技能需要考虑添加额外技能的属性,除武器外其他类型的技能暂不考虑
if (_skill.category == 0) {
skillsStats.atk += _skill.might!;
if (_skill.refineId != null) {
Skill _refine = Skill.fromJson(
Get.find<DataService>().skillBox.read(_skill.refineId!));
skillsStats.add(_refine.stats);
}
}
}
}

Stats _stats = Stats.fromJson(Utils.calcStats(
person,
1,
40,
build.rarity,
build.advantage,
build.disAdvantage,
build.merged,
build.dragonflowers,
build.resplendent,
build.summonerSupport,
build.ascendedAsset,
));
// 合并人物属性和装备属性
_stats.add(skillsStats);

// ! 加入技能属性
return HeroBuild(
personBuild: build,
stats: Stats.fromJson(Utils.calcStats(
person,
1,
40,
build.rarity,
build.advantage,
build.disAdvantage,
build.merged,
build.dragonflowers,
build.resplendent,
build.summonerSupport,
build.ascendedAsset,
)),
stats: _stats,
skills: skills,
tableData: tableData,
person: person);
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/heroBuildShare/widgets/build_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ class _SkillTile extends StatelessWidget {
Get.find<DataService>().appPath.path,
category == 15
? "assets/blessing/${skill!.iconId}.webp"
: "assets/icons/${skill!.iconId}.webp");
: category < 3
? "assets/icons/${category + 1}.webp"
: "assets/icons/${skill!.iconId}.webp");
}
}

Expand Down
13 changes: 12 additions & 1 deletion lib/pages/heroDetail/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ class HeroDetailController extends GetxController {

skillsStats.add(skill.stats, minus: true);
skillsStats.atk -= skill.might!;

if (skill.refineId != null) {
Skill _ = Skill.fromJson(data.skillBox.read(skill.refineId!));
skillsStats.add(_.stats, minus: true);
}
heroSkills[index] = null;

update();
Expand All @@ -296,6 +299,10 @@ class HeroDetailController extends GetxController {
if (skill != null) {
skillsStats.add(skill.stats);
skillsStats.atk += skill.might!;
if (skill.refineId != null) {
Skill _ = Skill.fromJson(data.skillBox.read(skill.refineId!));
skillsStats.add(_.stats);
}
}
equipStats.add(skillsStats);
update();
Expand Down Expand Up @@ -539,6 +546,10 @@ class HeroDetailController extends GetxController {
if (s != null) {
skillsStats.atk += s.might!;
skillsStats.add(s.stats);
if (s.refineId != null && s.category == 0) {
Skill _s = Skill.fromJson(data.skillBox.read(s.refineId!));
skillsStats.add(_s.stats);
}
// tempStats.add(skillStats);
}
}
Expand Down
25 changes: 21 additions & 4 deletions lib/pages/home/subview/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HomePage extends GetView<HomePageController> {
itemBuilder: (context, person) => MyTile(
path: controller.data.appPath.path,
person: person,
showVersion: controller.currentSortKey == SortKey.versionNum,
sum: controller.currentSortKey == SortKey.bst
? person.bst.toString()
: person.defaultStats!.sum.toString(),
Expand All @@ -35,12 +36,17 @@ class HomePage extends GetView<HomePageController> {
}

class MyTile extends StatelessWidget {
const MyTile(
{Key? key, required this.path, required this.person, required this.sum})
: super(key: key);
const MyTile({
Key? key,
required this.path,
required this.person,
required this.sum,
required this.showVersion,
}) : super(key: key);
final String path;
final Person person;
final String sum;
final bool showVersion;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -76,7 +82,18 @@ class MyTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(("M${person.idTag!}").tr),
Row(
children: [
Text(("M${person.idTag!}").tr),
// const Spacer(),
if (showVersion)
Text(
" [${(person.versionNum! / 100).floor()}.${person.versionNum! % 100}]"),
const SizedBox(
width: 40,
)
],
),
Row(
children: [
MyTile1(path: path, person: person),
Expand Down
Loading

0 comments on commit c72c1dd

Please sign in to comment.