Skip to content

Commit 173b075

Browse files
committed
- Added new items to the item database: Order's Oath, Veil of Dawn, Winds Harmony, Path of Heresy, Seer's Staff, Song of the Tide
- Introduced minor changes to the text search bar - Added support for upgrade and recipe deliveries - Bumped the version to 1.2.2
1 parent 86bea2c commit 173b075

File tree

8 files changed

+372
-28
lines changed

8 files changed

+372
-28
lines changed

assets/item_database.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,6 +3804,42 @@ description = "Striking Falcon is a weapon that can be purchased in a special of
38043804
traits = ["offer"]
38053805
enchantments = ["precision"]
38063806

3807+
[WEAPON_ORDERS_OATH_25]
3808+
name = "Order's Oath"
3809+
description = "Order's Oath is a weapon that can be purchased in a special offer in Shadow Fight 2. It can be purchased for real money."
3810+
traits = ["offer"]
3811+
enchantments = ["bleeding"]
3812+
3813+
[HELM_VEIL_OF_DAWN_25]
3814+
name = "Veil of Dawn"
3815+
description = ""
3816+
traits = ["offer"]
3817+
enchantments = ["shielding"]
3818+
3819+
[RANGED_WINDS_HARMONY_25]
3820+
name = "Winds Harmony"
3821+
description = ""
3822+
traits = ["offer"]
3823+
enchantments = ["precision"]
3824+
3825+
[RANGED_PATH_OF_HERESY_25]
3826+
name = "Path of Heresy"
3827+
description = ""
3828+
traits = ["offer"]
3829+
enchantments = ["stun"]
3830+
3831+
[WEAPON_SEERS_STAFF_25]
3832+
name = "Seer's Staff"
3833+
description = "Seer's Staff is a weapon that can be purchased in a special offer in Shadow Fight 2. It can be purchased for real money."
3834+
traits = ["offer"]
3835+
enchantments = ["weakness"]
3836+
3837+
[MAGIC_SONG_OF_THE_TIDE_25]
3838+
name = "Song of the Tide"
3839+
description = "Song of the Tide is a magic in Shadow Fight 2. This magic was available in a weekly offer for real money. The player makes a water wave with both hands, simultaneously extending both arms, then leans forward and launches magic at the enemy. Song of the Tide will move horizontally across the battlefield. When the magic hits the target, the opponent is thrown back and takes 45 points of damage."
3840+
traits = ["offer"]
3841+
enchantments = ["frenzy"]
3842+
38073843
[HELM_HOAXEN_25]
38083844
name = "Сhimera Paradox"
38093845
description = ""

lib/enchantment.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ extension EnchantmentTierExtension on EnchantmentTier {
4545
return 0xFF441752;
4646
}
4747
}
48+
49+
String get recipeDeliveryName {
50+
switch (this) {
51+
case EnchantmentTier.simple:
52+
return "Simple";
53+
case EnchantmentTier.medium:
54+
return "Medium";
55+
case EnchantmentTier.mythical:
56+
return "Mythical"; // either Mythical or Mythic, not tested
57+
}
58+
}
59+
60+
static EnchantmentTier? tierFromRecipeName(String recipeDeliveryName) {
61+
return EnchantmentTier.values
62+
.where((c) => c.recipeDeliveryName == recipeDeliveryName)
63+
.firstOrNull;
64+
}
4865
}
4966

