so I have this code, I have a soldier that implement Pawn and have default implementation of possible moves, and I have an ASoldier that do the same. I wanna make another soldier called superSolider that has the Soldier and Asoldier possible moves.
how should I build it, because that way I cant reach to the default implementation
struct PosibleMove {
let x: Int
let y: Int
}
protocol Pawn {
func posibleMoves() -> [PosibleMove]
}
protocol Soldier: Pawn {
func shot()
}
extension Soldier {
func posibleMoves() -> [PosibleMove] {
return [PosibleMove(x: 0, y: 0), PosibleMove(x: 1, y: 1)]
}
}
protocol ASoldier: Pawn {
func aShot()
}
extension ASoldier {
func posibleMoves() -> [PosibleMove] {
return [PosibleMove(x: 2, y: 2), PosibleMove(x: 3, y: 3)]
}
}
protocol SuperSoldier: ASoldier, Soldier {
}
extension SuperSoldier {
func posibleMoves() -> [PosibleMove] {
// here I would like to use ASoldier.posibleMoves() + Soldier.posibleMoves()
}
}
let pawns = [[Pawn]]()
func checkPosibleMoves(x: Int, y: Int) -> [PosibleMove] {
return pawns[x][y].posibleMoves()
}