pktool 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93dca54abe2ff355a7fd9f6043a685163eac9151
4
+ data.tar.gz: b1d40d852d5a8fa632887e9ed8551cc5fa3f6169
5
+ SHA512:
6
+ metadata.gz: b3f7f272ba9caebf21959fb08c2eed9f9014598eaac8c504781f6e471697b7f486a854f94340d20baca6c0d561f836717a3f818cf68ceeebf31f150fa4922491
7
+ data.tar.gz: 68ff3b69904507e2430d90e58a464b0fc1c43e08b9bbda9dd62823e87491e7f07c5c21c4b483e2293ea72d78d52e2a370a6cc3bafda4ee1fa4ef936ff12acbbb
@@ -0,0 +1,64 @@
1
+ ### https://raw.github.com/github/gitignore/dee587fee0df4dfdaa7a5edd78a746602978344a/ruby.gitignore
2
+
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+
14
+ ## Specific to RubyMotion:
15
+ .dat*
16
+ .repl_history
17
+ build/
18
+
19
+ ## Documentation cache and generated files:
20
+ /.yardoc/
21
+ /_yardoc/
22
+ /doc/
23
+ /rdoc/
24
+
25
+ ## Environment normalisation:
26
+ /.bundle/
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+
38
+
39
+ ### https://raw.github.com/github/gitignore/dee587fee0df4dfdaa7a5edd78a746602978344a/Global/OSX.gitignore
40
+
41
+ .DS_Store
42
+ .AppleDouble
43
+ .LSOverride
44
+
45
+ # Icon must end with two \r
46
+ Icon
47
+
48
+ # Thumbnails
49
+ ._*
50
+
51
+ # Files that might appear on external disk
52
+ .Spotlight-V100
53
+ .Trashes
54
+
55
+ # Directories potentially created on remote AFP share
56
+ .AppleDB
57
+ .AppleDesktop
58
+ Network Trash Folder
59
+ Temporary Items
60
+ .apdisk
61
+
62
+
63
+
64
+ /data/user/member.json
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ # Specify your gem's dependencies in pktool.gemspec
3
+ gemspec
4
+
5
+ gem "rspec"
6
+ gem "rspec-core"
7
+ gem "guard"
8
+ gem "guard-rspec"
9
+ gem "pry"
10
+ gem 'pry-byebug'
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pktool (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ byebug (3.5.1)
10
+ columnize (~> 0.8)
11
+ debugger-linecache (~> 1.2)
12
+ slop (~> 3.6)
13
+ celluloid (0.16.0)
14
+ timers (~> 4.0.0)
15
+ coderay (1.1.0)
16
+ columnize (0.8.9)
17
+ debugger-linecache (1.2.0)
18
+ diff-lcs (1.2.5)
19
+ ffi (1.9.6)
20
+ formatador (0.2.5)
21
+ guard (2.10.1)
22
+ formatador (>= 0.2.4)
23
+ listen (~> 2.7)
24
+ lumberjack (~> 1.0)
25
+ pry (>= 0.9.12)
26
+ thor (>= 0.18.1)
27
+ guard-rspec (4.3.1)
28
+ guard (~> 2.1)
29
+ rspec (>= 2.14, < 4.0)
30
+ hitimes (1.2.2)
31
+ listen (2.8.3)
32
+ celluloid (>= 0.15.2)
33
+ rb-fsevent (>= 0.9.3)
34
+ rb-inotify (>= 0.9)
35
+ lumberjack (1.0.9)
36
+ method_source (0.8.2)
37
+ pry (0.10.1)
38
+ coderay (~> 1.1.0)
39
+ method_source (~> 0.8.1)
40
+ slop (~> 3.4)
41
+ pry-byebug (2.0.0)
42
+ byebug (~> 3.4)
43
+ pry (~> 0.10)
44
+ rake (10.4.1)
45
+ rb-fsevent (0.9.4)
46
+ rb-inotify (0.9.5)
47
+ ffi (>= 0.5.0)
48
+ romaji (0.2.1)
49
+ rake (>= 0.8.0)
50
+ rspec (3.1.0)
51
+ rspec-core (~> 3.1.0)
52
+ rspec-expectations (~> 3.1.0)
53
+ rspec-mocks (~> 3.1.0)
54
+ rspec-core (3.1.7)
55
+ rspec-support (~> 3.1.0)
56
+ rspec-expectations (3.1.2)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.1.0)
59
+ rspec-mocks (3.1.3)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-support (3.1.2)
62
+ sequel (4.17.0)
63
+ slop (3.6.0)
64
+ sqlite3 (1.3.10)
65
+ termcolorlight (1.1.1)
66
+ thor (0.19.1)
67
+ timers (4.0.1)
68
+ hitimes
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ bundler (~> 1.3)
75
+ guard
76
+ guard-rspec
77
+ pktool!
78
+ pry
79
+ pry-byebug
80
+ rake
81
+ romaji
82
+ rspec
83
+ rspec-core
84
+ sequel
85
+ sqlite3
86
+ termcolorlight
87
+ thor
@@ -0,0 +1,39 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ # Note: The cmd option is now required due to the increasing number of ways
11
+ # rspec may be run, below are examples of the most common uses.
12
+ # * bundler: 'bundle exec rspec'
13
+ # * bundler binstubs: 'bin/rspec'
14
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
15
+ # installed the spring binstubs per the docs)
16
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
17
+ # * 'just' rspec: 'rspec'
18
+ guard :rspec, cmd: 'bundle exec rspec -c' do
19
+ watch(%r{^spec/.+_spec\.rb$})
20
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
+ watch('spec/spec_helper.rb') { "spec" }
22
+
23
+ # Rails example
24
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
25
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
26
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
27
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
28
+ watch('config/routes.rb') { "spec/routing" }
29
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
30
+ watch('spec/rails_helper.rb') { "spec" }
31
+
32
+ # Capybara features specs
33
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
34
+
35
+ # Turnip features and steps
36
+ watch(%r{^spec/acceptance/(.+)\.feature$})
37
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
38
+ end
39
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 uzimith
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+ 他の計算機と合わないのでダメージ計算式が間違っているようです。
2
+
3
+ # Pktool
4
+ Pktoolはポケモンのレート対戦の技選択時間1分の間になるべく様々な情報を得ることを目標としたツールです。
5
+ オフラインで動作するため、高速での検索を可能とします。
6
+
7
+ 1. ダメージ計算(開発中)
8
+ 2. ポケモンの能力値確認
9
+ 3. パーティメモ(開発中)
10
+ 4. 素早さ確認(開発中)
11
+
12
+ データはとりあえず暇ツール(http://blog.livedoor.jp/hima_shi/)のデータベースからです。
13
+
14
+ ## 使い方
15
+
16
+ ```
17
+ $ pktool info
18
+
19
+ なまえ>ガブリアス
20
+ せいかく>いじっぱり
21
+ 努力値(default: 0)>hAS
22
+ 個体値(default: 6V)>
23
+ 種族値
24
+ H:108 A:130 B:95 C:80 D:85 S:102 重さ:95.0
25
+ 能力値
26
+ H:184 A:200 B:115 C:90 D:105 S:154
27
+ ```
28
+
29
+ ```
30
+ $ pktool damage
31
+ 攻撃側の指定
32
+ なまえ>ガブリアス
33
+ せいかく>いじっぱり
34
+ 努力値(default: 0)>AS
35
+ 個体値(default: 6V)>
36
+ 防御側の指定
37
+ なまえ>クレセリア
38
+ せいかく>ずぶとい
39
+ 努力値(default: 0)>HB
40
+ 個体値(default: 6V)>
41
+ 技の指定
42
+ わざ>げきりん
43
+
44
+ 攻撃側
45
+ ガブリアス H:183 A:200 B:115 C:90 D:105 S:154
46
+ 防御側
47
+ クレセリア H:227 A:81 B:189 C:95 D:150 S:105
48
+
49
+ min:72 max:85
50
+ 確定数:4回 (31.72%)
51
+
52
+ ```
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ #! /usr/bin/env ruby
2
+ require_relative "../pktool.rb"
@@ -0,0 +1,4 @@
1
+ {
2
+ "いじっぱり": { "A": 1.1, "B": 1.0, "C": 0.9, "D": 1.0, "S": 1.0 },
3
+ "ずぶとい": { "A": 0.9, "B": 1.1, "C": 1.0, "D": 1.0, "S": 1.0 }
4
+ }
Binary file
@@ -0,0 +1,21 @@
1
+ {
2
+ "ノーマル" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 2, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 1, "いわ" : 1, "ゴースト" : 0, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 1},
3
+ "ほのお" : {"ノーマル" : 1, "ほのお" : 0.5, "みず" : 2, "でんき" : 1, "くさ" : 0.5, "こおり" : 0.5, "かくとう" : 1, "どく" : 1, "じめん" : 2, "ひこう" : 1, "エスパー" : 1, "むし" : 0.5, "いわ" : 2, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 0.5, "フェアリー" : 0.5},
4
+ "みず" : {"ノーマル" : 1, "ほのお" : 0.5, "みず" : 0.5, "でんき" : 2, "くさ" : 2, "こおり" : 0.5, "かくとう" : 1, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 1, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 0.5, "フェアリー" : 1},
5
+ "でんき" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 0.5, "くさ" : 1, "こおり" : 1, "かくとう" : 1, "どく" : 1, "じめん" : 2, "ひこう" : 0.5, "エスパー" : 1, "むし" : 1, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 0.5, "フェアリー" : 1},
6
+ "くさ" : {"ノーマル" : 1, "ほのお" : 2, "みず" : 0.5, "でんき" : 0.5, "くさ" : 0.5, "こおり" : 2, "かくとう" : 1, "どく" : 2, "じめん" : 0.5, "ひこう" : 2, "エスパー" : 1, "むし" : 2, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 1},
7
+ "こおり" : {"ノーマル" : 1, "ほのお" : 2, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 0.5, "かくとう" : 2, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 1, "いわ" : 2, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 2, "フェアリー" : 1},
8
+ "かくとう" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 1, "どく" : 1, "じめん" : 1, "ひこう" : 2, "エスパー" : 2, "むし" : 0.5, "いわ" : 0.5, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 0.5, "はがね" : 1, "フェアリー" : 2},
9
+ "どく" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 0.5, "こおり" : 1, "かくとう" : 0.5, "どく" : 0.5, "じめん" : 2, "ひこう" : 1, "エスパー" : 2, "むし" : 0.5, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 0.5},
10
+ "じめん" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 2, "でんき" : 0, "くさ" : 2, "こおり" : 2, "かくとう" : 1, "どく" : 0.5, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 1, "いわ" : 0.5, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 1},
11
+ "ひこう" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 2, "くさ" : 0.5, "こおり" : 2, "かくとう" : 0.5, "どく" : 1, "じめん" : 0, "ひこう" : 1, "エスパー" : 1, "むし" : 0.5, "いわ" : 2, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 1},
12
+ "エスパー" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 0.5, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 0.5, "むし" : 2, "いわ" : 1, "ゴースト" : 2, "ドラゴン" : 1, "あく" : 2, "はがね" : 1, "フェアリー" : 1},
13
+ "むし" : {"ノーマル" : 1, "ほのお" : 2, "みず" : 1, "でんき" : 1, "くさ" : 0.5, "こおり" : 1, "かくとう" : 0.5, "どく" : 1, "じめん" : 0.5, "ひこう" : 2, "エスパー" : 1, "むし" : 1, "いわ" : 2, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 1, "フェアリー" : 1},
14
+ "いわ" : {"ノーマル" : 0.5, "ほのお" : 0.5, "みず" : 2, "でんき" : 1, "くさ" : 2, "こおり" : 1, "かくとう" : 2, "どく" : 0.5, "じめん" : 2, "ひこう" : 0.5, "エスパー" : 1, "むし" : 1, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 1, "あく" : 1, "はがね" : 2, "フェアリー" : 1},
15
+ "ゴースト" : {"ノーマル" : 0, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 0, "どく" : 0.5, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 0.5, "いわ" : 1, "ゴースト" : 2, "ドラゴン" : 1, "あく" : 2, "はがね" : 1, "フェアリー" : 1},
16
+ "ドラゴン" : {"ノーマル" : 1, "ほのお" : 0.5, "みず" : 0.5, "でんき" : 0.5, "くさ" : 0.5, "こおり" : 2, "かくとう" : 1, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 1, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 2, "あく" : 1, "はがね" : 1, "フェアリー" : 2},
17
+ "あく" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 2, "どく" : 1, "じめん" : 1, "ひこう" : 1, "エスパー" : 0, "むし" : 2, "いわ" : 1, "ゴースト" : 0.5, "ドラゴン" : 1, "あく" : 0.5, "はがね" : 1, "フェアリー" : 2},
18
+ "はがね" : {"ノーマル" : 0.5, "ほのお" : 2, "みず" : 1, "でんき" : 1, "くさ" : 0.5, "こおり" : 0.5, "かくとう" : 2, "どく" : 0, "じめん" : 2, "ひこう" : 0.5, "エスパー" : 0.5, "むし" : 0.5, "いわ" : 0.5, "ゴースト" : 1, "ドラゴン" : 0.5, "あく" : 1, "はがね" : 0.5, "フェアリー" : 0.5},
19
+ "フェアリー" : {"ノーマル" : 1, "ほのお" : 1, "みず" : 1, "でんき" : 1, "くさ" : 1, "こおり" : 1, "かくとう" : 0.5, "どく" : 2, "じめん" : 1, "ひこう" : 1, "エスパー" : 1, "むし" : 0.5, "いわ" : 1, "ゴースト" : 1, "ドラゴン" : 0, "あく" : 0.5, "はがね" : 2, "フェアリー" : 1 }
20
+ }
21
+
@@ -0,0 +1 @@
1
+ [{"pokemon":"ガブリアス","item":"","ability":1,"effort_value":{"H":31,"A":31,"B":31,"C":31,"D":31,"S":31},"individual_value":{"H":0,"A":0,"B":0,"C":0,"D":0,"S":0}},{"pokemon":"ボーマンダ","item":"","ability":1,"effort_value":{"H":31,"A":31,"B":31,"C":31,"D":31,"S":31},"individual_value":{"H":31,"A":31,"B":31,"C":31,"D":31,"S":31}}]
@@ -0,0 +1,56 @@
1
+ require_relative 'pokemon'
2
+ require_relative 'move'
3
+ require_relative 'log'
4
+
5
+ module Pktool
6
+
7
+ class Builder
8
+
9
+ def self.pokemon
10
+ pokemons = Pokemon.select_map(:name)
11
+ natures = Pokemon::Nature.select_map(:name)
12
+ name = fetch("なまえ", pokemons)
13
+ feature = {}
14
+ feature[:nature] = fetch("せいかく", natures) do |input| input.to_sym end
15
+ feature[:effort_value] = fetch("努力値(default: 0)") do |input|
16
+ if(Pokemon.ways.include?(input.to_sym))
17
+ input.to_sym
18
+ else
19
+ { H: 0, A: 0, B: 0, C: 0, D: 0, S: 0 }
20
+ end
21
+ end
22
+ feature[:individual_value] = fetch("個体値(default: 6V)") do |input|
23
+ { H: 31, A: 31, B: 31, C: 31, D: 31, S: 31 }
24
+ end
25
+ return Pokemon.fetch(name, feature)
26
+ end
27
+
28
+ def self.move(attacker, defender)
29
+ moves = Move.select_map(:name)
30
+ move = fetch("わざ", moves)
31
+ move = Move.fetch(move, attacker, defender)
32
+ end
33
+
34
+ def self.fetch(name, completion = [])
35
+ Readline.completion_append_character = ""
36
+ Readline.completion_proc = proc {|s|
37
+ completion.grep(/^#{Romaji.romaji2kana(s)}|#{Romaji.romaji2kana(s, :kana_type => :hiragana)}/)
38
+ }
39
+ begin
40
+ fetch = ::Readline.readline(name + '>', true)
41
+ raise Error, "対象が見つかりません" unless completion.empty? or completion.include?(fetch)
42
+ if block_given?
43
+ return yield(fetch)
44
+ else
45
+ return fetch
46
+ end
47
+ rescue Error => e
48
+ Log::error e.message
49
+ retry
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,62 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+ require 'romaji'
4
+ require 'romaji/core_ext/string'
5
+ require_relative "log"
6
+ require_relative "version"
7
+ require_relative "pokemon"
8
+ require_relative "move"
9
+ require_relative "builder"
10
+ require_relative "exceptions"
11
+
12
+ Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), "command", "*.rb"))) do |path|
13
+ require path
14
+ end
15
+
16
+ module Pktool
17
+
18
+ class Cli < Thor
19
+ register(Pktool::Command::Party, "party", "party [COMMAND]", "自分のパーティを編成する")
20
+
21
+ desc "info", "ポケモンの情報を見る"
22
+ def info
23
+ pokemon = Builder.pokemon
24
+ puts "<underline>種族値</underline>".termcolor
25
+ puts pokemon.base_stat.map{|k,v| "<bold>#{k}</bold>:<red>#{v}</red> ".termcolor}.join
26
+ puts "<underline>能力値</underline>".termcolor
27
+ puts pokemon.stats.map{|k,v| "<bold>#{k}</bold>:<blue>#{v}</blue> ".termcolor}.join
28
+
29
+ #TODO: 相性
30
+ end
31
+
32
+ desc "damage", "ダメージ計算する"
33
+ def damage
34
+ puts "<underline>攻撃側の指定</underline>".termcolor
35
+ attacker = Builder.pokemon
36
+
37
+ puts "<underline>防御側の指定</underline>".termcolor
38
+ defender = Builder.pokemon
39
+
40
+ puts "<underline>技の指定</underline>".termcolor
41
+ move = Builder.move(attacker, defender)
42
+
43
+ puts ""
44
+ puts "<underline>攻撃側</underline>".termcolor
45
+ puts attacker.name + " " + attacker.stats.map{|k,v| "<bold>#{k}</bold>:<blue>#{v}</blue> ".termcolor}.join
46
+ puts "<underline>防御側</underline>".termcolor
47
+ puts defender.name + " " + defender.stats.map{|k,v| "<bold>#{k}</bold>:<blue>#{v}</blue> ".termcolor}.join
48
+ puts
49
+ puts move.damage.map{|k,v| "<bold>#{k}</bold>:<blue>#{v}</blue> ".termcolor}.join
50
+ defeat = move.defeat
51
+ puts "<bold>確定数</bold>:<red>#{defeat[:num]}回</red> (#{'%.2f' % (defeat[:rate] * 100)}%) ".termcolor
52
+
53
+ end
54
+
55
+ desc "version", "バーションを確認する。"
56
+ def version
57
+ puts VERSION
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,50 @@
1
+ require_relative "../party"
2
+ require_relative "../pokemon"
3
+ require 'termcolorlight'
4
+
5
+ module Pktool
6
+ module Command
7
+ class Party < Thor
8
+ desc "list", "一覧を表示する"
9
+ def list
10
+ Pktool::Party.new.list.each_with_index do |p,index|
11
+ puts "<bold>#{index+1} #{p.name}#{"(#{p.description})" unless p.description.empty?}</bold> #{p.nature} #{p.ability} #{p.item}".termcolor
12
+ puts "努力値:#{p.ev.map{|k,v| "#{k}#{v} "}.join} 個体値:#{p.iv.map{|k,v| "#{k}#{v} "}.join}".termcolor
13
+ puts ""
14
+ end
15
+ end
16
+
17
+ desc "add [NAME]", "ポケモンを追加する"
18
+ def add(name, description = "", nature = "", effort_value = "", individual_value = "", ability = "", item = "", level = "")
19
+ feature = {}
20
+ # feature = {
21
+ # description: description,
22
+ # nature: nature,
23
+ # effort_value: effort_value.to_sym,
24
+ # individual_value: individual_value,
25
+ # ability: ability,
26
+ # item: item,
27
+ # level: level
28
+ # }
29
+ party = Pktool::Party.new
30
+ pokemon = Pktool::Pokemon.fetch(name, feature)
31
+ party.add(pokemon)
32
+ party.save
33
+ end
34
+
35
+ desc "delete [ID]", "ポケモンを削除する"
36
+ def delete(id)
37
+ party = Pktool::Party.new
38
+ # todo: raise error
39
+ party.delete( - 1)
40
+ party.save
41
+ end
42
+
43
+ desc "update", "ポケモンを更新する"
44
+ def update
45
+ party = Pktool::party.new
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ require 'sequel'
2
+
3
+ module Pktool
4
+ DB = Sequel.connect('sqlite://data/pokemonData.sqlite')
5
+ end
@@ -0,0 +1,4 @@
1
+ module Pktool
2
+ class Error < ::StandardError
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ require 'termcolorlight'
2
+
3
+ module Pktool
4
+
5
+ class Log
6
+
7
+ def self.warn(str)
8
+ puts str
9
+ end
10
+
11
+ def self.error(str)
12
+ puts("<bold><red>[ERROR]</red></bold> #{str.escape}".termcolor)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,51 @@
1
+ require_relative "database"
2
+
3
+ module Pktool
4
+ class Move < Sequel::Model(:move)
5
+ attr_accessor :attacker, :defender
6
+
7
+ def self.fetch(name, attacker, defender)
8
+ move = self.where(name: name).first
9
+ raise Error, "存在ない技です。" unless move
10
+ move.attacker = attacker
11
+ move.defender = defender
12
+ return move
13
+ end
14
+
15
+ def damage
16
+ level = 50.0
17
+ effect = 1.0
18
+ effect *= 1.5 if [@attacker.type1, @attacker.type2].include?(self.type)
19
+
20
+ type_effect = open("data/type.json") do |io|
21
+ JSON.load(io)
22
+ end
23
+ type = 1.0
24
+ type *= type_effect[@defender.type1][self.type]
25
+ type *= type_effect[@defender.type2][self.type] if @defender.type2
26
+
27
+ vital = 1.0
28
+ case move_type
29
+ when "ぶつり"
30
+ attack_stat = :A
31
+ defence_stat = :B
32
+ when "とくしゅ"
33
+ attack_stat = :C
34
+ defence_stat = :D
35
+ end
36
+ # this equation may be mistake.
37
+ base = ((power * @attacker.statistics(attack_stat) * (level * 2.0 / 5.0 + 2.0 )) / @defender.statistics(defence_stat) / 50.0 * effect + 2.0) * type
38
+ min = base * vital * 0.85
39
+ max = base * vital * 1.0
40
+ {min: min.floor, max: max.floor}
41
+ end
42
+
43
+ def defeat
44
+ hp = @defender.statistics(:H)
45
+ damage = self.damage
46
+ return {num: (hp.to_f / damage[:min]).ceil, rate: (damage[:min] / hp.to_f)}
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,42 @@
1
+ require 'json'
2
+ require_relative "pokemon"
3
+
4
+ module Pktool
5
+
6
+ class Party
7
+ attr_accessor :list
8
+
9
+ @@json_path = "data/user/party.json"
10
+
11
+ def initialize
12
+ json = open(@@json_path) do |io|
13
+ JSON.load(io, nil, { symbolize_names: true})
14
+ end
15
+ @list = json.map {|j| Pokemon.fetch(j[:name], j)}
16
+ end
17
+
18
+ def save
19
+ open(@@json_path, 'w') do |io|
20
+ JSON.dump(@list.map{|p| p.to_h}, io)
21
+ end
22
+ end
23
+
24
+ def add(pokemon)
25
+ @list.push(pokemon)
26
+ end
27
+
28
+ def [](id)
29
+ return @list[id]
30
+ end
31
+
32
+ def delete(id)
33
+ @list.delete_at(id)
34
+ end
35
+
36
+ def update(id, pokemon)
37
+ $list[id] = pokemon
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'pokemon'
2
+ require_relative 'move'
3
+
4
+ module Pktool
5
+
6
+ end
@@ -0,0 +1,99 @@
1
+ require 'json'
2
+ require_relative "database"
3
+ require_relative "exceptions"
4
+
5
+ module Pktool
6
+
7
+ class Pokemon < Sequel::Model(:pokemon)
8
+
9
+ class Nature < Sequel::Model(:nature)
10
+ def to_s
11
+ self.name.to_s
12
+ end
13
+ def to_sym
14
+ self.name.to_sym
15
+ end
16
+ end
17
+
18
+ attr_accessor :nature, :effort_value, :individual_value, :ability, :item
19
+ attr_accessor :description
20
+ alias :ev :effort_value
21
+ alias :iv :individual_value
22
+
23
+ @@ways = [:AS, :CS, :hAS, :hCS, :HB, :HD, :HAs, :HCs]
24
+
25
+ def self.fetch(name, feature = {})
26
+ pokemon = self.where(name: name).first
27
+ raise Error, "存在ないポケモンです。" unless pokemon
28
+ pokemon.set(feature)
29
+ return pokemon
30
+ end
31
+
32
+ def self.ways
33
+ return @@ways
34
+ end
35
+
36
+ def base_stat
37
+ { H: self.H, A: self.A, B: self.B, C: self.C, D: self.D, S: self.S, 重さ: self.weight}
38
+ end
39
+
40
+ def set(feature)
41
+ @description = feature[:description] || ""
42
+ @nature = Nature[feature[:nature].to_s] || Nature["がんばりや"]
43
+ @effort_value = feature[:effort_value] || { H: 0, A: 0, B: 0, C: 0, D: 0, S: 0 }
44
+ @individual_value = feature[:individual_value] || { H: 31, A: 31, B: 31, C: 31, D: 31, S: 31 }
45
+ @ability = feature[:ability] || 1
46
+ @item = feature[:item] || ""
47
+ @level = feature[:level] || 50
48
+
49
+ if effort_value.instance_of?(Symbol) && @@ways.include?(effort_value)
50
+ case effort_value
51
+ when :AS
52
+ @effort_value = { H: 0, A: 252, B: 0, C: 0, D: 0, S: 252 }
53
+ when :CS
54
+ @effort_value = { H: 0, A: 0, B: 0, C: 252, D: 0, S: 252 }
55
+ when :hAS
56
+ @effort_value = { H: 6, A: 252, B: 0, C: 0, D: 0, S: 252 }
57
+ when :hCS
58
+ @effort_value = { H: 6, A: 0, B: 0, C: 252, D: 0, S: 252 }
59
+ when :HB
60
+ @effort_value = { H: 252, A: 0, B: 252, C: 0, D: 0, S: 0 }
61
+ when :HD
62
+ @effort_value = { H: 252, A: 0, B: 0, C: 0, D: 252, S: 0 }
63
+ when :HAs
64
+ @effort_value = { H: 252, A: 252, B: 0, C: 0, D: 0, S: 6 }
65
+ when :HCs
66
+ @effort_value = { H: 252, A: 0, B: 0, C: 252, D: 0, S: 6 }
67
+ else
68
+ @effort_value = { H: 0, A: 0, B: 0, C: 0, D: 0, S: 0 }
69
+ end
70
+ end
71
+ end
72
+
73
+ def statistics(name)
74
+ case name
75
+ when :H
76
+ statistics = ((self.H * 2 + @individual_value[:H] + @effort_value[:H] / 4 ) * @level / 100 ) + 10 + @level
77
+ else
78
+ statistics = (((self.send(name) * 2 + @individual_value[name] + @effort_value[name] / 4 ) * @level / 100 ) + 5) * @nature.send(name)
79
+ end
80
+ statistics.floor
81
+ end
82
+
83
+ def stats
84
+ [:H, :A, :B, :C, :D, :S].map { |name| [name, statistics(name)]}.to_h
85
+ end
86
+
87
+ def to_h
88
+ {
89
+ name: name,
90
+ description: @description,
91
+ nature: @nature.to_sym,
92
+ effort_value: @effort_value,
93
+ individual_value: @individual_value,
94
+ ability: @ability,
95
+ item: @item
96
+ }
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,3 @@
1
+ module Pktool
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pktool"
8
+ spec.version = Pktool::VERSION
9
+ spec.authors = ["uzimith"]
10
+ spec.email = ["uzimith.x9@gmail.com"]
11
+ spec.description = %q{pokemon battole support tool}
12
+ spec.summary = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "sequel"
24
+ spec.add_development_dependency "sqlite3"
25
+ spec.add_development_dependency "termcolorlight"
26
+ spec.add_development_dependency "thor"
27
+ spec.add_development_dependency "romaji"
28
+ end
@@ -0,0 +1,4 @@
1
+ require_relative 'lib/log'
2
+ require_relative 'lib/cli'
3
+
4
+ Pktool::Cli.start(ARGV)
@@ -0,0 +1,29 @@
1
+ require_relative '../lib/move.rb'
2
+ require_relative '../lib/pokemon.rb'
3
+
4
+ include Pktool
5
+
6
+ describe "Move" do
7
+
8
+ it "should calculate the damage without any aditional condition in case #1" do
9
+ attacker = Pokemon.fetch("ガブリアス", {nature: :いじっぱり, effort_value: :hAS})
10
+ defender = Pokemon.fetch("カビゴン", {nature: :ずぶとい, effort_value: :HB})
11
+ m = Move.fetch("げきりん", attacker, defender)
12
+ expect(m.damage).to eq({min: 106, max: 125})
13
+ end
14
+
15
+ it "should calculate the damage without any aditional condition in case #2" do
16
+ attacker = Pokemon.fetch("ガブリアス", {nature: :いじっぱり, effort_value: :hAS})
17
+ defender = Pokemon.fetch("クレセリア", {nature: :ずぶとい, effort_value: :HB})
18
+ m = Move.fetch("げきりん", attacker, defender)
19
+ expect(m.damage).to eq({min: 72, max: 85})
20
+ end
21
+
22
+ it "should calculate the damage with type effect" do
23
+ attacker = Pokemon.fetch("ボーマンダ", {nature: :いじっぱり, effort_value: :hAS})
24
+ defender = Pokemon.fetch("ナットレイ", {nature: :ずぶとい, effort_value: :HB})
25
+ m = Move.fetch("だいもんじ", attacker, defender)
26
+ # expect(m.damage(attacker, defender)).to eq({min: 144, max: 172})
27
+ expect(m.damage).to eq({min: 148, max: 174})
28
+ end
29
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../lib/pokemon.rb'
2
+
3
+ include Pktool
4
+
5
+ describe "Nature" do
6
+ it "should fecth nature effect" do
7
+ n = Pokemon::Nature[:まじめ.to_s]
8
+ expect(n.A).to eq 1.0
9
+ end
10
+ end
11
+
12
+ describe "Pokemon" do
13
+ it "should calculate status without nature effect" do
14
+ p = Pokemon.fetch("ガブリアス", {nature: :がんばりや, effort_value: :hAS})
15
+ expect(p.stats).to eq({:H=>184, :A=>182, :B=>115, :C=>100, :D=>105, :S=>154})
16
+ end
17
+
18
+ it "should calculate status with nature effect" do
19
+ p = Pokemon.fetch("ガブリアス", {nature: :いじっぱり, effort_value: :hAS})
20
+ expect(p.stats).to eq({:H=>184, :A=>200, :B=>115, :C=>90, :D=>105, :S=>154})
21
+ end
22
+
23
+ it "should be converted to hash" do
24
+ p = Pokemon.fetch("ガブリアス", {nature: :いじっぱり, effort_value: :hAS})
25
+ expect(p.to_h).to eq(
26
+ {
27
+ name: "ガブリアス",
28
+ description: "",
29
+ nature: :いじっぱり,
30
+ effort_value:{ H: 6, A: 252, B: 0, C: 0, D: 0, S: 252 } ,
31
+ individual_value:{ H: 31, A: 31, B: 31, C: 31, D: 31, S: 31 },
32
+ ability: 1,
33
+ item: ""
34
+ }
35
+ )
36
+ end
37
+ end
38
+
@@ -0,0 +1,17 @@
1
+ require 'rspec'
2
+ require 'pry-byebug'
3
+
4
+ Dir["./support/**/*.rb"].each do |f|
5
+ require f
6
+ end
7
+
8
+ #RSpec.configure do |config|
9
+ #end
10
+
11
+ class String
12
+ def inspect
13
+ self.to_s
14
+ end
15
+ end
16
+
17
+ Encoding.default_external = Encoding::UTF_8
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pktool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - uzimith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sequel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: termcolorlight
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: romaji
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: pokemon battole support tool
112
+ email:
113
+ - uzimith.x9@gmail.com
114
+ executables:
115
+ - pktool
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - Guardfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/pktool
127
+ - data/nature.json
128
+ - data/pokemonData.sqlite
129
+ - data/type.json
130
+ - data/user/party.json
131
+ - lib/builder.rb
132
+ - lib/cli.rb
133
+ - lib/command/party.rb
134
+ - lib/database.rb
135
+ - lib/exceptions.rb
136
+ - lib/log.rb
137
+ - lib/move.rb
138
+ - lib/party.rb
139
+ - lib/pktool.rb
140
+ - lib/pokemon.rb
141
+ - lib/version.rb
142
+ - pktool.gemspec
143
+ - pktool.rb
144
+ - spec/move_spec.rb
145
+ - spec/pokemon_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: ''
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.2.2
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: ''
171
+ test_files:
172
+ - spec/move_spec.rb
173
+ - spec/pokemon_spec.rb
174
+ - spec/spec_helper.rb