0
我在寫卡片遊戲。我看過一些例子,程序員將他們的struct
與service
分開。我不確定我是不是也應該這樣做。Swift - 我應該從邏輯函數中分離一個結構嗎?
但我的問題是 - 我應該從邏輯函數分離結構;或者把它們放在一起可以嗎?
我的代碼,例如:
// Card Model
struct FSCard {
var type: FSCardType // enum reference
var name: String
var value: Int
weak var owner: FSPlayer? // class reference
var description: String {
return ("Name: \(self.name) Value: \(self.value), Type: \(self.type)")
}
}
class FSCardAPI: NSObject {
// static functions
public static func filter(cards:[FSCard], type:FSCardType) -> [FSCard]
{
// some code goes here ...
}
}