Don't like ads? PRO users don't see any ads ;-)
Guest

Nighthawk

By: a guest on May 4th, 2012  |  syntax: PHP  |  size: 3.23 KB  |  hits: 89  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3. * Nighthawk
  4. * The Battle of the Tribes Module
  5. * Water, Wood, Fire module
  6. * You're a warrior deep in the jungle after World War 3, everything has regrown around earth and there are only 3 Tribes left.
  7. * The Water tribe
  8. * The Fire tribe
  9. * The Wood tribe
  10. * You are at war with other tribes but balance is always kept
  11. * Water defeats Fire
  12. * Fire defeats Wood
  13. * Wood defeats Water
  14. * Draw you drink with your tribe.
  15. * Choose your tribe
  16. /* Module initialization */
  17.  
  18.  
  19.  
  20. function waterwoodfire_init() {
  21.         global $hooks;      
  22.         $hooks['posting'][] = 'waterwoodfire';
  23. }
  24.  
  25.  
  26. function waterwoodfire__authorized($board) {
  27.         return true;
  28. }
  29.  
  30. function waterwoodfire__info() {
  31.         $info = array();
  32.         $info['type']['board-specific'] = false;
  33.        
  34.         return $info;
  35. }
  36.  
  37. function waterwoodfire_settings() {
  38.         $settings = array();
  39.        
  40. }
  41.  
  42. function waterwoodfire__help() {
  43.         $output = 'Water Wood Fire:  #water, #wood or #fire goes in email field.';      
  44.         return $output;
  45. }
  46.  
  47.  
  48.  
  49.  
  50. function waterwoodfire__process_posting($post) {
  51.         global $bans_class;
  52.  
  53.         /* EDIT */
  54.         $triggers = array('#water', '#wood', '#fire');
  55.         $choices = array('water', 'wood', 'fire');
  56.         $banseconds = 240;
  57.         $banmessage = 'You were defeated by your nemesis.';
  58.         /* End editing */
  59.        
  60.         if (in_array(strtolower($post['email']), $triggers)) {
  61.                 $boardSel = $choices[array_rand($choices)];
  62.                 $userSel = trim(strtolower($post['email']), "#");
  63.                 $newMsg = 'Me: ' . $boardSel . '<br />You: ' . $userSel . '<br />';
  64.                 switch($userSel) {
  65.                         case 'fire':
  66.                                 $win = ($boardSel == "water") ? true : false; //Water puts out fire and wins over fire
  67.                                 break;
  68.                         case 'water':
  69.                                 $win = ($boardSel == "wood") ? true : false; //Wood floats on water and wins over the water
  70.                                 break;
  71.                         case 'wood':
  72.                                 $win = ($boardSel == "fire") ? true : false; //Fire burns wood and wins over the wood
  73.                                 break;
  74.                 }
  75.                
  76.                 if($win != true){
  77.                         if($userSel == $boardSel) {
  78.                                 $newMsg .= '<span style="color: blue; background-color: white;">Draw! You get drunk with your tribe</span><br /><br />';
  79.                         }else{
  80.                                 $newMsg .= '<span style="color: red; background-color: black;">You lost, Death!</span><br /><br />';
  81.                                 $bans_class->BanUser($_SERVER['REMOTE_ADDR'], 'SERVER', 1, $banseconds, '', $banmessage, 0, 0);
  82.                         }
  83.                 }else{
  84.                         $newMsg .= '<span style="color: white; background-color: red;">You crushed your opponent!</span><br /><br />';
  85.                 }
  86.                
  87.                 $post['message'] = $newMsg . $post['message'];
  88.  
  89.                 $post['email'] = '';
  90.                 $post['email_save'] = false;
  91.         }
  92.  
  93.         return $post;
  94. }
  95.  
  96. ?>