Files
2024-03-28 19:39:04 -04:00

206 lines
6.9 KiB
Objective-C

/*
Copyright (c) 2015, Apple Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder(s) nor the names of any contributors
may be used to endorse or promote products derived from this software without
specific prior written permission. No license is granted to the trademarks of
the copyright holders even if such marks are included in this software.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <ResearchKit/ORKResult.h>
NS_ASSUME_NONNULL_BEGIN
@class ORKSpatialSpanMemoryGameRecord;
@class ORKSpatialSpanMemoryGameTouchSample;
/// An enumeration of values that describe the status of a round of the spatial span memory game.
typedef NS_ENUM(NSInteger, ORKSpatialSpanMemoryGameStatus) {
/// Unknown status. The game is still in progress or has not started.
ORKSpatialSpanMemoryGameStatusUnknown,
/// Success. The user has completed the sequence.
ORKSpatialSpanMemoryGameStatusSuccess,
/// Failure. The user has completed the sequence incorrectly.
ORKSpatialSpanMemoryGameStatusFailure,
/// Timeout. The game timed out during play.
ORKSpatialSpanMemoryGameStatusTimeout
} ORK_ENUM_AVAILABLE;
/**
The `ORKSpatialSpanMemoryResult` class represents the result of a spatial span memory step (`ORKSpatialSpanMemoryStep`).
A spatial span memory result records the score displayed to the user, the number of games, the
objects recording the actual game, and the user's taps in response
to the game.
A spatial span memory result is typically generated by the framework as the task proceeds. When the task
completes, it may be appropriate to serialize it for transmission to a server,
or to immediately perform analysis on it.
*/
ORK_CLASS_AVAILABLE
@interface ORKSpatialSpanMemoryResult : ORKResult
/**
The score in the game.
The score is an integer value that monotonically increases during the game, across multiple rounds.
*/
@property (nonatomic, assign) NSInteger score;
/**
The number of games.
The number of rounds that the user participated in, including successful,
failed, and timed out rounds.
*/
@property (nonatomic, assign) NSInteger numberOfGames;
/**
The number of failures.
The number of rounds in which the user participated, but did not correctly
complete the sequence.
*/
@property (nonatomic, assign) NSInteger numberOfFailures;
/**
An array that contains the results of the games played.
Each item in the array is an `ORKSpatialSpanMemoryGameRecord` object.
*/
@property (nonatomic, copy, nullable) NSArray<ORKSpatialSpanMemoryGameRecord *> *gameRecords;
@end
/**
The `ORKSpatialSpanMemoryGameRecord` class records the results of a
single playable instance of the spatial span memory game.
A spatial span memory game record is typically generated by the framework as the task proceeds. When the task
completes, it may be appropriate to serialize it for transmission to a server,
or to immediately perform analysis on it.
These records are found in the `records` property of an `ORKSpatialSpanMemoryResult` object.
*/
ORK_CLASS_AVAILABLE
@interface ORKSpatialSpanMemoryGameRecord : NSObject <NSCopying, NSSecureCoding>
/**
An integer used as the seed for the sequence.
If you pass a specific seed value to another game, you get the same sequence.
*/
@property (nonatomic, assign) uint32_t seed;
/**
An array of `NSNumber` objects that represent the sequence that was presented to the user.
The sequence is an array of length `sequenceLength` that contains a random permutation of integers (0..`gameSize`-1)
*/
@property (nonatomic, copy, nullable) NSArray<NSNumber *> *sequence;
/**
The size of the game.
The game size is the number of targets, such as flowers, in the game.
*/
@property (nonatomic, assign) NSInteger gameSize;
/**
An array of `NSValue` objects wrapped in `CGRect` that record the frames of the target
tiles as displayed, relative to the step view.
*/
@property (nonatomic, copy, nullable) NSArray<NSValue *> *targetRects;
/**
An array of `ORKSpatialSpanMemoryGameTouchSample` objects that record the onscreen locations
the user tapped during the game.
*/
@property (nonatomic, copy, nullable) NSArray<ORKSpatialSpanMemoryGameTouchSample *> *touchSamples;
/**
A value indicating whether the user completed the sequence and, if the game was not completed, why not.
*/
@property (nonatomic, assign) ORKSpatialSpanMemoryGameStatus gameStatus;
/**
An integer that records the number of points obtained during this game toward
the total score.
*/
@property (nonatomic, assign) NSInteger score;
@end
/**
The `ORKSpatialSpanMemoryGameTouchSample` class represents a tap during the
spatial span memory game.
A spatial span memory game touch sample is typically generated by the framework as the task proceeds. When the task
completes, it may be appropriate to serialize it for transmission to a server,
or to immediately perform analysis on it.
*/
ORK_CLASS_AVAILABLE
@interface ORKSpatialSpanMemoryGameTouchSample : NSObject <NSCopying, NSSecureCoding>
/**
A timestamp (in seconds) from the beginning of the game.
*/
@property (nonatomic, assign) NSTimeInterval timestamp;
/**
The index of the target that was tapped.
Usually, this index is a value that ranges between 0 and the number of targets,
indicating which target was tapped.
If the touch was outside all of the targets, the value of this property is -1.
*/
@property (nonatomic, assign) NSInteger targetIndex;
/**
A point that records the touch location in the step's view.
*/
@property (nonatomic, assign) CGPoint location;
/**
A Boolean value indicating whether the tapped target was the correct one.
The value of this property is `YES` when the tapped target is the correct
one, and `NO` otherwise.
*/
@property (nonatomic, assign, getter=isCorrect) BOOL correct;
@end
NS_ASSUME_NONNULL_END