ogem 0.0.2 → 0.1.2

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: ba181458b04bf25bb6f131e4405e07bfafbfb099
4
- data.tar.gz: dd94ac490afb7caa20a2d89d3f9b8f4b81a5670a
3
+ metadata.gz: 405237dd45ec8718e1e912144722455c18b3c5a3
4
+ data.tar.gz: 3da04ba666b20b45afb8946fac4a26bfcdf700f7
5
5
  SHA512:
6
- metadata.gz: a27ee2103f86c2373be5f3bbe01f08775f5c17aef6abd220092f9898d06bd974b058b4a80d843d21ea7cfd9db7b2449f3d177943300d378680915c998f033fa6
7
- data.tar.gz: d2c71c1f2e353b001025d8d2ca0e1bdc441aacca7a6af18f6f47e834093b98c6a3e5f7b96793ddadaef927dee069e7196365343af013cbddec1ce8c3fa17b4e4
6
+ metadata.gz: 78210c730ca95f1ac5dd9a10800d29b7a848d4a2089027f21570e2a23a5c9f6a493772693b7c6837e7551215e6866cab0241acedf4b3c08001bc4acde78bae4b
7
+ data.tar.gz: ce550989fab597d7a73501c958346d9129a2b893149b44bdffb302f14fc9bfa1bec7e0918e9f980407b7d319e0f926a1d00541b125feec71af0a0f145c69ddef
@@ -0,0 +1,6 @@
1
+ #encoding: utf-8
2
+
3
+ gem 'myerror'
4
+ require_relative 'ogem/ogamecalc'
5
+ require_relative 'ogem/ship.class.rb'
6
+ require_relative 'ogem/player.class.rb'
@@ -0,0 +1,25 @@
1
+ #encoding: utf-8
2
+
3
+ require_relative 'ship.class'
4
+ require_relative 'player.class'
5
+
6
+ module OgameCalc
7
+
8
+ SHIP_LIST = {
9
+ light_fighter: Ship.new("Chasseur léger", "cl", 3000, 1000, 0),
10
+ heavy_fighter: Ship.new("Chasseur lourd", "cL", 6000, 4000, 0),
11
+ cruiser: Ship.new("Croiseur", "cr", 20000, 7000, 2000),
12
+ battleship: Ship.new("Vaisseau de B.", "vb", 45000, 15000, 0),
13
+ battlecruiser: Ship.new("Traqueur", "tr", 30000, 40000, 15000),
14
+ bomber: Ship.new("Bombardier", "bb", 50000, 25000, 15000),
15
+ destroyer: Ship.new("Destroyer", "ds", 60000, 50000, 15000),
16
+ deathstar: Ship.new("Etoile de la M.", "edlm", 5000000, 4000000, 1000000)
17
+ }
18
+
19
+ RESOURCES = {
20
+ :m => "Metal",
21
+ :c => "Cristal",
22
+ :d => "Deuterium"
23
+ }
24
+
25
+ end
@@ -0,0 +1,20 @@
1
+ #encoding: utf-8
2
+
3
+ gem 'myerror'
4
+
5
+ module OgameCalc
6
+ class Player
7
+ attr_accessor :name, :r
8
+
9
+ def initialize name="Player", m=1000, c=1000, d=0
10
+ if !name.is_a?String
11
+ Error.call "OgameCalc::Player::new : invalid name", Error::ERR_MEDIUM
12
+ name = "Player"
13
+ end
14
+
15
+ @name = name
16
+ @r = {m: m.to_i, c: c.to_i, d: d.to_i}
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,47 @@
1
+ #encoding: utf-8
2
+
3
+ gem 'myerror'
4
+
5
+ module OgameCalc
6
+ class Ship
7
+ attr_reader :name, :r, :abv
8
+
9
+ def initialize name="Ship", abv="", m=3000, c=1000, d=0
10
+ if !name.is_a?String
11
+ Error.call "OgameCalc::Ship::new : invalid name", Error::ERR_MEDIUM
12
+ name = "UnknowShip"
13
+ elsif !abv.is_a?String
14
+ Error.call "OgameCalc::Ship::new : invalid abv", Error::ERR_MEDIUM
15
+ name = "unknow"
16
+ end
17
+ @name = name
18
+ @abv = abv
19
+ @r = {m: m.to_i, c: c.to_i, d: d.to_i}
20
+ end
21
+
22
+ def how_many? r
23
+ min = []
24
+ min << r[:m] / @r[:m] if @r[:m] != 0
25
+ min << r[:c] / @r[:c] if @r[:c] != 0
26
+ min << r[:d] / @r[:d] if @r[:d] != 0
27
+ return min.min.to_i
28
+ end
29
+
30
+ def cost
31
+ line = ""
32
+ OgameCalc::RESOURCES.each do |k, v|
33
+ line += "\t<#{v}:#{@r[k]}>"
34
+ end
35
+ return line
36
+ end
37
+
38
+ def self.get_abv abv
39
+ OgameCalc::SHIP_LIST.each do |k, ship|
40
+ Error.call "Ship::self.get_abv : Invalid element #{ship}" if !ship.is_a?Ship
41
+ return ship if ship.abv == abv
42
+ end
43
+ return nil
44
+ end
45
+
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ogem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - poulet_a
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: 1.1.0
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.0.0
@@ -26,39 +26,25 @@ dependencies:
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.0
29
+ version: 1.1.0
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.0.0
33
- - !ruby/object:Gem::Dependency
34
- name: epimath100
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: 1.7.0
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.6.1
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: 1.7.0
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.6.1
53
33
  description: A Gem to manage your fleet on Ogame. Fr
54
34
  email:
55
35
  - poulet_a@epitech.eu
56
- - - lib/ogem/ogem.class.rb
36
+ - - lib/ogem.rb
37
+ - lib/ogem/ogamecalc.rb
38
+ - lib/ogem/ship.class.rb
39
+ - lib/ogem/player.class.rb
57
40
  executables: []
58
41
  extensions: []
59
42
  extra_rdoc_files: []
60
43
  files:
61
- - lib/ogem/ogem.class.rb
44
+ - lib/ogem.rb
45
+ - lib/ogem/ogamecalc.rb
46
+ - lib/ogem/player.class.rb
47
+ - lib/ogem/ship.class.rb
62
48
  homepage: https://github.com/Sophen/ogem
63
49
  licenses:
64
50
  - GNU/GPLv3
@@ -1 +0,0 @@
1
- #encoding: utf-8