Class: Mgmg::Reinforcement

Inherits:
Object
  • Object
show all
Defined in:
lib/mgmg/reinforce.rb

Constant Summary collapse

Skill =

スキル名 攻 物 防 HP MP 腕 器 速 魔

{
	'物防御UP'       => Reinforcement.new( Vec[  0, 10,  0,  0,  0,  0,  0,  0,  0] ),
	'魔防御UP'       => Reinforcement.new( Vec[  0,  0, 10,  0,  0,  0,  0,  0,  0] ),
	'腕力UP'         => Reinforcement.new( Vec[  0,  0,  0,  0,  0, 10,  0,  0,  0] ),
	'メンテナンス'   => Reinforcement.new( Vec[ 50,  0,  0,  0,  0,  0,  0,  0,  0] ),
	'ガードアップ'   => Reinforcement.new( Vec[  0, 50,  0,  0,  0,  0,  0,  0,  0] ),
	'パワーアップ'   => Reinforcement.new( Vec[  0,  0,  0,  0,  0, 50,  0,  0,  0] ),
	'デックスアップ' => Reinforcement.new( Vec[  0,  0,  0,  0,  0,  0, 50,  0,  0] ),
	'スピードアップ' => Reinforcement.new( Vec[  0,  0,  0,  0,  0,  0,  0, 50,  0] ),
	'マジックアップ' => Reinforcement.new( Vec[  0,  0,  0,  0,  0,  0,  0,  0, 50] ),
	'オールアップ'   => Reinforcement.new( Vec[  0, 50,  0,  0,  0, 50, 50, 50, 50] ),
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vec) ⇒ Reinforcement

Returns a new instance of Reinforcement.



3
4
5
# File 'lib/mgmg/reinforce.rb', line 3

def initialize(vec)
	@vec = vec
end

Instance Attribute Details

#vecObject

Returns the value of attribute vec.



6
7
8
# File 'lib/mgmg/reinforce.rb', line 6

def vec
  @vec
end

Class Method Details

.compile(arg) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mgmg/reinforce.rb', line 34

def compile(arg)
	case arg
	when Reinforcement
		arg
	when Cuisine
		cuisine(arg)
	when String
		if Skill.has_key?(arg)
			Skill[arg]
		elsif SystemCuisine.has_key?(arg)
			cuisine(SystemCuisine[arg])
		else
			raise InvalidReinforcementNameError, arg
		end
	else
		raise ArgumentError, "The argument should be Mgmg::Cuisine or skill name String. (`#{arg}' is given)"
	end
end

.cuisine(c) ⇒ Object



31
32
33
# File 'lib/mgmg/reinforce.rb', line 31

def cuisine(c)
	Reinforcement.new( Vec[*(c.vec), *Array.new(6, 0)] )
end

Instance Method Details

#initialize_copy(other) ⇒ Object



7
8
9
# File 'lib/mgmg/reinforce.rb', line 7

def initialize_copy(other)
	@vec = other.vec.dup
end

#to_sObject Also known as: inspect



11
12
13
# File 'lib/mgmg/reinforce.rb', line 11

def to_s
	'(' + @vec.map.with_index{|e, i| e==0 ? nil : "#{Equip::ParamList[i]}:#{e}"}.compact.join(', ') + ')'
end