Sha256: 16d2b064acc21ef7a628bb58ca1c61515a350090d66a93909115c37718ac1824

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

module Cure
  def self.method_missing(name, *args)
    if Rubicure::Girl.valid?(name)
      Rubicure::Girl.find(name)
    else
      super
    end
  end

  [Cure.peace, Cure.cure_peace].each do |peace|
    class << peace
      HANDS =
        (["グー"] * 13) +
        (["チョキ"] * 14) +
        (["パー"] * 15) +
        ["グッチョッパー"]
      MESSAGE = <<EOF
ピカピカピカリン
ジャンケンポン!
(%s)
EOF
      def pikarin_janken
        print_by_line(MESSAGE % HANDS.sample)
      end
      alias_method :janken, :pikarin_janken
    end
  end

  def self.define_turnover_methods(target, original_human_name, another_human_name)
    target.instance_variable_set(:@__original_human_name, original_human_name)
    target.instance_variable_set(:@__another_human_name,  another_human_name)

    class << target
      def !
        humanize!
        @another_human_name ||= @__another_human_name

        # setup @state_names
        state_names

        @state_names[0], @another_human_name = @another_human_name, @state_names[0]
        self
      end

      def rollback
        @state_names[0]     = @__original_human_name
        @another_human_name = @__another_human_name
        self
      end
    end
  end

  [Cure.passion, Cure.cure_passion].each do |passion|
    define_turnover_methods(passion, "東せつな", "イース")
  end

  [Cure.beat, Cure.cure_beat].each do |beat|
    define_turnover_methods(beat, "黒川エレン", "セイレーン")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubicure-0.2.8.1 lib/rubicure/cure.rb
rubicure-0.2.8 lib/rubicure/cure.rb
rubicure-0.2.7 lib/rubicure/cure.rb
rubicure-0.2.6 lib/rubicure/cure.rb
rubicure-0.2.5 lib/rubicure/cure.rb