I'm making myself and a few of my friends a combat assistant for Dungeons and Dragons, since most of the keeping track is pretty repetitive so I thought I could Ruby something up. It was going well but now I've hit a roadblock.
This is my code
def party8
party7
puts "Last one! What's your eighth player's name?"
player8name = gets.chomp
puts "What's their AC?"
player8ac = gets.chomp.to_i
puts "Got it. What's their max HP?"
player8maxhp = gets.chomp.to_i
end
def partysetup
puts "hi"
if 8 == playercount
party8
else
party1
end
end
#intro----------------------------------------------------------------------
puts "-Hello. I am l1fecount, the DM's combat assistant."
puts "-Before we begin, would you like to see in-depth information about me?"
infoq = gets.chomp
infoq.downcase!
if infoq == "yes"
puts "-Very well, I'm glad to explain. I am l1fecount, a program designed to keep track of up to 5 types of mobs, with up to 10
of each. I can also keep track of up to 8 players. I keep track of turn order, current HP vs max HP, CR, and armor
class. I am still very young, so please be patient with me. ^^; "
else
puts "-Right then."
end
puts "-So, let's begin."
#intro end----------------------------------------------------------------
#party---------------------------------------------------------------------
loop do
puts "How many players today?"
playercount = gets.chomp.to_i
if 0 >= playercount
puts "You can't have no players in a party. That's not D&D, that's you having no friends."
redo
elsif 8 < playercount
puts "Hey now, that's a huge party. I can only handle eight players at once."
redo
elsif 8 >= playercount
break
else
puts "A number between 1 and 8, please."
redo
end
end
partysetup
`
(party1-7 exists, but is identical to party 8, so I didn't include it for brevity's sake.)
It runs just fine until I try to run partysetup. I added a puts statement so I could see if the method was being called, and it is, but I keep getting this:
-Hello. I am l1fecount, the DM's combat assistant.
-Before we begin, would you like to see in-depth information about me?
no
-Right then.
-So, let's begin.
How many players today?
8
hi
Error: undefined method `playercount' for main:Object
I've tried looking for simple spelling errors, converting playercount to a string or a symbol, but nothing has fixed this issue. Help please?