Battlefield 1.0.3 → 1.1.0
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/bin/battle +4 -0
- data/lib/battlefield.rb +5 -3
- data/{lib → test}/battlefield_test.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26151680d3e15a6e6e4d0c7dfab984c51e07be91
|
4
|
+
data.tar.gz: 5f8d4b54ade88fd7a1626bfa5ab40d41c75e86c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ece9c8ee79f3d6c2c56d7c71d043295c04a696d8e8b12b9fb293fd0b5b57364e438d8c2c2023438bfbef732a32392cb0a23edfc12e51773e499d716eba3bdac7
|
7
|
+
data.tar.gz: 0400cf0e0c9384092dad1908739c21da8828c553606f2aab475328afec8f5d31451fd6001ad4916f02955e87b696ed9f56714c571ca57fc18c526d2fb6459c4e
|
data/bin/battle
ADDED
data/lib/battlefield.rb
CHANGED
@@ -33,16 +33,16 @@ This is a great superclass if you want damage reductions.
|
|
33
33
|
class ArmouredCreature < Creature
|
34
34
|
attr_reader = :armour
|
35
35
|
# Initializes an ArmoredCreature. Parameter armour sets the damage reduction rate. It should be a float.
|
36
|
-
def initialize(health, armour); @health, @armour = health,
|
36
|
+
def initialize(health, armour); @health, @armour = health, armour; end
|
37
37
|
# Reduces damage by multiplying it by armour.
|
38
38
|
def damage(amt)
|
39
|
-
@health -= (amt
|
39
|
+
@health -= (amt * @armour)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
# The Hero is the main character in any story. Works great for the player's avatar and can have armour.
|
43
43
|
class Hero < ArmouredCreature
|
44
44
|
# Initializes a new Hero. Sets health to 100. If you want your hero to have armour, set it as a float.
|
45
|
-
def initialize(armour
|
45
|
+
def initialize(armour); @health, @armour = 100, armour; end
|
46
46
|
end
|
47
47
|
=begin
|
48
48
|
Specify your combatants in parameters hero and enemy
|
@@ -52,6 +52,7 @@ If you want your hero to heal, set parameter heal to 'hero'. If you want your en
|
|
52
52
|
=end
|
53
53
|
def battle(hero, enemy, heal = false)
|
54
54
|
until hero.health <= 0 || enemy.health <= 0
|
55
|
+
roll1, roll2 = hero.droll, enemy.droll
|
55
56
|
# You hit enemy and it takes your roll amount
|
56
57
|
if roll1 > roll2
|
57
58
|
if heal == "hero" or heal == "both"
|
@@ -73,6 +74,7 @@ def battle(hero, enemy, heal = false)
|
|
73
74
|
hero.damage roll2
|
74
75
|
sleep 1
|
75
76
|
end
|
77
|
+
puts "You: #{hero.health} #{enemy}: #{enemy.health}"
|
76
78
|
sleep 2
|
77
79
|
end
|
78
80
|
end
|
metadata
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Battlefield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Perlmutter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
|
-
Allows you to create combatants and let them battle. Useful for pick-your-path text games.
|
14
|
+
Allows you to create combatants and let them battle. Useful for pick-your-path text games. Comes with an executable for simulating battles.
|
15
15
|
email: zrp200@gmail.com
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- battle
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
21
|
+
- bin/battle
|
20
22
|
- lib/battlefield.rb
|
21
|
-
-
|
23
|
+
- test/battlefield_test.rb
|
22
24
|
homepage: https://rubygems.org/gems/Battlefield
|
23
25
|
licenses:
|
24
26
|
- MIT
|
@@ -44,4 +46,4 @@ signing_key:
|
|
44
46
|
specification_version: 4
|
45
47
|
summary: Allows your objects to battle
|
46
48
|
test_files:
|
47
|
-
-
|
49
|
+
- test/battlefield_test.rb
|