Created
December 7, 2017 21:21
-
-
Save CodePint/00e848c0c5cd99c98cada3dd7c8f0756 to your computer and use it in GitHub Desktop.
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
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 | |
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 | |
end | |
player1 = stats_initialize | |
player1.race_stat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment