View file pasika/igra/index.php

File size: 11.65Kb
<?
include_once 'inc/start.php';

// Игровая инфа
$_game = mysql_fetch_assoc(mysql_query("SELECT * FROM `slot_pasik_fc` WHERE `id_user` = $user[id] LIMIT 1"));
$_jeck = mysql_fetch_assoc(mysql_query("SELECT * FROM `slot_pasik_fc` WHERE `id_user` = '0' LIMIT 1"));
$_ss = array();


if (!isset($_SESSION['rate']))
$_SESSION['rate'] = 10;

if (!isset($_SESSION['line']))
$_SESSION['line'] = array(1);

$num_line = $_SESSION['line'];

if (isset($_POST['line']))
{
	for($i = 0; 8 >= $i; $i++)
	{
		if (isset($_POST[$i]))
		{
			$arr[] = $i;
		}
	}
	
	if (count($arr) > 0)
	{
		$_SESSION['line'] = $arr;
		header('Location: ?line_v=' . count($arr));
		exit;
	}
}

if (isset($_GET['line_v']))
{
	$_ss = $_SESSION['line'];
}

if (isset($_SESSION['massive']))
{
	$line = unserialize($_SESSION['massive']);
}
else
{
	$line = array(1 => 1, 2 => 1, 3 => 1, 4 => 5, 5 => 5, 6 => 5, 7 => 6, 8 => 6, 9 => 6);
}

if (isset($_SESSION['old_massive']))
{
	$old_line = unserialize($_SESSION['old_massive']);
}
else
{
	$old_line = array(1 => 1, 2 => 1, 3 => 1, 4 => 5, 5 => 5, 6 => 5, 7 => 6, 8 => 6, 9 => 6);
}

// Стоимость игры
$_rate = $_SESSION['rate'];


if (isset($_GET['rate']) && is_numeric($_GET['rate']))
{
	if ($_GET['rate'] > 0 && $_GET['rate'] <= 100)
	{
		$_SESSION['rate'] = (int) $_GET['rate'];
		header('Location: ?' . $_SESSION['rate']);
		exit;		
	}
}

$_win = 0;

