Battlefield 0.0.9 → 0.1.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/battlefield.rb +20 -17
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea35d68f2814c70585aa9f1520c7eb501cf6365d
4
- data.tar.gz: 7e1e69a87a0f70caaae3f96f68341d7d4d32044a
3
+ metadata.gz: 7db41d3f12bc6be854fb8390b3cae6b7000acd8b
4
+ data.tar.gz: a7edebab8e1c6c34b4866d7c801338237cdc5169
5
5
  SHA512:
6
- metadata.gz: d53ac2d164dc1bc2680f7a286c13e65f93d993c2fed8d708dc7d3e5e082ad0f45cc94ffc1fe62bf5eed8687adc7c685a070a1587baef37244e9a7513e6340b56
7
- data.tar.gz: b938407b8c1622d7e47a28a961a7f57e33255418ffbeefe15e38e06836b8d99f19554fd8143407b1cb46dde17681df000819b6fea018f3a5ab94e3bc77a93f67
6
+ metadata.gz: 926c60085b735bf4bbd292525cd8dcb0482cb270556385e0630a499abe4ab397a2f5b3d6efd4191ab9a53aa0b7588a886f2b142e5197eae38c8ba22f86fd591c
7
+ data.tar.gz: 04f99b38c4ab5fd75b0ccef0bb243ae402f5a587821e2803bd709d7a2d71689f42c4eae7cc44e29ee5c83653ae56a0aecb0a5caaadd7b741abef0863b0820416
@@ -1,10 +1,10 @@
1
1
  =begin
2
2
  If you want to make a new enemy, you have two ways to do it:
3
3
  1. Directly initialize it
4
- Creature.new (insert health here)
4
+ _enemy_ = Creature.new(rand(100))
5
5
 
6
- 2. Create a new class
7
- class (Insert enemy name here) < Creature
6
+ 2. Create a new class
7
+ class _Insert enemy name here_ < Creature
8
8
  def initialize; @health = _insert health here_; end
9
9
  end
10
10
 
@@ -13,39 +13,38 @@ Common ancestor of any battle-able objects
13
13
  =end
14
14
  class Creature
15
15
  attr_accessor :health
16
- # Really should specify health and now you can battle
17
- def initialize(health = 0)
16
+ # Initializes a Creature. Parameter health sets the Creature's health.
17
+ def initialize(health)
18
18
  @health = health
19
19
  end
20
20
  # Damage function
21
21
  def damage(amt)
22
22
  @health -= amt
23
23
  end
24
- # rolling function - higher # = more power
24
+ # Rolling function - higher # = more power.
25
25
  def roll
26
26
  (1..6).to_a.sample; end
27
27
  # roll twice
28
28
  def droll
29
29
  self.roll + self.roll
30
30
  end
31
- # The 1st argument is your attack power. The other is the enemy's. You heal c1 - c2 health
31
+ # The 1st argument is your attack power. The other is the enemy's. You heal c1 - c2 health.
32
32
  def heal(c1, c2)
33
33
  @health += c1 - c2
34
34
  end
35
35
  end
36
- # To use, create an instance first
36
+ # The Hero is the main character in any story. Works great for the player's avatar.
37
37
  class Hero < Creature
38
- # The hero starts with 100 health
39
- def initialize
40
- @health = 100
38
+ # Initializes a new Hero. Sets health to 100.
39
+ def initialize; @health = 100
41
40
  end
42
41
  end
43
- # Initializes an ArmoredCreature. It takes a reduced amount of damage.
44
- class ArmoredCreature < Creature
42
+ # ArmouredCreatures take a reduced amount of damage.
43
+ class ArmouredCreature < Creature
45
44
  attr_reader = :armour
46
- # specify damage reduction as a float in parameter armour
47
- def initialize(health = 0, armour = 0.5); @health, @armour = health, armor; end
48
- # Reduces damage by multiplying it by armour
45
+ # Initializes an ArmoredCreature. Parameter armour sets the damage reduction rate. It should be a float.
46
+ def initialize(health, armour); @health, @armour = health, armor; end
47
+ # Reduces damage by multiplying it by armour.
49
48
  def damage(amt)
50
49
  @health -= (amt*@armour)
51
50
  end
@@ -78,4 +77,8 @@ def battle(hero, enemy, heal = false)
78
77
  end
79
78
  sleep 2
80
79
  end
81
- end
80
+ end
81
+ # Initializes a new Creature. If no arguments are given, health is set to 0.
82
+ def Creature(health = 0); Creature.new health; end
83
+ # Initializes a new ArmouredCreature. By default, health is set to 0 and armour is set to 0.5
84
+ def ArmouredCreature(health=0, armour=0.5); ArmouredCreature.new health, armour; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Battlefield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Perlmutter
@@ -28,14 +28,14 @@ require_paths:
28
28
  - lib
29
29
  required_ruby_version: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.9.3
34
34
  required_rubygems_version: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ">="
36
+ - - '>'
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
38
+ version: 1.3.1
39
39
  requirements: []
40
40
  rubyforge_project:
41
41
  rubygems_version: 2.3.0