1EAAC7970D16E9950058A23D /* dictionary.ka in Resources */ = {isa = PBXBuildFile; fileRef = 1EAAC7960D16E9950058A23D /* dictionary.ka */; };
1EAAC79B0D16E9CE0058A23D /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EAAC79A0D16E9CE0058A23D /* AppController.m */; };
1EAAC8420D16F4A40058A23D /* Word.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EAAC8410D16F4A40058A23D /* Word.m */; };
+ 1EAAC93C0D17129D0058A23D /* NSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EAAC93B0D17129D0058A23D /* NSStringAdditions.m */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
1EAAC79A0D16E9CE0058A23D /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppController.m; path = Source/AppController.m; sourceTree = "<group>"; };
1EAAC8400D16F4A40058A23D /* Word.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Word.h; path = Source/Word.h; sourceTree = "<group>"; };
1EAAC8410D16F4A40058A23D /* Word.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Word.m; path = Source/Word.m; sourceTree = "<group>"; };
+ 1EAAC93A0D17129D0058A23D /* NSStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSStringAdditions.h; path = Source/NSStringAdditions.h; sourceTree = "<group>"; };
+ 1EAAC93B0D17129D0058A23D /* NSStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSStringAdditions.m; path = Source/NSStringAdditions.m; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1EAAC79A0D16E9CE0058A23D /* AppController.m */,
1EAAC8400D16F4A40058A23D /* Word.h */,
1EAAC8410D16F4A40058A23D /* Word.m */,
+ 1EAAC93A0D17129D0058A23D /* NSStringAdditions.h */,
+ 1EAAC93B0D17129D0058A23D /* NSStringAdditions.m */,
);
name = Classes;
sourceTree = "<group>";
8D11072D0486CEB800E47090 /* main.m in Sources */,
1EAAC79B0D16E9CE0058A23D /* AppController.m in Sources */,
1EAAC8420D16F4A40058A23D /* Word.m in Sources */,
+ 1EAAC93C0D17129D0058A23D /* NSStringAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#import "AppController.h"
#import "Word.h"
-
+#import "NSStringAdditions.h"
@implementation AppController
continue;
}
- [wordlist addObject:[[Word alloc] initWithWord:word]];
+ BOOL success = YES;
+ for (NSString *tile in tiles)
+ {
+ if ([word occurrenceOfChar:tile] > [tileString occurrenceOfChar:tile])
+ {
+ success = NO;
+ }
+ }
+
+ if (success)
+ {
+ [wordlist addObject:[[Word alloc] initWithWord:word]];
+ }
}
// resort
--- /dev/null
+/*
+ * Scrabbalize
+ * Copyright (c) 2007, Blue Static <http://www.bluestatic.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface NSString (NSStringAdditions)
+
+- (int)occurrenceOfChar:(NSString *)aChar;
+
+@end
--- /dev/null
+//
+// NSStringAdditions.m
+// Scrabbalize
+//
+// Created by Robert Sesek on 12/17/07.
+// Copyright 2007 __MyCompanyName__. All rights reserved.
+//
+
+#import "NSStringAdditions.h"
+
+
+@implementation NSString (NSStringAdditions)
+
+/**
+ * Counts the number of times a given character is in the string
+ */
+- (int)occurrenceOfChar:(NSString *)aChar
+{
+ int count = 0;
+
+ for (int i = 0; i < [self length]; i++)
+ {
+ if ([[self substringWithRange:NSMakeRange(i, 1)] isEqualToString:aChar])
+ {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+@end