Changeset 274


Ignore:
Timestamp:
09/19/03 08:54:27 (8 years ago)
Author:
jamesoff
Message:

fixed "no such user" errors finally i think

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/friendship.tcl

    r2 r274  
    11# bMotion - friendship handler 
    2 # 
     2 
     3# 
     4 
    35# $Id$ 
    4 # 
     6 
     7# 
     8 
     9 
    510 
    611############################################################################### 
     12 
    713# bMotion - an 'AI' TCL script for eggdrops 
     14 
    815# Copyright (C) James Michael Seward 2000-2002 
    9 # 
     16 
     17# 
     18 
    1019# This program is free software; you can redistribute it and/or modify 
     20 
    1121# it under the terms of the GNU General Public License as published by 
     22 
    1223# the Free Software Foundation; either version 2 of the License, or  
     24 
    1325# (at your option) any later version. 
    14 # 
     26 
     27# 
     28 
    1529# This program is distributed in the hope that it will be useful, but  
     30 
    1631# WITHOUT ANY WARRANTY; without even the implied warranty of  
     32 
    1733# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
     34 
    1835# General Public License for more details. 
    19 # 
     36 
     37# 
     38 
    2039# You should have received a copy of the GNU General Public License  
     40 
    2141# along with this program; if not, write to the Free Software  
     42 
    2243# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     44 
    2345############################################################################### 
    2446 
     47 
     48 
    2549proc getFriendship { nick } { 
     50 
    2651  if {![validuser $nick]} { 
     52 
    2753    set handle [nick2hand $nick] 
     54 
    2855    if {($handle == "*") || ($handle == "")} { 
     56 
    2957      bMotion_putloglev 1 * "bMotion: couldn't find a handle for $nick to get friendship." 
     58 
    3059      return 50 
    31     } 
     60 
     61    } 
     62 
    3263  } else { 
     64 
    3365    set handle $nick 
    34   } 
     66 
     67  } 
     68 
     69 
    3570 
    3671  set friendship 50 
    3772 
     73 
     74 
    3875  if {$handle != "*"} { 
     76 
    3977    set friendship [getuser $handle XTRA friend] 
     78 
    4079    if {$friendship == ""} { 
     80 
    4181      setFriendship $nick 50   
     82 
    4283      set friendship 50 
    43     } 
    44   } 
     84 
     85    } 
     86 
     87  } 
     88 
    4589  return $friendship 
    46 } 
     90 
     91} 
     92 
     93 
    4794 
    4895proc getFriendshipHandle { handle } { 
     96 
    4997  set friendship 50 
    5098 
     99 
     100 
    51101  set friendship [getuser $handle XTRA friend] 
     102 
    52103  if {$friendship == ""} { 
     104 
    53105    setFriendship $nick 50   
     106 
    54107    set friendship 50 
    55   } 
     108 
     109  } 
     110 
    56111  return $friendship 
    57 } 
     112 
     113} 
     114 
     115 
    58116 
    59117proc setFriendshipHandle { handle friendship } { 
     118 
    60119  if {$friendship > 100} { 
     120 
    61121    bMotion_putloglev 2 * "bMotion: friendship for $nick went over 100, capping back to 90" 
     122 
    62123    set friendship 90 
    63   } 
     124 
     125  } 
     126 
     127 
    64128 
    65129  if {$friendship < 1} { 
     130 
    66131    bMotion_putloglev 2 * "bMotion: friendship for $nick went under 1, capping back to 10" 
     132 
    67133    set friendship 10 
    68   } 
     134 
     135  } 
     136 
     137 
    69138 
    70139  setuser $handle XTRA friend $friendship 
    71 } 
     140 
     141} 
     142 
     143 
     144 
    72145 
    73146 
    74147proc setFriendship { nick friendship } { 
     148 
     149  bMotion_putloglev 4 * "setFriendship: nick = $nick, friendship = $friendship" 
     150 
    75151  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 
    76162  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 
    80171 
    81172  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 
    88189 
    89190proc 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 
     219proc 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 
     269proc bMotionIsFriend { nick } { 
    99270 
    100271  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 
    134273  bMotion_putloglev 2 * "bMotion: friendship for $nick is $friendship" 
     274 
    135275  if {$friendship < 35} { 
     276 
    136277    return 0 
    137   } 
     278 
     279  } 
     280 
    138281  return 1 
     282 
    139283}     
    140284 
     285 
     286 
    141287bMotion_putloglev d * "bMotion: friendship module loaded" 
     288 
Note: See TracChangeset for help on using the changeset viewer.