<?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 | 1097 |
공지 | 자유게시판 이용 안내 [1] | sachiharu | 2015.03.16 | 899 |
187 | 아니메 지갑을 허벌로 만든 레압 | anime | 2016.01.16 | 1251 |
186 | 시모츠키 커여엉 | 슬비 | 2016.01.18 | 430 |
185 | 하카타에서 꼬치구이 [1] | 슬비 | 2016.01.18 | 171 |
184 | 오빠 [2] | 슬비 | 2016.01.23 | 22942 |
183 | 카토 머리 맛있다 [2] | 냐아아악 | 2016.01.23 | 185 |
182 | 에바 신칸센~ | 今日子 | 2016.01.25 | 308 |
181 | "알아 들어셨죠 언니?" [1] | 슬비 | 2016.01.25 | 296 |
180 | 후쿠오카에서 건진 사진 | 슬비 | 2016.01.25 | 141 |
179 | 11인 스테이지 | sachiharu | 2016.01.25 | 238 |
178 | 뽑아버려 | 타카네씨 | 2016.01.26 | 193 |
177 | 포토샵 실력 ㅍㅌㅊ? [1] | 냐아아악 | 2016.01.26 | 302 |
176 | 카메라뽐뿌 [2] | 今日子 | 2016.01.26 | 325 |
175 | 타카네 | 타카네씨 | 2016.01.27 | 199 |
174 | 솔까 이건 나만있음 | 타카네씨 | 2016.01.27 | 143 |
173 | 슬비슬비 | 슬비 | 2016.01.28 | 362 |
172 | 책상 미친짓 [1] | 슬비 | 2016.01.28 | 160 |
171 | 그러하다 | 타카네씨 | 2016.01.30 | 317 |
170 | 클로저스 달력 일러스트 3508x2480 모음 [1] | 슬비 | 2016.02.01 | 405 |
169 | 오멜라스를 떠나는 사람들 / 어슐라 르 귄 | 슬비 | 2016.02.01 | 334 |
168 | Mad Max Wallpaper | 슬비 | 2016.02.02 | 242 |