· 10 years ago · Sep 14, 2016, 03:32 PM
1#eggdrop1.6 +/-
2#
3# Kinksters Game
4# Xy, Y(Bacon,Rishe,etc)
5#
6# usage:
7#
8# for in channel public commands - check that +kinksters is set
9# - if {[string match "*+kinksters*" [channel info $chan]]} {
10#
11# for private message commands, check that the nick is in the game
12# - if {[kdb exists {SELECT 1 FROM xy_kinksters where k_nick = $nick}]} {
13#
14# ----- Bindings --------
15#do .chanset <chan> +kinksters to initialize
16setudef flag kinksters
17
18bind pub -|- !joingame joingame
19bind pub -|- !not_playing not_playing
20bind pub -|- !resume game_resume
21bind pub -|- !kinksters_help kinksters_help
22bind pubm - * earn_money
23bind ctcp - ACTION act_earn_money
24bind pub - !balance balance
25bind pub - !transfer transfer
26
27bind msg - !pos position
28
29# ----- Op Commands ------
30bind pub o|o !op_help op_help
31bind pub o|o !show_db show_db
32bind pub o|o !remove_player remove_player
33bind pub o !givemoney givemoney
34# ----- Global variables
35package require sqlite3
36# ---- Change this path
37set kdbfile "/home/pi/eggdrop/bots/gav/kinksters.db"
38set positions {Merchant Trader Dominant Keeper pet toy sub slave}
39set statuses {Top Free Slave Poly Broken}
40# --- Help System
41proc kinksters_help {nick host hand chan text} {
42 if {[string match "*+kinksters*" [channel info $chan]]} {
43 putquick "NOTICE $nick :The Kinksters Game Commands!"
44 putquick "NOTICE $nick :!joingame - joins the game."
45 putquick "NOTICE $nick :!not_playing - marks you as inactive"
46 putquick "NOTICE $nick :!resume - resumes your current game"
47 putquick "NOTICE $nick :!balance - shows you your bank balance"
48 putquick "NOTICE $nick :!transfer <nick> <amount> - transfers <amount> from your balance to <nick>"
49 putlog "[isop $nick $chan] $nick $chan"
50 }
51}
52
53proc op_help {nick host hand chan text} {
54 if {[string match "*+kinksters*" [channel info $chan]]} {
55 putquick "NOTICE $nick : -- op only commands --"
56 putquick "NOTICE $nick :!givemoney <nick> <amount>"
57 putquick "NOTICE $nick :!show_db sends you a list of players and their information"
58 putquick "NOTICE $nick :!remove_player <nick> - removes the player from the db completely"
59 }
60}
61
62# ----- Database setup -----
63
64if {![file exists $kdbfile]} {
65 sqlite3 kdb $kdbfile
66 kdb eval {CREATE TABLE xy_kinksters (k_nick TEXT PRIMARY KEY , k_money INTEGER, k_status TEXT, k_position TEXT, k_owned INTEGER, k_owner TEXT, k_active INTEGER)}
67 kdb close
68}
69
70proc pos_new {selected nick} {
71 global kdbfile
72 # sqlite3 kdb $kdbfile
73 # db still open from position {}
74 putquick "PRIVMSG $nick:You have chosen $selected"
75 switch -exact $selected {
76 "Merchant" {
77 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Top" WHERE k_nick = $nick}
78 putquick "NOTICE $nick :You are now a Merchant and your status is Top."
79 putquick "NOTICE $nick :You have access to the following commands:"
80 putquick "NOTICE $nick :!sell <traded submissive> - to sell a submissive to a Top"
81 putquick "NOTICE $nick :!available - list submissives available to sell"
82 }
83 "Trader" {
84 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Top" WHERE k_nick = $nick}
85 putquick "NOTICE $nick :You are now a Trader and your status is Top."
86 putquick "NOTICE $nick :You have access to the following commands:"
87 putquick "NOTICE $nick :!capture <free submissive> - to try to capture a free (unowned) submissive"
88 putquick "NOTICE $nick :!trade <captured submissive> - to trade a submissive for some Coin"
89 }
90 "Dominant" {
91 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Top" WHERE k_nick = $nick}
92 putquick "NOTICE $nick :You are now a Dominant and your status is Top."
93 putquick "NOTICE $nick :You have access to the following commands:"
94 putquick "NOTICE $nick :!buy <available submissive> from <merchant> - to purchase a submissive"
95 }
96 "Keeper" {
97 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Top" WHERE k_nick = $nick}
98 putquick "NOTICE $nick :You are now a Keeper and your status is Top."
99 putquick "NOTICE $nick :You have access to the following commands:"
100 putquick "NOTICE $nick :!contend <other tops> - to challenge another Top"
101 putquick "NOTICE $nick :When a contention is won, Keepers have two options presented at the time of the challenge."
102 putquick "NOTICE $nick :When a contention is lost, Keepers lose all of their Coin to the challenged."
103 }
104 "pet" {
105 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Free" WHERE k_nick = $nick}
106 putquick "NOTICE $nick :You are now a pet and your status is Top."
107 }
108 "toy" {
109 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Free" WHERE k_nick = $nick}
110 putquick "NOTICE $nick :You are now a toy and your status is Free."
111 }
112 "sub" {
113 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Free" WHERE k_nick = $nick}
114 putquick "NOTICE $nick :You are now a sub and your status is Free."
115 }
116 "slave" {
117 kdb eval {UPDATE xy_kinksters SET k_position = $selected, k_status = "Free" WHERE k_nick = $nick}
118 putquick "NOTICE $nick :You are now a slave and your status is Free."
119 }
120 default {
121 putquick "NOTICE $nick :You must choose one of the following:"
122 putquick "NOTICE $nick :Merchant, Trader, Dominant, Keeper, pet, toy, sub, slave"
123 }
124 }
125 # kdb close
126}
127
128proc pos_chg {selected nick} {
129 putquick "NOTICE $nick : Change position logic TODO"
130}
131
132proc position {nick host hand text} {
133 global kdbfile positions statuses
134 sqlite3 kdb $kdbfile
135 set selected [lindex $text 0]
136 putquick "PRIVMSG $nick :You are chosing your position now"
137 if {[kdb exists {SELECT 1 FROM xy_kinksters where k_nick = $nick}]} {
138 kdb eval {SELECT k_position from xy_kinksters WHERE k_nick = $nick} {
139 if {$k_position == ""} {
140 pos_new $selected $nick
141 } else {
142 pos_new $selected $nick
143 }
144 }
145 }
146 kdb close
147}
148
149proc joingame {nick host hand chan text} {
150 global kdbfile
151 if { [string match "*+kinksters*" [channel info $chan]] } {
152 sqlite3 kdb $kdbfile
153 if {[kdb exists {SELECT 1 FROM xy_kinksters where k_nick like $nick}]} {
154 putquick "NOTICE $nick :You have already joined the game."
155 } else {
156 kdb eval {INSERT INTO xy_kinksters (k_nick, k_money, k_status, k_position, k_owned, k_owner, k_active) VALUES ($nick, 0, "NONE", "NONE", 0, "NONE", 1)}
157 putquick "NOTICE $nick :You have joined the game. You have no status and you are not owned. You have have \$0!"
158 putquick "NOTICE $nick :You each cash by talking in channel."
159 putquick "NOTICE $nick :You can set your position using the !position command"
160 putquick "NOTICE $nick :See !pos_help for position descriptions."
161 putquick "NOTICE $nick :Use !not_playing to remove yourself from the game (keeping current status)"
162 }
163 kdb close
164 }
165}
166
167proc not_playing {nick host hand chan text} {
168 global kdbfile
169 if {[string match "*+kinksters*" [channel info $chan]]} {
170 sqlite3 kdb $kdbfile
171 kdb eval {SELECT k_active FROM xy_kinksters WHERE k_nick = $nick} {
172 if {$k_active} {
173 kdb eval {UPDATE xy_kinksters SET k_active = 0 WHERE k_nick = $nick}
174 putquick "NOTICE $nick :You are removed from the game, use !resume to play again."
175 } else {
176 putquick "NOTICE $nick :You are already removed, use !resume to play again."
177 }
178 }
179 kdb close
180 }
181}
182
183proc game_resume {nick host hand chan text} {
184 if {[string match "*+kinksters*" [channel info $chan]]} {
185 global kdbfile
186 sqlite3 kdb $kdbfile
187 kdb eval {SELECT k_active FROM xy_kinksters WHERE k_nick = $nick} {
188 if {$k_active} {
189 putquick "NOTICE $nick :You are already active, use !not_playing to pause."
190
191 } else {
192 kdb eval {UPDATE xy_kinksters SET k_active = 1 WHERE k_nick = $nick}
193 putquick "NOTICE $nick :You have returned to the game - Enjoy!"
194 }
195 }
196 kdb close
197 }
198}
199
200proc show_db {nick host hand chan text} {
201 if {[string match "*+kinksters*" [channel info $chan]]} {
202 global kdbfile
203 sqlite3 kdb $kdbfile
204 putquick "NOTICE $nick :Here is the current database for the game:"
205 putquick "NOTICE $nick :nick | money | status | position | owned | owner | active"
206 kdb eval {SELECT * FROM xy_kinksters} {
207 set dataline [format "%s | %10.0f | %s | %s | %1.0f | %s | %1.0f" $k_nick $k_money $k_status $k_position $k_owned $k_owner $k_active]
208 putquick "NOTICE $nick :$dataline"
209 }
210 kdb close
211 }
212}
213
214proc remove_player {nick host hand chan text} {
215 if {[string match "*+kinksters*" [channel info $chan]]} {
216 global kdbfile
217 sqlite3 kdb $kdbfile
218 set target [lindex $text 0]
219 putlog "Removing $target"
220 putquick "PRIVMSG $chan : Removing $target"
221 kdb eval {DELETE FROM xy_kinksters WHERE k_nick = $target}
222 putquick "NOTICE $nick :$target has been removed from the db"
223 kdb close
224 }
225}
226
227proc earn_money {nick host hand chan text} {
228 if {[string match "*+kinksters*" [channel info $chan]]} {
229 global kdbfile
230 sqlite3 kdb $kdbfile
231 set words [llength $text]
232 if {$words > 65} {
233 #cheating writing too many words
234 } else {
235 #calculate more money and update database
236 set inc_cash [expr $words * 3]
237 kdb eval {SELECT k_money FROM xy_kinksters WHERE k_nick = $nick} {
238 set new_cash [expr $k_money + $inc_cash]
239 kdb eval {UPDATE xy_kinksters SET k_money = $new_cash WHERE k_nick = $nick}
240 }
241 }
242 kdb close
243 }
244}
245
246proc act_earn_money {nick host hand dest key text} {
247 if {[string match "*+kinksters*" [channel info $dest]]} {
248 if {[string index $dest 0] != "#"} {return 0}
249 earn_money $nick $host $hand $dest $text
250 }
251}
252
253proc balance {nick host hand chan text} {
254 if {[string match "*+kinksters*" [channel info $chan]]} {
255 global kdbfile
256 sqlite3 kdb $kdbfile
257 kdb eval {SELECT k_money FROM xy_kinksters WHERE k_nick = $nick} {
258 putquick "NOTICE $nick :You currently have \$$k_money in the bank"
259 }
260 kdb close
261 }
262}
263
264proc transfer {nick host hand chan text} {
265 if {[string match "*+kinksters*" [channel info $chan]]} {
266 global kdbfile
267 set target [lindex $text 0]
268 set amount [lindex $text 1]
269 sqlite3 kdb $kdbfile
270 kdb eval {SELECT k_money, k_active FROM xy_kinksters WHERE k_nick = $nick} {
271 if {$k_active} {
272 kdb eval {SELECT k_money AS t_money, k_active AS t_active FROM xy_kinksters WHERE k_nick = $target} {
273 if {$t_active} {
274 set increase [expr $k_money + $amount]
275 set decrease [expr $t_money - $amount]
276 if {$decrease < 0} {
277 putquick "NOTICE $nick :You only have $k_money you can't give $amount!"
278 } else {
279 putlog "$nick is active and $target is active and inc $increase and dec $decrease"
280 kdb eval {UPDATE xy_kinksters SET k_money = $increase WHERE k_nick = $target}
281 kdb eval {UPDATE xy_kinksters SET k_money = $decrease WHERE k_nick = $nick}
282 putquick "NOTICE $nick :You added $amount to $target - they now have $increase"
283 putquick "NOTICE $target :$nick gave you $amount - you now have $increase in your bank"
284 }
285 } else {
286 putquick "NOTICE $nick : $target is not active - transfer cancelled."
287 }
288 }
289 } else {
290 putquick "NOTICE $nick : You are not active type !resume to join the game"
291 }
292 }
293 kdb close
294 }
295}
296
297proc givemoney {nick host hand chan text} {
298 if {[string match "*+kinksters*" [channel info $chan]]} {
299 global kdbfile
300 set target [lindex $text 0]
301 set amount [lindex $text 1]
302 sqlite3 kdb $kdbfile
303 kdb eval {SELECT k_money, k_active FROM xy_kinksters WHERE k_nick = $target} {
304 if {$k_active} {
305 set increase [expr $k_money + $amount]
306 kdb eval {UPDATE xy_kinksters SET k_money = $increase WHERE k_nick = $target}
307 putquick "NOTICE $nick :You added $amount to $target - they now have $increase"
308 putquick "NOTICE $target :The gods have smiled upon you, you now have $increase in your bank"
309 } else {
310 putquick "NOTICE $nick :$target is not active - Cannot give them money"
311 }
312 }
313 kdb close
314 }
315}