Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Children of Ur
coUserver
Commits
22d2f6ac
Commit
22d2f6ac
authored
Jun 27, 2017
by
Andy Castille
Browse files
notify players when tools break
fixes
https://github.com/ChildrenOfUr/cou-issues/issues/2421
parent
8de3f11d
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/endpoints/inventory_new.dart
View file @
22d2f6ac
...
...
@@ -896,28 +896,44 @@ class InventoryV2 {
// sort the list and pick the one with the most used already
possibles
.
sort
();
DurabilitySlot
mostUsed
=
possibles
.
removeAt
(
0
);
String
newlyBroken
=
null
;
//write it to the tmpSlots array
if
(
mostUsed
.
subSlot
==
-
1
)
{
Slot
slotToModify
=
tmpSlots
[
mostUsed
.
slot
];
int
used
=
int
.
parse
(
slotToModify
.
metadata
[
'durabilityUsed'
]
?.
toString
()
??
'0'
);
slotToModify
.
metadata
[
'durabilityUsed'
]
=
'
${used + amount}
'
;
used
+=
amount
;
slotToModify
.
metadata
[
'durabilityUsed'
]
=
used
.
toString
();
tmpSlots
[
mostUsed
.
slot
]
=
slotToModify
;
if
(
used
==
items
[
slotToModify
.
itemType
]
.
durability
)
{
newlyBroken
=
items
[
slotToModify
.
itemType
]
.
name
;
}
}
else
{
//have to modify a bag slot
Slot
bag
=
tmpSlots
[
mostUsed
.
slot
];
List
<
Slot
>
bagSlots
=
jsonx
.
decode
(
bag
.
metadata
[
'slots'
],
type:
listOfSlots
);
Slot
bagSlot
=
bagSlots
[
mostUsed
.
subSlot
];
int
used
=
int
.
parse
(
bagSlot
.
metadata
[
'durabilityUsed'
]
?.
toString
()
??
'0'
);
bagSlot
.
metadata
[
'durabilityUsed'
]
=
'
${used + amount}
'
;
used
+=
amount
;
bagSlot
.
metadata
[
'durabilityUsed'
]
=
used
.
toString
();
bagSlots
[
mostUsed
.
subSlot
]
=
bagSlot
;
bag
.
metadata
[
'slots'
]
=
jsonx
.
encode
(
bagSlots
);
tmpSlots
[
mostUsed
.
slot
]
=
bag
;
if
(
used
==
items
[
bagSlot
.
itemType
]
.
durability
)
{
newlyBroken
=
items
[
bagSlot
.
itemType
]
.
name
;
}
}
//finally save the array as the new inventory
inventory_json
=
jsonx
.
encode
(
tmpSlots
);
await
_updateDatabase
(
email
);
if
(
newlyBroken
!=
null
)
{
toast
(
"Yikes! Your
$newlyBroken
just broke."
,
StreetUpdateHandler
.
userSockets
[
email
]);
}
return
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment