Create some dice comparator functions (in SA_DiceComparators)
This commit is contained in:
parent
aa4a4594b2
commit
8ef9920c62
17
SA_DiceComparators.h
Normal file
17
SA_DiceComparators.h
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// SA_DiceComparators.h
|
||||
// DieBot Mobile
|
||||
//
|
||||
// Created by Sandy Achmiz on 5/4/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef SA_DiceComparators_h
|
||||
#define SA_DiceComparators_h
|
||||
|
||||
NSComparisonResult compareEvaluatedExpressionsByResult(NSDictionary* expression1, NSDictionary *expression2);
|
||||
NSComparisonResult compareEvaluatedExpressionsByAttemptBonus(NSDictionary* expression1, NSDictionary *expression2);
|
||||
|
||||
#endif /* SA_DiceComparators_h */
|
||||
43
SA_DiceComparators.m
Normal file
43
SA_DiceComparators.m
Normal file
@ -0,0 +1,43 @@
|
||||
//
|
||||
// SA_DiceComparators.m
|
||||
// DieBot Mobile
|
||||
//
|
||||
// Created by Sandy Achmiz on 5/4/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "SA_DiceComparators.h"
|
||||
|
||||
#import "SA_DiceExpressionStringConstants.h"
|
||||
|
||||
NSComparisonResult compareEvaluatedExpressionsByResult(NSDictionary* expression1, NSDictionary *expression2)
|
||||
{
|
||||
if([expression1[SA_DB_RESULT] integerValue] < [expression2[SA_DB_RESULT] integerValue])
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
else if([expression1[SA_DB_RESULT] integerValue] > [expression2[SA_DB_RESULT] integerValue])
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
}
|
||||
|
||||
NSComparisonResult compareEvaluatedExpressionsByAttemptBonus(NSDictionary* expression1, NSDictionary *expression2)
|
||||
{
|
||||
if([expression1[SA_DB_OPERAND_RIGHT][SA_DB_RESULT] integerValue] < [expression2[SA_DB_OPERAND_RIGHT][SA_DB_RESULT] integerValue])
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
else if([expression1[SA_DB_OPERAND_RIGHT][SA_DB_RESULT] integerValue] > [expression2[SA_DB_OPERAND_RIGHT][SA_DB_RESULT] integerValue])
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user