<?php
//사용자 컨트롤러
class rockgameController extends rockgame {
//초기화
function init() {
}
//게임결과연산
function procRockgameUserView() {
//로그인 하지 않을경우 리턴
$logged_info = Context::get('logged_info');
if(!$logged_info) return new Object(-1,'로그인해주세요');
//입력값받음
$args = Context::getRequestVars();
//참여포인트 입력값
$setpoint = $args->game_point;
//포인트제한 설정값
$maxpoint = $this->module_info->maxpoint;
//참여포인트가 0보다 작거나 제한값보다 높으면 리턴
$over_point_msg = sprintf("참가포인트를 1 ~ %s 사이로 입력해주세요",$maxpoint);
if($setpoint > $maxpoint || $setpoint <= 0) $this->setMessage($over_point_msg);
if($setpoint > $maxpoint || $setpoint <= 0) return $this->setRedirectUrl(getNotEncodedUrl('act','dispRockgameUserView')); //초기화면
//포인트 부족할 경우 리턴
$args->member_srl = $logged_info->member_srl;
$oPointModel = getModel('point');
$point = $oPointModel->getPoint($logged_info->member_srl,true);
if($point < $setpoint) $this->setMessage('포인트가 부족합니다');
if($point < $setpoint) return $this->setRedirectUrl(getNotEncodedUrl('act','dispRockgameUserView')); //초기화면
//하루 게임횟수제한 설정값
$maxgame = $this->module_info->maxgame;
//오늘 게임횟수 불러옴
$oRockgameModel = &getModel('rockgame');
$game_count = $oRockgameModel->getRockgameCount(); //오늘 게임횟수 불러옴
//게임횟수가 제한값을 넘으면 리턴
if($game_count >= $maxgame) $this->setMessage('오늘은 더이상 게임에 참여하실수 없습니다');
if($game_count >= $maxgame) return $this->setRedirectUrl(getNotEncodedUrl('act','dispRockgameUserView')); //초기화면
//유저선택
$user_select = $args->rsp_slect;
//컴터선택
$rps = rand(1,3);
if($rps == 1){$com_select = 'rock';}
if($rps == 2){$com_select = 'scissors';}
if($rps == 3){$com_select = 'paper';}
//게임결과
if($user_select == 'rock' && $com_select == 'rock') {$result = 'draw';}
if($user_select == 'rock' && $com_select == 'paper') {$result = 'lose';}
if($user_select == 'rock' && $com_select == 'scissors') {$result = 'win';}
if($user_select == 'paper' && $com_select == 'paper') {$result = 'draw';}
if($user_select == 'paper' && $com_select == 'scissors'){$result = 'lose';}
if($user_select == 'paper' && $com_select == 'rock') {$result = 'win';}
if($user_select == 'scissors' && $com_select == 'scissors') {$result = 'draw';}
if($user_select == 'scissors' && $com_select == 'rock') {$result = 'lose';}
if($user_select == 'scissors' && $com_select == 'paper') {$result = 'win';}
//입력값설정 (db입력용)
$logged_info = Context::get('logged_info');
$args->member_srl = $logged_info->member_srl;
$args->nick_name = $logged_info->nick_name;
$args->regdate = date('Y-m-d H:i:s');
$args->com_select = $com_select;
$args->user_select = $user_select;
$args->result = $result;
$args->set_point = $args->game_point;
if($result == 'win') $args->game_point = +$args->game_point;
if($result == 'lose')$args->game_point = -$args->game_point;
if($result == 'draw')$args->game_point = 0;
//이상없으면 게임내용 db입력
$output = executeQuery("rockgame.insert_game",$args);
//db입력후 게임결과에 따라 포인트처리
$oPointController = &getController('point');
if($result == 'lose'){$oPointController->setPoint($logged_info->member_srl, $setpoint, 'minus');}
if($result == 'win'){$oPointController->setPoint($logged_info->member_srl, $setpoint, 'add');}
//게임결과로 돌아감
$this->setRedirectUrl(getNotEncodedUrl('act','dispRockgameUserResult')); //결과화면
}
}
?>
인것
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
공지 | 운영규칙 외 제제 사항 안내 [1] | sachiharu | 2015.08.02 | 1096 |
공지 | 자유게시판 이용 안내 [1] | sachiharu | 2015.03.16 | 899 |
187 | 국민연금 환멸했습니다 | 슬비 | 2016.03.27 | 195 |
186 | 그리다 찍쌈 [3] | 슬비 | 2016.03.27 | 138 |
185 | 월남쌈 먹었다 [2] | U.M.R | 2016.03.27 | 139 |
184 | 폰 배경화면 바꿈 [2] | 룰루이뻐 | 2016.03.27 | 174 |
183 | 드라이버 다 깔았다~ [3] | U.M.R | 2016.03.27 | 224 |
182 | 후식먹는다 [1] | U.M.R | 2016.03.26 | 166 |
181 | 고기먹었다 [4] | U.M.R | 2016.03.26 | 149 |
» | 가이바이보 | 슬비 | 2016.03.26 | 1051 |
179 | 사이타마 그려봤다 [2] | U.M.R | 2016.03.26 | 126 |
178 | 슬비 | U.M.R | 2016.03.26 | 244 |
177 | 오늘의 미식 [1] | 슬비 | 2016.03.25 | 154 |
176 | 슬비라디오 | U.M.R | 2016.03.20 | 237 |
175 | [망가저장]어른들보다 잘하는 슬비 | U.M.R | 2016.03.19 | 1218 |
174 | [망가저장] [ryoma]?愛せれぶれ?しょん(Love Celebreation) | U.M.R | 2016.03.19 | 212 |
173 | [망가저장] (Shinooka Homare) Rental Otouto [2] | U.M.R | 2016.03.18 | 4433 |
172 | 니코그려봤따 [3] | U.M.R | 2016.03.18 | 475 |
171 | ㅁ | U.M.R | 2016.03.17 | 173 |
170 | 러브라이브 사랑해요 | U.M.R | 2016.03.17 | 430 |
169 | 레미 색칠 [1] | U.M.R | 2016.03.16 | 290 |
168 | 레미 [1] | U.M.R | 2016.03.16 | 140 |