5067
class Enchantment {

lib/equipment.dart

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,40 @@ import 'package:stalker/item_database.dart';
2222
import 'package:stalker/record.dart';
2323
import 'package:xml/xml.dart';
2424

25+
class UpgradeDelivery {
26+
DateTime time = DateTime.fromMillisecondsSinceEpoch(0);
27+
int level = 0;
28+
int upgrade = 0;
29+
30+
String get upgradeLevel {
31+
return "$level${upgrade == 0 ? "00" : upgrade * 10}";
32+
}
33+
34+
UpgradeDelivery(this.time, this.level, this.upgrade);
35+
UpgradeDelivery.fromXml(String upgradeLevel, String deliveryTime) {
36+
time = DateTime.fromMillisecondsSinceEpoch(int.parse(deliveryTime) * 1000);
37+
level = int.parse(upgradeLevel.substring(0, upgradeLevel.length - 2));
38+
upgrade = int.parse(upgradeLevel.substring(
39+
upgradeLevel.length - 2, upgradeLevel.length - 1));
40+
}
41+
}
42+
43+
class RecipeDelivery {
44+
DateTime time = DateTime.fromMillisecondsSinceEpoch(0);
45+
late EnchantmentTier tier;
46+
int itemLevel = 0;
47+
int playerLevel = 0;
48+
49+
RecipeDelivery(this.tier, this.time, this.itemLevel, this.playerLevel);
50+
RecipeDelivery.fromXml(
51+
String tier, String deliveryTime, String itemLevel, String playerLevel) {
52+
time = DateTime.fromMillisecondsSinceEpoch(int.parse(deliveryTime) * 1000);
53+
this.itemLevel = int.parse(itemLevel);
54+
this.playerLevel = int.parse(playerLevel);
55+
this.tier = EnchantmentTierExtension.tierFromRecipeName(tier)!;
56+
}
57+
}
58+
2559
class Equipment {
2660
final EquipmentType type;
2761
final String id;
@@ -30,6 +64,8 @@ class Equipment {
3064
final String? acquireType;
3165
int level = 0;
3266
int upgrade = 0;
67+
UpgradeDelivery? upgradeDelivery;
68+
RecipeDelivery? recipeDelivery;
3369
static const minLevel = 1;
3470
static const maxLevel = 52;
3571
static const minUpgrade = 0;
@@ -38,13 +74,15 @@ class Equipment {
3874
List<AppliedEnchantment> enchantments = [];
3975

4076
Equipment.fromUpgradeString(this.type, this.id, String upgradeLevel,
41-
{this.acquireType}) {
42-
if (int.parse(upgradeLevel) < 0 || int.parse(upgradeLevel) > maxLevel * 100 + maxUpgrade * 100) {
77+
{this.acquireType, this.upgradeDelivery, this.recipeDelivery}) {
78+
if (int.parse(upgradeLevel) < 0 ||
79+
int.parse(upgradeLevel) > maxLevel * 100 + maxUpgrade * 100) {
4380
upgradeLevel = "100";
4481
}
4582
level = int.parse(upgradeLevel.substring(0, upgradeLevel.length - 2));
4683
upgrade = int.parse(upgradeLevel.substring(
4784
upgradeLevel.length - 2, upgradeLevel.length - 1));
85+
4886
name = ItemDatabase.getName(id);
4987
description = ItemDatabase.getDescription(id);
5088
}
@@ -59,6 +97,25 @@ class Equipment {
5997
}
6098

6199
XmlElement toXml(Record record) {
100+
List<XmlElement> children = [
101+
if (enchantments.isNotEmpty)
102+
XmlElement(XmlName("Enchantments"), [],
103+
enchantments.map((e) => e.toXml(type))),
104+
if (recipeDelivery != null)
105+
XmlElement(XmlName("RecipeDelivery"), [
106+
XmlAttribute(
107+
XmlName("Name"), recipeDelivery!.tier.recipeDeliveryName),
108+
XmlAttribute(
109+
XmlName("ItemLevel"), recipeDelivery!.itemLevel.toString()),
110+
XmlAttribute(
111+
XmlName("PlayerLevel"), recipeDelivery!.playerLevel.toString()),
112+
XmlAttribute(
113+
XmlName("DeliveryTime"),
114+
(recipeDelivery!.time.millisecondsSinceEpoch / 1000)
115+
.toInt()
116+
.toString()),
117+
], [])
118+
];
62119
return XmlElement(
63120
XmlName("Item"),
64121
[
@@ -67,15 +124,17 @@ class Equipment {
67124
XmlName("Equipped"), record.isEquipped(this) ? "1" : "0"),
68125
XmlAttribute(XmlName("Count"), "1"),
69126
XmlAttribute(XmlName("UpgradeLevel"), _upgradeLevel),
70-
XmlAttribute(XmlName("DeliveryTime"), "-1"),
71-
XmlAttribute(XmlName("DeliveryUpgradeLevel"), "-1"),
127+
XmlAttribute(
128+
XmlName("DeliveryTime"),
129+
upgradeDelivery == null
130+
? "-1"
131+
: (upgradeDelivery!.time.millisecondsSinceEpoch / 1000)
132+
.toInt()
133+
.toString()),
134+
XmlAttribute(XmlName("DeliveryUpgradeLevel"),
135+
upgradeDelivery == null ? "-1" : upgradeDelivery!.upgradeLevel),
72136
XmlAttribute(XmlName("AcquireType"), acquireType ?? "Upgrade"),
73137
],
74-
enchantments.isEmpty
75-
? []
76-
: [
77-
XmlElement(XmlName("Enchantments"), [],
78-
enchantments.map((e) => e.toXml(type)))
79-
]);
138+
children);
80139
}
81140
}

lib/pages/edit_xml/edit_xml.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,22 @@ class _EditXmlPageState extends State<EditXmlPage> {
8080
spacing: 8,
8181
children: [
8282
Expanded(
83-
child: TextSearchBar(onSubmitted: (query) {
84-
if (query.trim().isEmpty) return;
85-
setState(() {
86-
_updateMatches(query.trim());
87-
_jumpToMatch(currentMatchIndex);
88-
});
89-
}),
83+
child: TextSearchBar(
84+
onSubmitted: (query) {
85+
if (query.trim().isEmpty) return;
86+
setState(() {
87+
_updateMatches(query.trim());
88+
_jumpToMatch(currentMatchIndex);
89+
});
90+
},
91+
onCleared: () {
92+
setState(() {
93+
currentMatchIndex = 0;
94+
searchMatches.clear();
95+
});
96+
focusNode.unfocus();
97+
},
98+
),
9099
),
91100
Column(children: [
92101
Row(children: [

lib/pages/edit_xml/text_search_bar.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,41 @@ import 'package:flutter/material.dart';
22

33
class TextSearchBar extends StatefulWidget {
44
final void Function(String) onSubmitted;
5+
final VoidCallback onCleared;
56

6-
const TextSearchBar({super.key, required this.onSubmitted});
7+
const TextSearchBar(
8+
{super.key, required this.onSubmitted, required this.onCleared});
79

810
@override
911
State<TextSearchBar> createState() => _TextSearchBarState();
1012
}
1113

1214
class _TextSearchBarState extends State<TextSearchBar> {
1315
final controller = TextEditingController();
16+
final FocusNode focusNode = FocusNode();
1417

1518
@override
1619
void dispose() {
1720
super.dispose();
1821
controller.dispose();
22+
focusNode.dispose();
1923
}
2024

2125
@override
2226
Widget build(BuildContext context) {
2327
return SearchBar(
2428
hintText: "Search...",
2529
onSubmitted: widget.onSubmitted,
26-
controller: controller);
30+
controller: controller,
31+
focusNode: focusNode,
32+
trailing: [
33+
IconButton(
34+
onPressed: () {
35+
controller.clear();
36+
focusNode.unfocus();
37+
widget.onCleared();
38+
},
39+
icon: const Icon(Icons.clear))
40+
]);
2741
}
2842
}

0 commit comments

Comments
 (0)