mission_game 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/enemy.rb +49 -53
- data/lib/main.rb +148 -142
- data/lib/neworleans.rb +144 -149
- data/lib/player.rb +122 -121
- data/lib/story.rb +41 -45
- data/lib/ui.rb +269 -259
- data/mission_game.rb +41 -43
- metadata +1 -1
data/lib/neworleans.rb
CHANGED
@@ -1,149 +1,144 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Written by Webster Avosa
|
4
|
-
|
5
|
-
module MISSIONGAME
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
end
|
149
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Written by Webster Avosa
|
4
|
+
|
5
|
+
module MISSIONGAME
|
6
|
+
MAP_WIDTH = 64
|
7
|
+
MAP_HEIGHT = 14
|
8
|
+
|
9
|
+
MAP_KEY_TREE = "\u2663"
|
10
|
+
MAP_KEY_WATER = "\u2248"
|
11
|
+
MAP_KEY_GRASS = "\u2588"
|
12
|
+
MAP_KEY_MOUNTAIN = "\u25B2"
|
13
|
+
MAP_KEY_ENEMY = "\u263A"
|
14
|
+
MAP_KEY_WITCH = "\u263B"
|
15
|
+
MAP_KEY_PLAYER = "\u1330"
|
16
|
+
|
17
|
+
# Weighted
|
18
|
+
MAP_POSSIBLE_KEYS = [
|
19
|
+
MAP_KEY_TREE,
|
20
|
+
MAP_KEY_TREE,
|
21
|
+
MAP_KEY_TREE,
|
22
|
+
MAP_KEY_TREE,
|
23
|
+
MAP_KEY_WATER,
|
24
|
+
MAP_KEY_GRASS,
|
25
|
+
MAP_KEY_MOUNTAIN,
|
26
|
+
MAP_KEY_ENEMY,
|
27
|
+
MAP_KEY_ENEMY
|
28
|
+
]
|
29
|
+
|
30
|
+
# Make grass more common
|
31
|
+
32.times.each { MAP_POSSIBLE_KEYS << MAP_KEY_GRASS }
|
32
|
+
|
33
|
+
MAP_WITCH_X = MAP_WIDTH
|
34
|
+
MAP_WITCH_Y = 1
|
35
|
+
|
36
|
+
class NewOrleans
|
37
|
+
attr_reader :the_map
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
# Set initial New Orleans map
|
41
|
+
generate_map
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_width
|
45
|
+
MAP_WIDTH
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_height
|
49
|
+
MAP_HEIGHT
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return map data in a display format
|
53
|
+
def get_map(args)
|
54
|
+
player = args[:player]
|
55
|
+
buffer = Array.new
|
56
|
+
x = 1
|
57
|
+
y = 1
|
58
|
+
@the_map.each do |row|
|
59
|
+
tmp_row = Array.new
|
60
|
+
x = 1
|
61
|
+
row.each do |col|
|
62
|
+
placed = 0
|
63
|
+
|
64
|
+
# Place WITCH
|
65
|
+
if x == MAP_WITCH_X and y == MAP_WITCH_Y
|
66
|
+
tmp_row << MAP_KEY_WITCH.colorize(color: :white, background: :red)
|
67
|
+
placed = 1
|
68
|
+
end
|
69
|
+
|
70
|
+
# If player is here, display them
|
71
|
+
if x == player.x and y == player.y
|
72
|
+
tmp_row << MAP_KEY_PLAYER.colorize(color: :red, background: :white)
|
73
|
+
placed = 1
|
74
|
+
end
|
75
|
+
|
76
|
+
# If we haven't already placed the Player, run through the rest of the options
|
77
|
+
if placed == 0
|
78
|
+
case col
|
79
|
+
when MAP_KEY_TREE
|
80
|
+
tmp_row << col.colorize(color: :light_green, background: :green)
|
81
|
+
when MAP_KEY_GRASS
|
82
|
+
tmp_row << col.colorize(color: :green, background: :green)
|
83
|
+
when MAP_KEY_WATER
|
84
|
+
tmp_row << col.colorize(color: :white, background: :blue)
|
85
|
+
when MAP_KEY_MOUNTAIN
|
86
|
+
tmp_row << col.colorize(color: :yellow, background: :green)
|
87
|
+
when MAP_KEY_ENEMY
|
88
|
+
tmp_row << col.colorize(color: :red, background: :green)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
x += 1
|
92
|
+
end
|
93
|
+
buffer << tmp_row
|
94
|
+
y += 1
|
95
|
+
end
|
96
|
+
|
97
|
+
return buffer
|
98
|
+
end
|
99
|
+
|
100
|
+
# Check the current area on the map and describe it
|
101
|
+
def check_area(args)
|
102
|
+
player = args[:player]
|
103
|
+
ui = args[:ui]
|
104
|
+
story = args[:story]
|
105
|
+
x = player.x
|
106
|
+
y = player.y
|
107
|
+
current_area = @the_map[y - 1][x - 1]
|
108
|
+
case current_area
|
109
|
+
when MAP_KEY_TREE
|
110
|
+
ui.draw_frame({ text: story.area_tree })
|
111
|
+
when MAP_KEY_WATER
|
112
|
+
ui.draw_frame({ text: story.area_water })
|
113
|
+
when MAP_KEY_MOUNTAIN
|
114
|
+
ui.draw_frame({ text: story.area_mountain })
|
115
|
+
when MAP_KEY_ENEMY
|
116
|
+
ui.draw_frame({ text: story.area_enemy })
|
117
|
+
return false
|
118
|
+
end
|
119
|
+
return true
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def new_line
|
125
|
+
print "\n"
|
126
|
+
end
|
127
|
+
|
128
|
+
# Create a random new orleans map
|
129
|
+
def generate_map
|
130
|
+
tmp_map = Array.new
|
131
|
+
|
132
|
+
# Step through MAX_HEIGHT times
|
133
|
+
MAP_HEIGHT.times do
|
134
|
+
tmp_row = Array.new
|
135
|
+
MAP_WIDTH.times { tmp_row << MAP_POSSIBLE_KEYS.sample }
|
136
|
+
|
137
|
+
# Add our assembled row to the map
|
138
|
+
tmp_map << tmp_row
|
139
|
+
tmp_row = nil
|
140
|
+
end
|
141
|
+
@the_map = tmp_map
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/lib/player.rb
CHANGED
@@ -1,121 +1,122 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Written by Webster Avosa
|
4
|
-
|
5
|
-
module MISSIONGAME
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Written by Webster Avosa
|
4
|
+
|
5
|
+
module MISSIONGAME
|
6
|
+
ENEMY_KILLED = 'KILLED'
|
7
|
+
|
8
|
+
HIT_CHANCE_MODIFIER = 5
|
9
|
+
ATTACK_VALUE_MODIFIER = 1
|
10
|
+
|
11
|
+
class Player
|
12
|
+
attr_accessor :name
|
13
|
+
attr_accessor :lives
|
14
|
+
attr_accessor :bonus
|
15
|
+
attr_accessor :x
|
16
|
+
attr_accessor :y
|
17
|
+
attr_accessor :level
|
18
|
+
attr_accessor :str
|
19
|
+
attr_accessor :int
|
20
|
+
attr_accessor :in_combat
|
21
|
+
attr_accessor :current_enemy
|
22
|
+
attr_accessor :points
|
23
|
+
attr_accessor :dead
|
24
|
+
|
25
|
+
def initialize(args)
|
26
|
+
name = args[:name]
|
27
|
+
neworleans = args[:neworleans]
|
28
|
+
@name = name
|
29
|
+
@level = 1
|
30
|
+
@lives = 100
|
31
|
+
@bonus = 100
|
32
|
+
@str = 5
|
33
|
+
@int = 5
|
34
|
+
@x = 1
|
35
|
+
@y = neworleans.get_height
|
36
|
+
@in_combat = false
|
37
|
+
@current_enemy = nil
|
38
|
+
@points = 0
|
39
|
+
@dead = 0
|
40
|
+
return "Welcome %{name}! Let's play!"
|
41
|
+
end
|
42
|
+
|
43
|
+
# Player attacks enemy
|
44
|
+
def attack(args)
|
45
|
+
player = self
|
46
|
+
enemy = args[:enemy]
|
47
|
+
ui = args[:ui]
|
48
|
+
|
49
|
+
# Does the player even hit the enemy?
|
50
|
+
# We could use a hit chance stat here, but since we don't have one,
|
51
|
+
# we'll just base it off the player/enemy stength discrepency.
|
52
|
+
ui.enemy_info({ player: player })
|
53
|
+
ui.player_info({ player: player })
|
54
|
+
str_diff = (player.str - enemy.str) * 2
|
55
|
+
hit_chance = rand(1...100) + str_diff + HIT_CHANCE_MODIFIER
|
56
|
+
|
57
|
+
if (hit_chance > 50)
|
58
|
+
# Determine value of the attack
|
59
|
+
attack_value = rand(1...player.str) + ATTACK_VALUE_MODIFIER
|
60
|
+
if attack_value > enemy.lives
|
61
|
+
print 'You fought for your life and ' + 'hit'.light_yellow + ' ' +
|
62
|
+
enemy.name.light_red + ' for ' +
|
63
|
+
attack_value.to_s.light_white + " damages, killing him!\n"
|
64
|
+
print 'You gain ' + enemy.points.to_s.light_white + " points.\n"
|
65
|
+
return ENEMY_KILLED
|
66
|
+
else
|
67
|
+
print 'You fought for your life and ' + 'hit'.light_yellow + ' ' +
|
68
|
+
enemy.name.light_red + ' for ' +
|
69
|
+
attack_value.to_s.light_white + " damages, killing him!\n"
|
70
|
+
return attack_value
|
71
|
+
end
|
72
|
+
else
|
73
|
+
print 'You fought for your life and ' + 'missed'.light_red + ' ' +
|
74
|
+
enemy.name + "!\n"
|
75
|
+
return 0
|
76
|
+
end
|
77
|
+
return true
|
78
|
+
end
|
79
|
+
|
80
|
+
def move(args)
|
81
|
+
direction = args[:direction]
|
82
|
+
neworleans = args[:neworleans]
|
83
|
+
ui = args[:ui]
|
84
|
+
story = args[:story]
|
85
|
+
case direction
|
86
|
+
when :up
|
87
|
+
if @y > 1
|
88
|
+
@y -= 1
|
89
|
+
else
|
90
|
+
ui.out_of_bounds
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
when :down
|
94
|
+
if @y < neworleans.get_height
|
95
|
+
@y += 1
|
96
|
+
else
|
97
|
+
ui.out_of_bounds
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
when :left
|
101
|
+
if @x > 1
|
102
|
+
@x -= 1
|
103
|
+
else
|
104
|
+
ui.out_of_bounds
|
105
|
+
return false
|
106
|
+
end
|
107
|
+
when :right
|
108
|
+
if @x < neworleans.get_width
|
109
|
+
@x += 1
|
110
|
+
else
|
111
|
+
ui.out_of_bounds
|
112
|
+
return false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
unless neworleans.check_area({ player: self, ui: ui, story: story })
|
116
|
+
return false
|
117
|
+
else
|
118
|
+
return true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/story.rb
CHANGED
@@ -4,82 +4,78 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
module MISSIONGAME
|
7
|
-
|
8
7
|
STORY_INTRO = [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
'This is a game based on the movie series,' + 'The Originals'.light_green +
|
9
|
+
", that has it's setting in New Orleans, Louisiana, United States.",
|
10
|
+
'Your mission is to meet ' + 'Davina Clare'.light_white +
|
11
|
+
' a very powerful witch of New Orleans, and free her.',
|
12
|
+
'She is currently hostaged by the vampirers under the reign of Klaus Mikaelson.',
|
13
|
+
"She will provide you answers of all the questions you've always wanted to know.",
|
14
|
+
'',
|
15
|
+
'To get stated you will find a ' + 'map'.light_white +
|
16
|
+
' in the Mystic Falls of Virginia.',
|
17
|
+
'Understanding the map will be key to reaching the destination'
|
16
18
|
]
|
17
|
-
|
19
|
+
|
18
20
|
STORY_AREA_TREE = [
|
19
|
-
|
21
|
+
'Take a selfie of you before encountering a bloody scene lol.'
|
20
22
|
]
|
21
|
-
|
22
|
-
STORY_AREA_WATER = [
|
23
|
-
|
24
|
-
]
|
25
|
-
|
23
|
+
|
24
|
+
STORY_AREA_WATER = ['You just got close to Mississippi River.']
|
25
|
+
|
26
26
|
STORY_AREA_MOUNTAIN = [
|
27
|
-
|
28
|
-
]
|
29
|
-
|
30
|
-
STORY_AREA_VILLAINE = [
|
31
|
-
"You encountered a hungry vampire!"
|
27
|
+
'A cool place to get yourself a beer before continuing with your mission.'
|
32
28
|
]
|
33
|
-
|
29
|
+
|
30
|
+
STORY_AREA_VILLAINE = ['You encountered a hungry vampire!']
|
31
|
+
|
34
32
|
STORY_PLAYER_DEAD = [
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
'You have been fed on.',
|
34
|
+
'',
|
35
|
+
'You failed to reach the witch. Please try again.'
|
38
36
|
]
|
39
|
-
|
37
|
+
|
40
38
|
STORY_END = [
|
41
39
|
"You've reached Davina Clare, the powerful witch!".light_white,
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
'',
|
41
|
+
'She stares at you and utters',
|
42
|
+
'',
|
45
43
|
"I can't imagine the time has finally come".light_yellow,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
'This is going to be the end of dominance by vampires becuase this is your kingdom'
|
45
|
+
.light_yellow,
|
46
|
+
'you are special and powerful.'.light_yellow,
|
47
|
+
'',
|
48
|
+
'THANK YOU FOR PLAYING!'.light_red,
|
49
|
+
''
|
51
50
|
]
|
52
|
-
|
51
|
+
|
53
52
|
class Story
|
54
|
-
|
55
53
|
def intro
|
56
54
|
return STORY_INTRO
|
57
55
|
end
|
58
|
-
|
56
|
+
|
59
57
|
def ending
|
60
58
|
return STORY_END
|
61
59
|
end
|
62
|
-
|
60
|
+
|
63
61
|
def area_tree
|
64
62
|
return STORY_AREA_TREE
|
65
63
|
end
|
66
|
-
|
64
|
+
|
67
65
|
def area_water
|
68
66
|
return STORY_AREA_WATER
|
69
67
|
end
|
70
|
-
|
68
|
+
|
71
69
|
def area_mountain
|
72
70
|
return STORY_AREA_MOUNTAIN
|
73
71
|
end
|
74
|
-
|
75
|
-
def
|
72
|
+
|
73
|
+
def area_enemy
|
76
74
|
return STORY_AREA_VILLAINE
|
77
75
|
end
|
78
|
-
|
76
|
+
|
79
77
|
def player_dead
|
80
78
|
return STORY_PLAYER_DEAD
|
81
79
|
end
|
82
|
-
|
83
80
|
end
|
84
|
-
|
85
|
-
end
|
81
|
+
end
|