From a00d0ca11195e970242b95497fda6422d2abf82d Mon Sep 17 00:00:00 2001 From: pjht Date: Sat, 24 Feb 2018 16:21:29 -0600 Subject: [PATCH] Initial Commit --- Munchkin.xcodeproj/project.pbxproj | 348 +++++ .../contents.xcworkspacedata | 7 + .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 + .../xcschemes/xcschememanagement.plist | 14 + Munchkin/Ability.swift | 22 + Munchkin/AffectsSelectController.swift | 37 + Munchkin/AppDelegate.swift | 26 + .../AppIcon.appiconset/Contents.json | 58 + Munchkin/Base.lproj/Main.storyboard | 1184 +++++++++++++++++ Munchkin/Card.swift | 132 ++ Munchkin/CardSelectController.swift | 34 + Munchkin/CardType.swift | 20 + Munchkin/Global.swift | 42 + Munchkin/Info.plist | 32 + Munchkin/Munchkin.entitlements | 10 + Munchkin/Side.swift | 14 + Munchkin/ViewController.swift | 298 +++++ Munchkin/WeaponKind.swift | 18 + 18 files changed, 2301 insertions(+) create mode 100644 Munchkin.xcodeproj/project.pbxproj create mode 100644 Munchkin.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 Munchkin/Ability.swift create mode 100644 Munchkin/AffectsSelectController.swift create mode 100644 Munchkin/AppDelegate.swift create mode 100644 Munchkin/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Munchkin/Base.lproj/Main.storyboard create mode 100644 Munchkin/Card.swift create mode 100644 Munchkin/CardSelectController.swift create mode 100644 Munchkin/CardType.swift create mode 100644 Munchkin/Global.swift create mode 100644 Munchkin/Info.plist create mode 100644 Munchkin/Munchkin.entitlements create mode 100644 Munchkin/Side.swift create mode 100644 Munchkin/ViewController.swift create mode 100644 Munchkin/WeaponKind.swift diff --git a/Munchkin.xcodeproj/project.pbxproj b/Munchkin.xcodeproj/project.pbxproj new file mode 100644 index 0000000..fa2660e --- /dev/null +++ b/Munchkin.xcodeproj/project.pbxproj @@ -0,0 +1,348 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + F60F50F52041EB7C001D861C /* Ability.swift in Sources */ = {isa = PBXBuildFile; fileRef = F60F50F42041EB7C001D861C /* Ability.swift */; }; + F668975F204217D900D60FE4 /* WeaponKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = F668975E204217D900D60FE4 /* WeaponKind.swift */; }; + F69E99782040D40900053141 /* Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = F69E99772040D40900053141 /* Card.swift */; }; + F69E997A2040D4AD00053141 /* CardType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F69E99792040D4AD00053141 /* CardType.swift */; }; + F69E997C2040D53300053141 /* Side.swift in Sources */ = {isa = PBXBuildFile; fileRef = F69E997B2040D53300053141 /* Side.swift */; }; + F69E997E2040D81000053141 /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = F69E997D2040D81000053141 /* Global.swift */; }; + F6E73F7D2040E3FC005C6A28 /* CardSelectController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6E73F7C2040E3FC005C6A28 /* CardSelectController.swift */; }; + F6EEFA112041C9F4006EA9A6 /* AffectsSelectController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6EEFA102041C9F4006EA9A6 /* AffectsSelectController.swift */; }; + F6F931AC203F067100B50CAC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6F931AB203F067100B50CAC /* AppDelegate.swift */; }; + F6F931AE203F067100B50CAC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6F931AD203F067100B50CAC /* ViewController.swift */; }; + F6F931B0203F067100B50CAC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F6F931AF203F067100B50CAC /* Assets.xcassets */; }; + F6F931B3203F067100B50CAC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F6F931B1203F067100B50CAC /* Main.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + F60F50F42041EB7C001D861C /* Ability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Ability.swift; sourceTree = ""; }; + F668975E204217D900D60FE4 /* WeaponKind.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeaponKind.swift; sourceTree = ""; }; + F69E99772040D40900053141 /* Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = ""; }; + F69E99792040D4AD00053141 /* CardType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardType.swift; sourceTree = ""; }; + F69E997B2040D53300053141 /* Side.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Side.swift; sourceTree = ""; }; + F69E997D2040D81000053141 /* Global.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Global.swift; sourceTree = ""; }; + F6E73F7C2040E3FC005C6A28 /* CardSelectController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardSelectController.swift; sourceTree = ""; }; + F6EEFA102041C9F4006EA9A6 /* AffectsSelectController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AffectsSelectController.swift; sourceTree = ""; }; + F6F931A8203F067100B50CAC /* Munchkin.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Munchkin.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F6F931AB203F067100B50CAC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + F6F931AD203F067100B50CAC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + F6F931AF203F067100B50CAC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + F6F931B2203F067100B50CAC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + F6F931B4203F067100B50CAC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F6F931B5203F067100B50CAC /* Munchkin.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Munchkin.entitlements; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F6F931A5203F067100B50CAC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F6F9319F203F067100B50CAC = { + isa = PBXGroup; + children = ( + F6F931AA203F067100B50CAC /* Munchkin */, + F6F931A9203F067100B50CAC /* Products */, + ); + sourceTree = ""; + }; + F6F931A9203F067100B50CAC /* Products */ = { + isa = PBXGroup; + children = ( + F6F931A8203F067100B50CAC /* Munchkin.app */, + ); + name = Products; + sourceTree = ""; + }; + F6F931AA203F067100B50CAC /* Munchkin */ = { + isa = PBXGroup; + children = ( + F6F931AB203F067100B50CAC /* AppDelegate.swift */, + F6F931AD203F067100B50CAC /* ViewController.swift */, + F6E73F7C2040E3FC005C6A28 /* CardSelectController.swift */, + F6EEFA102041C9F4006EA9A6 /* AffectsSelectController.swift */, + F6F931AF203F067100B50CAC /* Assets.xcassets */, + F6F931B1203F067100B50CAC /* Main.storyboard */, + F6F931B4203F067100B50CAC /* Info.plist */, + F6F931B5203F067100B50CAC /* Munchkin.entitlements */, + F69E99772040D40900053141 /* Card.swift */, + F69E997D2040D81000053141 /* Global.swift */, + F69E997B2040D53300053141 /* Side.swift */, + F69E99792040D4AD00053141 /* CardType.swift */, + F60F50F42041EB7C001D861C /* Ability.swift */, + F668975E204217D900D60FE4 /* WeaponKind.swift */, + ); + path = Munchkin; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F6F931A7203F067100B50CAC /* Munchkin */ = { + isa = PBXNativeTarget; + buildConfigurationList = F6F931B8203F067100B50CAC /* Build configuration list for PBXNativeTarget "Munchkin" */; + buildPhases = ( + F6F931A4203F067100B50CAC /* Sources */, + F6F931A5203F067100B50CAC /* Frameworks */, + F6F931A6203F067100B50CAC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Munchkin; + productName = Munchkin; + productReference = F6F931A8203F067100B50CAC /* Munchkin.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F6F931A0203F067100B50CAC /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = "Peter Terpstra"; + TargetAttributes = { + F6F931A7203F067100B50CAC = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = F6F931A3203F067100B50CAC /* Build configuration list for PBXProject "Munchkin" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = F6F9319F203F067100B50CAC; + productRefGroup = F6F931A9203F067100B50CAC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F6F931A7203F067100B50CAC /* Munchkin */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F6F931A6203F067100B50CAC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F6F931B0203F067100B50CAC /* Assets.xcassets in Resources */, + F6F931B3203F067100B50CAC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F6F931A4203F067100B50CAC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F6EEFA112041C9F4006EA9A6 /* AffectsSelectController.swift in Sources */, + F60F50F52041EB7C001D861C /* Ability.swift in Sources */, + F6F931AE203F067100B50CAC /* ViewController.swift in Sources */, + F69E997A2040D4AD00053141 /* CardType.swift in Sources */, + F69E997C2040D53300053141 /* Side.swift in Sources */, + F668975F204217D900D60FE4 /* WeaponKind.swift in Sources */, + F69E997E2040D81000053141 /* Global.swift in Sources */, + F6E73F7D2040E3FC005C6A28 /* CardSelectController.swift in Sources */, + F69E99782040D40900053141 /* Card.swift in Sources */, + F6F931AC203F067100B50CAC /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + F6F931B1203F067100B50CAC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F6F931B2203F067100B50CAC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + F6F931B6203F067100B50CAC /* 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 = "-"; + 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; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + F6F931B7203F067100B50CAC /* 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 = "-"; + 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; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + F6F931B9203F067100B50CAC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Munchkin/Munchkin.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Munchkin/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = peterterpstra.Munchkin; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Debug; + }; + F6F931BA203F067100B50CAC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Munchkin/Munchkin.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Munchkin/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = peterterpstra.Munchkin; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F6F931A3203F067100B50CAC /* Build configuration list for PBXProject "Munchkin" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F6F931B6203F067100B50CAC /* Debug */, + F6F931B7203F067100B50CAC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F6F931B8203F067100B50CAC /* Build configuration list for PBXNativeTarget "Munchkin" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F6F931B9203F067100B50CAC /* Debug */, + F6F931BA203F067100B50CAC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F6F931A0203F067100B50CAC /* Project object */; +} diff --git a/Munchkin.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Munchkin.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..5bd8a9c --- /dev/null +++ b/Munchkin.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcschemes/xcschememanagement.plist b/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..95a6e5e --- /dev/null +++ b/Munchkin.xcodeproj/xcuserdata/peterterpstra.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Munchkin.xcscheme + + orderHint + 0 + + + + diff --git a/Munchkin/Ability.swift b/Munchkin/Ability.swift new file mode 100644 index 0000000..72e5f50 --- /dev/null +++ b/Munchkin/Ability.swift @@ -0,0 +1,22 @@ +// +// Ability.swift +// Munchkin +// +// Created by Peter Terpstra on 2/24/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +class Ability { + var type: String + var properties: [String:Any]? + init(type: String) { + self.type = type + properties = nil + } + init(type: String, properties: [String:Any]) { + self.type = type + self.properties = properties + } +} diff --git a/Munchkin/AffectsSelectController.swift b/Munchkin/AffectsSelectController.swift new file mode 100644 index 0000000..29fc274 --- /dev/null +++ b/Munchkin/AffectsSelectController.swift @@ -0,0 +1,37 @@ +// +// AffectsSelectController.swift +// Munchkin +// +// Created by Peter Terpstra on 2/24/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Cocoa + +class AffectsSelectController: NSViewController { + + @IBOutlet weak var affectsMenu: NSPopUpButton! + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + + @IBAction func setButtonClicked(_ sender: Any) { + if affectsMenu.titleOfSelectedItem != nil && currentCard != nil { + let selection = affectsMenu.titleOfSelectedItem! + let card = currentCard! + switch (selection) { + case "Player": + card.affects=Side.Player + case "Monster": + card.affects=Side.Monster + default: break + } + playCards.append(card) + NotificationCenter.default.post(name: Notification.Name(rawValue: "update"), object: self) + currentCard=nil + self.dismiss(self) + } + } +} diff --git a/Munchkin/AppDelegate.swift b/Munchkin/AppDelegate.swift new file mode 100644 index 0000000..426ea95 --- /dev/null +++ b/Munchkin/AppDelegate.swift @@ -0,0 +1,26 @@ +// +// AppDelegate.swift +// Munchkin +// +// Created by Peter Terpstra on 2/22/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } + + +} + diff --git a/Munchkin/Assets.xcassets/AppIcon.appiconset/Contents.json b/Munchkin/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/Munchkin/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Munchkin/Base.lproj/Main.storyboard b/Munchkin/Base.lproj/Main.storyboard new file mode 100644 index 0000000..090d311 --- /dev/null +++ b/Munchkin/Base.lproj/Main.storyboard @@ -0,0 +1,1184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Munchkin/Card.swift b/Munchkin/Card.swift new file mode 100644 index 0000000..f8972ca --- /dev/null +++ b/Munchkin/Card.swift @@ -0,0 +1,132 @@ +// +// Card.swift +// Munchkin +// +// Created by Peter Terpstra on 2/23/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +class Card { + let type: CardType + let description: String + var affects: Side? + let strength: Int? + let treasures: Int? + let abilities:[Ability]? + let big:Bool? + let kind:WeaponKind? + var affectsString: String { + get { + if affects != nil { + switch (affects!) { + case Side.Player: + return "Player" + case Side.Monster: + return "Monster" + } + } else { + return "" + } + } + } + + var strengthString: String { + get { + if strength != nil { + let strength=self.strength! + if strength > 0 { + return "+\(strength)" + } else { + return "\(strength)" + } + } else { + return "" + } + } + } + + init(description: String, abilities:[Ability],race:Bool) { + if race { + self.type=CardType.Race + } else { + self.type=CardType.Class + } + self.description=description + affects=nil + strength=nil + treasures=nil + self.abilities=abilities + self.big=nil + self.kind=nil + } + + + init(description: String, abilities:[Ability]) { + self.type=CardType.Class + self.description=description + affects=nil + strength=nil + treasures=nil + self.abilities=abilities + self.big=nil + self.kind=nil + } + + init(description: String, strength: Int) { + self.type=CardType.OneUse + self.description=description + self.strength=strength + treasures=nil + abilities=nil + self.big=nil + self.kind=nil + } + + init(description: String, strength: Int, big:Bool, kind:WeaponKind) { + self.type=CardType.OneUse + self.description=description + self.strength=strength + treasures=nil + abilities=nil + self.affects=Side.Player + self.big=big + self.kind=kind + } + + init(description: String, strength: Int, affects: Side) { + self.type=CardType.OneUse + self.description=description + self.strength=strength + self.affects=affects + treasures=nil + abilities=nil + self.big=nil + self.kind=nil + } + + init(description: String, strength: Int, treasures: Int, abilities:[Ability]) { + type=CardType.Monster + self.description=description + self.strength=strength + affects=nil + self.treasures=treasures + self.abilities=abilities + self.big=nil + self.kind=nil + } + + init(description: String, strength: Int, treasures: Int) { + self.type=CardType.Monster + self.description=description + self.strength=strength + affects=nil + self.treasures=treasures + self.abilities=nil + self.big=nil + self.kind=nil + } + + +} diff --git a/Munchkin/CardSelectController.swift b/Munchkin/CardSelectController.swift new file mode 100644 index 0000000..c972973 --- /dev/null +++ b/Munchkin/CardSelectController.swift @@ -0,0 +1,34 @@ +// +// CardSelectController.swift +// Munchkin +// +// Created by Peter Terpstra on 2/23/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Cocoa + +class CardSelectController: NSViewController { + + @IBOutlet weak var cardMenu: NSPopUpButton! + + override func viewDidLoad() { + super.viewDidLoad() + + for card in cards { + cardMenu.addItem(withTitle: card.description) + } + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + @IBAction func addButtonClicked(_ sender: Any) { + handCards.append(cards[cardMenu.indexOfSelectedItem]) + NotificationCenter.default.post(name: Notification.Name(rawValue: "update"), object: self) + } + +} diff --git a/Munchkin/CardType.swift b/Munchkin/CardType.swift new file mode 100644 index 0000000..9c957a3 --- /dev/null +++ b/Munchkin/CardType.swift @@ -0,0 +1,20 @@ +// +// CardType.swift +// Munchkin +// +// Created by Peter Terpstra on 2/23/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +enum CardType:String { + case Weapon = "Weapon" + case Curse = "Curse" + case OneUse = "One Use" + case None = "" + case Monster = "Monster" + case Item = "Item" + case Class = "Class" + case Race = "Race" +} diff --git a/Munchkin/Global.swift b/Munchkin/Global.swift new file mode 100644 index 0000000..aba02a2 --- /dev/null +++ b/Munchkin/Global.swift @@ -0,0 +1,42 @@ +// +// Global.swift +// Munchkin +// +// Created by Peter Terpstra on 2/23/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +let cards = [ + Card(description: "Freezing Explosive Potion", strength: 3), + Card(description: "Nasty Tasting Sports Drink", strength: 2), + Card(description: "Electric Radioactive Acid Potion", strength: 5), + Card(description: "Potion of Idiotic Bravery", strength: 2), + Card(description: "Magic Missile", strength: 5), + Card(description: "Flaming Poison Potion", strength: 3), + Card(description: "Sleep Potion", strength: 2), + Card(description: "Pretty Ballons", strength: 5), + Card(description: "Cotion of Ponfusion", strength: 3), + Card(description: "Potion of Halitosis", strength: 2), + Card(description: "Chainsaw of Bloody Dismemberment", strength: 3, big:false, kind: WeaponKind.TwoHands), + Card(description: "Flaming Armor", strength: 2, big:false, kind:WeaponKind.Armor), + Card(description: "Buckler of Swashing", strength: 2, big:false, kind:WeaponKind.OneHand), + Card(description: "Slimy Armor", strength: 1, big:false, kind:WeaponKind.Armor), + Card(description: "Spiky Knees", strength: 1, big:false, kind:WeaponKind.None), + Card(description: "Helm of Courage", strength: 1, big:false, kind:WeaponKind.Headgear), + Card(description: "Boots of Butt-Kicking", strength: 2, big:false, kind:WeaponKind.Footgear), + Card(description: "Eleven-Foot Pole", strength: 1, big:false, kind:WeaponKind.TwoHands), + Card(description: "Sneaky Bastard Sword", strength: 2, big:false, kind:WeaponKind.OneHand), + Card(description: "Really Impressive Title", strength: 3, big:false, kind:WeaponKind.None), + Card(description: "Huge Rock", strength: 3, big:true, kind:WeaponKind.None), + Card(description: "Leather Armor", strength: 1, big:false, kind:WeaponKind.Armor), + Card(description: "Rat on a Stick", strength: 1, big:false, kind:WeaponKind.None), + Card(description: "Baby", strength: -5, affects: Side.Monster), + Card(description: "Shrieking Geek", strength: 6, treasures: 2, abilities: [Ability(type: "Strength", properties:["Warrior":5])]) + +] + +var handCards:[Card] = [] +var playCards:[Card] = [] +var currentCard:Card? = nil diff --git a/Munchkin/Info.plist b/Munchkin/Info.plist new file mode 100644 index 0000000..0daccc9 --- /dev/null +++ b/Munchkin/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2018 Peter Terpstra. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/Munchkin/Munchkin.entitlements b/Munchkin/Munchkin.entitlements new file mode 100644 index 0000000..f2ef3ae --- /dev/null +++ b/Munchkin/Munchkin.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/Munchkin/Side.swift b/Munchkin/Side.swift new file mode 100644 index 0000000..d42218a --- /dev/null +++ b/Munchkin/Side.swift @@ -0,0 +1,14 @@ +// +// Side.swift +// Munchkin +// +// Created by Peter Terpstra on 2/23/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +enum Side { + case Player + case Monster +} diff --git a/Munchkin/ViewController.swift b/Munchkin/ViewController.swift new file mode 100644 index 0000000..a166598 --- /dev/null +++ b/Munchkin/ViewController.swift @@ -0,0 +1,298 @@ +// +// ViewController.swift +// Munchkin +// +// Created by Peter Terpstra on 2/22/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Cocoa + +class ViewController: NSViewController { + + @IBOutlet weak var playerLevelLabel: NSTextField! + @IBOutlet weak var playerScoreLabel: NSTextField! + @IBOutlet weak var monsterScoreLabel: NSTextField! + @IBOutlet weak var handCardsTable: NSTableView! + @IBOutlet weak var playCardsTable: NSTableView! + @IBOutlet weak var currentMonsterLabel: NSTextField! + @IBOutlet weak var statusLabel: NSTextField! + + var playerLevel = 1 + var playerScore = 1 + var monsterScore = 0 + var currentMonster = "" + var status = "" + var monsterCard:Card? = nil + + var gameInProgress = true + let forcePlayer = true + + override func viewDidLoad() { + super.viewDidLoad() + + handCardsTable.delegate = self + handCardsTable.dataSource = self + playCardsTable.delegate = self + playCardsTable.dataSource = self + + NotificationCenter.default.addObserver(self, selector: #selector(updateNotification(notification:)), name: NSNotification.Name(rawValue: "update"), object: nil) + newGameClicked(self) + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + func reloadCards() { + handCardsTable.reloadData() + playCardsTable.reloadData() + } + + + func updateLabels() { + playerLevelLabel.integerValue = playerLevel + playerScoreLabel.integerValue = playerScore + monsterScoreLabel.integerValue = monsterScore + currentMonsterLabel.stringValue = currentMonster + statusLabel.stringValue = status + } + + func calculateStats() { + playerScore=playerLevel + monsterScore=0 + monsterCard=nil + var monsterModifiers:[Card] = [] + var playerModifiers:[Card] = [] + for card in playCards { + switch(card.type) { + case .Monster: + monsterCard = card + case .OneUse: + switch (card.affects!) { + case .Player: + playerModifiers.append(card) + case .Monster: + monsterModifiers.append(card) + } + case .Weapon: + playerModifiers.append(card) + default: break + } + } + + for card in playerModifiers { + playerScore += card.strength! + } + + if monsterCard != nil { + monsterScore=monsterCard!.strength! + for card in monsterModifiers { + monsterScore += card.strength! + } + currentMonster = monsterCard!.description + } else { + currentMonster = "" + } + if playerLevel == 10 { + status="You win the game!" + gameInProgress=false + } + updateLabels() + } + + func update() { + reloadCards() + calculateStats() + updateLabels() + } + + @objc func updateNotification(notification: NSNotification) { + update() + } + + func openAffectsSelect() { + let myStoryboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"),bundle: nil) + if let vc = myStoryboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "AffectsSelect")) as? AffectsSelectController { + let myWindow = NSWindow(contentViewController: vc) + myWindow.makeKeyAndOrderFront(self) + let controller = NSWindowController(window: myWindow) + controller.showWindow(self) + } else { + print("Could not open AffectsSelect") + } + } + + func openCardSelect() { + let myStoryboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"),bundle: nil) + if let vc = myStoryboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "CardSelect")) as? CardSelectController { + let myWindow = NSWindow(contentViewController: vc) + myWindow.makeKeyAndOrderFront(self) + let controller = NSWindowController(window: myWindow) + controller.showWindow(self) + } else { + print("Could not open CardSelect") + } + } + + @IBAction func newGameClicked(_ sender: Any) { + playerLevel = 1 + playerScore = 1 + monsterScore = 0 + handCards = [] + playCards = [] + status="" + gameInProgress=true + update() + } + + @IBAction func handAddClicked(_ sender: Any) { + if gameInProgress { + openCardSelect() + } + } + + @IBAction func handRemoveClicked(_ sender: Any) { + if gameInProgress { + let index = handCardsTable.selectedRow + if index != -1 { + handCards.remove(at:index) + reloadCards() + } + } + } + + @IBAction func handMoveClicked(_ sender: Any) { + if gameInProgress { + let index = handCardsTable.selectedRow + if index != -1 { + let card = handCards[index] + if card.affects == nil && card.type != .Monster { + currentCard=card + handCards.remove(at: index) + if forcePlayer { + if card.affects == nil { + card.affects=Side.Player + playCards.append(card) + } + reloadCards() + } else { + openAffectsSelect() + } + } else { + playCards.append(card) + handCards.remove(at: index) + reloadCards() + calculateStats() + } + } + } + } + + @IBAction func playMoveClicked(_ sender: Any) { + if gameInProgress { + let index = playCardsTable.selectedRow + if index != -1 { + let card = playCards[index] + playCards.remove(at: index) + handCards.append(card) + reloadCards() + } + calculateStats() + } + } + + @IBAction func fightButtonClicked(_ sender: Any) { + if gameInProgress { + if monsterCard != nil { + if playerScore > monsterScore { + status="You win the battle! Draw \(monsterCard!.treasures!) treasures" + playerLevel+=1 + } else { + status="You lose" + } + var newPlayCards:[Card]=[] + for card in playCards { + if card.type != .OneUse && card.type != .Monster { + newPlayCards.append(card) + } + } + playCards=newPlayCards + monsterCard=nil + } else { + if status == "Uhh, there's no monster to fight" { + status = "I told you, there's no monster" + } else if status == "I told you, there's no monster" { + status = "SERIOUSLY! THERE'S NO MONSTER!" + } else if status != "SERIOUSLY! THERE'S NO MONSTER!" { + status = "Uhh, there's no monster to fight" + } + } + update() + } + } +} + +extension ViewController: NSTableViewDataSource { + + func numberOfRows(in tableView: NSTableView) -> Int { + if tableView == handCardsTable { + return handCards.count + } else if tableView == playCardsTable { + return playCards.count + } + return 0 + } + +} + +extension ViewController: NSTableViewDelegate { + + fileprivate enum CellIdentifiers { + static let NameCellHand = "NameCellHandID" + static let NameCellPlay = "NameCellPlayID" + static let AffectsCell = "AffectsCellID" + } + + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { + + var text: String = "" + var cellIdentifier: String = "" + + switch tableView { + case handCardsTable: + text=handCards[row].description + cellIdentifier = CellIdentifiers.NameCellHand + case playCardsTable: + switch tableColumn { + case tableView.tableColumns[0]?: + text=playCards[row].description + cellIdentifier = CellIdentifiers.NameCellPlay + case tableView.tableColumns[1]?: + if playCards[row].strength != nil && playCards[row].affects != nil { + let strength=playCards[row].strengthString + let affects=playCards[row].affectsString + text="\(affects) (\(strength))" + } else { + text="" + } + cellIdentifier = CellIdentifiers.AffectsCell + case .none: + text="" + case .some(_): + text="" + } + default: + text="" + } + + if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: cellIdentifier), owner: nil) as? NSTableCellView { + cell.textField?.stringValue = text + return cell + } + return nil + } + +} diff --git a/Munchkin/WeaponKind.swift b/Munchkin/WeaponKind.swift new file mode 100644 index 0000000..91f77b4 --- /dev/null +++ b/Munchkin/WeaponKind.swift @@ -0,0 +1,18 @@ +// +// WeaponKind.swift +// Munchkin +// +// Created by Peter Terpstra on 2/24/18. +// Copyright © 2018 Peter Terpstra. All rights reserved. +// + +import Foundation + +enum WeaponKind { + case TwoHands + case OneHand + case Armor + case Headgear + case Footgear + case None +}