ogs_katacheck 0.1.3 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dc3dff0e80657df3ef23d7011da1e81bbf3e5dfcfe5e2ace5c28eb9cf69fefc
4
- data.tar.gz: 5cd7c089b569f5c53ae90af5270580c82347a167346f12ec40931d366a5d15df
3
+ metadata.gz: 2baab19f04bb46ebca2c9233288ea4af806716bbf6871765aa6a5048f2c868b7
4
+ data.tar.gz: aadc143d83e47a546345fbeecebc5c0a24599b505f495f68c0137374efd5a8bb
5
5
  SHA512:
6
- metadata.gz: 9eda8f4751dbffcbc5367e9ecb07577647e57bbd6aba54b1d717b36c96fcaf1b4daffcfeeb9948f14957b1e78c90307b4057f0b37dbdba896717190e2646c4e2
7
- data.tar.gz: c694ff37f069ccd2b2aac02d398fc0b9e85b921fb622b7459e888731e85dbb5bc72e833017a6916b09c95ed6b319e5913c1c89f6e983724ec5677d172356c1ef
6
+ metadata.gz: 3ff08796e04916871bc281944e78ca87bcaf6693618fc9cb7c091e09b571b9662a694f3422c3bbd36b1eb90f9887b23309cec4727de4b9f4ad870873899f951b
7
+ data.tar.gz: dc9268e55c96cd61bac98a06f9b92865c1a52d82d7660cc76e1e93aa42ee2b35f0ade3d18f2f8bc8fd0e7e303ce3665d365b4cae10d8eed814dcf4eb6cac5990
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .DS_Store
@@ -11,3 +11,16 @@
11
11
 
12
12
  ### 0.1.3
13
13
  - bug fix
14
+
15
+ ### 0.1.4
16
+ - bug fix
17
+
18
+ ### 0.1.5
19
+ - bug fix
20
+
21
+ ### 0.1.6
22
+ - fixes bug in the way percentages are calculated
23
+
24
+ ### 0.2.0
25
+ - new formatting for output table
26
+ - fixes error introduced by new uuid attribute on reviews
data/Gemfile CHANGED
@@ -5,4 +5,10 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem 'faraday'
8
+ gem 'colorize'
9
+ gem "terminal-table"
8
10
  # gem 'pry'
11
+
12
+ if RUBY_PLATFORM =~ /win32/
13
+ gem 'win32console'
14
+ end
@@ -1,25 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ogs_katacheck (0.1.3)
4
+ ogs_katacheck (0.2.1)
5
+ faraday
6
+ terminal-table
5
7
 
6
8
  GEM
7
9
  remote: https://rubygems.org/
8
10
  specs:
11
+ colorize (0.8.1)
9
12
  faraday (1.1.0)
10
13
  multipart-post (>= 1.2, < 3)
11
14
  ruby2_keywords
12
15
  multipart-post (2.1.1)
13
16
  rake (12.3.0)
14
17
  ruby2_keywords (0.0.2)
18
+ terminal-table (1.8.0)
19
+ unicode-display_width (~> 1.1, >= 1.1.1)
20
+ unicode-display_width (1.7.0)
15
21
 
16
22
  PLATFORMS
17
23
  ruby
18
24
 
19
25
  DEPENDENCIES
26
+ colorize
20
27
  faraday
21
28
  ogs_katacheck!
22
29
  rake (~> 12.0)
30
+ terminal-table
23
31
 
24
32
  BUNDLED WITH
25
33
  2.1.4
data/README.md CHANGED
@@ -6,7 +6,7 @@ It pulls game information from the OGS API and checks the user submitted moves a
6
6
 
7
7
  ## Installation
8
8
 
