Permalink
Browse files

adding ability to ensure the correct words use the correct letters. T…

…He numbering may still be off, so that is disabled atm.
  • Loading branch information...
1 parent b450ef1 commit f122a9101c1da6c255365b3a7100e874727bc598 @debreuil committed Dec 30, 2011
@@ -2,4 +2,92 @@
<Bucket
type = "1"
version = "1.0">
+ <FileBreakpoints>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "WordGrid/LevelEditorGrid.m"
+ timestampString = "346922993.001561"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "252"
+ endingLineNumber = "252"
+ landmarkName = "-serializeGridLetters"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "WordGrid/GameVC.m"
+ timestampString = "346923999.311846"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "164"
+ endingLineNumber = "164"
+ landmarkName = "-testWordComplete"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "WordGrid/GameVC.m"
+ timestampString = "346924040.234651"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "169"
+ endingLineNumber = "169"
+ landmarkName = "-testWordComplete"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "WordGrid/GameVC.m"
+ timestampString = "346924562.046444"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "174"
+ endingLineNumber = "174"
+ landmarkName = "-testWordComplete"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "WordGrid/GameVC.m"
+ timestampString = "346924785.438361"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "166"
+ endingLineNumber = "166"
+ landmarkName = "-testWordComplete"
+ landmarkType = "5">
+ </FileBreakpoint>
+ </FileBreakpoints>
+ <SymbolicBreakpoints>
+ <SymbolicBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ symbolName = "[NSException raise]"
+ moduleName = "">
+ </SymbolicBreakpoint>
+ <SymbolicBreakpoint
+ shouldBeEnabled = "Yes"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ symbolName = "NSRangeException"
+ moduleName = "">
+ </SymbolicBreakpoint>
+ </SymbolicBreakpoints>
</Bucket>
View
@@ -9,7 +9,8 @@
+ (int) getCurrentIndex;
+ (NSString *) getCurrentQuote;
+ (NSString *) getCurrentSource;
-+ (NSString *) getCurrentGrid;
++ (NSArray *) getCurrentIndexes;
++ (NSString *) getCurrentGrid;
+ (void) incrementIndex;
@end
View
@@ -4,10 +4,12 @@ @implementation AnswerData
static int currentIndex;
static NSArray *quotes;
+static BOOL hasPlayed;
+ (void) initialize
{
currentIndex = 0;
+ hasPlayed = NO;
quotes = [NSArray arrayWithObjects:
@@ -28,6 +30,7 @@ + (void) initialize
//[NSArray arrayWithObjects:@"THERE ARE LIES, DAMNED LIES AND STATISTICS.", @"", @"MARK TWAIN", nil],
//[NSArray arrayWithObjects:@"I'VE NEVER LET MY SCHOOLING INTERFERE WITH MY EDUCATION.", @"", @"MARK TWAIN", nil],
//[NSArray arrayWithObjects:@"ACTION SPEAKS LOUDER THAN WORDS, BUT NOT NEARLY AS OFTEN.", @"", @"MARK TWAIN", nil],
+
/* [NSArray arrayWithObjects:@"ANY EMOTION, IF IT IS SINCERE, IS INVOLUNTARY.", @"", @"MARK TWAIN", nil],
[NSArray arrayWithObjects:@"BUY LAND, THEY'RE NOT MAKING IT ANYMORE.", @"", @"MARK TWAIN", nil],
[NSArray arrayWithObjects:@"CAULIFLOWER IS NOTHING BUT CABBAGE WITH A COLLEGE EDUCATION.", @"", @"MARK TWAIN", nil],
@@ -47,20 +50,17 @@ + (void) initialize
[NSArray arrayWithObjects:@"REALITY IS MERELY AN ILLUSION, ALBEIT A VERY PERSISTENT ONE.", @"", @"ALBERT EINSTEIN", nil],
[NSArray arrayWithObjects:@"TIME IS WHAT PREVENTS EVERYTHING FROM HAPPENING AT ONCE.", @"", @"ALBERT EINSTEIN", nil],
*/
-
[NSArray arrayWithObjects:
- @"FIND ALL THE WORDS",
- @" TW ALHO FINDLERDS", nil
+ @"PRESS ON THE ANSWER TO UNDO WORDS",
+ @" UTHE AWORERP NNNDOSTO OSWERSDS",
+ @"WAS THE CORRECT ANSWER!",
+ @"44,43,42,51,60,55,55,30,31,32,38,47,56,57,58,59,52,53,56,57,58,59,57,58,59,61,62", nil
],
[NSArray arrayWithObjects:
- @"PRESS ON THE ANSWER AREA TO UNDO SOME WORDS",
- @" SW UNDOOO PRESSMRDSANSAREETOTHEWERAON", nil
- ],
- [NSArray arrayWithObjects:
- @"ALL GREAT TRUTHS BEGIN AS BLASPHEMIES",
- @" E TBTH RUGS BLINALA EHPGRELS MIEASATS",
- @"George Bernard Shaw",
- @"42,43,52,49,50,51,60,61,22,31,32,33,34,43,32,33,42,51,52,60,61,42,43,44,53,52,51,50,59,60,61,62", nil
+ @"FIND ALL THE WORDS",
+ @" F A IW THLL NDOREDS",
+ @"WAS THE CORRECT ANSWER!",
+ @"38,47,56,57,43,52,53,50,51,60,58,59,60,61,62", nil
],
[NSArray arrayWithObjects:
@"I AM NOT YOUNG ENOUGH TO KNOW EVERYTHING",
@@ -69,6 +69,12 @@ + (void) initialize
@"53,61,62,60,61,62,12,13,14,23,32,41,50,59,60,61,62,26,25,34,35,44,53,15,24,33,42,43,52,51,60,61,62", nil
],
[NSArray arrayWithObjects:
+ @"ALL GREAT TRUTHS BEGIN AS BLASPHEMIES",
+ @" E TBTH RUGS BLINALA EHPGRELS MIEASATS",
+ @"George Bernard Shaw",
+ @"42,43,52,49,50,51,60,61,22,31,32,33,34,43,32,33,42,51,52,60,61,42,43,44,53,52,51,50,59,60,61,62", nil
+ ],
+ [NSArray arrayWithObjects:
@"ONE SHOULD ALWAYS PLAY FAIRLY WHEN ONE HAS THE WINNING CARDS",
@" TN PA CWHEONEYAAIOAFAHSIRNESRLOUYDNHWLWALDSINHELYSNG",
@"Oscar Wilde",
@@ -222,11 +228,15 @@ + (int) getCurrentIndex
+ (void) incrementIndex
{
- currentIndex++;
- if(currentIndex >= quotes.count)
+ if(hasPlayed)
{
- currentIndex = 0;
+ currentIndex++;
+ if(currentIndex >= quotes.count)
+ {
+ currentIndex = 0;
+ }
}
+ hasPlayed = YES;
}
+ (NSString *) getCurrentQuote
@@ -245,6 +255,28 @@ + (NSString *) getCurrentSource
return result;
}
++ (NSArray *) getCurrentIndexes
+{
+ NSArray *result;
+ NSArray *ar = [quotes objectAtIndex:[AnswerData getCurrentIndex]];
+ if(ar.count > 3)
+ {
+ NSString *s = [ar objectAtIndex:3];
+ NSArray *sInts = [s componentsSeparatedByString:@","];
+ int count = sInts.count;
+ id nums[count];
+
+ for (int i = 0; i < count; i++)
+ {
+ int num = [[sInts objectAtIndex:i] intValue];
+ nums[i] = [NSNumber numberWithInt:num];
+ }
+
+ result = [NSArray arrayWithObjects:nums count:count];
+ }
+ return result;
+}
+
+ (NSString *) getCurrentGrid
{
return [[quotes objectAtIndex:[AnswerData getCurrentIndex]] objectAtIndex:1];
View
@@ -22,14 +22,7 @@ - (void) setup
- (void) setDirection:(int)dir
{
direction = dir;
- if(dir == 1)
- {
- currentIndex = 0;
- }
- else
- {
- currentIndex = answerLength - 1;
- }
+ currentIndex = (direction == 1) ? 0 : answerLength - 1;
}
- (void) createLetters
@@ -40,7 +33,6 @@ - (void) createLetters
answer = [answer stringByReplacingOccurrencesOfString:@"'" withString:@""];
answerWords = [answer componentsSeparatedByString: @" "];
wordBoundries = [[NSMutableArray alloc] init];
- currentIndex = 0;
answerLength = 0;
int wordIndex = 0;
@@ -87,7 +79,8 @@ - (void) createLetters
}
}
}
- }
+ }
+ currentIndex = (direction == 1) ? 0 : answerLength - 1;
}
- (void) ownTileSelected:(Tile *)tile;
View
@@ -10,6 +10,8 @@ @implementation GameVC
typedef enum { Game, Victory } GameState;
GameState gameState = Game;
Boolean isLandscape = NO;
+NSArray *indexes;
+
SystemSoundID correctWordSoundID;
SystemSoundID errorSoundID;
@@ -154,7 +156,22 @@ - (void) testWordComplete
{
if([answerGrid atWordBoundry])
{
- [tileGrid resetGrid];
+ [tileGrid resetGrid];
+
+ Boolean correct = [answerGrid testCurrentWordCorrect];
+ if(correct)
+ {
+ /* NSRange r = NSMakeRange([answerGrid getAnswerIndex] - answerRefs.count, answerRefs.count);
+ NSArray *correctTileIndexes = [indexes subarrayWithRange:r];
+ for (int i = 0; i < correctTileIndexes.count; i++)
+ {
+ NSNumber *corIndex = [correctTileIndexes objectAtIndex:i];
+ Tile *corTile = [tileGrid getTileAtIndex:[corIndex integerValue]];
+ [answerRefs replaceObjectAtIndex:i withObject:corTile];
+ }
+ */
+ }
+
[tileGrid removeWordAndDrop:answerRefs];
[answerRefs removeAllObjects];
@@ -187,27 +204,30 @@ - (void) testWordComplete
- (void) nextRound
{
gameState = Game;
+
[AnswerData incrementIndex];
+
[tileGrid createRound];
[answerGrid createRound];
+
NSString *let = [answerGrid getCurrentCorrectLetter];
[tileGrid setSelectableByLetter:let];
+
+ indexes = [AnswerData getCurrentIndexes];
+
[self setOrientation];
}
- (void)didReceiveMemoryWarning
{
- // Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
}
- (void)viewDidLoad
{
[super viewDidLoad];
- [answerGrid setup];
+ [answerGrid setup]; // answer grid needs to be setup first
[tileGrid setup];
answerRefs = [[NSMutableArray alloc] initWithCapacity:20];
@@ -236,13 +256,7 @@ - (void)viewDidLoad
tickURLRef = [[NSBundle mainBundle] URLForResource:@"win" withExtension:@"caf"];
AudioServicesCreateSystemSoundID ( (__bridge CFURLRef) tickURLRef, &winSoundID);
- [self setOrientation];
-
- NSString *let = [answerGrid getCurrentCorrectLetter];
- if(let != nil)
- {
- [tileGrid setSelectableByLetter:let];
- }
+ [self nextRound];
}
- (void)viewDidUnload
Oops, something went wrong.

0 comments on commit f122a91

Please sign in to comment.