sciolyff 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sciolyff +1 -1
  3. data/lib/sciolyff.rb +20 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3cd6e98f70075a515863431f659b59fcc88f7ab9bd6d01ee46329cbc5bf4eb1
4
- data.tar.gz: 966829031a03f79bac525757c2cef44ccc515829afb066bd04779ddf6e3fb596
3
+ metadata.gz: 3bc0709e109b89da26d0c66d2f1f0ef69a9b2ca2f4ac729a74ac156d2bf20f5e
4
+ data.tar.gz: 1c0cd81c92947527ba549dc4bf53d0c7e6c403b090694976fc601061526c0a66
5
5
  SHA512:
6
- metadata.gz: 382ae2b2de24a1ed587d2e7c89273d55b2f5e84c26ca8d8a7f68e16d0eb15f5e612eff41f627fe83529a6458f4fd75867952c2461ce6043fc17f08ae7a555c3c
7
- data.tar.gz: 24d865ebbff8545257810b9ede5f31d32cf232a8a69c52ff3f6e9c79f860af4ca32d6733a1c41039ff29f78d61e3e1fe67485663d76846f4c539069e775b9295
6
+ metadata.gz: d6b3e37f27e29b78df485db79c6a0ca756d56fee18f42f135aba843f7284016451d32ae1992d73e5532c4477411d39b74bcfff924013db550616d79d7cb78df7
7
+ data.tar.gz: e5ac57ff0cd5d495903ba47c09f81663b5d6c5860d2994767205cae1da2cc85f3f038483d3f378c3bc2393bcb98c2cb36e6cc5942d81582865111321b2ad34a7
data/bin/sciolyff CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
6
6
  require 'sciolyff'
7
7
 
8
8
  opts = Optimist.options do
9
- version 'sciolyff 0.2.1'
9
+ version 'sciolyff 0.3.0'
10
10
  banner <<~STRING
11
11
  Checks if a given file is in the Scioly File Format
12
12
 
data/lib/sciolyff.rb CHANGED
@@ -64,12 +64,17 @@ module SciolyFF
64
64
  @penalties_by_team = index_array(rep[:Penalties], [:team])
65
65
  end
66
66
 
67
+ def nonexhibition_teams
68
+ @teams_by_number.reject { |_, t| t[:exhibition] }
69
+ end
70
+
67
71
  def event_points(team_number, event_name)
68
72
  placing = @placings_by_event[event_name][team_number]
73
+ number_of_teams = number_of_competing_teams(event_name)
69
74
 
70
- if placing[:disqualified] then @teams_by_number.count + 2
71
- elsif placing[:participated] == false then @teams_by_number.count + 1
72
- elsif placing[:place].nil? then @teams_by_number.count
75
+ if placing[:disqualified] then number_of_teams + 2
76
+ elsif placing[:participated] == false then number_of_teams + 1
77
+ elsif placing[:place].nil? then number_of_teams
73
78
  else calculate_event_points(placing)
74
79
  end
75
80
  end
@@ -93,13 +98,16 @@ module SciolyFF
93
98
  @teams_by_number
94
99
  .values
95
100
  .sort do |a, b|
101
+ next 1 if a[:exhibition] && !b[:exhibition]
102
+ next -1 if !a[:exhibition] && b[:exhibition]
103
+
96
104
  cmp = team_points(a[:number]) - team_points(b[:number])
97
105
  cmp.zero? ? break_tie(a[:number], b[:number]) : cmp
98
106
  end
99
107
  end
100
108
 
101
109
  def medal_counts(team_number)
102
- (1..(@teams_by_number.count + 2)).map do |m|
110
+ (1..(nonexhibition_teams.count + 2)).map do |m|
103
111
  @events_by_name
104
112
  .values
105
113
  .reject { |e| e[:trial] || e[:trialed] }
@@ -119,7 +127,15 @@ module SciolyFF
119
127
  end
120
128
  end
121
129
 
130
+ def number_of_competing_teams(event_name)
131
+ return @teams_by_number.count if @events_by_name[event_name][:trial]
132
+
133
+ nonexhibition_teams.count
134
+ end
135
+
122
136
  def calculate_event_points(placing)
137
+ return placing[:place] if @events_by_name[placing[:event]][:trial]
138
+
123
139
  # Points is place minus number of exhibition teams with a better place
124
140
  placing[:place] -
125
141
  @placings_by_event[placing[:event]]
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.2.1
4
+ version: 0.3.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-05-27 00:00:00.000000000 Z
11
+ date: 2019-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest