Skip to content
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

Add achievement rarity to GameCenter plugin #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ddossot
Copy link

@ddossot ddossot commented Oct 30, 2023

Objective

Support the rarityPercent property that was added to GKAchievementDescription in iOS 17.0.

Doc: https://developer.apple.com/documentation/gamekit/gkachievementdescription/4273663-raritypercent

Changes

  • Add rarity_percents to the achievement_descriptions event dictionary and wire the value from the newly introduced property,
  • Fallback to -1 if the iOS version is below 17.0 or if the achievement doesn't have a rarity percent value (i.e. nil is provided by GameKit).

Testing

Tested with Godot 3.5.0 and iOS 17, fetching achievements that have and do not have rarities.

@ddossot
Copy link
Author

ddossot commented Nov 13, 2023

@Calinou Any interest in taking this one in?

@Calinou
Copy link
Contributor

Calinou commented Nov 13, 2023

This looks good to me, but CI is failing.

@ddossot ddossot force-pushed the gc-achievement-rarity-percent branch from a5fe31a to 8995bc7 Compare November 13, 2023 20:36

NSNumber *number;
#ifdef __IPHONE_17_0
if (@available(iOS 17.0, *)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need both the macro and the availability checks, the former to allow building on pre-17.0 SDKs and the latter to silence compilation warnings when building on >17.0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this will probably work without ifdefs (property should have default getter with the same name):

if ([description respondsToSelector:@selector(rarityPercent)]) {
	number = [description performSelector:@selector(rarityPercent)];
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, great suggestion! I confirmed this works with iOS 17.

@ddossot
Copy link
Author

ddossot commented May 20, 2024

@Calinou @bruvzg Anything else preventing this PR to be merged?

@Calinou Calinou requested a review from bruvzg May 21, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants