Class: GamesAndRpgParadise::Mechwars::Arena
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mechwars::Arena
show all
- Defined in:
- lib/games_and_rpg_paradise/games/mechwars/arena.rb
Overview
GamesAndRpgParadise::Mechwars::Arena
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(how_many_mechs = 4) ⇒ Arena
21
22
23
24
25
26
27
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 21
def initialize(
how_many_mechs = 4
)
@how_many_mechs = how_many_mechs
report_how_many_mechs_will_be_created
reset
end
|
Instance Attribute Details
#experience ⇒ Object
Returns the value of attribute experience.
15
16
17
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 15
def experience
@experience
end
|
#how_many_mechs ⇒ Object
Also known as:
n_mechs
Returns the value of attribute how_many_mechs.
16
17
18
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 16
def how_many_mechs
@how_many_mechs
end
|
Instance Method Details
#combat_round(object1, object2) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 96
def combat_round(object1,object2)
while true
damage=@array_storing_mech_objects[0].shoot_at(@array_storing_mech_objects[1].name)
@array_storing_mech_objects[1].got_hit(damage)
damage=@array_storing_mech_objects[1].shoot_at(@array_storing_mech_objects[0].name)
@array_storing_mech_objects[0].got_hit(damage)
@combat_round_counter += 1
sleep(1) end
end
|
#fight(object1 = , object2 = ) ⇒ Object
#
fight
Here our objects fight with each other.
#
114
115
116
117
118
119
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 114
def fight(
object1 = @array_storing_mech_objects[0],
object2 = @array_storing_mech_objects[1]
)
combat_round(object1, object2)
end
|
#fill_arena ⇒ Object
#
fill_arena
just fills our arena with mechs
#
75
76
77
78
79
80
81
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 75
def fill_arena
@how_many_mechs.times { |tmp|
foo = Mech.new
foo.random
@array_storing_mech_objects << foo
}
end
|
#fill_arena_and_set_targets ⇒ Object
#
fill_arena_and_set_targets
#
65
66
67
68
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 65
def fill_arena_and_set_targets
fill_arena
set_targets
end
|
#report ⇒ Object
58
59
60
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 58
def report
pp @array_storing_mech_objects
end
|
#report_how_many_mechs_will_be_created ⇒ Object
#
report_how_many_mechs_will_be_created
#
32
33
34
35
36
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 32
def report_how_many_mechs_will_be_created
e "="*80
e "Creating #{@how_many_mechs} Mechs."
e "="*80
end
|
#reset ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 41
def reset
@array_storing_mech_objects = []
@combat_round_counter = 0 @experience = 0+rand(200)
end
|
#set_targets ⇒ Object
#
set_targets
sets targets
#
88
89
90
91
|
# File 'lib/games_and_rpg_paradise/games/mechwars/arena.rb', line 88
def set_targets
@array_storing_mech_objects[0].engage_target(@array_storing_mech_objects[1])
@array_storing_mech_objects[1].engage_target(@array_storing_mech_objects[0])
end
|