if (isset($_GET['start']) && $user[$_table] >= ($_rate * count($_SESSION['line'])) && isset($_true))
{
	mysql_query("UPDATE `user` SET `$_table` =  `$_table` - '".($_rate * count($_SESSION['line']))."' WHERE `id` = '$user[id]' LIMIT 1");
	
	$user[$_table] = $user[$_table] - $_rate;
	
	$line = array(
		 1 => mt_rand(1, 6), 
		 2 => mt_rand(1, 6),
		 3 => mt_rand(1, 6),
		 4 => mt_rand(1, 6),
		 5 => mt_rand(1, 6),
		 6 => mt_rand(1, 6),
		 7 => mt_rand(1, 6),
		 8 => mt_rand(1, 6),
		 9 => mt_rand(1, 6)
	);
	
	function win_array($v = 1)
	{
		global $line;
		
		// Комбинации выигрышных линий
		if ($v == 1)
		{ $r = array('1' => '4', '2' => '5', '3' => '6'); $l = 1; }
		
		if ($v == 2)
		{ $r = array('1' => '1', '2' => '2', '3' => '3'); $l = 2; }
		
		if ($v == 3)
		{ $r = array('1' => '7', '2' => '8', '3' => '9'); $l = 3; }	
		
		if ($v == 4)
		{ $r = array('1' => '1', '2' => '4', '3' => '7'); $l = 4; }	
		
		if ($v == 5)
		{ $r = array('1' => '2', '2' => '5', '3' => '8'); $l = 5; }	
		
		if ($v == 6)
		{ $r = array('1' => '3', '2' => '6', '3' => '9'); $l = 6; }		
		
		if ($v == 7)
		{ $r = array('1' => '1', '2' => '5', '3' => '9'); $l = 7; }	
		
		if ($v == 8)
		{ $r = array('1' => '7', '2' => '5', '3' => '3'); $l = 8; }	
		
		$array = array(); 
		
		if ($line[$r[1]] == $line[$r[2]] && $line[$r[1]] == $line[$r[3]])	
		{
			return array('win' => '1', 'number' => $line[$r[1]], 'line' => $l);
		}
	}
	
	foreach($_SESSION['line'] AS $key)
	{
		$testing = win_array($key);
		
		if (isset($testing['win']))
		{
			$_win = $_win + ($_rate * $line_money[$testing['number']] * count($_SESSION['line']));
			$_ss[] = $testing['line'];		
			
			if ($testing['number'] == 6 && $_game['j_count'] >= 4)
			{
				// Джекпот
				$jeckpot = mysql_fetch_assoc(mysql_query("SELECT * FROM `slot_pasik_fc` WHERE `id_user` = '0' LIMIT 1"));

				mysql_query("UPDATE `user` SET `$_table` =  `$_table` + '$jeckpot[j_money]' WHERE `id` = '$user[id]' LIMIT 1");
				mysql_query("UPDATE `slot_pasik_fc` SET `j_count` = '0', `j_money` = '0', `win` =  `win` + '$jeckpot[j_money]' WHERE `id_user` = '$user[id]' OR `id_user` = '0' LIMIT 2");
				$_game['j_count']++;
			}
			elseif ($testing['number'] == 6)
			{
				mysql_query("UPDATE `slot_pasik_fc` SET `j_count` = `j_count` + '1' WHERE `id_user` = '$user[id]' LIMIT 1");
			}
		}

	}

	if ($_win > 0)
	{
		mysql_query("UPDATE `user` SET `$_table` = `$_table` + '$_win' WHERE `id` = '$user[id]' LIMIT 1");
		mysql_query("UPDATE `slot_pasik_fc` SET `win` =  `win` + '$_win' WHERE `id_user` = '$user[id]' LIMIT 1");
	}
	else
	{
		mysql_query("UPDATE `slot_pasik_fc` SET `loss` =  `loss` + '".($_rate * count($_SESSION['line']))."' WHERE `id_user` = '$user[id]' LIMIT 1");
	}
	
	mysql_query("UPDATE `slot_pasik_fc` SET `j_money` = `j_money` + '".($_rate * count($_SESSION['line']) / 10)."' WHERE `id_user` = '0' LIMIT 1");
	
	$_SESSION['old_massive'] = serialize($line);
	$_SESSION['massive'] = serialize($line);
	
	$_script = true;
}

