Commits

Allan Davis committed 21fd206

starting the player object

  • Participants
  • Parent commits c362cb3

Comments (0)

Files changed (11)

File code/HuntTheWumpus/HuntTheWumpus.xcodeproj/project.pbxproj

 		CED42A0B16128EC6008E24E7 /* EntitySpec.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A0A16128EC6008E24E7 /* EntitySpec.m */; };
 		CED42A0F16128F01008E24E7 /* Entity.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A0E16128F01008E24E7 /* Entity.m */; };
 		CED42A1016128F01008E24E7 /* Entity.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A0E16128F01008E24E7 /* Entity.m */; };
+		CED42A15161800D2008E24E7 /* ADInput.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A14161800D2008E24E7 /* ADInput.m */; };
+		CED42A16161800D2008E24E7 /* ADInput.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A14161800D2008E24E7 /* ADInput.m */; };
+		CED42A1A161947C5008E24E7 /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A19161947C5008E24E7 /* Player.m */; };
+		CED42A1B161947C5008E24E7 /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A19161947C5008E24E7 /* Player.m */; };
+		CED42A1D16194831008E24E7 /* PlayerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = CED42A1C16194831008E24E7 /* PlayerSpec.m */; };
 		D1273479777047BF9CE29AC8 /* libPods-test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CB58754371D54EE5B4FCAE36 /* libPods-test.a */; };
 /* End PBXBuildFile section */
 
 		CED42A0A16128EC6008E24E7 /* EntitySpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EntitySpec.m; sourceTree = "<group>"; };
 		CED42A0D16128F01008E24E7 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Entity.h; path = models/Entity.h; sourceTree = "<group>"; };
 		CED42A0E16128F01008E24E7 /* Entity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Entity.m; path = models/Entity.m; sourceTree = "<group>"; };
+		CED42A13161800D2008E24E7 /* ADInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADInput.h; path = helpers/ADInput.h; sourceTree = "<group>"; };
+		CED42A14161800D2008E24E7 /* ADInput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ADInput.m; path = helpers/ADInput.m; sourceTree = "<group>"; };
+		CED42A18161947C5008E24E7 /* Player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Player.h; sourceTree = "<group>"; };
+		CED42A19161947C5008E24E7 /* Player.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Player.m; sourceTree = "<group>"; };
+		CED42A1C16194831008E24E7 /* PlayerSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerSpec.m; sourceTree = "<group>"; };
 		ECD265712D6D4BA3A3C19E38 /* Pods-test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.xcconfig"; path = "Pods/Pods-test.xcconfig"; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
 		4E46ABAF16111B48006592D7 /* HuntTheWumpus */ = {
 			isa = PBXGroup;
 			children = (
+				CED42A171618017C008E24E7 /* helpers */,
 				4E46ABDA161155DF006592D7 /* models */,
 				4E46ABB016111B48006592D7 /* main.m */,
 				4E46ABB416111B48006592D7 /* HuntTheWumpus.1 */,
 				4E46ABCA16111D81006592D7 /* Supporting Files */,
 				4E46ABE0161161DC006592D7 /* GameSpec.m */,
 				CED42A0A16128EC6008E24E7 /* EntitySpec.m */,
+				CED42A1C16194831008E24E7 /* PlayerSpec.m */,
 			);
 			path = HuntTheWumpusTests;
 			sourceTree = "<group>";
 				CED42A0E16128F01008E24E7 /* Entity.m */,
 				4E46ABD6161155A8006592D7 /* Game.h */,
 				4E46ABD7161155A8006592D7 /* Game.m */,
+				CED42A18161947C5008E24E7 /* Player.h */,
+				CED42A19161947C5008E24E7 /* Player.m */,
 			);
 			name = models;
 			sourceTree = "<group>";
 		};
