From 135c5ca89c57628c91f89441bbc1881d199fd83c Mon Sep 17 00:00:00 2001 From: Siddique Date: Tue, 19 Dec 2017 22:48:55 +0530 Subject: [PATCH] Initial Commit --- .DS_Store | Bin 0 -> 6148 bytes Tictactoe/Tictactoe.xcodeproj/project.pbxproj | 329 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + Tictactoe/Tictactoe/AppDelegate.swift | 46 +++ .../AppIcon.appiconset/Contents.json | 93 +++++ .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Tictactoe/Base.lproj/Main.storyboard | 204 +++++++++++ Tictactoe/Tictactoe/Info.plist | 45 +++ .../Tictactoe/gameModeViewController.swift | 22 ++ Tictactoe/Tictactoe/rootViewController.swift | 137 ++++++++ 10 files changed, 908 insertions(+) create mode 100644 .DS_Store create mode 100644 Tictactoe/Tictactoe.xcodeproj/project.pbxproj create mode 100644 Tictactoe/Tictactoe.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Tictactoe/Tictactoe/AppDelegate.swift create mode 100644 Tictactoe/Tictactoe/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Tictactoe/Tictactoe/Base.lproj/LaunchScreen.storyboard create mode 100644 Tictactoe/Tictactoe/Base.lproj/Main.storyboard create mode 100644 Tictactoe/Tictactoe/Info.plist create mode 100644 Tictactoe/Tictactoe/gameModeViewController.swift create mode 100644 Tictactoe/Tictactoe/rootViewController.swift diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3435a77b0f6706e7c98b8eaef2bdb40bfb05620e GIT binary patch literal 6148 zcmeHKu};H441EV3idZ@_-pGW+%o3_}=)eMe0JLR53d#a|Ha;8Pvt4KuSQ(Hl+3(Kh zmrLFd-vKDgx7{VM05GQu@vbm6t;;8N6d7T$XWU?g3%p>r?k3egC&WF$EqT{yalr4l zo37t*Rj+nMKmRb}NQ`?tV~bZjTI}((?!FmbxsS%kkP4&%sX!`_3Zw$A0DHDE7f1$u9;|DG= literal 0 HcmV?d00001 diff --git a/Tictactoe/Tictactoe.xcodeproj/project.pbxproj b/Tictactoe/Tictactoe.xcodeproj/project.pbxproj new file mode 100644 index 0000000..82e0220 --- /dev/null +++ b/Tictactoe/Tictactoe.xcodeproj/project.pbxproj @@ -0,0 +1,329 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 1B453D581FE96F9F002D83FC /* gameModeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B453D571FE96F9F002D83FC /* gameModeViewController.swift */; }; + 1B8FF7211FE0592500A07337 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B8FF7201FE0592500A07337 /* AppDelegate.swift */; }; + 1B8FF7231FE0592500A07337 /* rootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B8FF7221FE0592500A07337 /* rootViewController.swift */; }; + 1B8FF7261FE0592500A07337 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B8FF7241FE0592500A07337 /* Main.storyboard */; }; + 1B8FF7281FE0592500A07337 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B8FF7271FE0592500A07337 /* Assets.xcassets */; }; + 1B8FF72B1FE0592500A07337 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B8FF7291FE0592500A07337 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1B453D571FE96F9F002D83FC /* gameModeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = gameModeViewController.swift; sourceTree = ""; }; + 1B8FF71D1FE0592500A07337 /* Tictactoe.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tictactoe.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1B8FF7201FE0592500A07337 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 1B8FF7221FE0592500A07337 /* rootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = rootViewController.swift; sourceTree = ""; }; + 1B8FF7251FE0592500A07337 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 1B8FF7271FE0592500A07337 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 1B8FF72A1FE0592500A07337 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 1B8FF72C1FE0592500A07337 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1B8FF71A1FE0592500A07337 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1B8FF7141FE0592500A07337 = { + isa = PBXGroup; + children = ( + 1B8FF71F1FE0592500A07337 /* Tictactoe */, + 1B8FF71E1FE0592500A07337 /* Products */, + ); + sourceTree = ""; + }; + 1B8FF71E1FE0592500A07337 /* Products */ = { + isa = PBXGroup; + children = ( + 1B8FF71D1FE0592500A07337 /* Tictactoe.app */, + ); + name = Products; + sourceTree = ""; + }; + 1B8FF71F1FE0592500A07337 /* Tictactoe */ = { + isa = PBXGroup; + children = ( + 1B453D571FE96F9F002D83FC /* gameModeViewController.swift */, + 1B8FF7201FE0592500A07337 /* AppDelegate.swift */, + 1B8FF7221FE0592500A07337 /* rootViewController.swift */, + 1B8FF7241FE0592500A07337 /* Main.storyboard */, + 1B8FF7271FE0592500A07337 /* Assets.xcassets */, + 1B8FF7291FE0592500A07337 /* LaunchScreen.storyboard */, + 1B8FF72C1FE0592500A07337 /* Info.plist */, + ); + path = Tictactoe; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1B8FF71C1FE0592500A07337 /* Tictactoe */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1B8FF72F1FE0592500A07337 /* Build configuration list for PBXNativeTarget "Tictactoe" */; + buildPhases = ( + 1B8FF7191FE0592500A07337 /* Sources */, + 1B8FF71A1FE0592500A07337 /* Frameworks */, + 1B8FF71B1FE0592500A07337 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Tictactoe; + productName = Tictactoe; + productReference = 1B8FF71D1FE0592500A07337 /* Tictactoe.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1B8FF7151FE0592500A07337 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = Siddique; + TargetAttributes = { + 1B8FF71C1FE0592500A07337 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 1B8FF7181FE0592500A07337 /* Build configuration list for PBXProject "Tictactoe" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1B8FF7141FE0592500A07337; + productRefGroup = 1B8FF71E1FE0592500A07337 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1B8FF71C1FE0592500A07337 /* Tictactoe */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1B8FF71B1FE0592500A07337 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1B8FF72B1FE0592500A07337 /* LaunchScreen.storyboard in Resources */, + 1B8FF7281FE0592500A07337 /* Assets.xcassets in Resources */, + 1B8FF7261FE0592500A07337 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1B8FF7191FE0592500A07337 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1B8FF7231FE0592500A07337 /* rootViewController.swift in Sources */, + 1B8FF7211FE0592500A07337 /* AppDelegate.swift in Sources */, + 1B453D581FE96F9F002D83FC /* gameModeViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 1B8FF7241FE0592500A07337 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1B8FF7251FE0592500A07337 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 1B8FF7291FE0592500A07337 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1B8FF72A1FE0592500A07337 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1B8FF72D1FE0592500A07337 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 1B8FF72E1FE0592500A07337 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1B8FF7301FE0592500A07337 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Tictactoe/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.siddique.Tictactoe; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1B8FF7311FE0592500A07337 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Tictactoe/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.siddique.Tictactoe; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1B8FF7181FE0592500A07337 /* Build configuration list for PBXProject "Tictactoe" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1B8FF72D1FE0592500A07337 /* Debug */, + 1B8FF72E1FE0592500A07337 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1B8FF72F1FE0592500A07337 /* Build configuration list for PBXNativeTarget "Tictactoe" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1B8FF7301FE0592500A07337 /* Debug */, + 1B8FF7311FE0592500A07337 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1B8FF7151FE0592500A07337 /* Project object */; +} diff --git a/Tictactoe/Tictactoe.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Tictactoe/Tictactoe.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..928ce07 --- /dev/null +++ b/Tictactoe/Tictactoe.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Tictactoe/Tictactoe/AppDelegate.swift b/Tictactoe/Tictactoe/AppDelegate.swift new file mode 100644 index 0000000..2a4e743 --- /dev/null +++ b/Tictactoe/Tictactoe/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Tictactoe +// +// Created by Siddique on 13/12/17. +// Copyright © 2017 Siddique. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Tictactoe/Tictactoe/Assets.xcassets/AppIcon.appiconset/Contents.json b/Tictactoe/Tictactoe/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..1d060ed --- /dev/null +++ b/Tictactoe/Tictactoe/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Tictactoe/Tictactoe/Base.lproj/LaunchScreen.storyboard b/Tictactoe/Tictactoe/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f83f6fd --- /dev/null +++ b/Tictactoe/Tictactoe/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tictactoe/Tictactoe/Base.lproj/Main.storyboard b/Tictactoe/Tictactoe/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f2418df --- /dev/null +++ b/Tictactoe/Tictactoe/Base.lproj/Main.storyboard @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tictactoe/Tictactoe/Info.plist b/Tictactoe/Tictactoe/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/Tictactoe/Tictactoe/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Tictactoe/Tictactoe/gameModeViewController.swift b/Tictactoe/Tictactoe/gameModeViewController.swift new file mode 100644 index 0000000..96ed7b0 --- /dev/null +++ b/Tictactoe/Tictactoe/gameModeViewController.swift @@ -0,0 +1,22 @@ +// +// gameModeViewController.swift +// Tictactoe +// +// Created by Siddique on 19/12/17. +// Copyright © 2017 Siddique. All rights reserved. +// + +import UIKit + +class gameModeViewController: UIViewController { + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + + + } + + +} diff --git a/Tictactoe/Tictactoe/rootViewController.swift b/Tictactoe/Tictactoe/rootViewController.swift new file mode 100644 index 0000000..b7106c3 --- /dev/null +++ b/Tictactoe/Tictactoe/rootViewController.swift @@ -0,0 +1,137 @@ +// +// ViewController.swift +// Tictactoe +// +// Created by Siddique on 13/12/17. +// Copyright © 2017 Siddique. All rights reserved. +// + +import UIKit + + + +class rootViewController: UIViewController { + var player1 = [Int]() + var player2 = [Int]() + var winner = 0 + @IBOutlet weak var button9: UIButton! + @IBOutlet weak var button8: UIButton! + @IBOutlet weak var button7: UIButton! + @IBOutlet weak var button6: UIButton! + @IBOutlet weak var button5: UIButton! + @IBOutlet weak var button4: UIButton! + @IBOutlet weak var button3: UIButton! + @IBOutlet weak var button2: UIButton! + @IBOutlet weak var button1: UIButton! + @IBOutlet var buttons: [UIButton]! + @IBAction func buttonEvent(_ sender: UIButton) { + let button = sender + playGame(button) + } + var activePlayer = 1 + func playGame(_ buttonSelect: UIButton){ + if activePlayer == 1{ + buttonSelect.setTitle("X", for: UIControlState.normal) + buttonSelect.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1) + player1.append(buttonSelect.tag) + activePlayer = 2 + }else{ + buttonSelect.setTitle("O", for: UIControlState.normal) + buttonSelect.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1) + player2.append(buttonSelect.tag) + activePlayer = 1 + } + findWinner() + + } + @IBAction func restart(_ sender: UIButton) { + restart() + } + func restart(){ + for index in buttons.indices{ + buttons[index].setTitle("", for: UIControlState.normal) + buttons[index].backgroundColor = #colorLiteral(red: 0.1215686275, green: 0.4980392157, blue: 1, alpha: 1) + } + player1 = [] + player2 = [] + activePlayer = 1 + winner = 0 + } + func findWinner(){ + + //row1 + if (player1.contains(1) && player1.contains(2) && player1.contains(3)){ + winner = 1 + } + if (player2.contains(1) && player2.contains(2) && player2.contains(3)){ + winner = 2 + } + //row2 + if (player1.contains(4) && player1.contains(5) && player1.contains(6)){ + winner = 1 + } + if (player2.contains(4) && player2.contains(5) && player2.contains(6)){ + winner = 2 + } + //row3 + if (player1.contains(7) && player1.contains(8) && player1.contains(9)){ + winner = 1 + } + if (player2.contains(7) && player2.contains(8) && player2.contains(9)){ + winner = 2 + } + //col1 + if (player1.contains(1) && player1.contains(4) && player1.contains(7)){ + winner = 1 + } + if (player2.contains(1) && player2.contains(4) && player2.contains(7)){ + winner = 2 + } + //col2 + if (player1.contains(2) && player1.contains(5) && player1.contains(8)){ + winner = 1 + } + if (player2.contains(2) && player2.contains(5) && player2.contains(8)){ + winner = 2 + } + //col3 + if (player1.contains(3) && player1.contains(6) && player1.contains(9)){ + winner = 1 + } + if (player2.contains(3) && player2.contains(6) && player2.contains(9)){ + winner = 2 + } + //dig1 + if (player1.contains(1) && player1.contains(5) && player1.contains(9)){ + winner = 1 + } + if (player2.contains(1) && player2.contains(5) && player2.contains(9)){ + winner = 2 + } + //dig2 + if (player1.contains(3) && player1.contains(5) && player1.contains(7)){ + winner = 1 + } + if (player2.contains(3) && player2.contains(5) && player2.contains(7)){ + winner = 2 + } + + if winner != 0{ + var showThis = "" + if winner == 1{ + showThis = "Player 1 won" + }else{ + showThis = "Player 2 won" + } + //alertMessage + let alert = UIAlertController(title: "Winner", message: showThis, preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "Restart", style: UIAlertActionStyle.default){ + action -> Void in + self.restart() + }) + self.present(alert, animated: true, completion: nil) + } + } +} + +