Class: GamesAndRpgParadise::ShakesAndFidgets::Zauberladen

Inherits:
Base
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb

Constant Summary

Constants included from Base::Extensions::Colours

Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

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(char, run_already = true) ⇒ Zauberladen

#

initialize

You must supply the character.

#


25
26
27
28
29
30
31
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 25

def initialize(
    char,
    run_already = true
  )
  @character = char
  run if run_already
end

Instance Method Details

#ask_user_what_to_do_nextObject

#

ask_user_what_to_do_next

#


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 80

def ask_user_what_to_do_next
  e 'Your current stats have these values:'
  ee '  '
  pp available_stats?
  e 'Which stat do you want to raise? '
  _ = available_stats?
  array = []
  the_keys = _.keys
  the_keys.each_with_index {|this_stat, index|
    index += 1
    e ' - '+sfancy(index)+' '+simp(this_stat.capitalize)
    array << this_stat
  }
  improve_this_attribute = $stdin.gets.chomp
  if improve_this_attribute =~ /^\d+$/ # If is a number.
    improve_this_attribute = array[improve_this_attribute.to_i - 1]
  end
  e 'You want to improve on:'
  e '  '+sfancy(improve_this_attribute.capitalize)
  e improve_this_attribute+': '+_[improve_this_attribute].to_s
  e 'You have n money:'
  e char?.money?
  n_times_improved_already = char?.attributes?[improve_this_attribute] -
                             char?.original_attributes?[improve_this_attribute]
  cost = calculate_cost_for_n_increase_of_attribute(
    n_times_improved_already
  )
  if cost > char?.n_money?
    e 'You can not do this upgrade (Cost: '+simp(cost.to_s)+
      ') because you lack the necessary coins.'
  else # Else do the improve here.
    e 'This will cost you:'
    e simp(cost)
    e simp(char?.deduct_money(cost))
    e 'You have n money:'
    e simp(char?.money?)
    char?.increase(improve_this_attribute, 1) # Apply the change finally.
  end
end

#available_stats?Boolean

#

available_stats?

#

Returns:

  • (Boolean)


73
74
75
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 73

def available_stats?
  char?.available_stats?
end

#character?Boolean Also known as: char?

#

character?

#

Returns:

  • (Boolean)


42
43
44
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 42

def character?
  @character
end

#enter_shopObject

#

enter_shop

#


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

def enter_shop
  e 'You enter the shop for magical items and glance at the various '\
    'offered items.'
  e 'TODO: 6 slots are available'
  e
  e 'You can also raise your stats.'
  e
  reset_the_inventory
  ask_user_what_to_do_next
end

#resetObject

#

reset

#


36
37
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 36

def reset
end

#reset_the_inventoryObject

#

reset_the_inventory

#


63
64
65
66
67
68
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 63

def reset_the_inventory
  # === @inventory
  #
  # This refers to the shop-inventory.
  @inventory = []
end

#runObject

#

run (run tag)

#


123
124
125
# File 'lib/games_and_rpg_paradise/games/shakes_and_fidgets/zauberladen/zauberladen.rb', line 123

def run
  enter_shop
end