TrackableType: cleanup default value, reduce need of extra classes#10751
TrackableType: cleanup default value, reduce need of extra classes#10751Hanmac wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Imo it'd break (at least here) now, modifying the default value:
forge/forge-game/src/main/java/forge/game/card/CardView.java
Lines 1764 to 1770 in 908c095
|
wait, my fix doesn't work, need to do it another time Edit: |
|
@tool4ever your opinion on using: |
|
Hmn, I think it's still just asking for trouble but not enough benefit: Besides what's the point of switching the default anyway? We know we'll still want to work with |
Because it's stupid that we need to differ between (empty) collection and (Even if we store empty collection as null behind) |
|
@tool4ever i can't really overwrite but i would be okay if: public FCollectionView<CardView> getChosenCards() {
return get(TrackableProperty.ChosenCards);
}Would return empty Collection if able? hm The GUI part doesn't need to know that it's a Trackable Collection inside 🤔 |
|
Maybe related, but i noticed that the CardView helper functions that work with CardCollection stuff, forge/forge-game/src/main/java/forge/game/card/CardView.java Lines 1736 to 1857 in 50dfcde should be moved to GameEntityView to be used with |
|
hmn, type safety can get a bit messy with these generics 🤔 |
yeah that what i was thinking too, the functions doesn't need to know that they are TrackableCollection on the inside, so i might not need a TrackableCollection.Empty variant i don't have a problem with Tracker Properties to be null inside the Tracker,
You mean for the addCard/removeCard ones? i will try to make bit of the collection cleanup in another MR |
|
@tool4ever found the piece again i have been looking for: forge/forge-game/src/main/java/forge/game/player/PlayerView.java Lines 98 to 100 in 89af34e Something like that on the View classes for the get methods, to return an empty List? |
|
@tool4ever with #10801 I probably don't need to touch the default value for collection |

This cleanup reduce the need to define extra classes just for
getDefaultValue(java makes them anyway under the hood)
add new TrackableValueType where you can give its default value, mostly variant of0or Empty Viewnullas default