From 000af456e3fbf3964b087fcb89d2d98109947cd6 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:46:41 +0000 Subject: [PATCH] forgot to add files --- CookieSwifter.xcodeproj/project.pbxproj | 630 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcschemes/CookieSwifter.xcscheme | 102 +++ CookieSwifter/AchievementsView.swift | 59 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 85 +++ CookieSwifter/Assets.xcassets/Contents.json | 6 + CookieSwifter/ContentView.swift | 250 +++++++ CookieSwifter/CookieGame.swift | 211 ++++++ CookieSwifter/CookieSwifter.entitlements | 10 + CookieSwifter/CookieSwifterApp.swift | 21 + .../Preview Assets.xcassets/Contents.json | 6 + CookieSwifterTests/CookieSwifterTests.swift | 35 + .../CookieSwifterUITests.swift | 41 ++ .../CookieSwifterUITestsLaunchTests.swift | 32 + 16 files changed, 1514 insertions(+) create mode 100644 CookieSwifter.xcodeproj/project.pbxproj create mode 100644 CookieSwifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 CookieSwifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 CookieSwifter.xcodeproj/xcshareddata/xcschemes/CookieSwifter.xcscheme create mode 100644 CookieSwifter/AchievementsView.swift create mode 100644 CookieSwifter/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 CookieSwifter/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 CookieSwifter/Assets.xcassets/Contents.json create mode 100644 CookieSwifter/ContentView.swift create mode 100644 CookieSwifter/CookieGame.swift create mode 100644 CookieSwifter/CookieSwifter.entitlements create mode 100644 CookieSwifter/CookieSwifterApp.swift create mode 100644 CookieSwifter/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 CookieSwifterTests/CookieSwifterTests.swift create mode 100644 CookieSwifterUITests/CookieSwifterUITests.swift create mode 100644 CookieSwifterUITests/CookieSwifterUITestsLaunchTests.swift diff --git a/CookieSwifter.xcodeproj/project.pbxproj b/CookieSwifter.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f236299 --- /dev/null +++ b/CookieSwifter.xcodeproj/project.pbxproj @@ -0,0 +1,630 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + A9E3415F2D233C3B007F2246 /* CookieSwifterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E3415E2D233C3B007F2246 /* CookieSwifterApp.swift */; }; + A9E341612D233C3B007F2246 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E341602D233C3B007F2246 /* ContentView.swift */; }; + A9E341652D233C43007F2246 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9E341642D233C43007F2246 /* Assets.xcassets */; }; + A9E341692D233C43007F2246 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9E341682D233C43007F2246 /* Preview Assets.xcassets */; }; + A9E341732D233C44007F2246 /* CookieSwifterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E341722D233C44007F2246 /* CookieSwifterTests.swift */; }; + A9E3417D2D233C44007F2246 /* CookieSwifterUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E3417C2D233C44007F2246 /* CookieSwifterUITests.swift */; }; + A9E3417F2D233C44007F2246 /* CookieSwifterUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E3417E2D233C44007F2246 /* CookieSwifterUITestsLaunchTests.swift */; }; + A9E3418D2D233D11007F2246 /* CookieGame.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E3418B2D233D10007F2246 /* CookieGame.swift */; }; + A9E3418E2D233D11007F2246 /* AchievementsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9E3418C2D233D10007F2246 /* AchievementsView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + A9E3416F2D233C44007F2246 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A9E341532D233C3B007F2246 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A9E3415A2D233C3B007F2246; + remoteInfo = CookieSwifter; + }; + A9E341792D233C44007F2246 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A9E341532D233C3B007F2246 /* Project object */; + proxyType = 1; + remoteGlobalIDString = A9E3415A2D233C3B007F2246; + remoteInfo = CookieSwifter; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + A9E3415B2D233C3B007F2246 /* CookieSwifter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CookieSwifter.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A9E3415E2D233C3B007F2246 /* CookieSwifterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieSwifterApp.swift; sourceTree = ""; }; + A9E341602D233C3B007F2246 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + A9E341642D233C43007F2246 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A9E341662D233C43007F2246 /* CookieSwifter.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CookieSwifter.entitlements; sourceTree = ""; }; + A9E341682D233C43007F2246 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + A9E3416E2D233C44007F2246 /* CookieSwifterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CookieSwifterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + A9E341722D233C44007F2246 /* CookieSwifterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieSwifterTests.swift; sourceTree = ""; }; + A9E341782D233C44007F2246 /* CookieSwifterUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CookieSwifterUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + A9E3417C2D233C44007F2246 /* CookieSwifterUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieSwifterUITests.swift; sourceTree = ""; }; + A9E3417E2D233C44007F2246 /* CookieSwifterUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CookieSwifterUITestsLaunchTests.swift; sourceTree = ""; }; + A9E3418B2D233D10007F2246 /* CookieGame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CookieGame.swift; sourceTree = ""; }; + A9E3418C2D233D10007F2246 /* AchievementsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AchievementsView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A9E341582D233C3B007F2246 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E3416B2D233C44007F2246 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E341752D233C44007F2246 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A9E341522D233C3B007F2246 = { + isa = PBXGroup; + children = ( + A9E3415D2D233C3B007F2246 /* CookieSwifter */, + A9E341712D233C44007F2246 /* CookieSwifterTests */, + A9E3417B2D233C44007F2246 /* CookieSwifterUITests */, + A9E3415C2D233C3B007F2246 /* Products */, + ); + sourceTree = ""; + }; + A9E3415C2D233C3B007F2246 /* Products */ = { + isa = PBXGroup; + children = ( + A9E3415B2D233C3B007F2246 /* CookieSwifter.app */, + A9E3416E2D233C44007F2246 /* CookieSwifterTests.xctest */, + A9E341782D233C44007F2246 /* CookieSwifterUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + A9E3415D2D233C3B007F2246 /* CookieSwifter */ = { + isa = PBXGroup; + children = ( + A9E3415E2D233C3B007F2246 /* CookieSwifterApp.swift */, + A9E341602D233C3B007F2246 /* ContentView.swift */, + A9E3418C2D233D10007F2246 /* AchievementsView.swift */, + A9E3418B2D233D10007F2246 /* CookieGame.swift */, + A9E341642D233C43007F2246 /* Assets.xcassets */, + A9E341662D233C43007F2246 /* CookieSwifter.entitlements */, + A9E341672D233C43007F2246 /* Preview Content */, + ); + path = CookieSwifter; + sourceTree = ""; + }; + A9E341672D233C43007F2246 /* Preview Content */ = { + isa = PBXGroup; + children = ( + A9E341682D233C43007F2246 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + A9E341712D233C44007F2246 /* CookieSwifterTests */ = { + isa = PBXGroup; + children = ( + A9E341722D233C44007F2246 /* CookieSwifterTests.swift */, + ); + path = CookieSwifterTests; + sourceTree = ""; + }; + A9E3417B2D233C44007F2246 /* CookieSwifterUITests */ = { + isa = PBXGroup; + children = ( + A9E3417C2D233C44007F2246 /* CookieSwifterUITests.swift */, + A9E3417E2D233C44007F2246 /* CookieSwifterUITestsLaunchTests.swift */, + ); + path = CookieSwifterUITests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A9E3415A2D233C3B007F2246 /* CookieSwifter */ = { + isa = PBXNativeTarget; + buildConfigurationList = A9E341822D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifter" */; + buildPhases = ( + A9E341572D233C3B007F2246 /* Sources */, + A9E341582D233C3B007F2246 /* Frameworks */, + A9E341592D233C3B007F2246 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CookieSwifter; + productName = CookieSwifter; + productReference = A9E3415B2D233C3B007F2246 /* CookieSwifter.app */; + productType = "com.apple.product-type.application"; + }; + A9E3416D2D233C44007F2246 /* CookieSwifterTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A9E341852D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifterTests" */; + buildPhases = ( + A9E3416A2D233C44007F2246 /* Sources */, + A9E3416B2D233C44007F2246 /* Frameworks */, + A9E3416C2D233C44007F2246 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A9E341702D233C44007F2246 /* PBXTargetDependency */, + ); + name = CookieSwifterTests; + productName = CookieSwifterTests; + productReference = A9E3416E2D233C44007F2246 /* CookieSwifterTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + A9E341772D233C44007F2246 /* CookieSwifterUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = A9E341882D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifterUITests" */; + buildPhases = ( + A9E341742D233C44007F2246 /* Sources */, + A9E341752D233C44007F2246 /* Frameworks */, + A9E341762D233C44007F2246 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + A9E3417A2D233C44007F2246 /* PBXTargetDependency */, + ); + name = CookieSwifterUITests; + productName = CookieSwifterUITests; + productReference = A9E341782D233C44007F2246 /* CookieSwifterUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A9E341532D233C3B007F2246 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1540; + LastUpgradeCheck = 1540; + TargetAttributes = { + A9E3415A2D233C3B007F2246 = { + CreatedOnToolsVersion = 15.4; + }; + A9E3416D2D233C44007F2246 = { + CreatedOnToolsVersion = 15.4; + TestTargetID = A9E3415A2D233C3B007F2246; + }; + A9E341772D233C44007F2246 = { + CreatedOnToolsVersion = 15.4; + TestTargetID = A9E3415A2D233C3B007F2246; + }; + }; + }; + buildConfigurationList = A9E341562D233C3B007F2246 /* Build configuration list for PBXProject "CookieSwifter" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A9E341522D233C3B007F2246; + productRefGroup = A9E3415C2D233C3B007F2246 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A9E3415A2D233C3B007F2246 /* CookieSwifter */, + A9E3416D2D233C44007F2246 /* CookieSwifterTests */, + A9E341772D233C44007F2246 /* CookieSwifterUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A9E341592D233C3B007F2246 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A9E341692D233C43007F2246 /* Preview Assets.xcassets in Resources */, + A9E341652D233C43007F2246 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E3416C2D233C44007F2246 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E341762D233C44007F2246 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A9E341572D233C3B007F2246 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A9E3418E2D233D11007F2246 /* AchievementsView.swift in Sources */, + A9E3418D2D233D11007F2246 /* CookieGame.swift in Sources */, + A9E341612D233C3B007F2246 /* ContentView.swift in Sources */, + A9E3415F2D233C3B007F2246 /* CookieSwifterApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E3416A2D233C44007F2246 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A9E341732D233C44007F2246 /* CookieSwifterTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A9E341742D233C44007F2246 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A9E3417D2D233C44007F2246 /* CookieSwifterUITests.swift in Sources */, + A9E3417F2D233C44007F2246 /* CookieSwifterUITestsLaunchTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + A9E341702D233C44007F2246 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A9E3415A2D233C3B007F2246 /* CookieSwifter */; + targetProxy = A9E3416F2D233C44007F2246 /* PBXContainerItemProxy */; + }; + A9E3417A2D233C44007F2246 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = A9E3415A2D233C3B007F2246 /* CookieSwifter */; + targetProxy = A9E341792D233C44007F2246 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + A9E341802D233C44007F2246 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + A9E341812D233C44007F2246 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + A9E341832D233C44007F2246 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = CookieSwifter/CookieSwifter.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"CookieSwifter/Preview Content\""; + DEVELOPMENT_TEAM = 8626DL2GW3; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A9E341842D233C44007F2246 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = CookieSwifter/CookieSwifter.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"CookieSwifter/Preview Content\""; + DEVELOPMENT_TEAM = 8626DL2GW3; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; + "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; + "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + A9E341862D233C44007F2246 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8626DL2GW3; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifterTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CookieSwifter.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/CookieSwifter"; + }; + name = Debug; + }; + A9E341872D233C44007F2246 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8626DL2GW3; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifterTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CookieSwifter.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/CookieSwifter"; + }; + name = Release; + }; + A9E341892D233C44007F2246 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8626DL2GW3; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifterUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = CookieSwifter; + }; + name = Debug; + }; + A9E3418A2D233C44007F2246 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 8626DL2GW3; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.5; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.neon443.CookieSwifterUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = auto; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = CookieSwifter; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A9E341562D233C3B007F2246 /* Build configuration list for PBXProject "CookieSwifter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A9E341802D233C44007F2246 /* Debug */, + A9E341812D233C44007F2246 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A9E341822D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A9E341832D233C44007F2246 /* Debug */, + A9E341842D233C44007F2246 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A9E341852D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifterTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A9E341862D233C44007F2246 /* Debug */, + A9E341872D233C44007F2246 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A9E341882D233C44007F2246 /* Build configuration list for PBXNativeTarget "CookieSwifterUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A9E341892D233C44007F2246 /* Debug */, + A9E3418A2D233C44007F2246 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A9E341532D233C3B007F2246 /* Project object */; +} diff --git a/CookieSwifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CookieSwifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/CookieSwifter.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CookieSwifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CookieSwifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/CookieSwifter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/CookieSwifter.xcodeproj/xcshareddata/xcschemes/CookieSwifter.xcscheme b/CookieSwifter.xcodeproj/xcshareddata/xcschemes/CookieSwifter.xcscheme new file mode 100644 index 0000000..e787145 --- /dev/null +++ b/CookieSwifter.xcodeproj/xcshareddata/xcschemes/CookieSwifter.xcscheme @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CookieSwifter/AchievementsView.swift b/CookieSwifter/AchievementsView.swift new file mode 100644 index 0000000..88d1aab --- /dev/null +++ b/CookieSwifter/AchievementsView.swift @@ -0,0 +1,59 @@ +// +// AchievementsView.swift +// CookieSwifter +// +// Created by Nihaal Sharma on 28/12/2024. +// + +import SwiftUI + +struct AchievementButton: View { + @ObservedObject var game: CookieGame + @Binding var showAchievements: Bool + + var body: some View { + VStack(spacing: 10) { + Button(action: { + showAchievements.toggle() + }) { + Text("\(game.achievements.count) Achievements") + .font(.title3) + .padding(5) + .background(Color.purple.opacity(0.2)) + .cornerRadius(10) + } + .sheet(isPresented: $showAchievements) { + AchievementsView(achievements: game.achievements) + } + } + } +} +struct AchievementsView: View { + let achievements: [Achievement] + + var body: some View { + NavigationView { + List(achievements, id: \.title) { achievement in + VStack(alignment: .leading) { + Text(achievement.title) + .font(.headline) + Text(achievement.description) + .font(.subheadline) + .foregroundColor(.gray) + } + } + .navigationTitle("Achievements") + } + } +} + +#Preview { + AchievementsView( + achievements: [ + Achievement( + title: "Cookie Beginner", + description: "Earn 100 cookies." + ) + ] + ) +} diff --git a/CookieSwifter/Assets.xcassets/AccentColor.colorset/Contents.json b/CookieSwifter/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/CookieSwifter/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CookieSwifter/Assets.xcassets/AppIcon.appiconset/Contents.json b/CookieSwifter/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..ffdfe15 --- /dev/null +++ b/CookieSwifter/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,85 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CookieSwifter/Assets.xcassets/Contents.json b/CookieSwifter/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/CookieSwifter/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CookieSwifter/ContentView.swift b/CookieSwifter/ContentView.swift new file mode 100644 index 0000000..dfbfa1c --- /dev/null +++ b/CookieSwifter/ContentView.swift @@ -0,0 +1,250 @@ +// +// ContentView.swift +// CookieSwifter +// +// Created by Nihaal Sharma on 16/12/2024. +// + +import SwiftUI + +struct ContentView: View { + @ObservedObject var game: CookieGame + @State private var selectedSave: String? = nil + @State private var showSavedGames: Bool = false + @State private var buyQuantity: Int = 1 + @State var gameName: String + @State var showAchievemetns: Bool = false + + var body: some View { + VStack { + HStack { + Text("\(game.cookies)") + .font(.largeTitle) + .fontWeight(.bold) + Spacer() + VStack { + CookieTapView(game: game) + Text("CPS: \(game.cps)") + .font(.headline) + } + } + TabView { + VStack { + Picker("Buy", selection: $buyQuantity) { + ForEach([1, 10, 100], id: \.self) { option in + Text("\(option)").tag(option) + } + } + .pickerStyle(SegmentedPickerStyle()) + .padding(.top) + ScrollView(.vertical) { + ItemsListView(game: game, buyQuantity: $buyQuantity) + } + } + .tabItem { + Label("Items", systemImage: "star.fill") + } + + ScrollView(.vertical) { + UpgradesListView(game: game) + } + .tabItem { + Label("Upgrades", systemImage: "wand.and.stars") + } + + List { + Text("Game Name") + .font(.caption) + .bold() + TextField("", text: $gameName) + .textFieldStyle(RoundedBorderTextFieldStyle()) + Button("Save Game") { + let saveDate = "Saved \(Date().formatted())" + game.saveGame(name: gameName+saveDate) + } + + Button("Load Game") { + showSavedGames = true + } + .sheet(isPresented: $showSavedGames) { + SavedGamesListView(game: game, selectedSave: $selectedSave) + } + .onChange(of: selectedSave) { newValue in + if let saveName = newValue { + game.loadGame(named: saveName) + } + } + } + .tabItem { + Label("Settings", systemImage: "gear") + } + + ScrollView(.vertical) { + AchievementsView(achievements: game.achievements) + }.tabItem { + Label("Achievements", systemImage: "trophy.fill") + } + .badge(game.achievements.count) + } + } + } +} + +struct SavedGamesListView: View { + @ObservedObject var game: CookieGame + @Binding var selectedSave: String? + + var body: some View { + NavigationView { + List { + ForEach(game.savedGames, id: \ .name) { save in + HStack { + VStack(alignment: .leading) { + Text(save.name).font(.headline) + Text("Cookies: \(save.cookies), CPS: \(save.cps)").font(.subheadline) + Text("Items: \(save.items.count), Achievements: \(save.achievements.count)").font(.footnote) + } + Spacer() + Button("Load") { + selectedSave = save.name + } + .padding(5) + .background(Color.orange) + .foregroundColor(.white) + .cornerRadius(5) + } + } + .onDelete { indexSet in + indexSet.map { game.savedGames[$0].name }.forEach(game.deleteGame(named:)) + } + } + .navigationTitle("Saved Games") + } + } +} + +struct CookieTapView: View { + @ObservedObject var game: CookieGame + + var body: some View { + VStack { + Button(action: { + game.cookies += 1 + game.checkAchievements() + }) { + Text("🍪") + .font(.system(size: 75)) + } + } + } +} +struct ItemsListView: View { + @ObservedObject var game: CookieGame + @Binding var buyQuantity: Int + + var body: some View { + HStack { + Text("Buy") + .font(.footnote) + Spacer() + Text("Items") + .font(.footnote) + Spacer() + Text("Sell") + .font(.footnote) + } + .padding(.horizontal, 5) + VStack { + ForEach(game.items.indices, id: \.self) { index in + ItemView(game: game, buyQuantity: $buyQuantity, index: index) + } + } + } +} + +struct ItemView: View { + @ObservedObject var game: CookieGame + @Binding var buyQuantity: Int + @State var index: Int + + var body: some View { + let canBuy = !(game.cookies < game.totalCost(of: index, quantity: buyQuantity)) + let thisItem = game.items[index] + HStack(spacing: 5) { + Button(action: { + game.buyItem(at: index, quantity: buyQuantity) + }) { + HStack { + Text("\(thisItem.count) x") + Text("\(thisItem.name)") + .bold() + Text("🍪\(thisItem.cps) per second") + Spacer() + Text("🍪\(game.totalCost(of: index, quantity: buyQuantity))") + .font(.caption) + } + .padding(5) + .background(Color.blue.opacity(canBuy ? 0.5 : 0.2)) + .cornerRadius(10) + } + .disabled(!canBuy) + SellButton( + game: game, + index: $index, + buyQuantity: $buyQuantity + ) + } + } +} + +struct SellButton: View { + @ObservedObject var game: CookieGame + @Binding var index: Int + @Binding var buyQuantity: Int + + var body: some View { + let canSell = !(game.items[index].count < buyQuantity) + Button(action: { + game.sellItem(at: index, quantity: buyQuantity) + }) { + Text("🍪\(game.totalCost(of: index, quantity: buyQuantity) / 2)") + .padding(5) + .background(Color.red.opacity(canSell ? 0.5 : 0.2)) + .cornerRadius(10) + .font(.caption) + } + .disabled(!canSell) + } +} + + +struct UpgradesListView: View { + @ObservedObject var game: CookieGame + + var body: some View { + VStack(spacing: 10) { + ForEach(game.upgrades.indices, id: \.self) { index in + let thisUpgrade = game.upgrades[index] + Button(action: { + game.purchaseUpgrade(at: index) + }) { + HStack { + Text(thisUpgrade.name) + .bold() + Text(thisUpgrade.description) + Spacer() + Text("🍪\(thisUpgrade.cost)") + } + .padding(5) + .background(thisUpgrade.isPurchased ? Color.green.opacity(0.2) : Color.gray.opacity(0.2)) + .cornerRadius(10) + } + .disabled(game.cookies < game.upgrades[index].cost || game.upgrades[index].isPurchased) + } + } + } +} + +#Preview { + ContentView(game: CookieGame(), gameName: "Preview Bakery") +} diff --git a/CookieSwifter/CookieGame.swift b/CookieSwifter/CookieGame.swift new file mode 100644 index 0000000..37dc085 --- /dev/null +++ b/CookieSwifter/CookieGame.swift @@ -0,0 +1,211 @@ +// +// CookieGame.swift +// CookieSwifter +// +// Created by Nihaal Sharma on 16/12/2024. +// + + +import Foundation + +class CookieGame: ObservableObject { + @Published var cookies: Int = 0 + @Published var cps: Int = 0 + @Published var savedGames: [SavedGame] = [] + @Published var items: [Item] = [ + Item(name: "Finger", cps: 1, baseCost: 10, count: 0), + Item(name: "Chef", cps: 4, baseCost: 50, count: 0), + Item(name: "Farm", cps: 16, baseCost: 200, count: 0), + Item(name: "Mine", cps: 64, baseCost: 800, count: 0), + Item(name: "Factory", cps: 256, baseCost: 3200, count: 0), + Item(name: "Bank", cps: 1024, baseCost: 12800, count: 0) + ] + @Published var upgrades: [Upgrade] = [ + Upgrade(name: "Golden Finger", description: "Double the CPS of fingers.", cost: 500, appliesTo: "Finger", isPurchased: false), + Upgrade(name: "Farm Efficiency", description: "Farms are 50% more efficient.", cost: 2000, appliesTo: "Farm", isPurchased: false), + Upgrade(name: "Double the Dough", description: "Doubles the CPS of all items.", cost: 10000, appliesTo: "All", isPurchased: false), + Upgrade(name: "Banker’s Delight", description: "Banks generate 2x cookies.", cost: 50000, appliesTo: "Bank", isPurchased: false), + Upgrade(name: "Efficient Farms", description: "Farms are 10% cheaper.", cost: 15000, appliesTo: "Farm", isPurchased: false), + Upgrade(name: "Factory Booster", description: "Factories are 50% more efficient.", cost: 100000, appliesTo: "Factory", isPurchased: false), + Upgrade(name: "Golden Era", description: "Triple CPS for 30 seconds.", cost: 200000, appliesTo: "Temporary", isPurchased: false) + ] + @Published var achievements: [Achievement] = [] + + private let saveKey = "CookieGameSave" + var timer: Timer? + + func saveGame(name: String) { + let save = SavedGame( + name: name, + cookies: cookies, + cps: cps, + items: items, + achievements: achievements + ) + savedGames.append(save) + persistSavedGames() + } + + func loadGame(named name: String) { + guard let save = savedGames.first(where: { $0.name == name }) else { return } + cookies = save.cookies + cps = save.cps + items = save.items + achievements = save.achievements + } + + func deleteGame(named name: String) { + savedGames.removeAll { $0.name == name } + persistSavedGames() + } + + private func persistSavedGames() { + if let data = try? JSONEncoder().encode(savedGames) { + UserDefaults.standard.set(data, forKey: saveKey) + } + } + + func loadSavedGames() { + guard let data = UserDefaults.standard.data(forKey: saveKey), + let saves = try? JSONDecoder().decode([SavedGame].self, from: data) else { return } + savedGames = saves + } + + init() { + //FLAG: DONT REMOVE + //im so stupid + startTimer() + loadSavedGames() + } + + func startTimer() { + if timer == nil { + timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in + DispatchQueue.main.async { + self.cookies += self.cps + self.checkAchievements() + } + } + } + } + + func buyItem(at index: Int, quantity: Int) { + let cost = totalCost(of: index, quantity: quantity) + guard cookies >= cost else { return } + + cookies -= cost + items[index].count += quantity + cps += items[index].cps * quantity + } + + func sellItem(at index: Int, quantity: Int) { + print("selling \(quantity) of \(index) which is \(items[index ])") + guard items[index].count >= quantity else { return } + + items[index].count -= quantity + cps -= items[index].cps * quantity + let sellValue = totalCost(of: index, quantity: quantity) / 2 + cookies += sellValue + } + + func purchaseUpgrade(at index: Int) { + let upgrade = upgrades[index] + guard cookies >= upgrade.cost, !upgrade.isPurchased else { return } + + if upgrade.appliesTo == "All" { + for i in items.indices { + items[i].cps *= 2 + } + cps = items.reduce(0) { $0 + $1.cps * $1.count } + } else if upgrade.appliesTo == "Temporary" { + DispatchQueue.main.asyncAfter(deadline: .now() + 30) { + self.cps /= 3 + } + cps *= 3 + } else if let itemIndex = items.firstIndex(where: { $0.name == upgrade.appliesTo }) { + var item = items[itemIndex] + if upgrade.name.contains("Efficien") { + item.cps = Int(Double(item.cps) * 1.5) + } else { + item.cps *= 2 + } + } + + cookies -= upgrade.cost + upgrades[index].isPurchased = true + } + + func totalCost(of index: Int, quantity: Int) -> Int { + var total = 0 + for i in 0..= 100, + "Cookie Enthusiast" where cookies >= 10000, + "Master Baker" where cookies >= 1000000, + "Quick Clicker" where cps >= 100, + "Investment Master" where items.allSatisfy({ $0.count >= 10 }), + "Upgrade Collector" where upgrades.allSatisfy({ $0.isPurchased }), + "Ultimate Tycoon" where cookies >= 10000000000: + achievements.append(achievement) + default: + continue + } + } + } + } +} + +// MARK: - Game State for Saving +struct GameState: Codable { + let cookies: Int + let cps: Int + let items: [Item] + let upgrades: [Upgrade] + let achievements: [Achievement] +} + +struct Item: Codable { + let name: String + var cps: Int + let baseCost: Int + var count: Int +} + +struct Upgrade: Codable { + let name: String + let description: String + let cost: Int + let appliesTo: String + var isPurchased: Bool +} + +struct Achievement: Codable { + let title: String + let description: String +} + +struct SavedGame: Codable { + let name: String + let cookies: Int + let cps: Int + let items: [Item] + let achievements: [Achievement] +} diff --git a/CookieSwifter/CookieSwifter.entitlements b/CookieSwifter/CookieSwifter.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/CookieSwifter/CookieSwifter.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/CookieSwifter/CookieSwifterApp.swift b/CookieSwifter/CookieSwifterApp.swift new file mode 100644 index 0000000..5f06762 --- /dev/null +++ b/CookieSwifter/CookieSwifterApp.swift @@ -0,0 +1,21 @@ +// +// CookieSwifterApp.swift +// CookieSwifter +// +// Created by Nihaal Sharma on 16/12/2024. +// + +import SwiftUI + +@main +struct CookieSwifterApp: App { + let listOfNames = ["John", "Jane", "Alex", "Chris", "Taylor", "Morgan", "Emily", "Joshua", "Sophie", "Lucas", "Olivia", "Liam", "Isabella", "Ethan", "Amelia", "Aiden", "Mia", "James", "Charlotte", "Benjamin", "Ava", "Henry", "Ella", "Samuel", "Grace", "Daniel", "Zoe", "Matthew", "Madeline", "Ryan", "Chloe", "Michael", "Leah", "William", "Hannah", "David", "Scarlett", "Jack", "Victoria", "Noah", "Lily", "Gabriel", "Sophia", "Caleb", "Harper", "Mason", "Lillian", "Nathan", "Eleanor", "Jacob", "Ruby", "Isaac", "Harper", "Jackson", "Abigail", "Charlotte", "Oliver", "Ella", "Scarlett", "Henry", "Evelyn", "Elijah", "Aria", "Mason", "Amos", "Leo", "Luna", "Zachary", "Hazel", "Samuel", "Nora", "Owen", "Anna"] + var body: some Scene { + WindowGroup { + ContentView( + game: CookieGame(), + gameName: (listOfNames.randomElement() ?? "Bob") + "'s Bakery" + ) + } + } +} diff --git a/CookieSwifter/Preview Content/Preview Assets.xcassets/Contents.json b/CookieSwifter/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/CookieSwifter/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CookieSwifterTests/CookieSwifterTests.swift b/CookieSwifterTests/CookieSwifterTests.swift new file mode 100644 index 0000000..f8f3255 --- /dev/null +++ b/CookieSwifterTests/CookieSwifterTests.swift @@ -0,0 +1,35 @@ +// +// CookieSwifterTests.swift +// CookieSwifterTests +// +// Created by Nihaal Sharma on 30/12/2024. +// + +import XCTest + +final class CookieSwifterTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/CookieSwifterUITests/CookieSwifterUITests.swift b/CookieSwifterUITests/CookieSwifterUITests.swift new file mode 100644 index 0000000..c603c89 --- /dev/null +++ b/CookieSwifterUITests/CookieSwifterUITests.swift @@ -0,0 +1,41 @@ +// +// CookieSwifterUITests.swift +// CookieSwifterUITests +// +// Created by Nihaal Sharma on 30/12/2024. +// + +import XCTest + +final class CookieSwifterUITests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } + } +} diff --git a/CookieSwifterUITests/CookieSwifterUITestsLaunchTests.swift b/CookieSwifterUITests/CookieSwifterUITestsLaunchTests.swift new file mode 100644 index 0000000..2927daa --- /dev/null +++ b/CookieSwifterUITests/CookieSwifterUITestsLaunchTests.swift @@ -0,0 +1,32 @@ +// +// CookieSwifterUITestsLaunchTests.swift +// CookieSwifterUITests +// +// Created by Nihaal Sharma on 30/12/2024. +// + +import XCTest + +final class CookieSwifterUITestsLaunchTests: XCTestCase { + + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + } + + func testLaunch() throws { + let app = XCUIApplication() + app.launch() + + // Insert steps here to perform after app launch but before taking a screenshot, + // such as logging into a test account or navigating somewhere in the app + + let attachment = XCTAttachment(screenshot: app.screenshot()) + attachment.name = "Launch Screen" + attachment.lifetime = .keepAlways + add(attachment) + } +}