All pastes #265067 Raw Edit

Unnamed

public php v1 · immutable
·published 2006-12-03 00:00 UTC
rendered paste body
<?phpfunction Monopoly_start(&$irc, &$data, &$vars){	$vars['play'] = 2;	$vars['list'] = array(strtolower($data->nick));	$vars['user'] = 0;	$vars['roll'] = 'no';	$vars['users'] = array(strtolower($data->nick) => array('money' => '1500', 'position' => '0', 'doubles' => '0', 'jail' => 'no'));	$vars['location'] = array('0' => array('name' => 'Go', 'price' => 'Special', 'owner' => 'Impossible'),				  '1' => array('name' => 'Mediterranean Avenue', 'price' => '60', 'buy' => '50', 'owner' => 'None'),				  '2' => array('name' => 'Community Chest', 'price' => 'Special', 'owner' => 'Impossible'),				  '3' => array('name' => 'Baltic Avenue', 'price' => '60', 'buy' => '50', 'owner' => 'None'),				  '4' => array('name' => 'Income Tax', 'price' => 'Special', 'owner' => 'Impossible'),				  '5' => array('name' => 'Reading Railroad', 'price' => '200', 'buy' => '200', 'owner' => 'None'),				  '6' => array('name' => 'Oriental Avenue', 'price' => '100', 'buy' => '50', 'owner' => 'None'),				  '7' => array('name' => 'Chance', 'price' => 'Special', 'owner' => 'Impossible'),				  '8' => array('name' => 'Vermont Avenue', 'price' => '100', 'buy' => '50', 'owner' => 'None'),				  '9' => array('name' => 'Connecticut Avenue', 'price' => '120', 'buy' => '50', 'owner' => 'None'),				  				  '10' => array('name' => 'Visiting Jail', 'price' => 'Special', 'owner' => 'Impossible'),				  '11' => array('name' => 'Jail', 'price' => 'Special', 'owner' => 'Impossible'),				  '12' => array('name' => 'St. Charles Place', 'price' => '140', 'buy' => '100', 'owner' => 'None'),				  '13' => array('name' => 'Electric Company', 'price' => 'Special', 'buy' => '150', 'owner' => 'None'),				  '14' => array('name' => 'States Avenue', 'price' => '140', 'buy' => '100', 'owner' => 'None'),				  '15' => array('name' => 'Virgina Avenue', 'price' => '160', 'buy' => '100', 'owner' => 'None'),				  '16' => array('name' => 'Pennsylvania Railroad', 'price' => '200', 'buy' => '200', 'owner' => 'None'),				  '17' => array('name' => 'St. James Place', 'price' => '180', 'buy' => '100', 'owner' => 'None'),				  '18' => array('name' => 'Community Chest', 'price' => 'Special', 'owner' => 'Impossible'),				  '19' => array('name' => 'Tennessee Avenue', 'price' => '180', 'buy' => '100', 'owner' => 'None'),				  '20' => array('name' => 'New York Avenue', 'price' => '200', 'buy' => '100', 'owner' => 'None'),				  				  '21' => array('name' => 'Free Parking', 'price' => 'Special', 'money' => '0.50', 'owner' => 'Impossible'),				  '22' => array('name' => 'Kentucky Avenue', 'price' => '220', 'buy' => '150', 'owner' => 'None'),				  '23' => array('name' => 'Chance', 'price' => 'Special', 'owner' => 'Impossible'),				  '24' => array('name' => 'Indiana Avenue', 'price' => '220', 'buy' => '150', 'owner' => 'None'),				  '25' => array('name' => 'Illinois Avenue', 'price' => '240', 'buy' => '150', 'owner' => 'None'),				  '26' => array('name' => 'B and O Railroad', 'price' => '200', 'buy' => '200', 'owner' => 'None'),				  '27' => array('name' => 'Atlantic Avenue', 'price' => '260', 'buy' => '150', 'owner' => 'None'),				  '28' => array('name' => 'Ventnor Avenue', 'price' => '260', 'buy' => '150', 'owner' => 'None'),				  '29' => array('name' => 'Water Works', 'price' => 'Special', 'buy' => '150', 'owner' => 'None'),				  '30' => array('name' => 'Marvin Gardens', 'price' => '280', 'buy' => '150', 'owner' => 'None'),				  '31' => array('name' => 'Goto Jail', 'price' => 'Special', 'owner' => 'Impossible'),				  				  '32' => array('name' => 'Pacific Avenue', 'price' => '300', 'buy' => '200', 'owner' => 'None'),				  '33' => array('name' => 'North Carolina Avenue', 'price' => '300', 'buy' => '200', 'owner' => 'None'),				  '34' => array('name' => 'Community Chest', 'price' => 'Special', 'owner' => 'Impossible'),				  '35' => array('name' => 'Pennsylvania Avenue', 'price' => '320', 'buy' => '200', 'owner' => 'None'),				  '36' => array('name' => 'Short Line', 'price' => '200', 'buy' => '200', 'owner' => 'None'),				  '37' => array('name' => 'Chance', 'price' => 'Special', 'owner' => 'Impossible'),				  '38' => array('name' => 'Park Place', 'price' => '350', 'buy' => '200', 'owner' => 'None'),$vars['users'][$user]['money']				  '39' => array('name' => 'Luxury Tax', 'price' => 'Special', 'owner' => 'Impossible'),				  '40' => array('name' => 'Boardwalk', 'price' => '400', 'buy' => '200', 'owner' => 'None'));	$speed = end(explode(' ', $data->message, 3));	if ($speed == 'quick') {		$vars['timer_start'] = 10;	} else {		$vars['timer_start'] = 30;	}	$message = 'Type "join" to play Monopoly. Starting in ' . ($vars['timer_start'] / 2) . ' seconds.';	$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);	$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, '(' . $data->nick . ' is automatically joined.)');}function Monopoly_message(&$irc, &$data, &$vars){	if (!$vars['play'])	{		return;	} else if ($vars['play'] == 1) {			$user = $vars['list'][$vars['user']];		if (strtolower($data->nick) == $user)		{			if ($data->message == 'roll' && $vars['roll'] == 'no')			{				$vars['roll'] = 'yes';				//Roll the dice...				$dice_one = mt_rand(1,6);				$dice_two = mt_rand(1,6);				$vars['users'][$user]['dice']['1'] = $dice_one;				$vars['users'][$user]['dice']['2'] = $dice_two;				$dice_total = $dice_one + $dice_two;				$message = $user.': You rolled a total of '.$dice_total.' ('.$dice_one.' and '.$dice_two.').';				$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);				//Moving the player...				$position = $vars['users'][$user]['position'];				if ($dice_total + $position > 40)				{					//Don't go outside the board...thats cheating...					echo "Err.. Outside the board, moving back in...\n";					$position = ($dice_total + $position) - 40;					$dice_total = -1;					//Assume going around/to Go!					$message = $user.': You passed Go! Collecting the $200.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					$money = $vars['users'][$user]['money'];					$money = $money + 200;					$vars['users'][$user]['money'] = $money;				}				/*if ($position + $dice_total == 11 && $vars['users'][$user]['jail'] == "no")				{					echo "We're not in jail...\n";					//We're don't going to jail unless we are told to...					$position = 12;					$dice_total = 0;				}*/				if ($position < 11 && ($position + $dice_total) > 11 || ($position + $dice_total) == 11)				{					echo "Moving around the prison...\n";					$dice_total = $dice_total + 1;				}				if ($vars['users'][$user]['jail'] == "no")				{					$new_pos = $position + $dice_total;					echo "Moving from ".$vars['location'][$position]['name']." ($position) to ".$vars['location'][$new_pos]['name']." ($position+$dice_total).\n";					$vars['users'][$user]['position'] = $position + $dice_total;					$position = $vars['users'][$user]['position'];									$message = $user.': You are now at '.$vars['location'][$position]['name'].'.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);				}								if ($vars['location'][$position]['name'] == 'Jail' && $vars['users'][$user]['jail'] == 'yes')				{					//If we're in jail...					$message = $user.': You\'re in jail. You cannot getout until you roll doubles in three tries or pay $50.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					$vars['users'][$user]['jail'] == 'yes';					if ($dice_one != $dice_two && $vars['users'][$user]['doubles'] <= '3')					{						$message = $user.': No doubles this time.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$double_count = $vars['users'][$user]['doubles'];						$vars['users'][$user]['doubles'] = $double_count + 1;					}					if ($dice_one == $dice_two && $vars['users'][$user]['doubles'] <= '3')					{						$message = $user.': You got doubles.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$vars['users'][$user]['doubles'] = '0';						$vars['users'][$user]['jail'] = 'no';						$vars['users'][$user]['position'] = '12';					}					if ($vars['users'][$user]['doubles'] == '3')					{						$message = $user.': Three tries already. Paying $50.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$money = $vars['users'][$user]['money'];						$money -= 50;						$vars['users'][$user]['money'] = $money;											}				}								if ($vars['location'][$position]['price'] == 'Special')				{					//Ok, we're at something we can't exactly pay for...					if ($vars['location'][$position]['name'] == 'Income Tax')					{						//Eeek!						echo "Eek! Income tax...\n";						$message = $user.': Eeek! Paying the $200.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$money = $vars['users'][$user]['money'];						$money -= 200;						$vars['users'][$user]['money'] = $money;						$vars['location']['19']['money'] += + 200;					}					if ($vars['location'][$position]['name'] == 'Luxury Tax')					{						//Eeek!						echo "Eek! Luxury tax...\n";						$message = $user.': Eeek! Paying the $75.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$money = $vars['users'][$user]['money'];						$money -= 75;						$vars['users'][$user]['money'] = $money;						$vars['location']['19']['money'] += 75;					}					if ($vars['location'][$position]['name'] == 'Free Parking')					{						//YAY						echo "Eek! free parking...\n";						$money_recieved = $vars['location']['19']['money'];						$message = $user.': YAY! You received $'.$money_received.'!';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$money = $vars['users'][$user]['money'];						$money = $money + $money_recieved;						$vars['users'][$user]['money'] = $money;						$vars['location']['19']['money'] = '0.50';					}					if ($vars['location'][$position]['name'] == 'Visiting Jail')					{						//YAY						echo "Eek! visiting jail...\n";						$message = $user.': Don\'t forget to say hi to the inmates.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					}					if ($vars['location'][$position]['name'] == 'Goto Jail')					{						//Eeek!						echo "Eek! goto jail...\n";						$message = $user.': Eeek! Going to jail...';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$vars['users'][$user]['jail'] = 'yes';						$vars['location'][$position]['name'] = 'Jail';						$vars['users'][$user]['doubles'] = '0';					}					/*if ($vars['location'][$position]['name'] == 'Electric Company' || $vars['location'][$position]['name'] == 'Water Works')					{						echo "Eek! utility...\n";						$ec_owner = $vars['location']['13']['owner'];						$ww_owner = $vars['location']['27']['owner'];						if ($ec_owner != $ww_owner)						{							$pay = $dice_total*4;						}						if ($ec_owner == $ww_owner)						{							$pay = $dice_total*10;						}						//The user's money						$money = $vars['users'][$user]['money'];						$money = $money - $pay;						$vars['users'][$user]['money'] = $money;						$message = $user.': You now have $'.$money.'.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						//The owners money...						$money = $vars['users'][$vars['location'][$position]['owner']]['money'];						$money = $money + $pay;						$vars['users'][$vars['location'][$position]['owner']]['money'] = $money;						$message = $vars['location'][$position]['owner'].': You now have $'.$vars['users'][$vars['location'][$position]['owner']]['money'].'.';						$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					}*/					$data->message = 'no';				}								if ($vars['location'][$position]['owner'] == "None")				{					//Do we want to buy it?					$message = $user.': Would you like to buy it for $'.$vars['location'][$position]['buy'].'?';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);				} else if ($vars['location'][$position]['owner'] != "Impossible" && $vars['location'][$position]['owner'] != $user) {					//Oi! Someone owns this joint...					$message = $user.': '.$vars['location'][$position]['name'].' is owned by '.$vars['location'][$position]['owner'].', $'.$vars['location'][$position]['price'].' has been taken from your account.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					//The user's money					$money = $vars['users'][$user]['money'];					$money = $money - $vars['location'][$position]['price'];					$vars['users'][$user]['money'] = $money;					//The owners money...					$money = $vars['users'][$vars['location'][$position]['owner']]['money'];					$money = $money + $vars['location'][$position]['price'];					$vars['users'][$vars['location'][$position]['owner']]['money'] = $money;					$message = $vars['location'][$position]['owner'].': You now have $'.number_format($vars['users'][$vars['location'][$position]['owner']]['money']).'.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);										$data->message = 'no';				}				if ($vars['location'][$position]['owner'] == $user)				{					$message = $user.': You own this!';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					$data->message = 'no';				}			}			if ($vars['users'][$user]['jail'] == 'yes' && $data->message == 'yes')			{				$message = $user.': Ok, paying $50...';				$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);				$money = $vars['users'][$user]['money'];				$money -= 50;				$vars['users'][$user]['money'] = $money;				$vars['location']['19']['money'] = $vars['location']['19']['money'] + 50;			}			if ($data->message == 'yes' && $vars['roll'] == 'yes' && $vars['users'][$user]['jail'] == 'no' && $vars['location'][$position]['buy'] != 'Impossible')			{				//Buy the property.				$position = $vars['users'][$user]['position'];				if ($vars['location'][$position]['owner'] != 'None')				{					$message = $user.': Sorry, '.$vars['location'][$position]['name'].' is owned by '.$vars['location'][$position]['owner'].'.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					return;				}				if ($vars['users'][$user]['money'] >= $vars['location'][$position]['buy'])				{					$vars['location'][$position]['owner'] = $user;					//$message = $user.': You bought '.$vars['location'][$position]['name'].'.';					//$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);										$money = $vars['users'][$user]['money'];					$money = $money - $vars['location'][$position]['buy'];					$vars['users'][$user]['money'] = $money;										$message = $user.': You bought '.$vars['location'][$position]['name'].'.';					$message .= ' You now have $'.number_format($vars['users'][$user]['money']).'.';					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);				}			}			if ($vars['location'][$position]['buy'] == 'Impossible')			{				$data->message = 'no';				$message = $user.': Sorry, you can\'t buy '.$vars['location'][$position]['name'].'.';				$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);			}			$reset = false;			if ($data->message == "yes" || $data->message == "no")			{				if ($vars['roll'] == "yes" && $vars['users'][$user]['dice']['1'] != $vars['users'][$user]['dice']['2'])				{					//Change users...					if ($vars['user']+1 > count($vars['users']) || $vars['user']+1 == count($vars['users']))					{						//Uh oh! Turn back to the first player...						$vars['user'] = 0;						$reset = true;					}					if ($vars['user'] < count($vars['users']) && $reset == false)					{						//Continue on to the next player...						$vars['user']++;					}									$user = $vars['list'][$vars['user']];					$message = "Ok, ".$user."'s ($".number_format($vars['users'][$user]['money']).") turn! (roll)";					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					$vars['roll'] = 'no';				}				if ($vars['roll'] == 'yes' && $vars['users'][$user]['dice']['1'] == $vars['users'][$user]['dice']['2'])				{					$message = $user.": You rolled doubles, you get to go again.";					$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);					$vars['roll'] = 'no';					$user = $vars['list'][$vars['user']];				}			}		}	} else if ($vars['play'] == 2) {		if (strtolower($data->message) == 'join' && !isset($vars['users'][strtolower($data->nick)]))		{			$vars['users'][strtolower($data->nick)] = array('money' => '1500', 'position' => '0', 'doubles' => '0', 'jail' => 'no');			$vars['list'][] = strtolower($data->nick);			$message = $data->nick . ' has joined.';			$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);		}	}}function Monopoly_action(&$irc, &$data, &$vars){	return;}function Monopoly_timer(&$irc, &$vars){	if ($vars['play'] == 2)	{		$vars['timer_start']--;		if ($vars['timer_start']/2 == 0)		{			$vars['play'] = 1;						$data = new Net_SmartIRC_data;			$data->channel = $GLOBALS['channel'];						$message = 'Game started!';			$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						$message = 'Ok, you\'re up first '.$vars['list'][$vars['user']].'!';			$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);						Monopoly_message($irc, $data, $vars);		}		if ($vars['timer_start']/2 == 5 || $vars['timer_start']/2 == 10)		{			$data = new Net_SmartIRC_data;			$data->channel = $GLOBALS['channel'];						$time = $vars['timer_start']/2;			$message = "$time seconds left!";			$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);		}	}}?>