//
//  ConsoleCell.swift
//  Zockerhoehle
//
//  Created by Julian-Steffen Müller on 12.09.18.
//  Copyright © 2018 Julian-Steffen Müller. All rights reserved.
//

import UIKit

class ConsoleCell: UITableViewCell {
    @IBOutlet weak var consoleName: UILabel!
    @IBOutlet weak var logo: UIImageView!
    @IBOutlet weak var gamesCounter: UILabel!
    @IBOutlet weak var accessoryCounter: UILabel!
    
    public var console: Console? {
        didSet {
            consoleName.text = console?.name
            self.logo.image = console?.logo?.image
            
            let ownedGames = console?.games.filtered(using: NSPredicate(format: "inWishlist = false")).count ?? 0
            let ownedAccessories = console?.accessories.filtered(using: NSPredicate(format: "inWishlist = false")).count ?? 0
            self.gamesCounter.text = "\(ownedGames)"
            self.accessoryCounter.text = "\(ownedAccessories)"
            
            self.setNeedsDisplay()
        }
    }
}
