Advertisement
Guest User

Untitled

a guest
Apr 1st, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. ( @alts, a terrible April fools prank. )
  2. $include $lib/character
  3.  
  4. $def TRUE 1
  5. $def FALSE 0
  6.  
  7. : do_help ( -- )
  8. ( Display 'helpful' information. )
  9. { "@Alts, (C) 2013 Kelketek of Winter's Oasis."
  10. " "
  11. " This program will list the alts of another character, based on information"
  12. "gathered by the system to determine, with certainty, which characters are"
  13. "another one's alts. It may not detect all alts, but any it detects are"
  14. "verified to be alts of the target player."
  15. " "
  16. "Usage:"
  17. " @alts someone"
  18. "... where 'someone' is the name of someone you want to look up the alts of."
  19. }list foreach
  20. swap pop
  21. .tell
  22. repeat
  23. ;
  24.  
  25. : list_alts[ ref:target list:alt_list -- ]
  26. alt_list @ not if
  27. { "Could not find any alts for " target @ }cat .tell exit
  28. then
  29.  
  30. { }list var! work_list
  31.  
  32. alt_list @ foreach
  33. swap pop name work_list @ array_appenditem work_list !
  34. repeat
  35.  
  36.  
  37. { "The following alts were found for " target @ ":\r"
  38. work_list @ ", " array_join }cat
  39. .tell
  40. ;
  41.  
  42. : hash_string[ str:name -- int:hash ]
  43. ( Create a 'hash' of a string. This will just be the average of all
  44. ASCII values for the target string.
  45.  
  46. This is picked because it should have a high degree of collision. )
  47.  
  48. var total
  49. name @ var! workname
  50.  
  51. workname @ strlen 1 swap 1 for
  52. pop
  53. workname @ 1 strcut swap ctoi total @ + total !
  54. workname !
  55. repeat
  56.  
  57. total @ name @ strlen /
  58. ;
  59.  
  60. : fake_compare[ ref:player1 ref:player2 -- int:bool ]
  61. ( Compares two players on superficial, but back and forth
  62. compatible levels. )
  63.  
  64. player1 @ name hash_string player2 @ name hash_string = not if
  65. FALSE exit
  66. then
  67.  
  68. player1 @ intostr hash_string player2 @ intostr hash_string = not if
  69. FALSE exit
  70. then
  71.  
  72. TRUE
  73. ;
  74.  
  75. : do_fake_alts[ ref:target -- list:alt_list ]
  76. ( Generate a bogus but consistent list of alts. )
  77. ( We only show characters who have at least one approval, )
  78. ( So that way we're not overcrowding and the players are more likely to )
  79. ( be known. )
  80.  
  81. { }list var! alt_list
  82.  
  83. dbtop int 1 swap 1 for
  84. dbref var! victim
  85. victim @ player? if
  86. target @ victim @ fake_compare victim @ getApprovalLevel and
  87. victim @ target @ dbcmp not and
  88. me @ "@/email" getpropstr strip victim @ "@/email" getpropstr strip
  89. stringcmp
  90. and if
  91. victim @ alt_list @ array_appenditem alt_list !
  92. then
  93. then
  94. repeat
  95.  
  96. alt_list @
  97. ;
  98.  
  99. : do_real_alts[ ref:target -- list:alt_list ]
  100. ( Generate a legitimate alts listing. )
  101. { }list var! alt_list
  102.  
  103. target @ "@/email" getpropstr strip var! email
  104. dbtop int 1 swap 1 for
  105. dbref var! victim
  106. victim @ player? if
  107. victim @ "@/email" getpropstr strip email @ stringcmp not
  108. victim @ target @ dbcmp not
  109. and if
  110. victim @ alt_list @ array_appenditem alt_list !
  111. then
  112. then
  113. repeat
  114.  
  115. alt_list @
  116. ;
  117.  
  118. : main ( s -- )
  119. var alt_list
  120. strip var! arg
  121. arg @ not if
  122. "You must specify a player to check their alts." .tell exit
  123. then
  124.  
  125. arg @ "#h*" smatch if
  126. do_help exit
  127. then
  128.  
  129. arg @ pmatch dup ok? not if
  130. pop arg @ part_pmatch arg !
  131. else
  132. arg !
  133. then
  134.  
  135. arg @ ok? not if
  136. "Invalid or ambiguous player." .tell exit
  137. then
  138.  
  139. arg @ "@/email" getpropstr var! email
  140.  
  141. me @ "@/email" getpropstr strip email @ stringcmp not if
  142. arg @ do_real_alts alt_list !
  143. else
  144. arg @ do_fake_alts alt_list !
  145. then
  146.  
  147. arg @ alt_list @ list_alts
  148. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement