nature 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/src/Combos.rb +2 -1
- data/src/Fantasy.rb +10 -17
- data/src/Util.rb +20 -0
- data/src/glade/Fantasy.glade +13 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23b4e11e530f92323e9d996074b3cb5ebef6d456
|
4
|
+
data.tar.gz: 87a042730ab16c8cfd5637abb2fadb6532d721c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d874388a685196b94477ebf87a1d02259e388ddd0e519c73d1be8bd7acf7323b0ffc1c4d0ba9230d00df4472ffb3451f1b74ef23eef3add99eec896c7757149
|
7
|
+
data.tar.gz: fc4b267de3431e753f9a27e7131a93d3c3b040a18e004e75edf4c17718f878a261c15d01015c093928ac264e5cab781b2af4025f2392f9d989a6eca80f9d2556
|
data/src/Combos.rb
CHANGED
@@ -9,9 +9,10 @@ class Combos
|
|
9
9
|
|
10
10
|
|
11
11
|
def before_show()
|
12
|
-
@view = VR::ListView.new(team1: String, team2: String, avg_run_pts: Float, avg_wr_pts: Float, avg_te_pts: Float, avg_qb_pts: Float)
|
12
|
+
@view = VR::ListView.new(team1: String, team2: String, bye_match: String, avg_run_pts: Float, avg_wr_pts: Float, avg_te_pts: Float, avg_qb_pts: Float)
|
13
13
|
@view.add_active_record_rows(Combo.all)
|
14
14
|
@view.col_sortable(true)
|
15
|
+
@view.col_width(bye_match: 20)
|
15
16
|
@view.show
|
16
17
|
@builder[:scrolledwindow1].add @view
|
17
18
|
end
|
data/src/Fantasy.rb
CHANGED
@@ -69,7 +69,6 @@ class Fantasy
|
|
69
69
|
|
70
70
|
|
71
71
|
def buttonComputeCombos__clicked(*a)
|
72
|
-
# Combo.destroy_all
|
73
72
|
out "clear"
|
74
73
|
type = @builder[:type].active_text
|
75
74
|
@teams = []
|
@@ -102,6 +101,7 @@ class Fantasy
|
|
102
101
|
|
103
102
|
def combo_pts(team1,team2, type, show = false)
|
104
103
|
@show, @old_show = show, @show
|
104
|
+
@opponents = []
|
105
105
|
tot1 = 0
|
106
106
|
tot2 = 0
|
107
107
|
tot_best = 0
|
@@ -111,6 +111,7 @@ class Fantasy
|
|
111
111
|
for week in 1..16 do
|
112
112
|
best_pts = -99
|
113
113
|
best_team = "Error"
|
114
|
+
best_opponent = "Error"
|
114
115
|
out "\nweek ##{week}"
|
115
116
|
clear_events
|
116
117
|
Game.where("(home = '#{team1}' or away = '#{team1}' or home = '#{team2}' or away = '#{team2}') and week = #{week}").each do |g|
|
@@ -121,6 +122,7 @@ class Fantasy
|
|
121
122
|
if home_pts > best_pts
|
122
123
|
best_pts = home_pts
|
123
124
|
best_team = g.home
|
125
|
+
best_opponent = g.away
|
124
126
|
end
|
125
127
|
end
|
126
128
|
if g.away == team1 or g.away == team2
|
@@ -128,21 +130,21 @@ class Fantasy
|
|
128
130
|
if away_pts > best_pts
|
129
131
|
best_pts = away_pts
|
130
132
|
best_team = g.away
|
133
|
+
best_opponent = "@" + g.home
|
131
134
|
end
|
132
135
|
end
|
133
136
|
end
|
134
137
|
if best_team != "Error"
|
138
|
+
@opponents << best_opponent
|
135
139
|
out "best = #{best_team} (#{r2(best_pts)})"
|
136
140
|
tot_best = tot_best + best_pts
|
137
141
|
tot_games = tot_games + 1
|
138
142
|
end
|
139
143
|
end
|
140
144
|
out "\ntot games: #{tot_games} total: #{r2(tot_best)} avg: #{r2(tot_best/tot_games)}"
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
c.team2 = team2
|
145
|
-
end
|
145
|
+
out "\nOpponents: "
|
146
|
+
@opponents.each { |o| out o }
|
147
|
+
c = Combo.where("team1 = '#{team1}' and team2 = '#{team2}'").first
|
146
148
|
c.send("avg_#{type}_pts=", tot_best/tot_games)
|
147
149
|
c.save!
|
148
150
|
@show = @old_show
|
@@ -157,17 +159,8 @@ class Fantasy
|
|
157
159
|
clear_events
|
158
160
|
end
|
159
161
|
|
160
|
-
def
|
161
|
-
|
162
|
-
for week in 1..17
|
163
|
-
if Game.where("'#{t.code}' IN (home, away) AND week =#{week}").first
|
164
|
-
next
|
165
|
-
else
|
166
|
-
t.bye_week = week
|
167
|
-
t.save!
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
162
|
+
def buttonBuildComboDB__clicked(*a)
|
163
|
+
Util.fill_combo_db
|
171
164
|
end
|
172
165
|
|
173
166
|
end
|
data/src/Util.rb
CHANGED
@@ -14,4 +14,24 @@ module Util
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.fill_combo_db()
|
18
|
+
Combo.destroy_all
|
19
|
+
@teams = []
|
20
|
+
@bye_week = {}
|
21
|
+
Team.all.each do |team1|
|
22
|
+
@teams << team1.code
|
23
|
+
@bye_week[team1.code] = team1.bye_week
|
24
|
+
end
|
25
|
+
@teams = @teams.sort
|
26
|
+
for i in 0..31 do
|
27
|
+
for j in (i+1)..31 do
|
28
|
+
c = Combo.create
|
29
|
+
c.team1 = @teams[i]
|
30
|
+
c.team2 = @teams[j]
|
31
|
+
c.bye_match = @bye_week[@teams[i]] == @bye_week[@teams[j]] ? "X" : ""
|
32
|
+
c.save!
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
17
37
|
end
|
data/src/glade/Fantasy.glade
CHANGED
@@ -197,6 +197,19 @@
|
|
197
197
|
<property name="position">2</property>
|
198
198
|
</packing>
|
199
199
|
</child>
|
200
|
+
<child>
|
201
|
+
<object class="GtkButton" id="buttonBuildComboDB">
|
202
|
+
<property name="label" translatable="yes">BuildComboDB</property>
|
203
|
+
<property name="visible">True</property>
|
204
|
+
<property name="can_focus">True</property>
|
205
|
+
<property name="receives_default">True</property>
|
206
|
+
</object>
|
207
|
+
<packing>
|
208
|
+
<property name="expand">False</property>
|
209
|
+
<property name="fill">True</property>
|
210
|
+
<property name="position">3</property>
|
211
|
+
</packing>
|
212
|
+
</child>
|
200
213
|
</object>
|
201
214
|
<packing>
|
202
215
|
<property name="left_attach">1</property>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nature
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Cunningham
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 1.2.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: activerecord
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
56
70
|
description: Full description here
|
57
71
|
email: you@yoursite.com
|
58
72
|
executables:
|