Boardgame

final class Boardgame : Model, Searchable

A boardgame in the Games Library.

Properties

  • id

    The game’s ID.

    Declaration

    Swift

    @ID
    var id: UUID?
  • The game’s title.

    Declaration

    Swift

    @Field
    var gameName: String
  • How many copies the Games Library has of this game.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    @OptionalField
    var notes: String?
  • 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

    @OptionalField
    var bggGameName: String?
  • Declaration

    Swift

    @OptionalField
    var yearPublished: String?
  • Declaration

    Swift

    @OptionalField
    var gameDescription: String?
  • Declaration

    Swift

    @Field
    var gameTypes: [String]
  • Declaration

    Swift

    @Field
    var categories: [String]
  • Declaration

    Swift

    @Field
    var mechanisms: [String]
  • Declaration

    Swift

    @OptionalField
    var minPlayers: Int?
  • Declaration

    Swift

    @OptionalField
    var maxPlayers: Int?
  • Declaration

    Swift

    @OptionalField
    var suggestedPlayers: Int?
  • Declaration

    Swift

    @OptionalField
    var minPlayingTime: Int?
  • Declaration

    Swift

    @OptionalField
    var maxPlayingTime: Int?
  • Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    @OptionalField
    var avgRating: Float?
  • 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

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

    Declaration

    Swift

    @Timestamp
    var createdAt: Date?

Relations

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

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    @Siblings
    var favorites: [User]

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