botemon 0.2.3 → 0.2.4
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 +8 -8
- data/bin/botemon +21 -18
- data/lib/botemon/storage.rb +8 -9
- data/lib/botemon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODk1NDM4YzcwYWRkZWVmNzFmNTg0MmRhNTc1MjZkNWE4Njc5YmM5ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTg4NDUxZmFjNzg2NGY4ZmViNWMyMjEyODYyY2Q1MDYzYWFjZWQ2ZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTZkYjkwOGRlYjZhNDM4MzU5MTQ1N2ExODk5MDQ0YTIyNGJkZWJlZjI2MzVi
|
10
|
+
OGUwNDc5MGExZDZmYTM1ZWIwMDYxNWFkYmJkZTNjYmQzOGIzYjJmOTM0M2Y3
|
11
|
+
ZjE3ZDAyYmVmMjkyNmFiNzNlMDBmNGYzYWE5NmQ5YmQ1MDkyODg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjliN2Y0MjQyN2FlZWRkYjNmOTU0Mjc5ZTAyZmU0YzU4NTYyNjU2NjFiNjlm
|
14
|
+
ZDc3MzgxZjE0NDBhNDRjNzQ4YmEwMGQ1NzMwZTkwYzc0ODgwYjk3MzdiMDUy
|
15
|
+
NGVmZjE1MzFiMWYwYjAyYmQzZWEzYjI3MGYzNDhkYjQzMTdmNDU=
|
data/bin/botemon
CHANGED
@@ -39,6 +39,7 @@ Cinch::Bot.new {
|
|
39
39
|
@pokemon_trivia = nil
|
40
40
|
@players = []
|
41
41
|
@trivia_owner = ''
|
42
|
+
@trivia_wrong = 0
|
42
43
|
end
|
43
44
|
|
44
45
|
on :message, /^pkmn (.+)/ do |m, name|
|
@@ -74,26 +75,10 @@ Cinch::Bot.new {
|
|
74
75
|
else
|
75
76
|
@pokemon_trivia = Pokedex.get Pokedex.id2name(Random.new.rand(1..649)), @storage
|
76
77
|
@trivia_owner = m.user.nick
|
78
|
+
@trivia_wrong = 0
|
77
79
|
|
78
80
|
m.reply @pokemon_trivia.clues.split("\n").map { |l| Format(:red, l) }.join("\n")
|
79
|
-
m.reply Format(:red, "You have
|
80
|
-
|
81
|
-
Timer(60) {
|
82
|
-
if @pokemon_trivia != nil
|
83
|
-
m.reply Format(:red, "Time expired. The secret Pokémon is #{@pokemon_trivia.name}!")
|
84
|
-
@pokemon_trivia = nil
|
85
|
-
end
|
86
|
-
}
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
on :message, /^pkstop$/ do |m|
|
91
|
-
if @pokemon_trivia != nil && (m.user.nick == 'mirkosp' || m.user.nick == 'RoxasShadowRS' || m.user.nick == @trivia_owner)
|
92
|
-
@pokemon_trivia = nil
|
93
|
-
@trivia_owner = ''
|
94
|
-
m.reply Format(:red, "Game aborted by #{m.user.nick}.")
|
95
|
-
else
|
96
|
-
m.reply Format(:red, "Only ops can stop the game. #{m.user.nick} GTFO.")
|
81
|
+
m.reply Format(:red, "You have 3 chances to try to say which Pokémon is this!")
|
97
82
|
end
|
98
83
|
end
|
99
84
|
|
@@ -103,8 +88,26 @@ Cinch::Bot.new {
|
|
103
88
|
elsif pokemon.downcase == @pokemon_trivia.name.downcase
|
104
89
|
m.reply Format(:red, "Right, #{m.user.nick} won!")
|
105
90
|
@pokemon_trivia = nil
|
91
|
+
@trivia_wrong = 0
|
106
92
|
else
|
107
93
|
m.reply Format(:red, "Nope, #{m.user.nick} was wrong.")
|
94
|
+
@trivia_wrong += 1
|
95
|
+
if @trivia_wrong >= 3
|
96
|
+
m.reply Format(:red, "Time expired. The secret Pokémon is #{@pokemon_trivia.name}!")
|
97
|
+
@pokemon_trivia = nil
|
98
|
+
@trivia_wrong = 0
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
on :message, /^pkstop$/ do |m|
|
104
|
+
if @pokemon_trivia != nil && (m.user.nick == 'mirkosp' || m.user.nick == 'RoxasShadowRS' || m.user.nick == @trivia_owner)
|
105
|
+
@pokemon_trivia = nil
|
106
|
+
@trivia_owner = ''
|
107
|
+
@trivia_wrong = 0
|
108
|
+
m.reply Format(:red, "Game aborted by #{m.user.nick}.")
|
109
|
+
else
|
110
|
+
m.reply Format(:red, "Only ops and the game luncher can stop the game. #{m.user.nick} GTFO.")
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
data/lib/botemon/storage.rb
CHANGED
@@ -22,15 +22,15 @@ class Storage
|
|
22
22
|
|
23
23
|
def initialize(file)
|
24
24
|
@file = file
|
25
|
-
db
|
26
|
-
|
27
|
-
db.each { |p| d << Pokemon.to_pokemon(p) }
|
25
|
+
@db = [].tap { |db|
|
26
|
+
(File.exists?(file) ? JSON.load(File.read(file)) : []).each { |p| db << Pokemon.to_pokemon(p) }
|
28
27
|
}
|
29
28
|
end
|
30
29
|
|
31
30
|
def is_cached?(name)
|
32
31
|
return @db.select { |p| p._name == name.downcase }.any?
|
33
32
|
end
|
33
|
+
alias :include? :is_cached?
|
34
34
|
|
35
35
|
def get(name)
|
36
36
|
return @db.select { |p| p._name == name.downcase }.first
|
@@ -42,17 +42,16 @@ class Storage
|
|
42
42
|
alias :dump :get_all
|
43
43
|
|
44
44
|
def add(pokemon)
|
45
|
-
@db << pokemon
|
45
|
+
@db << pokemon unless is_cached?(pokemon.name)
|
46
46
|
end
|
47
47
|
alias :put :add
|
48
48
|
|
49
49
|
def save
|
50
|
-
|
50
|
+
[].tap { |ary|
|
51
51
|
@db.each { |p| ary << p.to_ary }
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
f.write JSON.dump(db_ary)
|
52
|
+
File.open(@file, 'wb') { |f|
|
53
|
+
f.write JSON.dump(ary)
|
54
|
+
}
|
56
55
|
}
|
57
56
|
end
|
58
57
|
end
|
data/lib/botemon/version.rb
CHANGED