9
- You will need to have Ruby installed on your machine to run this CLI. If you are using a Mac, this is already done for you. If on a Windows machine you can install it by following [these instructions](https://stackify.com/install-ruby-on-windows-everything-you-need-to-get-going/).
9
+ **You will need to have Ruby installed on your machine to run this CLI.** If you are using a Mac, this should already be done for you. If on a Windows machine you can install it by following [these instructions](https://stackify.com/install-ruby-on-windows-everything-you-need-to-get-going/). You can verify that everything is installed properly by running `ruby -v` and `gem -v`, you should see versions for both after running these commands.
10
10
 
11
11
  To install this Gem, open a terminal and run:
12
12
 
@@ -26,15 +26,13 @@ You will be asked to enter a game ID. This can be simply copied and pasted from
26
26
 
27
27
  You will then be presented with a list of available OGS AI reviews. **Only full reviews** are useable with this tool. If you do not see a full review in the list, open the game in OGS and run a full review. Once the server has completed the review, re-run the tool.
28
28
 
29
- The tool will output the number of user submitted moves that match the top 4 moves suggested by the AI in the review. Obviously, `tier 1` and `tier 2` moves are most important to look at, but the overall percentages can also be helpful.
30
-
31
- ***Note:** A high percentage match in a game does not necessarily mean the user is cheating, but high percentage matches across many games will certainly warrant further investigation.*
29
+ ![Review Selection](https://github.com/RubyMineshaft/ogs_katacheck/blob/main/images/reviews.png)
32
30
 
33
- ## Development
31
+ The tool will output the number of user submitted moves that match the top 4 moves suggested by the AI in the review. Obviously, `tier 1` and `tier 2` moves are most important to look at, but the overall percentages can also be helpful.
34
32
 
35
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ ![Output Example](https://github.com/RubyMineshaft/ogs_katacheck/blob/main/images/output.png)
36
34
 
37
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ ***Note:** A high percentage match in a game does not necessarily mean the user is cheating, but high percentage matches across many games will certainly warrant further investigation.*
38
36
 
39
37
  ## Contributing
40
38
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require './lib/ogs_katacheck'
3
+ require 'ogs_katacheck'
4
4
 
5
5
  OGSKataCheck::CLI.new.call
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require './lib/ogs_katacheck'
3
+ require 'ogs_katacheck'
4
4
 
5
5
  OGSKataCheck::CLI.new.call
Binary file
Binary file
@@ -1,5 +1,7 @@
1
1
  require 'faraday'
2
2
  require 'json'
3
+ require 'colorize'
4
+ require 'terminal-table'
3
5
  require_relative "./ogs_katacheck/version"
4
6
  require_relative "./ogs_katacheck/cli"
5
7
  require_relative "./ogs_katacheck/review"
@@ -37,7 +37,8 @@ class OGSKataCheck::CLI
37
37
  puts "The following reviews are available:"
38
38
 
39
39
  Review.all.each do |review|
40
- puts "#{review.number}. #{review.id} - #{review.engine} - #{review.type} - #{review.date}"
40
+ review.date = Time.new(review.date.slice(0,4), review.date.slice(5, 2), review.date.slice(8, 2), review.date.slice(11, 2), review.date.slice(14, 2), review.date.slice(17, 2), "+00:00")
41
+ puts "#{review.number}. #{review.id} -- #{review.engine} -- #{review.type} -- #{review.date.localtime.strftime("%e %b %Y, %I:%M%p %Z")}"
41
42
  end
42
43
 
43
44
  puts ""
@@ -1,5 +1,5 @@
1
1
  class FullReview
2
- attr_accessor :win_rates, :scores, :id, :type, :game_id, :engine, :engine_version, :network, :network_size, :date, :strength, :win_rate, :moves,
2
+ attr_accessor :win_rates, :uuid, :scores, :id, :type, :game_id, :engine, :engine_version, :network, :network_size, :date, :strength, :win_rate, :moves,
3
3
  :total_moves, :black_tier_1, :black_tier_2, :black_tier_3, :black_tier_4, :white_tier_1, :white_tier_2, :white_tier_3, :white_tier_4, :black_total, :white_total
4
4
 
5
5
  @@all = []
@@ -25,18 +25,21 @@ class FullReview
25
25
  end
26
26
 
27
27
  def self.destroy_all
28
- self.all.clear
28
+ self.all.clear
29
29
  end
30
30
 
31
31
  def calculate_percentages
32
- @black_tier_1[1] = @black_tier_1[0].to_f / @total_moves / 2 * 100
33
- @black_tier_2[1] = @black_tier_2[0].to_f / @total_moves / 2 * 100
34
- @black_tier_3[1] = @black_tier_3[0].to_f / @total_moves / 2 * 100
35
- @black_tier_4[1] = @black_tier_4[0].to_f / @total_moves / 2 * 100
36
- @white_tier_1[1] = @white_tier_1[0].to_f / @total_moves / 2 * 100
37
- @white_tier_2[1] = @white_tier_2[0].to_f / @total_moves / 2 * 100
38
- @white_tier_3[1] = @white_tier_3[0].to_f / @total_moves / 2 * 100
39
- @white_tier_4[1] = @white_tier_4[0].to_f / @total_moves / 2 * 100
32
+ white_moves = (@total_moves / 2.0).floor
33
+ black_moves = (@total_moves / 2.0).ceil
34
+
35
+ @black_tier_1[1] = @black_tier_1[0].to_f / black_moves * 100
36
+ @black_tier_2[1] = @black_tier_2[0].to_f / black_moves * 100
37
+ @black_tier_3[1] = @black_tier_3[0].to_f / black_moves * 100
38
+ @black_tier_4[1] = @black_tier_4[0].to_f / black_moves * 100
39
+ @white_tier_1[1] = @white_tier_1[0].to_f / white_moves * 100
40
+ @white_tier_2[1] = @white_tier_2[0].to_f / white_moves * 100
41
+ @white_tier_3[1] = @white_tier_3[0].to_f / white_moves * 100
42
+ @white_tier_4[1] = @white_tier_4[0].to_f / white_moves * 100
40
43
 
41
44
  @black_total[0] = @black_tier_1[0] + @black_tier_2[0] + @black_tier_3[0] + @black_tier_4[0]
42
45
  @white_total[0] = @white_tier_1[0] + @white_tier_2[0] + @white_tier_3[0] + @white_tier_4[0]
@@ -1,5 +1,5 @@
1
1
  class Review
2
- attr_accessor :full_review, :number, :id, :type, :game_id, :engine, :engine_version, :network, :network_size, :date, :strength, :win_rate, :moves
2
+ attr_accessor :full_review, :number, :uuid, :id, :type, :game_id, :engine, :engine_version, :network, :network_size, :date, :strength, :win_rate, :moves
3
3
  @@all = []
4
4
 
5
5
  def initialize(attributes, number:)
@@ -25,21 +25,80 @@ class Review
25
25
  puts "Checking player submitted moves against #{@engine} #{@type} review ##{@id}..."
26
26
  review = load_review
27
27
  review.process
28
- puts ""
29
- puts "-----------------------------------------------------"
30
- puts "Black Tier 1 Moves: #{review.black_tier_1[0]} --- #{review.black_tier_1[1].round(2)}%"
31
- puts "Black Tier 2 Moves: #{review.black_tier_2[0]} --- #{review.black_tier_2[1].round(2)}%"
32
- puts "Black Tier 3 Moves: #{review.black_tier_3[0]} --- #{review.black_tier_3[1].round(2)}%"
33
- puts "Black Tier 4 Moves: #{review.black_tier_4[0]} --- #{review.black_tier_4[1].round(2)}%"
34
- puts "-----------------------------------------------------"
35
- puts "White Tier 1 Moves: #{review.white_tier_1[0]} --- #{review.white_tier_1[1].round(2)}%"
36
- puts "White Tier 2 Moves: #{review.white_tier_2[0]} --- #{review.white_tier_2[1].round(2)}%"
37
- puts "White Tier 3 Moves: #{review.white_tier_3[0]} --- #{review.white_tier_3[1].round(2)}%"
38
- puts "White Tier 4 Moves: #{review.white_tier_4[0]} --- #{review.white_tier_4[1].round(2)}%"
39
- puts "-----------------------------------------------------"
40
- puts "Black Total Top Moves: #{review.black_total[0]} --- #{review.black_total[1].round(2)}%"
41
- puts "White Total Top Moves: #{review.white_total[0]} --- #{review.white_total[1].round(2)}%"
42
- puts "-----------------------------------------------------"
28
+
29
+ # table = Terminal::Table.new title: "Results".bold, headings: ['Color'.bold, 'Tier'.bold, "#".bold, "%".bold]
30
+ # x = 1
31
+ # while x < 4 do
32
+ # table.add_row [x == 2 ? "Black".bold : nil, x, review.public_send("black_tier_#{x}")[0], review.public_send("black_tier_#{x}")[1].round(2)]
33
+ # x += 1
34
+ # end
35
+ #
36
+ # table.add_separator
37
+ # table.add_row [{:value => 'Total'.bold, :colspan => 2, :alignment => :center}, review.black_total[0], "#{review.black_total[1].round(2)}%"]
38
+ # table.add_separator
39
+ # table.add_separator
40
+ #
41
+ # x = 1
42
+ # while x < 4 do
43
+ # table.add_row [x == 2 ? "White".bold : nil, x, review.public_send("black_tier_#{x}")[0], review.public_send("black_tier_#{x}")[1].round(2)]
44
+ # x += 1
45
+ # end
46
+ #
47
+ # table.add_separator
48
+ #
49
+ # table.add_row [{:value => 'Total'.bold, :colspan => 2, :alignment => :center}, review.white_total[0], "#{review.white_total[1].round(2)}%"]
50
+ #
51
+ # table.style = {:width => 80, :padding_left => 3, :border_x => "=", :border_i => "x"}
52
+ #
53
+ # puts table
54
+
55
+ table = Terminal::Table.new title: "Results".bold, headings: ['Tier'.bold, "#".bold, "%".bold]
56
+ x = 1
57
+ table.add_row [{value: "Black".bold.light_white.on_black, alignment: :center, colspan: 3}]
58
+ table.add_separator
59
+ while x < 4 do
60
+ table.add_row [x, {value: review.public_send("black_tier_#{x}")[0], alignment: :center}, {value: review.public_send("black_tier_#{x}")[1].round(2).to_s + " %", alignment: :center}]
61
+ x += 1
62
+ end
63
+
64
+ table.add_separator
65
+ table.add_row [{:value => 'Total'.bold, :alignment => :center}, review.black_total[0], "#{review.black_total[1].round(2)}%"]
66
+ table.add_separator
67
+
68
+ table.add_row [{value: "White".bold.black.on_light_white.blink, alignment: :center, colspan: 3}]
69
+ table.add_separator
70
+ x = 1
71
+ while x < 4 do
72
+ table.add_row [x, review.public_send("white_tier_#{x}")[0], review.public_send("white_tier_#{x}")[1].round(2).to_s + " %"]
73
+ x += 1
74
+ end
75
+
76
+ table.add_separator
77
+
78
+ table.add_row [{:value => 'Total'.bold, :alignment => :center}, review.white_total[0], "#{review.white_total[1].round(2)}%"]
79
+
80
+ table.style = {:width => 70, :padding_left => 2, :border_x => "=".blue, :border_i => "x".blue, :alignment => :center}
81
+
82
+ puts table
83
+
84
+ # puts ""
85
+ # puts "^^ new"
86
+ # puts "vv old"
87
+ # puts ""
88
+ # puts "-----------------------------------------------------"
89
+ # puts "Black Tier 1 Moves: #{review.black_tier_1[0]} --- #{review.black_tier_1[1].round(2)}%"
90
+ # puts "Black Tier 2 Moves: #{review.black_tier_2[0]} --- #{review.black_tier_2[1].round(2)}%"
91
+ # puts "Black Tier 3 Moves: #{review.black_tier_3[0]} --- #{review.black_tier_3[1].round(2)}%"
92
+ # puts "Black Tier 4 Moves: #{review.black_tier_4[0]} --- #{review.black_tier_4[1].round(2)}%"
93
+ # puts "-----------------------------------------------------"
94
+ # puts "White Tier 1 Moves: #{review.white_tier_1[0]} --- #{review.white_tier_1[1].round(2)}%"
95
+ # puts "White Tier 2 Moves: #{review.white_tier_2[0]} --- #{review.white_tier_2[1].round(2)}%"
96
+ # puts "White Tier 3 Moves: #{review.white_tier_3[0]} --- #{review.white_tier_3[1].round(2)}%"
97
+ # puts "White Tier 4 Moves: #{review.white_tier_4[0]} --- #{review.white_tier_4[1].round(2)}%"
98
+ # puts "-----------------------------------------------------"
99
+ # puts "Black Total Top Moves: #{review.black_total[0]} --- #{review.black_total[1].round(2)}%"
100
+ # puts "White Total Top Moves: #{review.white_total[0]} --- #{review.white_total[1].round(2)}%"
101
+ # puts "-----------------------------------------------------"
43
102
 
44
103
  end
45
104
 
@@ -1,3 +1,3 @@
1
1
  module OGSKataCheck
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -22,7 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  end
25
+ spec.add_runtime_dependency "faraday"
26
+ spec.add_runtime_dependency "terminal-table"
25
27
  spec.bindir = "bin"
26
28
  spec.executables = ["ogs-katacheck", "katacheck"]
27
29
  spec.require_paths = ["lib"]
28
30
  end
31
+
32
+ # to release, bump version and run `bundle exec rake release`
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ogs_katacheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RubyMineshaft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-22 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: terminal-table
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: This CLI gem is written for OGS team members in order to aid in investigating
14
42
  suspicions of botting.
15
43
  email:
@@ -20,6 +48,7 @@ executables:
20
48
  extensions: []
21
49
  extra_rdoc_files: []
22
50
  files:
51
+ - ".DS_Store"
23
52
  - ".gitignore"
24
53
  - CHANGELOG.md
25
54
  - Gemfile
@@ -30,6 +59,8 @@ files:
30
59
  - bin/katacheck
31
60
  - bin/ogs-katacheck
32
61
  - bin/setup
62
+ - images/output.png
63
+ - images/reviews.png
33
64
  - lib/ogs_katacheck.rb
34
65
  - lib/ogs_katacheck/cli.rb
35
66
  - lib/ogs_katacheck/full_review.rb