1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/12/23
- * Time: 下午3:35
- */
- namespace room;
- use Log;
- class shake_room extends base_room
- {
- public function __construct($cinfos, array $participants = [])
- {
- $this->mRoomType = 'shake_bonus';
- parent::__construct($cinfos, $participants);
- }
- public function shakeOp($input)
- {
- $this->clear();
- $user = $input['user'];
- $userinfo = $this->find($user);
- if($userinfo == false) {
- return false;
- }
- if(!isset($input['amount'])) return false;
- if($input['amount'] > 0) {
- $amount = intval($input['amount'] * 100 + 0.5);
- } else {
- $amount = intval($input['amount'] * 100 - 0.5);
- }
- if($amount === 0) return false;
- Log::record("amount = {$amount}",Log::DEBUG);
- $type = proto_type::msg_type_shakebonus;
- $content = $amount / 100;
- $msgid = $this->record_message($userinfo['userid'],$type,$content);
- if($msgid > 0) {
- $this->relay_broadcast('shake',['msgid' => $msgid, 'from' => $userinfo,'content' => "{$content}",'send_time' => time(),'seq' => $input['seq']]);
- return ['act' => 'room','op' => 'shake','room' => $this->room_id()];
- }
- else {
- return false;
- }
- }
- }
|