module Codebreaker class CreateStatService def initialize(game) @game = game end def call StatsStorage.new.add(stat_data) end private def stat_data { name: @game.player.name, difficulty: @game.difficulty.type, attempts_total: @game.difficulty.attempts, attempts_used: @game.difficulty.attempts - @game.attempts_left, hints_total: @game.difficulty.hints, hints_used: @game.difficulty.hints - @game.hints_left } end end end