1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rubyでRPGっぽいのを作ってみる その2

Posted at

プレイヤーの名前を入力するところまで作成してみました。

status.rb

class Status
    attr_accessor :name
    attr_accessor :job
    attr_accessor :level
    attr_accessor :life
    attr_accessor :atacck
    attr_accessor :defence
    
    def initialize
        puts "あなたの名前を入力して下さい"
        self.name = gets.chomp
        
        while true
            print "あなたの名前は#{self.name}でいいですか(y/n)?"
            response = gets.chomp
            if response == "y" || response == "Y"
                break
            else
                puts "あなたの名前を入力して下さい"
                self.name = gets.chomp
            end
                
        end
        
    end
end

もっとスマートなやり方があるのかもしれないけど、今はこれが限界。
あと、ステータスを決めるためにクラスにjobを追加したけど、各職業の能力値もクラスで管理した方がいいのだろうか?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?