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 +4 -4
- data/lib/ogem.rb +6 -0
- data/lib/ogem/ogamecalc.rb +25 -0
- data/lib/ogem/player.class.rb +20 -0
- data/lib/ogem/ship.class.rb +47 -0
- metadata +11 -25
- data/lib/ogem/ogem.class.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 405237dd45ec8718e1e912144722455c18b3c5a3
|
4
|
+
data.tar.gz: 3da04ba666b20b45afb8946fac4a26bfcdf700f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78210c730ca95f1ac5dd9a10800d29b7a848d4a2089027f21570e2a23a5c9f6a493772693b7c6837e7551215e6866cab0241acedf4b3c08001bc4acde78bae4b
|
7
|
+
data.tar.gz: ce550989fab597d7a73501c958346d9129a2b893149b44bdffb302f14fc9bfa1bec7e0918e9f980407b7d319e0f926a1d00541b125feec71af0a0f145c69ddef
|
data/lib/ogem.rb
ADDED
@@ -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.
|
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.
|
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.
|
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
|
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
|
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
|
data/lib/ogem/ogem.class.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|