Skip to content
Permalink
Browse files

main boss added, as well as his room's items, and a win state upon de…

…feat; beast_mode for super strength and more debugging options and help messages; lots of other refactoring and updating
  • Loading branch information...
michaelchadwick committed Jun 10, 2015
1 parent 541b759 commit 9bdb50ed9de98a31b4ea1389ec1ac927592b4f50
@@ -29,16 +29,16 @@ Run the commands above and you'll be whisked away to Jool, ready to start or con
This is in super-hyper-turbo-edition pre-pre-pre-alpha right now, but a working console prompt, some commands (type `h` for a list), and a few locations exist already. Each time you start the game a new hero will be created with a randomized name, but you can change that with `> change name`.

`> c` - character check for visual identity
`> i [object]` - check your inventory (or an individual item within)
`> i [object]` - check your inventory (or an individual item within)
`> ls [entity_type]` - list entities in the game (monsters, items, locations)
`> r` - take a load off and replenish hp
`> l [object]` - look at current location and its items and monsters
`> t [object]` - take an item from a location
`> d [object]` - drop an item from your inventory
`> e [object]` - equip an item in your inventory as a weapon
`> l [object]` - look at current location and its items and monsters
`> t [object]` - take an item from a location
`> d [object]` - drop an item from your inventory
`> e [object]` - equip an item in your inventory as a weapon
`> ue [object]` - unequip an item in your inventory
`> g [direction]` - go in a direction, if possible
`> a [monster]` - attack a monster
`> g [direction]` - go in a direction, if possible
`> a [monster]` - attack a monster
`> ch [attribute]` - change some things about yourself
`> h` - display available commands
`> q` - quit this nonsense w/ prompt
@@ -51,6 +51,7 @@ To come:
* ~~Ability to fight those monsters!~~
* ~~Monsters to fight back!~~
* ~~Items you can pick up!~~
* ~~Main Boss and Win State!~~
* Saving!
* Loading of said saved state!
* More locations to move between!
@@ -8,7 +8,7 @@ require_relative '../lib/gemwarrior/game'
GAME_NAME = "Gem Warrior"

def parse_options
options = {:god_mode => false}
options = {:god_mode => false, :beast_mode => false}

optparse = OptionParser.new do |opts|
opts.on('-v', '--version', 'Display version number and exit') do
@@ -19,6 +19,10 @@ def parse_options
opts.on('-g', '--god', 'Set godmode to true on load') do
options[:god_mode] = true
end

opts.on('-b', '--beast', 'Set beastmode to true on load') do
options[:beast_mode] = true
end
end

optparse.parse!()
@@ -162,13 +162,22 @@ def monster_dead?
end

def monster_death
puts "You have defeated #{monster.name}!".colorize(:green)
puts 'You get the following spoils of war:'
puts " XP : #{monster.xp}".colorize(:green)
puts " ROX: #{monster.rox}".colorize(:green)
print_battle_line
update_player_stats
world.location_by_coords(player.cur_coords).remove_monster(monster.name)
puts "You have defeated #{monster.name}!\n".colorize(:green)
if monster.is_boss
if monster.name.eql?("Emerald")
monster.defeated_text
exit(0)
else
puts 'You just beat a boss monster. Way to go!'
end
else
puts 'You get the following spoils of war:'
puts " XP : #{monster.xp}".colorize(:green)
puts " ROX: #{monster.rox}".colorize(:green)
print_battle_line
update_player_stats
world.location_by_coords(player.cur_coords).remove_monster(monster.name)
end
end

def update_player_stats
@@ -0,0 +1,18 @@
# lib/gemwarrior/entities/boss.rb
# Boss monster

require_relative 'monster'

module Gemwarrior
class Boss < Monster
attr_reader :win_text

def win_text
win_text = 'You beat #{name}! You win! '
win_text << 'You become the true Gem Warrior, marry Queen Ruby, and have many fine, sparkling children. '
win_text << 'Thank you for playing. Goodbye.'
puts win_text
exit(0)
end
end
end
@@ -7,7 +7,7 @@ class Entity
:description

def status
status_text = name.ljust(20).upcase
status_text = name.ljust(26).upcase
status_text << "#{description}\n"
end
end
@@ -0,0 +1,19 @@
# lib/gemwarrior/entities/items/sparklything.rb
# Item::SparklyThing

