Boardgame

final class Boardgame : Model, Searchable, @unchecked Sendable

A boardgame in the Games Library.

Properties

  • id

    The game’s ID.

    Declaration

    Swift

    @Boardgame
    .ID var id: UUID? { get set }
  • The game’s title.

    Declaration

    Swift

    @Boardgame
    .Field var gameName: String { get set }
  • How many copies the Games Library has of this game.

    Declaration

    Swift

    @Boardgame
    .Field var numCopies: Int { get set }
  • If the game was donated (or perhaps loaned) by a cruisegoer, the person that donated it.

    Declaration

    Swift

    @Boardgame
    .OptionalField var donatedBy: String? { get set }
  • Any notes on the game, e.g.box condition, missing pieces.

    Declaration

    Swift

    @Boardgame
    .OptionalField var notes: String? { get set }
  • The rest of these properties are pulled from BoardGameGeek’s API, and may not exactly match the game in the library. Some games get re-released with slightly different versions, and the script guesses which one the Library most likely has. All these properties are optional because we may not find a match on BGG BoardGameGeek sometimes has a slightly different title for a game. This is the exact BGG title.

    Declaration

    Swift

    @Boardgame
    .OptionalField var bggGameName: String? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var yearPublished: String? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var gameDescription: String? { get set }
  • Declaration

    Swift

    @Boardgame
    .Field var gameTypes: [String] { get set }
  • Declaration

    Swift

    @Boardgame
    .Field var categories: [String] { get set }
  • Declaration

    Swift

    @Boardgame
    .Field var mechanisms: [String] { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var minPlayers: Int? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var maxPlayers: Int? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var suggestedPlayers: Int? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var minPlayingTime: Int? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var maxPlayingTime: Int? { get set }
  • Declaration

    Swift

    @Boardgame
    .OptionalField var avgPlayingTime: Int? { get set }
  • The recommended min age to play this game. May be based on complexity or on content.

    Declaration

    Swift

    @Boardgame
    .OptionalField var minAge: Int? { get set }
  • The number of BGG reviewers that have provided a rating on the game.

    Declaration

    Swift

    @Boardgame
    .OptionalField var numRatings: Int? { get set }
  • The average rating by BGG game raters. Ratings range is 1…10.

    Declaration

    Swift

    @Boardgame
    .OptionalField var avgRating: Float? { get set }
  • Roughly, how complex the rules are for this game. Scale is 1…5. 1 is “tic-tac-toe”, 5 is “Roll 3d100 on Table 38/b to find out which sub-table to roll on”

    Declaration

    Swift

    @Boardgame
    .OptionalField var complexity: Float? { get set }
  • Timestamp of the model’s creation, set automatically.

    Declaration

    Swift

    @Boardgame
    .Timestamp var createdAt: Date? { get set }

Relations

  • If this is an expansion set, the base game that it expands

    Declaration

    Swift

    @Boardgame
    .OptionalParent var expands: Boardgame? { get set }
  • For games that have expansions, the set of expansions for this base game.

    Declaration

    Swift

    @Boardgame
    .Children var expansions: [Boardgame] { get set }
  • The users that have favorited this game.

    Declaration

    Swift

    @Boardgame
    .Siblings var favorites: [User] { get set }

Initialization

  • Used by Fluent

    Declaration

    Swift

    init()
  • Initializes a new Boardgame from the JSON games file data.

    Declaration

    Swift

    init(jsonGame: JsonGamesListGame)

    Parameters

    jsonGame

    Game value decoded from the BoardGamesList JSON file..

  • Determines whether a game has enough information to be used by the recommendation engine.

    BoardGameGeek’s data is user-provided and is not complete for all games in their database. If a game is missing one of these fields, we can still create a reasonable score for how well the game matches a set of criteria. If it’s missing a bunch of these fields, scoring the game would be meaningless.

    Declaration

    Swift

    func canUseForRecommendations() -> Bool
  • Declaration

    Swift

    func getSuggestedPlayers() -> Int
  • Declaration

    Swift

    func getAvgPlayingTime() -> Int
  • Unwraps, and gives games with no rating a low but not terrible default rating

    Declaration

    Swift

    func getAvgRating() -> Float
  • Unwraps, and gives games with no complexity rating an average complexity value as a default. Ideally we’d give games with no complexity value a scoring penalty.

    Declaration

    Swift

    func getComplexity() -> Float