sciolyff 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sciolyff +1 -1
- data/lib/sciolyff/interpreter/event.rb +7 -3
- data/lib/sciolyff/interpreter/model.rb +0 -1
- data/lib/sciolyff/interpreter/placing.rb +23 -14
- data/lib/sciolyff/interpreter/team.rb +4 -6
- data/lib/sciolyff/interpreter/tournament.rb +7 -3
- data/lib/sciolyff/placings.rb +2 -0
- data/lib/sciolyff/tournament.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0b0585e73d7a00ceda5496078ca65998b8bea5fa1ece51bd76ac4c496074767
|
4
|
+
data.tar.gz: 3f9770165cfccc02e9d575b457ebf397e7f6a65d6861fbb9ee27959f9614445d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebacad7be6d0faa35892d239d48562b37d894919ea0b41bc40d4ebd668b306c3a2dda093605d18c0a924735366ab061597f941375f938c71313440beb1941bc5
|
7
|
+
data.tar.gz: f9ab9e0d567ef8cbf9d5740e7205f49324715ce0db3633716a689e61170a9ad2a576ac1ecd78029f1b8864b9255690ee36b793db2b0ef8b2d3c3bbd09eba16f0
|
data/bin/sciolyff
CHANGED
@@ -40,10 +40,14 @@ module SciolyFF
|
|
40
40
|
@placings_by_team[team]
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
return placings.
|
43
|
+
def maximum_place
|
44
|
+
return placings.size if trial?
|
45
45
|
|
46
|
-
|
46
|
+
tournament.maximum_place
|
47
|
+
end
|
48
|
+
|
49
|
+
def maximum_points
|
50
|
+
maximum_place + 2
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -50,23 +50,19 @@ module SciolyFF
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def points
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
@points ||= if !considered_for_team_points? then 0
|
54
|
+
else isolated_points
|
55
|
+
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def isolated_points
|
59
|
-
|
60
|
-
|
61
|
-
n = event.competing_teams.count
|
59
|
+
n = event.maximum_place
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
else calculate_points
|
69
|
-
end
|
61
|
+
if disqualified? then n + 2
|
62
|
+
elsif did_not_participate? then n + 1
|
63
|
+
elsif participation_only? || unknown? then n
|
64
|
+
else [calculate_points, n].min
|
65
|
+
end
|
70
66
|
end
|
71
67
|
|
72
68
|
def considered_for_team_points?
|
@@ -78,12 +74,25 @@ module SciolyFF
|
|
78
74
|
!(event.trial? || event.trialed? || exempt?)
|
79
75
|
end
|
80
76
|
|
77
|
+
def points_affected_by_exhibition?
|
78
|
+
considered_for_team_points? && place && !exhibition_placings_behind.zero?
|
79
|
+
end
|
80
|
+
|
81
|
+
def points_limited_by_maximum_place?
|
82
|
+
tournament.custom_maximum_place? &&
|
83
|
+
(unknown? || (place && calculate_points > event.maximum_place))
|
84
|
+
end
|
85
|
+
|
81
86
|
private
|
82
87
|
|
83
88
|
def calculate_points
|
84
89
|
return place if event.trial?
|
85
90
|
|
86
|
-
place -
|
91
|
+
place - exhibition_placings_behind
|
92
|
+
end
|
93
|
+
|
94
|
+
def exhibition_placings_behind
|
95
|
+
@exhibition_placings_behind ||= event.placings.count do |p|
|
87
96
|
(p.exempt? || p.team.exhibition?) &&
|
88
97
|
p.place &&
|
89
98
|
p.place < place
|
@@ -59,9 +59,7 @@ module SciolyFF
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def points
|
62
|
-
|
63
|
-
|
64
|
-
@cache[:points] = placings.sum(&:points) + penalties.sum(&:points)
|
62
|
+
@points ||= placings.sum(&:points) + penalties.sum(&:points)
|
65
63
|
end
|
66
64
|
|
67
65
|
def worst_placings_to_be_dropped
|
@@ -79,16 +77,16 @@ module SciolyFF
|
|
79
77
|
end
|
80
78
|
|
81
79
|
def medal_counts
|
82
|
-
(1..@tournament.
|
80
|
+
(1..@tournament.events.first.maximum_points).map do |medal_points|
|
83
81
|
placings.select(&:considered_for_team_points?)
|
84
82
|
.count { |p| p.points == medal_points }
|
85
83
|
end
|
86
84
|
end
|
87
85
|
|
88
86
|
def trial_event_medal_counts
|
89
|
-
(1..@tournament.
|
87
|
+
(1..@tournament.events.last.maximum_points).map do |medal_points|
|
90
88
|
placings.select { |p| p.event.trial? }
|
91
|
-
.count { |p| p.
|
89
|
+
.count { |p| p.isolated_points == medal_points }
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -68,10 +68,14 @@ module SciolyFF
|
|
68
68
|
exempt_placings? ? @rep[:'exempt placings'] : 0
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
72
|
-
|
71
|
+
def custom_maximum_place?
|
72
|
+
maximum_place != @teams.count { |t| !t.exhibition? }
|
73
|
+
end
|
74
|
+
|
75
|
+
def maximum_place
|
76
|
+
return @rep[:'maximum place'] if @rep[:'maximum place']
|
73
77
|
|
74
|
-
@teams.count { |t| !t.exhibition? }
|
78
|
+
@teams.count { |t| !t.exhibition? }
|
75
79
|
end
|
76
80
|
end
|
77
81
|
end
|
data/lib/sciolyff/placings.rb
CHANGED
data/lib/sciolyff/tournament.rb
CHANGED
@@ -24,6 +24,7 @@ module SciolyFF
|
|
24
24
|
def test_does_not_have_extra_info
|
25
25
|
info = Set.new %i[name location level division state year date]
|
26
26
|
info << :'short name' << :'worst placings dropped' << :'exempt placings'
|
27
|
+
info << :'maximum place'
|
27
28
|
assert Set.new(@tournament.keys).subset? info
|
28
29
|
end
|
29
30
|
|
@@ -84,5 +85,10 @@ module SciolyFF
|
|
84
85
|
skip unless @tournament.key? :'exempt placings'
|
85
86
|
assert_instance_of Integer, @tournament[:'exempt placings']
|
86
87
|
end
|
88
|
+
|
89
|
+
def test_has_valid_maximum_place
|
90
|
+
skip unless @tournament.key? :'maximum place'
|
91
|
+
assert_instance_of Integer, @tournament[:'maximum place']
|
92
|
+
end
|
87
93
|
end
|
88
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sciolyff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Em Zhan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|