<?php
if($_GET['prize']){
$prizes = json_decode($_GET['prize']);
}else{
$prizes = '';
}
$msg = array();
$huases = array('1'=>'diamond','2'=>'spade','3'=>'heart','4'=>'club');
$huase = $huases[rand(1,4)];
$num = rand(1,13);
if($huase=='diamond' || $huase=='heart'){
$color = 'red';
}else{
$color = 'black';
}
$msg['num'] = $num;
$msg['color'] = $color; // black red
$msg['zhi'] = $num;
$msg['huase'] = $huase; // diamond spade heart club
$winmobao = 0;
if($prizes){
foreach($prizes as $r){
if($num==7){
if($r->prize_name=='seven'){
$winmobao = $winmobao + $r->prize_num*10;
}else{
if($r->prize_name=='diamond' || $r->prize_name=='spade' || $r->prize_name=='heart' || $r->prize_name=='club'){
$winmobao = $winmobao - $r->prize_num*1;
}else{
$winmobao = $winmobao - $r->prize_num*1;
}
}
}else{
if($r->prize_name=='double'){
if($num%2==0){// 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='single'){
if($num%2==1){//单 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='small'){
if($num < 7){// 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='big'){
if($num > 7){// 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='black'){
if($color == 'black'){// 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='red'){
if($color == 'red'){// 赢了
$winmobao = $winmobao + 1*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='diamond'){
if($huase=='diamond'){
$winmobao = $winmobao + 3*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='spade'){
if($huase=='spade'){
$winmobao = $winmobao + 3*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='club'){
if($huase=='club'){
$winmobao = $winmobao + 3*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
if($r->prize_name=='heart'){
if($huase=='club'){
$winmobao = $winmobao + 3*$r->prize_num;
}else{
$winmobao = $winmobao - 1*$r->prize_num;
}
}
}
}
}
$msg['winmobao'] = $winmobao;
echo json_encode($msg);
die();
?>