Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xcuserdata
942 changes: 942 additions & 0 deletions client/CoolCards.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions client/CoolCards.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions client/CoolCards/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// CoolCards
//
// Created by Chatterjee, Sumeru(AWF) on 12/18/17.
// Copyright © 2017 Chatterjee, Sumeru. 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:.
}


}

57 changes: 57 additions & 0 deletions client/CoolCards/CoolCardsAPI/CoolCardAPIRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// CoolCardAPIRequest.swift
// CoolCards
//
// Created by Chatterjee, Sumeru(AWF) on 12/18/17.
// Copyright © 2017 Chatterjee, Sumeru. All rights reserved.
//

import Foundation
import Moya

enum CoolCardsAPIRequest {
case cards
case card(cardId: String)
}

extension CoolCardsAPIRequest: TargetType {

var baseURL: URL {
// The server is running on google app engine in a docker container and the code is also in the repository

return URL(string: "http://35.205.213.172:5000")!
}

var headers: [String : String]? {
return nil
}

var path: String {
switch self {
case .cards:
return "/cards"
case .card(let cardId):
return "/card/\(cardId)"
}
}

var method: Moya.Method {
return .get
}

var parameterEncoding: ParameterEncoding {
return JSONEncoding.default
}

var parameters: [String: Any]? {
return nil
}

var sampleData: Data {
return Data()
}

var task: Moya.Task {
return .requestPlain
}
}
50 changes: 50 additions & 0 deletions client/CoolCards/CoolCardsAPI/CoolCardsAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// CoolCardsAPI.swift
// CoolCards
//
// Created by Chatterjee, Sumeru(AWF) on 12/18/17.
// Copyright © 2017 Chatterjee, Sumeru. All rights reserved.
//

import Foundation
import Moya

class CoolCardsAPI {
static let provider = MoyaProvider<CoolCardsAPIRequest>()

static func getCards(completion: @escaping (([Card]?, Error?) -> Void)) {
provider.request(.cards) { result in
switch result {
case let .success(response):
do {
let results = try JSONDecoder().decode([Card].self, from: response.data)
completion(results, nil)
} catch let exception {
print (exception)
completion(nil, exception)
}
case let .failure(error):
print (error)
completion(nil, error)
}
}
}

static func getCard(cardId: String, completion: @escaping ((Card?, Error?) -> Void)) {
provider.request(.card(cardId: cardId)) { result in
switch result {
case let .success(response):
do {
let results = try JSONDecoder().decode(Card.self, from: response.data)
completion(results, nil)
} catch let exception {
print (exception)
completion(nil, exception)
}
case let .failure(error):
print (error)
completion(nil, error)
}
}
}
}
53 changes: 53 additions & 0 deletions client/CoolCards/CoolCardsAPI/DataEntities/Card.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Card.swift
// CoolCards
//
// Created by Chatterjee, Sumeru(AWF) on 12/18/17.
// Copyright © 2017 Chatterjee, Sumeru. All rights reserved.
//

struct Card: Decodable {
let cardId : String
let name: String
let cardSet: String
let type: String
let rarity: String
let cost: Int
let attack: Int
let health: Int
let text: String
let flavor: String
let artist: String
let collectible: Bool
let elite: Bool
let playerClass: String
let multiClassGroup: String?
let howToGet: String?
let howToGetGold: String?
let img: String
let imgGold: String
let locale: String

private enum CodingKeys: String, CodingKey {
case cardId = "cardId"
case name = "name"
case cardSet = "cardSet"
case type = "type"
case rarity = "rarity"
case cost = "cost"
case attack = "attack"
case health = "health"
case text = "text"
case flavor = "flavor"
case artist = "artist"
case collectible = "collectible"
case elite = "elite"
case playerClass = "playerClass"
case multiClassGroup = "multiClassGroup"
case howToGet = "howToGet"
case howToGetGold = "howToGetGold"
case img = "img"
case imgGold = "imgGold"
case locale = "locale"
}
}
51 changes: 51 additions & 0 deletions client/CoolCards/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"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"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading