Changeset 274
- Timestamp:
- 09/19/03 08:54:27 (8 years ago)
- File:
-
- 1 edited
-
trunk/modules/friendship.tcl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/friendship.tcl
r2 r274 1 1 # bMotion - friendship handler 2 # 2 3 # 4 3 5 # $Id$ 4 # 6 7 # 8 9 5 10 6 11 ############################################################################### 12 7 13 # bMotion - an 'AI' TCL script for eggdrops 14 8 15 # Copyright (C) James Michael Seward 2000-2002 9 # 16 17 # 18 10 19 # This program is free software; you can redistribute it and/or modify 20 11 21 # it under the terms of the GNU General Public License as published by 22 12 23 # the Free Software Foundation; either version 2 of the License, or 24 13 25 # (at your option) any later version. 14 # 26 27 # 28 15 29 # This program is distributed in the hope that it will be useful, but 30 16 31 # WITHOUT ANY WARRANTY; without even the implied warranty of 32 17 33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34 18 35 # General Public License for more details. 19 # 36 37 # 38 20 39 # You should have received a copy of the GNU General Public License 40 21 41 # along with this program; if not, write to the Free Software 42 22 43 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 44 23 45 ############################################################################### 24 46 47 48 25 49 proc getFriendship { nick } { 50 26 51 if {![validuser $nick]} { 52 27 53 set handle [nick2hand $nick] 54 28 55 if {($handle == "*") || ($handle == "")} { 56 29 57 bMotion_putloglev 1 * "bMotion: couldn't find a handle for $nick to get friendship." 58 30 59 return 50 31 } 60 61 } 62 32 63 } else { 64 33 65 set handle $nick 34 } 66 67 } 68 69 35 70 36 71 set friendship 50 37 72 73 74 38 75 if {$handle != "*"} { 76 39 77 set friendship [getuser $handle XTRA friend] 78 40 79 if {$friendship == ""} { 80 41 81 setFriendship $nick 50 82 42 83 set friendship 50 43 } 44 } 84 85 } 86 87 } 88 45 89 return $friendship 46 } 90 91 } 92 93 47 94 48 95 proc getFriendshipHandle { handle } { 96 49 97 set friendship 50 50 98 99 100 51 101 set friendship [getuser $handle XTRA friend] 102 52 103 if {$friendship == ""} { 104 53 105 setFriendship $nick 50 106 54 107 set friendship 50 55 } 108 109 } 110 56 111 return $friendship 57 } 112 113 } 114 115 58 116 59 117 proc setFriendshipHandle { handle friendship } { 118 60 119 if {$friendship > 100} { 120 61 121 bMotion_putloglev 2 * "bMotion: friendship for $nick went over 100, capping back to 90" 122 62 123 set friendship 90 63 } 124 125 } 126 127 64 128 65 129 if {$friendship < 1} { 130 66 131 bMotion_putloglev 2 * "bMotion: friendship for $nick went under 1, capping back to 10" 132 67 133 set friendship 10 68 } 134 135 } 136 137 69 138 70 139 setuser $handle XTRA friend $friendship 71 } 140 141 } 142 143 144 72 145 73 146 74 147 proc setFriendship { nick friendship } { 148 149 bMotion_putloglev 4 * "setFriendship: nick = $nick, friendship = $friendship" 150 75 151 set handle [nick2hand $nick] 152 153 if {($handle == "*") || ($handle == "")} { 154 155 bMotion_putloglev 1 * "bMotion: couldn't find a handle for $nick to set friendship." 156 157 return 50 158 159 } 160 161 76 162 if {$friendship > 100} { 77 bMotion_putloglev 2 * "bMotion: friendship for $nick went over 100, capping back to 90" 78 set friendship 90 79 } 163 164 bMotion_putloglev 2 * "bMotion: friendship for $nick went over 100, capping back to 9" 165 166 set friendship 99 167 168 } 169 170 80 171 81 172 if {$friendship < 0} { 82 bMotion_putloglev 2 * "bMotion: friendship for $nick went under 0, capping back to 10" 83 set friendship 10 84 } 85 86 setuser $handle XTRA friend $friendship 87 } 173 174 bMotion_putloglev 2 * "bMotion: friendship for $nick went under 0, capping back to 1" 175 176 set friendship 1 177 178 } 179 180 181 182 catch { 183 setuser $handle XTRA friend $friendship 184 185 } 186 } 187 188 88 189 89 190 proc driftFriendship { nick drift } { 90 if {![validuser $nick]} { 91 set handle [nick2hand $nick] 92 if {($handle == "*") || ($handle == "")} { 93 bMotion_putloglev 1 * "bMotion: couldn't find a handle for $nick to drift friendship." 94 return 50 95 } 96 bMotion_putloglev 1 * "bMotion: mmm dynamic update of nick $nick to handle $handle :P" 97 set nick $handle 98 } 191 192 bMotion_putloglev 4 * "driftFriendship: nick = $nick, drift = $drift" 193 set handle [nick2hand $nick] 194 195 if {($handle == "*") || ($handle == "")} { 196 197 bMotion_putloglev 1 * "bMotion: couldn't find a handle for $nick to drift friendship." 198 199 return 50 200 201 } 202 203 204 205 set friendship [getFriendship $handle] 206 207 incr friendship $drift 208 209 setFriendship $nick $friendship 210 211 bMotion_putloglev 2 * "bMotion: drifting friendship for $nick by $drift, now $friendship" 212 213 return $friendship 214 215 } 216 217 218 219 proc getFriendsList { } { 220 221 set users [userlist] 222 223 set r "" 224 225 set best(name) "" 226 227 set best(val) 0 228 229 set worst(name) "" 230 231 set worst(val) 100 232 233 foreach user $users { 234 235 set f [getuser $user XTRA friend] 236 237 if {$f != ""} { 238 239 append r "$user:$f " 240 241 } 242 243 if {$f > $best(val)} { 244 245 set best(val) $f 246 247 set best(name) $user 248 249 } 250 251 if {($f < $worst(val)) && ($f > 0)} { 252 253 set worst(val) $f 254 255 set worst(name) $user 256 257 } 258 259 } 260 261 set r "Best friend: $best(name), worst friend: $worst(name). $r" 262 263 return $r 264 265 } 266 267 268 269 proc bMotionIsFriend { nick } { 99 270 100 271 set friendship [getFriendship $nick] 101 incr friendship $drift 102 setFriendship $nick $friendship 103 bMotion_putloglev 2 * "bMotion: drifting friendship for $nick by $drift, now $friendship" 104 return $friendship 105 } 106 107 proc getFriendsList { } { 108 set users [userlist] 109 set r "" 110 set best(name) "" 111 set best(val) 0 112 set worst(name) "" 113 set worst(val) 100 114 foreach user $users { 115 set f [getuser $user XTRA friend] 116 if {$f != ""} { 117 append r "$user:$f " 118 } 119 if {$f > $best(val)} { 120 set best(val) $f 121 set best(name) $user 122 } 123 if {($f < $worst(val)) && ($f > 0)} { 124 set worst(val) $f 125 set worst(name) $user 126 } 127 } 128 set r "Best friend: $best(name), worst friend: $worst(name). $r" 129 return $r 130 } 131 132 proc bMotionIsFriend { nick } { 133 set friendship [getFriendship $nick] 272 134 273 bMotion_putloglev 2 * "bMotion: friendship for $nick is $friendship" 274 135 275 if {$friendship < 35} { 276 136 277 return 0 137 } 278 279 } 280 138 281 return 1 282 139 283 } 140 284 285 286 141 287 bMotion_putloglev d * "bMotion: friendship module loaded" 288
Note: See TracChangeset
for help on using the changeset viewer.
