Class: GamesAndRpgParadise::Godmode::Player

Inherits:
Base
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/godmode/player.rb

Overview

GamesAndRpgParadise::Godmode::Player

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
MAXIMUM_NUMBER_OF_GLADIATORS =
#

MAXIMUM_NUMBER_OF_GLADIATORS

#
5
MAXIMUM_NUMBER_SIDE_GLADIATORS =
#

MAXIMUM_NUMBER_SIDE_GLADIATORS

#
12

Constants included from Base::Extensions::Colours

Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::Extensions::Colours

ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ Player

#

initialize

#


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 49

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  set_name(first_argument?)
  run if run_already
end

Instance Attribute Details

#array_storing_gladiatorsObject

Returns the value of attribute array_storing_gladiators.



42
43
44
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 42

def array_storing_gladiators
  @array_storing_gladiators
end

#n_gold_coinsObject

Returns the value of attribute n_gold_coins.



44
45
46
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 44

def n_gold_coins
  @n_gold_coins
end

#n_slavesObject

Returns the value of attribute n_slaves.



43
44
45
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 43

def n_slaves
  @n_slaves
end

#player_nameObject

Returns the value of attribute player_name.



41
42
43
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 41

def player_name
  @player_name
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

GamesAndRpgParadise::Godmode::Player[]

#


174
175
176
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 174

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#add_main_gladiator(i = Gladiator.new) ⇒ Object

#

add_main_gladiator

Use only this method when appending to @array_storing_gladiators Reason for this constraint is that we disallow to have more than MAXIMUM_NUMBER_OF_GLADIATORS.

#


149
150
151
152
153
154
155
156
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 149

def add_main_gladiator(i = Gladiator.new)
  if @array_storing_main_gladiators.size == MAXIMUM_NUMBER_OF_GLADIATORS
    warn 'You can not add any more Gladiator as the limit of '+
          MAXIMUM_NUMBER_OF_GLADIATORS.to_s+' was already reached.'
  else
    @array_storing_main_gladiators << i
  end
end

#add_side_gladiator(i = Gladiator.new) ⇒ Object

#

add_side_gladiator

#


114
115
116
117
118
119
120
121
122
123
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 114

def add_side_gladiator(
    i = Gladiator.new
  )
  if @array_storing_side_gladiators.size == MAXIMUM_NUMBER_SIDE_GLADIATORS
    ewarn 'You can not add any more Gladiator as the limit of '+
           MAXIMUM_NUMBER_SIDE_GLADIATORS.to_s+' was already reached.'
  else
    @array_storing_side_gladiators << i
  end
end

#deduct_n_gold_coins(i) ⇒ Object

#

decut_n_gold_coins

This method will deduct some gold coins.

#


97
98
99
100
101
102
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 97

def deduct_n_gold_coins(i)
  @n_gold_coins -= i.to_i
  if @n_gold_coins < 0
    @n_gold_coins = 0
  end
end

#get_nameObject

#

get_name

this gets player name.

#


130
131
132
133
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 130

def get_name
  e 'Input your name now please:'
  @player_name = STDIN.gets.chomp
end

#n_gladiators?Boolean

#

n_gladiators?

#

Returns:

  • (Boolean)


138
139
140
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 138

def n_gladiators?
  e "You have #{@array_storing_gladiators.size} Gladiators."
end

#name?Boolean

#

name?

#

Returns:

  • (Boolean)


161
162
163
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 161

def name?
  @name
end

#resetObject

#

reset (reset tag)

#


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 64

def reset
  super()
  # ======================================================================= #
  # === @n_gold_coins
  #
  # This variable keeps track as to how many gold coins a given player
  # has.
  # ======================================================================= #
  @n_gold_coins = 1000+rand(101)
  # ======================================================================= #
  # === @n_slaves
  #
  # How many slaves this player (the merchant) owns. This has to be 0
  # initially, for a clean game state.
  # ======================================================================= #
  @n_slaves = 0
  # ======================================================================= #
  # === @array_storing_main_gladiators
  # ======================================================================= #
  @array_storing_main_gladiators = []
  # ======================================================================= #
  # === @array_storing_side_gladiators
  # ======================================================================= #
  @array_storing_side_gladiators = []
  add_main_gladiator
  add_side_gladiator
end

#runObject

#

run (run tag)

#


168
169
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 168

def run
end

#set_name(i) ⇒ Object

#

set_name

#


107
108
109
# File 'lib/games_and_rpg_paradise/games/godmode/player.rb', line 107

def set_name(i)
  @name = i
end