require_relative '../item'

module Gemwarrior
class SparklyThing < Item
def initialize
self.name = 'SparklyThing(tm)'
self.description = 'The sparkling that this thing does is unimaginably brilliant.'
self.atk_lo = nil
self.atk_hi = nil
self.takeable = true
self.useable = true
self.equippable = false
self.equipped = false
end
end
end
@@ -0,0 +1,19 @@
# lib/gemwarrior/entities/items/throne.rb
# Item::Throne

require_relative '../item'

module Gemwarrior
class Throne < Item
def initialize
self.name = 'throne'
self.description = 'Made of what appears to be unfulfilled desires and latent, flawed happiness, the well-crafted seat still looks kinda comfy.'
self.atk_lo = nil
self.atk_hi = nil
self.takeable = false
self.useable = false
self.equippable = false
self.equipped = false
end
end
end
@@ -11,10 +11,9 @@ class Location < Entity

## ERRORS
ERROR_LOCATION_ITEM_REMOVE_INVALID = 'That item cannot be removed as it does not exist here.'
ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You do not see that here.'

attr_accessor :coords, :locs_connected, :danger_level, :items,
:monsters_abounding, :checked_for_monsters
:monsters_abounding, :bosses_abounding, :checked_for_monsters

def initialize(options)
self.name = options.fetch(:name)
@@ -24,11 +23,12 @@ def initialize(options)
self.danger_level = options.fetch(:danger_level)
self.items = options.fetch(:items)
self.monsters_abounding = []
self.bosses_abounding = options[:bosses_abounding]
self.checked_for_monsters = false
end

def status
status_text = name.ljust(20).upcase
status_text = name.ljust(26).upcase
status_text << coords.values.to_a.to_s
status_text << " #{description}\n"
end
@@ -59,9 +59,11 @@ def has_loc_to_the?(direction)
locs_connected[direction.to_sym]
end

def monster_by_name(name)
monsters_abounding.each do |m|
if m.name.eql?(name)
def monster_by_name(monster_name)
monsters_list = monsters_abounding | bosses_abounding

monsters_list.each do |m|
if m.name.downcase.eql?(monster_name.downcase)
return m.clone
end
end
@@ -86,13 +88,17 @@ def has_monster?
end

def list_items
return "\n >> Shiny object(s): #{items.map(&:name).join(', ')}" if items.length > 0
return "\n >> Curious object(s): #{items.map(&:name).join(', ')}" if items.length > 0
end

def list_monsters
return "\n >> Monster(s) abound: #{monsters_abounding.map(&:name).join(', ')}" if monsters_abounding.length > 0
end

def list_bosses
return "\n >> Boss(es) abound: #{bosses_abounding.map(&:name).join(', ')}" if bosses_abounding.length > 0
end

def list_paths
valid_paths = []
locs_connected.each do |key, value|
@@ -104,10 +110,20 @@ def list_paths
end

def populate_monsters(monsters_available)
self.checked_for_monsters = true
if has_monster?
self.checked_for_monsters = true
self.monsters_abounding = []
monsters_abounding.push(monsters_available[rand(0..monsters_available.length-1)])
random_monster = nil

# get random non-boss monster
loop do
random_monster = monsters_available[rand(0..monsters_available.length-1)]
unless random_monster.is_boss
break
end
end

monsters_abounding.push(random_monster)
else
return nil
end
@@ -5,10 +5,10 @@

module Gemwarrior
class Monster < Creature
attr_accessor :battlecry
attr_accessor :battlecry, :is_boss

def describe
status_text = name.upcase.ljust(20)
status_text = name.upcase.ljust(26)
status_text << "LEVEL: #{level.to_s.rjust(2)}, "
status_text << "HP: #{hp_cur.to_s.rjust(3)}/#{hp_max.to_s.rjust(3)} "
status_text << "ATK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)} "
@@ -0,0 +1,54 @@
# lib/gemwarrior/entities/monsters/bosses/emerald.rb
# Emerald boss monster

require_relative '../../monster'
require_relative '../../items/sparklything'

module Gemwarrior
class Emerald < Monster
attr_accessor :defeated_text

