<?php
/*
* Nighthawk
* The Battle of the Tribes Module
* Water, Wood, Fire module
* You're a warrior deep in the jungle after World War 3, everything has regrown around earth and there are only 3 Tribes left.
* The Water tribe
* The Fire tribe
* The Wood tribe
* You are at war with other tribes but balance is always kept
* Water defeats Fire
* Fire defeats Wood
* Wood defeats Water
* Draw you drink with your tribe.
* Choose your tribe
/* Module initialization */
function waterwoodfire_init() {
global $hooks;
$hooks['posting'][] = 'waterwoodfire';
}
function waterwoodfire__authorized($board) {
return true;
}
function waterwoodfire__info() {
$info = array();
$info['type']['board-specific'] = false;
return $info;
}
function waterwoodfire_settings() {
$settings = array();
}
function waterwoodfire__help() {
$output = 'Water Wood Fire: #water, #wood or #fire goes in email field.';
return $output;
}
function waterwoodfire__process_posting($post) {
global $bans_class;
/* EDIT */
$triggers = array('#water', '#wood', '#fire');
$choices = array('water', 'wood', 'fire');
$banseconds = 240;
$banmessage = 'You were defeated by your nemesis.';
/* End editing */
if (in_array(strtolower($post['email']), $triggers)) {
$boardSel = $choices[array_rand($choices)];
$userSel = trim(strtolower($post['email']), "#");
$newMsg = 'Me: ' . $boardSel . '<br />You: ' . $userSel . '<br />';
switch($userSel) {
case 'fire':
$win = ($boardSel == "water") ? true : false; //Water puts out fire and wins over fire
break;
case 'water':
$win = ($boardSel == "wood") ? true : false; //Wood floats on water and wins over the water
break;
case 'wood':
$win = ($boardSel == "fire") ? true : false; //Fire burns wood and wins over the wood
break;
}
if($win != true){
if($userSel == $boardSel) {
$newMsg .= '<span style="color: blue; background-color: white;">Draw! You get drunk with your tribe</span><br /><br />';
}else{
$newMsg .= '<span style="color: red; background-color: black;">You lost, Death!</span><br /><br />';
$bans_class->BanUser($_SERVER['REMOTE_ADDR'], 'SERVER', 1, $banseconds, '', $banmessage, 0, 0);
}
}else{
$newMsg .= '<span style="color: white; background-color: red;">You crushed your opponent!</span><br /><br />';
}
$post['message'] = $newMsg . $post['message'];
$post['email'] = '';
$post['email_save'] = false;
}
return $post;
}
?>