Skip to content

Commit 3a9e7c1

Browse files
author
Robert W. Oliver II
committed
Bug fixes
* Changed colors and icons to work better with various platforms * Killing an enemy now removes them from the map * Added the "clear" or "cls" command
1 parent 4422d65 commit 3a9e7c1

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Written by Robert W. Oliver II
1313

1414
Copyright (C) 2018 Sourcerer, All Rights Reserved.
1515

16+
# Running the Game
17+
18+
```
19+
ruby bin/lots
20+
```
21+
1622
# License
1723

1824
```

bin/lots

100755100644
File mode changed.

lib/main.rb

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
ui.draw_frame({:text => map})
4343
when "version", "ver"
4444
ui.display_version
45+
when "clear", "cls"
46+
ui.clear
4547
when "name", "whoami"
4648
ui.display_name({:player => player})
4749
when "location", "loc", "where", "whereami"
@@ -52,61 +54,58 @@
5254
unless player.in_combat
5355
if !player.move({:direction => :up, :world => world, :ui => ui, :story => story})
5456
player.in_combat = 1
55-
end
57+
end
5658
else
5759
ui.cannot_travel_combat
5860
end
5961
when "down", "south", "d", "s"
6062
unless player.in_combat
6163
if !player.move({:direction => :down, :world => world, :ui => ui, :story => story})
6264
player.in_combat = 1
63-
end
65+
end
6466
else
6567
ui.cannot_travel_combat
6668
end
6769
when "left", "west", "l", "w"
6870
unless player.in_combat
6971
if !player.move({:direction => :left, :world => world, :ui => ui, :story => story})
7072
player.in_combat = 1
71-
end
73+
end
7274
else
7375
ui.cannot_travel_combat
7476
end
7577
when "right", "east", "r", "e"
7678
unless player.in_combat
7779
if !player.move({:direction => :right, :world => world, :ui => ui, :story => story})
7880
player.in_combat = 1
79-
end
81+
end
8082
else
8183
ui.cannot_travel_combat
8284
end
8385
when "attack", "a"
8486
if player.in_combat
8587
retval = player.attack({:enemy => player.current_enemy, :ui => ui})
86-
if retval == LOTS::ENEMY_KILLED
87-
player.lines += player.current_enemy.lines
88+
if retval == LOTS::ENEMY_KILLED
89+
player.lines += player.current_enemy.lines
90+
# Remove enemy from map
91+
world.the_map[player.y-1][player.x-1] = LOTS::MAP_KEY_GRASS
92+
# Take player out of combat
8893
player.current_enemy = nil
89-
player.in_combat = false
90-
end
91-
if retval.is_a? Numeric
94+
player.in_combat = false
95+
end
96+
if retval.is_a? Numeric
9297
player.current_enemy.health -= retval
93-
retval = player.current_enemy.attack({:player => player})
94-
if retval.is_a? Numeric
98+
retval = player.current_enemy.attack({:player => player})
99+
if retval.is_a? Numeric
95100
player.health -= retval
96101
end
97-
if retval == LOTS::PLAYER_DEAD
98-
player.dead = 1
99-
end
100-
end
101-
else
102-
ui.not_in_combat
103-
end
104-
when "cast", "spell"
105-
if player.in_combat
106-
# TODO: Cast a spell
107-
else
108-
ui.not_in_combat
109-
end
102+
if retval == LOTS::PLAYER_DEAD
103+
player.dead = 1
104+
end
105+
end
106+
else
107+
ui.not_in_combat
108+
end
110109
when "player", "me", "info", "status", "i"
111110
ui.player_info({:player => player})
112111
when "enemy"
@@ -121,7 +120,7 @@
121120
player.dead = 1
122121
when "help", "h", "?"
123122
ui.help
124-
when "quit"
123+
when "quit", "exit"
125124
ui.quit
126125
running = nil
127126
else

lib/ui.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def help
5757
new_line
5858
print UI_ARROW.light_yellow + " " + "lines, score, status, info".light_white + " - Display lines of code (score)"
5959
new_line
60-
print UI_ARROW.light_yellow + " " + "quit".light_white + " - Quits the game"
60+
print UI_ARROW.light_yellow + " " + "clear, cls".light_white + " - Clears the screen"
61+
new_line
62+
print UI_ARROW.light_yellow + " " + "quit, exit".light_white + " - Quits the game"
6163
new_line
6264
end
6365

lib/world.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ module LOTS
1010
MAP_WIDTH = 64
1111
MAP_HEIGHT = 14
1212

13-
MAP_KEY_TREE = "\u2618"
14-
MAP_KEY_WATER = "\u2668"
13+
MAP_KEY_TREE = "\u2663"
14+
MAP_KEY_WATER = "\u2248"
1515
MAP_KEY_GRASS = "\u2588"
1616
MAP_KEY_MOUNTAIN = "\u25B2"
1717
MAP_KEY_ENEMY = "\u263A"
18-
MAP_KEY_SOURCERER = "\u2658"
18+
MAP_KEY_SOURCERER = "\u263B"
1919
MAP_KEY_PLAYER = "\u1330"
2020

2121
# Weighted
@@ -69,22 +69,22 @@ def get_map(args)
6969
placed = 0
7070
# Place sourcerer
7171
if x == MAP_SOURCERER_X and y == MAP_SOURCERER_Y
72-
tmp_row << MAP_KEY_SOURCERER.colorize(:color => :blue, :background => :light_white)
72+
tmp_row << MAP_KEY_SOURCERER.colorize(:color => :white, :background => :red)
7373
placed = 1
7474
end
7575
# If player is here, display them
7676
if x == player.x and y == player.y
77-
tmp_row << MAP_KEY_PLAYER.colorize(:color => :light_white, :background => :red)
77+
tmp_row << MAP_KEY_PLAYER.colorize(:color => :red, :background => :white)
7878
placed = 1
7979
end
8080
# If we haven't already placed the character, run through the rest of the options
8181
if placed == 0
8282
case col
8383
when MAP_KEY_TREE
8484
tmp_row << col.colorize(:color => :light_green, :background => :green)
85-
when MAP_KEY_GRASS
85+
when MAP_KEY_GRASS
8686
tmp_row << col.colorize(:color => :green, :background => :green)
87-
when MAP_KEY_WATER
87+
when MAP_KEY_WATER
8888
tmp_row << col.colorize(:color => :white, :background => :blue)
8989
when MAP_KEY_MOUNTAIN
9090
tmp_row << col.colorize(:color => :yellow, :background => :green)

0 commit comments

Comments
 (0)