+		CED42A171618017C008E24E7 /* helpers */ = {
+			isa = PBXGroup;
+			children = (
+				CED42A13161800D2008E24E7 /* ADInput.h */,
+				CED42A14161800D2008E24E7 /* ADInput.m */,
+			);
+			name = helpers;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
 				4E46ABB116111B48006592D7 /* main.m in Sources */,
 				4E46ABD8161155A8006592D7 /* Game.m in Sources */,
 				CED42A0F16128F01008E24E7 /* Entity.m in Sources */,
+				CED42A15161800D2008E24E7 /* ADInput.m in Sources */,
+				CED42A1A161947C5008E24E7 /* Player.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				4E46ABE1161161DC006592D7 /* GameSpec.m in Sources */,
 				CED42A0B16128EC6008E24E7 /* EntitySpec.m in Sources */,
 				CED42A1016128F01008E24E7 /* Entity.m in Sources */,
+				CED42A16161800D2008E24E7 /* ADInput.m in Sources */,
+				CED42A1B161947C5008E24E7 /* Player.m in Sources */,
+				CED42A1D16194831008E24E7 /* PlayerSpec.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

File code/HuntTheWumpus/HuntTheWumpus/Player.h

+//
+//  Player.h
+//  HuntTheWumpus
+//
+//  Created by Allan Davis on 9/30/12.
+//  Copyright (c) 2012 Cajun Code. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface Player : NSObject
+@property (strong) NSString *name;
+
+- (NSString *) preformAction:(NSString* ) action;
+@end

File code/HuntTheWumpus/HuntTheWumpus/Player.m

+//
+//  Player.m
+//  HuntTheWumpus
+//
+//  Created by Allan Davis on 9/30/12.
+//  Copyright (c) 2012 Cajun Code. All rights reserved.
+//
+
+#import "Player.h"
+
+@implementation Player
+
+- (NSString *) preformAction:(NSString* ) action{
+    return @"hello";
+}
+@end

File code/HuntTheWumpus/HuntTheWumpus/helpers/ADInput.h

+//
+//  Input.h
+//  HuntTheWumpus
+//
+//  Created by Allan Davis on 9/30/12.
+//  Copyright (c) 2012 Cajun Code. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface ADInput : NSObject
+
++ (NSString *) getString;
++ (char) getChar;
++ (int) getInt;
++ (float) getFloat;
++ (void) clearScreen;
+
+@end

File code/HuntTheWumpus/HuntTheWumpus/helpers/ADInput.m

+//
+//  Input.m
+//  HuntTheWumpus
+//
+//  Created by Allan Davis on 9/30/12.
+//  Copyright (c) 2012 Cajun Code. All rights reserved.
+//
+
+#import "ADInput.h"
+
+@implementation ADInput
+
++ (NSString *) getString{
+    char data[100];
+    scanf("%s", data);
+    return [NSString stringWithUTF8String:data];
+}
++ (char) getChar{
+    char data;
+    scanf("%c", &data);
+    return data;
+}
++ (int) getInt{
+    int data;
+    scanf("%d", &data);
+    return data;
+}
++ (float) getFloat;{
+    float data;
+    scanf("%f", &data);
+    return data;
+}
++ (void) clearScreen{
+    system("clear");
+}
+
+@end

File code/HuntTheWumpus/HuntTheWumpus/models/Game.h

 
 + (void)startLoop;
 
+
 @end

File code/HuntTheWumpus/HuntTheWumpus/models/Game.m

 //
 
 #import "Game.h"
-
+#import "ADInput.h"
 @implementation Game
 
 
     Game * game = [[Game alloc]init];
     game.gameRunning = YES;
     while (game.gameRunning) {
-        printf("Press x to quit. \n");
-        char input;
-        scanf("%c", &input);
-        if (input == 'x') {
+        // update objects
+        //draw the object
+        //gather input
+        printf("Type exit to quit. \n");
+        NSString *input = [ADInput getString];
+        puts(input.UTF8String);
+        if ([input isEqualToString:@"exit"]) {
             game.gameRunning = NO;
         }
         

File code/HuntTheWumpus/HuntTheWumpusTests/GameSpec.m

 SPEC_BEGIN(GameSpec)
     describe(@"Game", ^{
         context(@"gameloop", ^{
-            it(@"should make sure the screen is clear before drawing", ^{
-                Game *game = [[Game alloc]init];
-                [[game should] receive:@selector(clearTheScreen)];
-                [game startLoop];
-            });
-            it(@"should gather the input", ^{
-                
-            });
-            it(@"should update the game data", ^{
-                
-            });
-            it(@"should draw the game", ^{});
-            it(@"should allow breaking of the game loop", ^{});
+//            it(@"should make sure the screen is clear before drawing", ^{
+//                Game *game = [[Game alloc]init];
+//                [[game should] receive:@selector(clearTheScreen)];
+//                [game startLoop];
+//            });
+//            it(@"should gather the input", ^{
+//                
+//            });
+//            it(@"should update the game data", ^{
+//                
+//            });
+//            it(@"should draw the game", ^{});
+//            it(@"should allow breaking of the game loop", ^{});
         });
         
     });

File code/HuntTheWumpus/HuntTheWumpusTests/PlayerSpec.m

+#import <Kiwi/Kiwi.h>
+#import "Player.h"
+
+SPEC_BEGIN(PlayerSpec)
+    describe(@"Player", ^{
+        __block Player *player = nil;
+        beforeEach(^{
+            player = [[Player alloc]init];
+        });
+        it(@"should have a name", ^{
+            player.name = @"Allan";
+            [[player.name should] equal: @"Allan"];
+        });
+        pending(@"should keep track of it hit points", ^{});
+        
+        describe(@"preformAction", ^{
+            it(@"Should respond with I can't do this if it cannot respond to the action", ^{
+                NSString * result = [player preformAction: @"bark"];
+                [[result should] equal: @"I can't do that"];
+            });
+        });
+    });
+SPEC_END

File code/HuntTheWumpus/page247.gif

Added
New image

File presentations/huntWumpus.odp

Binary file added.