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.
- checksums.yaml +4 -4
- data/lib/battlefield.rb +20 -17
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db41d3f12bc6be854fb8390b3cae6b7000acd8b
|
4
|
+
data.tar.gz: a7edebab8e1c6c34b4866d7c801338237cdc5169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 926c60085b735bf4bbd292525cd8dcb0482cb270556385e0630a499abe4ab397a2f5b3d6efd4191ab9a53aa0b7588a886f2b142e5197eae38c8ba22f86fd591c
|
7
|
+
data.tar.gz: 04f99b38c4ab5fd75b0ccef0bb243ae402f5a587821e2803bd709d7a2d71689f42c4eae7cc44e29ee5c83653ae56a0aecb0a5caaadd7b741abef0863b0820416
|
data/lib/battlefield.rb
CHANGED
@@ -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
|
4
|
+
_enemy_ = Creature.new(rand(100))
|
5
5
|
|
6
|
-
2. Create
|
7
|
-
class
|
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
|
-
#
|
17
|
-
def initialize(health
|
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
|
-
#
|
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
|
-
#
|
36
|
+
# The Hero is the main character in any story. Works great for the player's avatar.
|
37
37
|
class Hero < Creature
|
38
|
-
#
|
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
|
-
#
|
44
|
-
class
|
42
|
+
# ArmouredCreatures take a reduced amount of damage.
|
43
|
+
class ArmouredCreature < Creature
|
45
44
|
attr_reader = :armour
|
46
|
-
#
|
47
|
-
def initialize(health
|
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.
|
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:
|
38
|
+
version: 1.3.1
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
41
|
rubygems_version: 2.3.0
|