This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 六局上半 | |
// 更換守備:曾子祐-=>游擊手。 更換投手:江承諺=>謝葆錡。 | |
hawks.changeDefense(in: 曾子祐, out: 胡冠俞) | |
hawks.changePitcher(in: 謝葆錡, out: 江承諺) | |
// 第3棒 DH 胡金龍: 擊出左外野高飛球,二壘安打 。 | |
// 第4棒 1B 林子豪: 擊出內野滾地球,擊出二壘方向內野安打。 二壘跑者胡金龍 上三壘。 | |
// 更換代跑:胡金龍=>張偉聖。 | |
lions.changeRunner(in: 張偉聖, out: 胡金龍) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 二局上半 | |
var inning2Top = TopInning(number: 2) | |
// 第5棒 LF 蘇智傑: 擊出內野平飛球, 打者-一壘手 飛球接殺出局。 1人出局。 | |
// 第6棒 3B 陳重廷: 擊出左外野高飛球,全壘打。1分打點。 | |
let secondBatter = lions.currentBatters[5] | |
let play2 = Play(batter: secondBatter, result: .homeRun) | |
inning2Top.plays.append(play2) | |
inning2Top.score += 1 | |
// 全壘打! 統一獅 1:0 台鋼雄鷹 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inning1Bottom = BottomInning(number: 1) | |
// 第1棒 CF 紀慶然: 擊出內野滾地球, 打者-二壘手 傳一壘手刺殺出局。 1人出局。 | |
let firstBatter = hawks.currentBatters[0] | |
let play1 = Play(batter: firstBatter, result: .groundOut(to: .secondBase)) | |
inning1Bottom.plays.append(play1) | |
inning1Bottom.outs += 1 | |
// 第2棒 2B 林家鋐: 揮棒落空。 打者出局-三振出局。 2人出局。 | |
let secondBatter = hawks.currentBatters[1] | |
let play2 = Play(batter: secondBatter, result: .strikeOut) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 第2棒 RF 邱智呈: 擊出右外野平飛球,一壘安打 。 | |
let secondBatter = lions.currentBatters[1] | |
let play2 = Play(batter: secondBatter, result: .hit(.single)) | |
inning1Top.plays.append(play2) | |
inning1Top.runnersOnBase = .firstBase | |
// 第3棒 DH 胡金龍: 好球沒揮棒。 打者出局-三振出局。 2人出局。 | |
let thirdBatter = lions.currentBatters[2] | |
let play3 = Play(batter: thirdBatter, result: .strikeOut) | |
inning1Top.plays.append(play3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Play Ball! | |
match103.startGame(at: Date()) | |
match103.initializeGameState() | |
// 一局上半 | |
var inning1Top = TopInning(number: 1) | |
// 一棒陳傑憲 | |
let firstBatter = lions.currentBatters[0] | |
// 好球沒揮棒。0-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 統一獅球員名單 | |
let 林岳平 = Coach(name: "林岳平") | |
let 陳傑憲 = Player(name: "陳傑憲", number: 24, position: .centerField) | |
let 邱智呈 = Player(name: "邱智呈", number: 14, position: .rightField) | |
let 布雷克 = Player(name: "布雷克", number: 50, position: .startingPitcher) | |
// ...剩下以此類推 | |
let lions = Team( | |
name: "統一 7-ELEVEn 獅", | |
coach: 林岳平, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Play { | |
var batter: Player | |
var result: BattingResult | |
} | |
protocol Inning { | |
var number: Int { set get } | |
var isTop: Bool { get } | |
var plays: [Play] { set get } | |
var score: Int { set get } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum BattingResult { | |
case strikeOut | |
case flyOut(to: FieldPosition) | |
case groundOut(to: FieldPosition) | |
case hit(HitType) | |
case doublePlay(involvedFielders: [FieldPosition]) | |
case error(by: FieldPosition) | |
case walk // 四壞球保送 | |
case hitByPitch // 觸身球 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let matchInfo = MatchInfo( | |
number: 103 , // 比賽編號 | |
date: DateComponents(calendar: .current, year: 2025, month: 5, day: 17).date!, // 比賽日期 | |
stadium: "澄清湖棒球場", // 比賽場地 | |
weather: .cloudy, // 比賽天氣 | |
umpires: [ | |
Umpire(name: "王俊宏", role: .plate), // 主審 | |
Umpire(name: "陳均瑋", role: .first), // 一壘審 | |
Umpire(name: "劉世偉", role: .second), // 二壘審 | |
Umpire(name: "曾鈞威", role: .third) // 三壘審 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 🟠 統一 7-ELEVEn 獅 | |
let lions = Team( | |
name: "統一 7-ELEVEn 獅", | |
coach: "林岳平", | |
startingBatters: [ | |
Player(name: "陳傑憲", number: 24, position: .centerField), // 一棒 | |
Player(name: "邱智呈", number: 14, position: .rightField), // 二棒 | |
Player(name: "胡金龍", number: 51, position: .designatedHitter), // 三棒 | |
Player(name: "林子豪", number: 2, position: .firstBase), // 四棒 | |
Player(name: "蘇智傑", number: 32, position: .leftField), // 五棒 |
NewerOlder