Battlefield 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa18572f350de68cb43a22f90c7eac533233b891
4
- data.tar.gz: 0d04d567322d981119b98d3dafec7bf3aea9cd85
3
+ metadata.gz: 26151680d3e15a6e6e4d0c7dfab984c51e07be91
4
+ data.tar.gz: 5f8d4b54ade88fd7a1626bfa5ab40d41c75e86c9
5
5
  SHA512:
6
- metadata.gz: a197d8ae9ad17ddd2dbceacd306d3eb588231e9fef78993a5a382ba8a2db6ded95276f6ef0625533e598120b5243390b71a96f3f5332b5337803568da96bc178
7
- data.tar.gz: cd11f3803b989d22b40c50d42b349b9de626d2a935b576978bfd0372ab00b0fa1c9d0600cd8a77fd3991a247a9863466aba89a13a588d6c0b56045ef6c0021de
6
+ metadata.gz: ece9c8ee79f3d6c2c56d7c71d043295c04a696d8e8b12b9fb293fd0b5b57364e438d8c2c2023438bfbef732a32392cb0a23edfc12e51773e499d716eba3bdac7
7
+ data.tar.gz: 0400cf0e0c9384092dad1908739c21da8828c553606f2aab475328afec8f5d31451fd6001ad4916f02955e87b696ed9f56714c571ca57fc18c526d2fb6459c4e
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env/ruby
2
+
3
+ require 'Battlefield'
4
+ battle Hero(), Creature(ARGV[0].to_i)
@@ -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, armor; end
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*@armour)
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 = 1); @health = 100; end
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
@@ -1,5 +1,5 @@
1
1
  require 'test/unit'
2
- require_relative 'battlefield.rb'
2
+ require 'Battlefield'
3
3
  class TestCreature < Test::Unit::TestCase
4
4
  def test_inititialize
5
5
  assert_raise {Creature.new}
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.3
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-19 00:00:00.000000000 Z
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
- - lib/battlefield_test.rb
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
- - lib/battlefield_test.rb
49
+ - test/battlefield_test.rb