GameData
@interface GameData : NSObject
GameData
contains all the data for a game / challenge.
It contains data that will stay static (eg. the title of the game),
and data that will change based on which Voucher
it is in (eg. scoreToWin).
-
The title of the game.
Declaration
Objective-C
@property (readonly, strong, nonatomic) NSString *_Nonnull gameTitle;
Swift
var gameTitle: String { get }
-
A large local image used in the
CreateChallengesViewController
.Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSString *imageName;
Swift
var imageName: String? { get }
-
A large remote image url used in the
CreateChallengesViewController
.Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSString *imageUrl;
Swift
var imageUrl: String? { get }
-
A small thumbnail image for use in small views.
Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSString *thumbnailImageUrl;
Swift
var thumbnailImageUrl: String? { get }
-
A ‘lock’ icon image is used to show that a
Voucher
is locked by a game.Declaration
Objective-C
@property (readonly, strong, nonatomic) NSString *_Nonnull lockIconImageUrl;
Swift
var lockIconImageUrl: String { get }
-
The current difficulty of a game. The creator of a Voucher can change this difficulty from the
CreateChallengesViewController
.Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) GameDifficulty *gameDifficulty;
Swift
var gameDifficulty: GameDifficulty? { get }
-
A list of all difficulties this game can have.
Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSArray<GameDifficulty *> *gameDifficulties;
Swift
var gameDifficulties: [GameDifficulty]? { get }
-
The score required to win the game.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) NSInteger scoreToWin;
Swift
var scoreToWin: Int { get set }
-
The seed value used to randomly generate values consistently across devices.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) NSInteger gameSeed;
Swift
var gameSeed: Int { get set }
-
Whether or not the game can be previewed during the time of creation.
Declaration
Objective-C
@property (readonly, nonatomic) BOOL canPreview;
Swift
var canPreview: Bool { get }
-
Initializer that creates a
GameData
that is of type NoGame.Declaration
Objective-C
+ (nonnull GameData *)gameDataForNoGame;
Swift
class func forNoGame() -> GameData
Return Value
Instance of
GameData
with gameType = NoGame. -
Static initializer of
GameData
from a dictionary form. Internally calls initWithDictionary.Declaration
Objective-C
+ (nonnull GameData *)gameDataFromDictionary:(nonnull NSDictionary *)dictionary;
Swift
/*not inherited*/ init(from dictionary: [AnyHashable : Any])
Parameters
dictionary
- dictionary form of the GameData.
Return Value
Instance of
GameData
with the properties from dictionary. -
Default initializer of
GameData
from a dictionary form.Declaration
Objective-C
- (nonnull instancetype)initWithDictionary:(nonnull NSDictionary *)dictionary;
Swift
init(dictionary: [AnyHashable : Any])
Parameters
dictionary
- dictionary form of the GameData.
Return Value
Instance of
GameData
with the properties from dictionary. -
Converts a string to enum
GameType
.Declaration
Objective-C
+ (GameType)stringToGameType:(nonnull NSString *)gameType;
Swift
class func string(toGameType gameType: String) -> GameType
Parameters
gameType
- string value of the
GameType
.Return Value
GameType
enum value.UnknownGame
if it cannot determine from the string. -
Sets the current game difficulty for the GameType to that difficultyLevel.
Declaration
Objective-C
- (void)setGameDifficultyLevel:(GameDifficultyLevel)difficultyLevel;
Swift
func setGameDifficultyLevel(_ difficultyLevel: GameDifficultyLevel)
Parameters
difficultyLevel
- the desired difficulty for the game.
-
Converts a
GameData
to an NSDictionary that can be used for caching or sending to the server.Declaration
Objective-C
- (nonnull NSDictionary *)dictionaryRepresentation;
Swift
func dictionaryRepresentation() -> [AnyHashable : Any]
Return Value
dictionary - Dictionary form of a
GameData
.