-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Storage API + Metrics API #113
[Feature] Storage API + Metrics API #113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think generally this looks ok.
|
||
import Foundation | ||
|
||
extension Double { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file should be in the extensions folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it like that in the Finder aka local machine not in xcode as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice thanks for letting me know, that seems to be the issue. It's fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine but I feel that the retrieval of stats from events is a bit hardcoded and there is some commented code that needs to be cleaned up.
|
||
if let statsSystem = target.system(ofType: StatisticSystem.self) { | ||
if player != .ownPlayer { | ||
statsSystem.notify(for: self) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to somehow register the stats system notifier as a handler in the EventManager? So that we select which stats we want to get notified for via the StatsEngine rather than being controlled via the event? I believe this Prof will feel that this current method is kind of hard coding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing this, I forgot to remove the player check here. I've implemented something similar which removes the hard coding:
let eventUpdateClosure: (Statistic, DamageEvent?) -> Void = { statistic, event in
guard let event = event, event.player != .ownPlayer else {
return
}
statistic.updateCurrentValue(by: Double(event.damage))
Logger.log("Updating statistic with event detail: \(String(describing: event))", self)
}
This code snippet is from the TotalDamageDealtStatistic, the StatisticUpdateActor (i.e. eventUpdateClosure) related to this Statistic now takes in an Event as opposed to just EventType from the prior implementation (which had the check inside the event itself) and the parsing is done by the StatsEngine when it calls to execute the above closure.
/*func getStatisticUpdateLinks() -> StatisticUpdateLinkDatabase { | ||
let eventType = TFEventTypeWrapper(type: DamageEvent.self) | ||
let updateActor: StatisticUpdateActor = { statistic in statistic.updateCurrentValue(by: ) } | ||
let eventUpdateDictionary = [eventType: updateActor] | ||
let statsLink = StatisticUpdateLinkDatabase(statisticUpdateLinks: eventUpdateDictionary) | ||
|
||
return statsLink | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks.
Summary
This PR adds the entire Metrics API + Storage API. Added both together given the close link between them (i.e. Storage is needed to see if the Metrics work properly).
MetricsAPI
StorageAPI
Pending & Concerns
PR Status
Ready for review. UIView for Achievements and missions to be move to another PR. Some commented code is retained just in case the newer StatisticsUpdateActors fail and we need to revert back (which we can only tell after some more testing)
Closes #52