include_once 'inc/head.php';
?>
<div class="navig">
<?= $_menu?>
</div>
<?
if (isset($_GET['top']))
{
	if ($_GET['top'] == 'win')
	{
		$order = 'win';
	}
	else $order = 'loss';
	
	$my = mysql_result(mysql_query("SELECT COUNT(*) FROM `slot_pasik_fc` WHERE `$order` >= '$_game[$order]'"), 0);
	
	?>
	<div class="fruit_foot">
	<table class="fruit_foot">
	<tr>
	<td style="width: 40%"><a class="start"  href="?top=win">Лучшие</a></td>
	<td style="width: 10%"><a class="blue"><?= $my?> место</a></td>
	<td style="width: 40%"><a class="red"  href="?top=loss">Лузеры</a></td>
	</tr>
	</table>
	</div>
	<?
	$q = mysql_query("SELECT * FROM `slot_pasik_fc` WHERE `id_user` != '0' ORDER BY `$order` DESC LIMIT 10");

	if (mysql_num_rows($q) == 0)
	{
		?>
		<div style="background: #f1f1f1; padding: 3px; border: 0; color: #000; font-weight: normal; width: 98%; text-align: left; height: 20px;">
		В игре еще нет участников
		</div>
		<?
	}
	
	$i = 0;

	while ($post = mysql_fetch_assoc($q))
	{
		$i++;
		$ank = mysql_fetch_assoc(mysql_query("SELECT `nick`, `pol` FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
		
		?>
		<div style="background: #f1f1f1; padding: 3px; border: 0; color: #000; font-weight: normal; max-width:240px; text-align: left; height: auto; border-bottom: 1px solid gray;">
		<?= $i?>) <a href="/info.php?id=<?= $post['id_user']?>"><?= $ank['nick']?></a><br />
		<?= ($order == 'win' ? 'Выиграно' : 'Проиграно')?> <?= $post[$order]?>
		</div>
		<?
	}
	
	?>
	<div class="fruit_foot">
	<table class="fruit_foot">
	<tr>
	<td style="width: 50%"><a class="start"  href="?">В игру</a></td>
	<td style="width: 50%"><a class="red"  href="/pasika/">На пасику</a></td>
	</tr>
	</table>
	</div>
	<?
}
elseif (isset($_GET['line']))
{
	?><form class="navig_help" method='post' action='?line'><?
	
	for($i = 1; 8 >= $i; $i++){
		?>
		<div style="background: #f1f1f1; padding: 3px; border: 0; color: #000; font-weight: normal; width: 98%; text-align: left; height: 20px;">
		<label><input type='checkbox' name='<?= $i?>' value='1' <?= (in_array($i, $num_line) ? 'checked="checked"' : '')?> /> <?= $i?> Линия</label>
		</div>
		<?
	}
	?>
	<input class="start" type='submit' name='line' value='Сохранить' />
	</form>	
	<?
}
elseif (isset($_GET['rate']))
{
	for($i = 1; 10 >= $i; $i++){
		?>
		<div class="navig_rate">
		<a href="?rate=<?= $i * 10?>">Ставка <?= $i * 10?></a>
		</div>
		<?
	}
}
elseif (isset($_GET['help']))
{
	?>
	<div class="navig_help">
	При выпадении этих комбинаций, ваш выигрыш умножается на указанное колличество ниже, раз.
	</div>
	<?
	
	for($i = 1; 6 >= $i; $i++)
	{
		?>
		<div class="navig_help">
		<img src="style/img/<?= $i?>.PNG">
		<img src="style/img/<?= $i?>.PNG">
		<img src="style/img/<?= $i?>.PNG">
		<div><?= ($i != 6 ? 'x' . $line_money[$i] : 'WILD')?></div>
		</div>
		<?
	}
	?>
	<div class="navig_help">
	<b>WILD</b> - Это система "Джек - Пот". 
	За каждый ход в игре, списывается 10% от общей ставки пользователя, в общий "Банк" игрового автомата.
	Тот кто первый набирает 5 WILD комбинаций, забирает весь "Джек - Пот".
	После этого система обнуляет банк Джек - Пот, и счетчик WILD комбинаций.
	<span style="color: red;">Внимание! Комбинация <b>WILD</b> разыгрывается только для главного приза Джек - Пот.</span>
	</div>

	<div class="fruit_foot">
	<table class="fruit_foot">
	<tr>
	<td><a class="start"  href="?">Назад</a></td>
	</tr>
	</table>
	</div>
	<?
}
else
{
	$chars = preg_split('//', $_jeck['j_money'], -1, PREG_SPLIT_NO_EMPTY);
	?><div class="fruit_foot"><b>Джек-пот</b></div>
	<div class="fruit_head">
	<table class="fruit_head">
	<tr>
	<td>
	<?	
	foreach($chars AS $el => $str){
		?><img src="style/number/<?= $str?>.png"><?
	}
	?>
	</td>
	</tr>
	</table>
	</div>
	
	
	<div class="fruit_back">
	
	<? foreach($_ss AS $ss => $s) { ?>
	<img src="style/line/<?= $s?>.png" style="position: absolute; z-index: 3; left: 0px;">
	<? } ?>
	
	<div class="fruit"></div>
	<div class="fruit_img">
	<div id="matrix">

	<div class="column column1"><img class="regular" src="style/img/<?= $line[1]?>.PNG" alt="."/></div>
	<div class="column column2"><img class="regular" src="style/img/<?= $line[2]?>.PNG" alt="."/></div>
	<div class="column column3"><img class="regular" src="style/img/<?= $line[3]?>.PNG" alt="."/></div>

	<div class="column column1"><img class="regular" src="style/img/<?= $line[4]?>.PNG" alt="."/></div>
	<div class="column column2"><img class="regular" src="style/img/<?= $line[5]?>.PNG" alt="."/></div>
	<div class="column column3"><img class="regular" src="style/img/<?= $line[6]?>.PNG" alt="."/></div>

	<div class="column column1"><img class="regular" src="style/img/<?= $line[7]?>.PNG" alt="."/></div>
	<div class="column column2"><img class="regular" src="style/img/<?= $line[8]?>.PNG" alt="."/></div>
	<div class="column column3"><img class="regular" src="style/img/<?= $line[9]?>.PNG" alt="."/></div>
	
	</div>
	</div>
	</div>
	
	<?if (isset($_GET['start']) && isset($_script)) { ?>
	<script type="text/javascript">
	checkAnimation(document.body);
	prepareAnimation('fc_modern', '240', 3, 1);

	window.onload = function(){
		startAnimation(0, 3)
	};
	</script> 
	<? } ?> 
	
	
	<div class="fruit_head">
	<table class="fruit_head">
	<tr>
	<td><font color=blue><b>Ставка</b><br /><span style="color: #ff0000"><b><?= $_rate?>/<?= $_rate * count($_SESSION['line'])?></b></span></td>
	<?if (isset($jeckpot)) { ?>
	<td><font color=blue><b>Джек-Пот</b><br /><span style="color: #ff0000"><b><?= $_win + $_jeck['j_money']?></b></span></td>
	<? } else { ?>
	
		<?if ($_win > 0) { ?>
		<td><font color=blue><b>Выигрыш</b><br /><span style="color: #ff0000"><b><?= $_win?></b></span></td>
		<? } else { ?>
		<td><font color=blue><b>Линий</b><br /><span style="color: #ff0000"><b><?= count($_SESSION['line'])?></b></span></td>
		<? } ?>
		
	<? } ?>
	<td><font color=blue><b><?= $_name?></b><br /><span style="color: #ff0000"><b><?= ($user[$_table] + $_win)?></b></span></td>
	</tr>
	</table>
	</font></div>

	<div class="fruit_foot">
	<div class="fruit_bottom"><span style="color: #7f7f7f; font-size: small;"><font color=blue><b>Линий:</font></span> <?= count($_SESSION['line'])?></b></div>
	<div class="fruit_bottom"><span style="color: #7f7f7f; font-size: small;"><font color=blue><b>WILD:</font></span> <?= $_game['j_count']?></b></div>
	
	<table class="fruit_foot" cellspacing="0" cellpadding="0">
	<tr>
	<?if ($user[$_table] + $_win < $_rate) {?>
	<td><a class="start"  href="<?= $no_money?>">Улик</a></td>
	<? } else { ?>
	<td><?= ($_win == 0 ? '<a class="start"  href="?start&amp;nc=' . _NC . '">Крутить</a>' : '<a class="start"  href="?take">Забрать</a>')?></td>
	<? } ?>
	<td><a class="red" href="?line">Линии</a></td>
	<td><a class="blue" href="?rate">Ставка</a></td>
	</tr>
	<tr>
	<td><a class="gray" href="?help">Справка</a></td>
	<td><a class="blue" href="?top=win">Топ 10</a></td>
	<td><a class="red" href="/pasika/">На пасику</a></td>
	</tr>
	</table>
	</div>
	<?	
}

?>
<div class="navig">
<?= $_menu?>
</div>
<?

include_once H.'sys/inc/tfoot.php';
?>