class CwCardUtils::CurveCalculator
Public: Computes mana curve distributions from a deck. 日本語: デッキからマナカーブ分布を計算します。
Public Class Methods
Source
# File lib/cw_card_utils/curve_calculator.rb, line 11 def initialize(deck) @deck = deck @deck_size = @deck.count_without_lands @raw_curve = {} @normalized_curve = {} @collapsed_normalized_curve = {} @collapsed_curve = {} end
Public: Initialize with a deck-like object. 日本語: デッキ相当のオブジェクトで初期化します。
@param deck [CwCardUtils::DecklistParser::Deck]
Public Instance Methods
Source
# File lib/cw_card_utils/curve_calculator.rb, line 32 def collapsed_curve return @collapsed_curve if @collapsed_curve.values.any? @collapsed_curve = { '0-1' => 0, '2' => 0, '3' => 0, '4' => 0, '5' => 0, '6+' => 0, } curve.each do |cmc, count| case cmc when 0..1 then @collapsed_curve['0-1'] += count when 2 then @collapsed_curve['2'] += count when 3 then @collapsed_curve['3'] += count when 4 then @collapsed_curve['4'] += count when 5 then @collapsed_curve['5'] += count else @collapsed_curve['6+'] += count end end @collapsed_curve end
Public: Collapsed curve counts (0-1,2,3,4,5,6+). 日本語: まとめられたカーブ分布(0-1,2,3,4,5,6+)。
How it works (EN): Builds upon the raw curve, bucketing CMCs into coarse buckets for quick, human-readable summaries. Lands are excluded, and nil/zero CMC non-lands are treated as 0.
仕組み (JA): 素のカーブを基に、CMC を粗い区分へまとめて人が読みやすい集計を生成します。土地は除外し、nil/0 の CMC (土地でない) は 0 として扱います。
@return [Hash{String=>Integer}]
Source
# File lib/cw_card_utils/curve_calculator.rb, line 100 def collapsed_normalized_curve normalize_collapsed_curve if @collapsed_normalized_curve.values.empty? @collapsed_normalized_curve end
Public: Collapsed and normalized curve distribution. 日本語: まとめかつ正規化したカーブ分布。
How it works (EN): Applies the same normalization as above to the collapsed buckets, providing an at-a-glance shape of the deck.
仕組み (JA): まとめたバケットに対して同様の正規化を行い、デッキの形状を直感的に把握できるようにします。
@return [Hash{String=>Float}]
Source
# File lib/cw_card_utils/curve_calculator.rb, line 70 def curve calculate_curve if @raw_curve.empty? @raw_curve end
Public: Raw curve counts keyed by CMC bucket. 日本語: CMCバケットごとの素のカウント。
How it works (EN): Iterates over non-land cards and increments a bucket equal to ceil(CMC). Cards with nil/0 CMC and non-land type are assigned to bucket 0; lands are skipped entirely.
仕組み (JA): 土地以外のカードを走査し、ceil(CMC) をバケットに加算します。CMC が nil/0 で土地でない場合は 0 バケットへ。土地はスキップします。
@return [Hash{Integer=>Integer}]
Source
# File lib/cw_card_utils/curve_calculator.rb, line 85 def normalized_curve normalize_curve if @normalized_curve.values.empty? @normalized_curve end
Public: Normalized curve (fractions of non-land count). 日本語: 正規化されたカーブ (土地を除く総数に対する割合)。
How it works (EN): Sorts buckets by CMC and divides each count by the number of non-land cards, rounding to 4 decimals.
仕組み (JA): CMC 順にソートし、各バケットを土地以外の総枚数で割って 4 桁に丸めます。
@return [Hash{Integer=>Float}]