Class: GamesAndRpgParadise::PlayerClass
- Inherits:
-
GridLayout
- Object
- GridLayout
- GamesAndRpgParadise::PlayerClass
- Defined in:
- lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb
Overview
#
Nimmt die PlayerClass
#
Constant Summary
Constants inherited from GridLayout
Constants included from Colours
Instance Attribute Summary collapse
-
#computer ⇒ Object
Returns the value of attribute computer.
Attributes inherited from GridLayout
Instance Method Summary collapse
-
#info ⇒ Object
# === info ========================================================================= #.
-
#initialize(name) ⇒ PlayerClass
constructor
initialize.
-
#play_against_computer ⇒ Object
# == lay_against_computer ========================================================================= #.
-
#prepare_game ⇒ Object
# === prepare_game.
Methods inherited from GridLayout
#calculate_grid, #debug, #output_grid, #owner?, #randomly_place_ship, #randomly_shoot_at, #reset, #shoot_at, #win_the_game
Methods included from Colours
#brown, #cfile, #convert_colour, convert_colour, #fancy, #normal, #pink, #red, #yel
Constructor Details
#initialize(name) ⇒ PlayerClass
initialize
222 223 224 225 226 227 228 229 230 231 |
# File 'lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb', line 222 def initialize(name) super() @player_name = name if @player_name.nil? @player_name = "TestPlayer" else @player_name = name end @computer = '' end |
Instance Attribute Details
#computer ⇒ Object
Returns the value of attribute computer.
220 221 222 |
# File 'lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb', line 220 def computer @computer end |
Instance Method Details
#info ⇒ Object
#
info
#
249 250 251 |
# File 'lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb', line 249 def info e "You are #{@player_name}." end |
#play_against_computer ⇒ Object
#
lay_against_computer
#
256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb', line 256 def play_against_computer e 'The computer.' @computer = GridLayout.new @computer.randomly_place_ship @computer.calculate_grid @computer.owner = 'Computer' puts @computer.owner? 5.times { randomly_shoot_at(@computer) } # neu berechnen des grid @computer.calculate_grid puts "Der Computer Grid" @computer.display_grid end |
#prepare_game ⇒ Object
#
prepare_game
This method will prepare the game. Right now it only randomly places a ship somewhere and calculates the grid. And starts the play_against_computer method.
#
240 241 242 243 244 |
# File 'lib/games_and_rpg_paradise/games/schiffe_versenken/schiffe_versenken.rb', line 240 def prepare_game randomly_place_ship calculate_grid play_against_computer end |