Add playoff round view, game numbers, goal scorer notifications, standings

- Fetch NHL standings and surface league/season game counts in the menu bar
- Prefix regular-season rows with the league-wide game number (from gameId)
- New ROUND section shows each active playoff series (matchup, series score,
  next game number + time) derived from /v1/playoff-bracket; rows always open
  the NHL series page so completed series remain clickable
- Goal notifications include scorer sweater, abbreviated name, and strength
  (PPG/SHG/EN), resolved via /v1/gamecenter/{id}/play-by-play
- Drop the per-team filter submenu and NHLTeam enum
- Regenerate AppIcon with the full 10-size macOS set (alpha preserved) so
  notifications render the app icon correctly; rename the iOS marketing PNG
  to icon-ios-1024.png
- gitignore .claude/ local tooling settings
This commit is contained in:
2026-04-18 21:51:27 -04:00
parent 8f8f8b2755
commit 57358797e1
44 changed files with 596 additions and 286 deletions
+94
View File
@@ -0,0 +1,94 @@
//
// PlayByPlayModel.swift
// IceGlass
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
struct PlayByPlay: Codable {
let awayTeam: Team
let homeTeam: Team
let plays: [Play]
let rosterSpots: [RosterSpot]
struct Team: Codable {
let id: Int
let abbrev: String
}
struct Play: Codable {
let typeDescKey: String
let situationCode: String?
let details: Details?
struct Details: Codable {
let scoringPlayerId: Int?
let eventOwnerTeamId: Int?
let awayScore: Int?
let homeScore: Int?
}
}
struct RosterSpot: Codable {
let teamId: Int
let playerId: Int
let firstName: LocalizedString
let lastName: LocalizedString
let sweaterNumber: Int
struct LocalizedString: Codable {
let `default`: String
}
}
/// Find the goal play whose trailing score matches the given totals exactly.
/// Returns nil if play-by-play hasn't caught up with the scoreboard yet
/// safer than guessing, since a stale fallback could name the previous scorer.
func goal(matchingAwayScore awayScore: Int, homeScore: Int) -> Play? {
plays.last { play in
play.typeDescKey == "goal"
&& play.details?.awayScore == awayScore
&& play.details?.homeScore == homeScore
}
}
func player(id: Int) -> RosterSpot? {
rosterSpots.first { $0.playerId == id }
}
/// Derived strength tag for a goal ("PPG", "SHG", "EN"), or nil for even-strength.
/// `situationCode` is 4 digits: awayGoalie, awaySkaters, homeSkaters, homeGoalie.
static func strengthTag(situationCode: String?, scoringTeamIsAway: Bool) -> String? {
guard let code = situationCode, code.count == 4 else { return nil }
let digits = code.compactMap { $0.wholeNumberValue }
guard digits.count == 4 else { return nil }
let awayGoalie = digits[0]
let awaySkaters = digits[1]
let homeSkaters = digits[2]
let homeGoalie = digits[3]
let scoringSkaters = scoringTeamIsAway ? awaySkaters : homeSkaters
let opposingSkaters = scoringTeamIsAway ? homeSkaters : awaySkaters
let opposingGoalie = scoringTeamIsAway ? homeGoalie : awayGoalie
if opposingGoalie == 0 { return "EN" }
if scoringSkaters > opposingSkaters { return "PPG" }
if scoringSkaters < opposingSkaters { return "SHG" }
return nil
}
}
struct GoalScorer {
let name: String
let sweaterNumber: Int
let strength: String?
/// "#14 J. Eriksson Ek (PPG)" strength suffix omitted for even-strength goals.
var displayLine: String {
let head = "#\(sweaterNumber) \(name)"
if let strength = strength { return "\(head) (\(strength))" }
return head
}
}