def initialize
self.name = 'Emerald'
self.description = 'A wily, beefy, tower of a man, champion of both wisdom and strength, sporting a constant glint in his eyes.'
self.face = 'gleaming'
self.hands = 'tantalizing'
self.mood = 'enraged'

self.level = 15
self.hp_cur = rand((level * 2)..(level * 3))
self.hp_max = hp_cur
self.atk_lo = rand(level..(level * 2.5).floor)
self.atk_hi = rand((level * 2.5).floor..(level * 3).floor)
self.defense = rand(5..7)
self.dexterity = rand(8..10)

self.inventory = Inventory.new(items = [SparklyThing.new])
self.rox = rand((level * 2)..(level * 3))
self.xp = rand(level..(level * 2))

self.battlecry = 'Ha ha ha ha ha! Prepare yourself: today your whole life crumbles!'
self.is_boss = true
self.defeated_text = defeated_text
end

def defeated_text
0.upto(9) do print '<^>' end
print "\n"
puts "You beat #{name}! You win!\n"
print "You receive the "
print "SparklyThing(tm)".colorize(:magenta)
print " and become the true "
print "Gem Warrior".colorize(:yellow)
print "!\n"
print "You decide to ignore "
print "Queen Ruby".colorize(:red)
print " and take your spoils back home\n"
print "where you live out the rest of your days staring at it, wondering\n"
print "what it was all about.\n\n"
puts "Thank you for playing. Goodbye."
0.upto(9) do print '<^>' end
puts
end
end
end
@@ -16,7 +16,8 @@ class Player < Creature
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']

attr_accessor :stam_cur, :stam_max, :cur_coords, :god_mode
attr_accessor :stam_cur, :stam_max, :cur_coords,
:god_mode, :beast_mode

def initialize(options)
self.name = generate_name
@@ -25,13 +26,13 @@ def initialize(options)
self.face = generate_face
self.hands = generate_hands
self.mood = generate_mood

self.level = options.fetch(:level)
self.xp = options.fetch(:xp)
self.hp_cur = options.fetch(:hp_cur)
self.hp_max = options.fetch(:hp_max)
self.atk_lo = options.fetch(:atk_lo)
self.atk_hi = options.fetch(:atk_hi)
self.atk_lo = options.fetch(:beast_mode) ? 40 : options.fetch(:atk_lo)
self.atk_hi = options.fetch(:beast_mode) ? 40 : options.fetch(:atk_hi)

self.defense = options.fetch(:defense)
self.dexterity = options.fetch(:dexterity)
@@ -42,8 +43,9 @@ def initialize(options)
self.stam_cur = options.fetch(:stam_cur)
self.stam_max = options.fetch(:stam_max)
self.cur_coords = options.fetch(:cur_coords)

self.god_mode = options.fetch(:god_mode)
self.beast_mode = options.fetch(:beast_mode)
end

def check_self(show_pic = true)
@@ -60,16 +62,17 @@ def check_self(show_pic = true)
self.atk_hi = inventory.weapon.atk_hi
end

self_text = "NAME: #{name}\n"
self_text = "XY : #{cur_coords.values.to_a}\n"
self_text << "WPN : #{cur_weapon_name}\n"
self_text << "LVL : #{level}\n"
self_text << "XP : #{xp}\n"
self_text << "HP : #{hp_cur}|#{hp_max}\n"
self_text << "ATK : #{atk_lo}-#{atk_hi}\n"
self_text << "DEX : #{dexterity}\n"
self_text << "DEF : #{defense}\n"
self_text << "GOD : #{god_mode}\n\n"
self_text = "NAME : #{name}\n"
self_text = "XY : #{cur_coords.values.to_a}\n"
self_text << "WPN : #{cur_weapon_name}\n"
self_text << "LVL : #{level}\n"
self_text << "XP : #{xp}\n"
self_text << "HP : #{hp_cur}/#{hp_max}\n"
self_text << "ATK : #{atk_lo}-#{atk_hi}\n"
self_text << "DEX : #{dexterity}\n"
self_text << "DEF : #{defense}\n"
self_text << "GOD : #{god_mode}\n"
self_text << "BEAST: #{beast_mode}\n\n"

self_text << "#{description}\n\n"

Oops, something went wrong.

0 comments on commit 9bdb50e

Please sign in to comment.
You can’t perform that action at this time.