Created
December 7, 2017 21:35
-
-
Save CodePint/866f87852225993cb6267402e0d8e462 to your computer and use it in GitHub Desktop.
text_adv_classselect.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Text Adventure ## | |
=begin | |
Project Mission | |
*********************** | |
NPC/Player creation | |
- Create races | |
- Create classes | |
- Create NPC | |
- Create Mobs | |
*********************** | |
Game mechanics | |
- Health + Take damage | |
- Attacks + Heal | |
- Death | |
- NPC/Mob AI (logic) | |
*********************** | |
Story logic | |
- Create main story | |
- Create random events | |
- write story text | |
Game logic | |
- Progress | |
- Win condition | |
- Player I/O | |
*********************** | |
Items | |
- Create weapons | |
- Create buffs | |
- Create loot | |
=end | |
# importing + displaying ascii art banner | |
def banner | |
File.open("banner.txt").each do |line| | |
puts line | |
end | |
end | |
banner | |
#super player/AI class | |
class Gamesuper | |
def whoissuper | |
puts "I am a superclass" | |
end | |
end | |
class Player < Gamesuper | |
attr_accessor :name, :age, :race, :backstory, :base_health, :base_damage, | |
:hp, :location, :victory, :inventory | |
def initialize(name, age, race, backstory, base_health=nil, base_damage=nil, hp=nil, location=nil, victory=false, inventory=[]) | |
@name = name | |
@age = age | |
@race = race | |
@backstory = backstory | |
@base_damage = base_damage | |
@base_health = base_health | |
@hp = hp | |
@location = location | |
@victory = victory | |
@inventory = inventory | |
end | |
def race_stat | |
if race == "elf" | |
@base_health = 200 | |
@base_damage = 100 | |
elsif race == "dwarf" | |
@base_health = 250 | |
@base_damage = 75 | |
else race == "human" | |
@base_health = 150 | |
@base_damage = 150 | |
end | |
end | |
end | |
def race_stats_text | |
puts "Race stats" | |
line_break | |
puts "Elf = 200HP \t 100DMG | |
Dwarf = 250HP \t 75DMG | |
Human = 150HP \t 150DMG" | |
puts line_break | |
end | |
def line_break(text="*", n=30) | |
puts text * n | |
end | |
def stats_initialize | |
puts race_stats_text | |
puts "what race are you (elf, dwarf, human)" | |
myrace = gets.chomp | |
puts "what is your name? " | |
name = gets.chomp.capitalize | |
puts "how old are you? " | |
age = gets.chomp | |
puts "tell us your story" | |
story = gets.chomp | |
player1 = Player.new(name, age, myrace, story) | |
line_break("*", 60) | |
puts "Your character is a #{age} year old #{myrace}, and their name is #{name}" | |
puts "\n" | |
puts "This is their story:\n#{story}" | |
puts line_break("*", 60) | |
puts "\n" | |
return player1 | |
end | |
player1 = stats_initialize | |
player1.race_stat | |
puts player1.inspect | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment