当前位置: 首页>>代码示例>>PHP>>正文


PHP Team::getFromPin方法代码示例

本文整理汇总了PHP中Team::getFromPin方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::getFromPin方法的具体用法?PHP Team::getFromPin怎么用?PHP Team::getFromPin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Team的用法示例。


在下文中一共展示了Team::getFromPin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _start_challenge

function _start_challenge($stationTag = null)
{
    if ($stationTag === null) {
        rest_sendBadRequestResponse(400, "missing station Tag");
        // doesn't return
    }
    $station = Station::getFromTag($stationTag);
    if ($station === false) {
        rest_sendBadRequestResponse(404, "can find station stationTag=" . $stationTag);
        // doesn't return
    }
    $stationType = new StationType($station->get('typeId'), -1);
    if ($stationType === false) {
        trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
    }
    $json = json_getObjectFromRequest("POST");
    json_checkMembers("team_id,message", $json);
    $teamPIN = $json['team_id'];
    $team = Team::getFromPin($teamPIN);
    if ($team === false) {
        trace("_start_challenge can't find team teamPin=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "team not found PIN=" . $teamPIN);
        // doesn't return
    }
    try {
        $xxxData = XXXData::factory($stationType->get('typeCode'));
        $msg = $xxxData->startChallenge($team, $station, $stationType);
        json_sendObject(array('message' => $msg));
    } catch (InternalError $ie) {
        rest_sendBadRequestResponse($ie->getCode(), $ie->getMessage());
    }
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:33,代码来源:start_challenge.php

示例2: _submit

function _submit($stationTag = null)
{
    if ($stationTag === null) {
        trace("brata missing stationId", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(400, "missing stationId");
        // doesn't return
    }
    $station = Station::getFromTag($stationTag);
    if ($station === false) {
        trace("brata can't find station stationTag=" . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "can't find station stationTag=" . $stationTag);
        // doesn't return
    }
    $json = json_getObjectFromRequest("POST");
    // won't return if an error happens
    json_checkMembers("message,team_id", $json);
    $team = Team::getFromPin($json['team_id']);
    if ($team === false) {
        trace("can't find team from team " . $json['team_id']);
        rest_sendBadRequestResponse(404, "can't find team pin=" . $json['team_id']);
    }
    $stationType = new StationType($station->get('typeId'), -1);
    if ($stationType === false) {
        trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
    }
    try {
        $xxxData = XXXData::factory($stationType->get('typeCode'));
        $msg = $xxxData->brataSubmit($json['message'], $team, $station, $stationType);
        json_sendObject(array('message' => $msg));
    } catch (InternalError $ie) {
        rest_sendBadRequestResponse($ie->getCode(), $ie->getMessage());
    }
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:34,代码来源:submit.php

示例3: generatePin

function generatePin()
{
    for ($retry = 0; $retry < PIN_RETRY_MAX; $retry++) {
        $pin = Team::generatePIN();
        if (Team::getFromPin($pin) === false) {
            return $pin;
        }
        // not a duplicate
    }
    return false;
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:11,代码来源:ops_loaddb.php

示例4: _cpaMeasure

function _cpaMeasure($stationTag = null)
{
    if ($stationTag === null) {
        rest_sendBadRequestResponse(400, "missing station Tag");
        // doesn't return
    }
    $station = Station::getFromTag($stationTag);
    if ($station === false) {
        rest_sendBadRequestResponse(404, "can find station stationTag=" . $stationTag);
        // doesn't return
    }
    $stationType = new StationType($station->get('typeId'), -1);
    if ($stationType === false) {
        trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
    }
    $json = json_getObjectFromRequest("POST");
    json_checkMembers("team_id,message", $json);
    $teamPIN = $json['team_id'];
    $team = Team::getFromPin($teamPIN);
    if ($team === false) {
        trace("_cpaMeasure can't find team teamPin=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "team not found PIN=" . $teamPIN);
        // doesn't return
    }
    $stationId = $station->get('OID');
    $parms = null;
    // compute challenge parameters into a message
    switch ($stationType->get('typeCode')) {
        case StationType::STATION_TYPE_CPA:
            $random = new CPAData();
            $parms = $random->getItemsToMeasure();
            trace("CPA measure generated for team " . $teamPIN . " this data " . print_r($parms, true));
            // record the challenge data randomly generated
            $team->setChallengeData($parms);
            break;
        default:
            trace("_cpaMeasure can't find station tyecode=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
            rest_sendBadRequestResponse(404, "station tyecode not found =" . $stationType->get('typeCode'));
            // doesn't return
    }
    if (Event::createEvent(Event::TYPE_START, $team, $station, 0) === false) {
        trace("create event failed", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "database create failed");
    }
    $msg = $team->expandMessage("PA is trying to escape. Quickly measure [fence=[label]] [building=[label]] and scan Start QR Code.", $parms);
    trace("message before decode {$msg}", __FILE__, __LINE__, __METHOD__);
    $msg = $team->encodeText($msg);
    json_sendObject(array('message' => $msg));
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:50,代码来源:cpaMeasure.php

示例5: _ops_update

function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = "";
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_TEAM)) {
        redirect("errors/401");
    }
    $itemName = "Team";
    $urlPrefix = "mgmt_team";
    $object = new Team();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        for ($retry = 0; $retry < PIN_RETRY_MAX; $retry++) {
            $pin = Team::generatePIN();
            if (Team::getFromPin($pin) === false) {
                // not a duplicate
                $object->set('pin', $pin);
                transactionBegin();
                if ($object->create() !== false) {
                    transactionCommit();
                    $msg = "{$itemName} created!";
                    break;
                }
            }
        }
        if ($retry >= PIN_RETRY_MAX) {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:49,代码来源:ops_update.php

示例6: _register

function _register()
{
    $json = json_getObjectFromRequest("POST");
    json_checkMembers("team_id,message", $json);
    $teamPIN = $json['team_id'];
    if ($teamPIN === null) {
        trace("missing PIN", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(400, "missing team PIN");
        // doesn't return
    }
    $team = Team::getFromPin($teamPIN);
    if ($team === false) {
        trace("_can't find team PIN=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "missing can't find team PIN=" . $teamPIN);
        // doesn't return
    }
    // we are assuming that the QR code won't include the station tag.
    $station = Station::getRegistrationStation();
    if ($station === false) {
        trace("can't find registration station", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find registration station");
    }
    $points = 3;
    if (Event::createEvent(Event::TYPE_REGISTER, $team, $station, $points) === false) {
        trace("createEvent Fails", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "could not create event object");
    }
    $stationType = StationType::getFromTypeCode($station->get('tag'));
    trace("registration complete", __FILE__, __LINE__, __METHOD__);
    $team->endChallenge();
    // clear any stale challenge data
    $team->_updateScore($stationType, $points);
    $msg = $team->expandMessage($stationType->get('instructions'), null);
    $msg = $team->encodeText($msg);
    json_sendObject(array('message' => $msg));
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:36,代码来源:register.php

示例7: _at_waypoint

function _at_waypoint($waypointId = null)
{
    if ($waypointId === null) {
        rest_sendBadRequestResponse(400, "missing waypointId");
        // doesn't return
    }
    $json = json_getObjectFromRequest("POST");
    json_checkMembers("team_id,message", $json);
    $teamPIN = $json['team_id'];
    $team = Team::getFromPin($teamPIN);
    if ($team === false) {
        trace("can't find team PIN=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "missing can't find team PIN=" . $teamPIN);
        // doesn't return
    }
    $stationType = StationType::getFSLType();
    if ($stationType === false) {
        trace("can't find team PIN=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find the FSL StationType");
        // doesn't return
    }
    $fslState = $team->getChallengeData();
    switch ($fslState['index']) {
        case 0:
            // use "default" messages for waypoints 1 and 2
        // use "default" messages for waypoints 1 and 2
        case 1:
            break;
        case 2:
            // for waypoint 2 change success and failed messages, keep retry message the same
            $stationType->set('success_msg', 'Success! Use [radius1=[a_rad]], [radius2=[b_rad]], and [radius3=[c_rad]]. Find Secret Labatory marker.');
            $stationType->set('failed_msg', 'Too bad, you failed. Use [radius1=[a_rad]], [radius2=[b_rad]], and [radius3=[c_rad]]. Find Secret Labatory marker');
            break;
        case 3:
            // for the lab change
            $stationType->set('success_msg', 'Success! go quickly to the next queue');
            $stationType->set('retry_msg', 'Wrong secret Laboratory marker, try again!');
            $stationType->set('failed_msg', 'Too bad, you failed. Go quickly to the next queue.');
    }
    $count = $team->get('count');
    $isCorrect = FSLData::isMatch($fslState, $waypointId);
    $challengeComplete = false;
    $points = 1;
    // one for showing up
    if ($count >= 2) {
        $points = 2;
        // two for pushing all the way through
    }
    if ($isCorrect) {
        $points = 3;
        // full credit regardless of tries if get it right
    }
    if ($isCorrect || $count >= 2) {
        $team->updateFSLScore($points, $fslState['index']);
        $challengeComplete = !FSLData::nextSection($fslState);
        $team->set('count', 0);
    } else {
        $team->set('count', $count + 1);
    }
    $team->setChallengeData($fslState);
    // put the update state data back into the team object
    $team->update();
    if ($challengeComplete) {
        $team->endChallenge();
    }
    if ($isCorrect) {
        $msg = $stationType->get('success_msg');
    } else {
        if ($count >= 2) {
            $msg = $stationType->get('failed_msg');
        } else {
            $msg = $stationType->get('retry_msg');
        }
    }
    $msg = $team->expandMessage($msg, $fslState['msg_values']);
    $msg = $team->encodeText($msg);
    $json = array("message" => $msg);
    json_sendObject($json);
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:79,代码来源:at_waypoint.php

示例8: _start_challengeOLD

function _start_challengeOLD($stationTag = null)
{
    if ($stationTag === null) {
        rest_sendBadRequestResponse(400, "missing station Tag");
        // doesn't return
    }
    $station = Station::getFromTag($stationTag);
    if ($station === false) {
        rest_sendBadRequestResponse(404, "can find station stationTag=" . $stationTag);
        // doesn't return
    }
    $stationType = new StationType($station->get('typeId'), -1);
    if ($stationType === false) {
        trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
    }
    if ($stationType->get('hasrPI')) {
        $rpi = RPI::getFromStationId($station->get('OID'));
        if ($rpi === false) {
            trace("_start_challenge can't find RPI stationTag=" . $stationTag, __FILE__, __LINE__, __METHOD__);
            rest_sendBadRequestResponse(500, "can't find RPI stationTag=" . $stationTag);
        }
    } else {
        $rpi = null;
    }
    $json = json_getObjectFromRequest("POST");
    json_checkMembers("team_id,message", $json);
    $teamPIN = $json['team_id'];
    $team = Team::getFromPin($teamPIN);
    if ($team === false) {
        trace("_start_challenge can't find team teamPin=" . $teamPIN, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "team not found PIN=" . $teamPIN);
        // doesn't return
    }
    $stationId = $station->get('OID');
    $parms = null;
    // compute challenge parameters into a php hash which will be sent to rPI and used to populate message sent to team
    $state = null;
    switch ($stationType->get('typeCode')) {
        case StationType::STATION_TYPE_CTS:
            $parms = CTSData::_startChallenge($stationId);
            break;
        case StationType::STATION_TYPE_HMB:
            $parms = HMBData::_startChallenge($stationId);
            break;
        case StationType::STATION_TYPE_CPA:
            $parms = CPAData::_startChallenge($stationId);
            break;
        case StationType::STATION_TYPE_FSL:
            $state = FSLData::_startChallenge($stationId);
            $parms = $state['msg_values'];
            break;
        case StationType::STATION_TYPE_EXT:
            $state = EXTData::_startChallenge($stationId);
            $parms = $state;
            break;
    }
    if ($rpi != null) {
        trace("sending to rPI");
        $rpi->start_challenge($stationType->get('delay'), $parms);
    }
    trace("station and team start calls");
    //TODO transaction
    $station->startChallenge($team);
    $team->startChallenge($parms, $stationType->get('typeCode'), $state);
    // $state
    if (Event::createEvent(Event::TYPE_START, $team, $station, 0, $state) === false) {
        trace("create event failed", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "database create failed");
    }
    $msg = $team->expandMessage($stationType->get('instructions'), $parms);
    if ($GLOBALS['SYSCONFIG_ENCODE'] == 1) {
        // if not in student mode encode, if in student mode we only encrypt the even team numbers responses
        if ($GLOBALS['SYSCONFIG_STUDENT'] == 0 or $GLOBALS['SYSCONFIG_STUDENT'] == 1 and $teamPIN % 2 == 0) {
            $msg = $team->encodeText($msg);
        }
    }
    json_sendObject(array('message' => $msg));
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:79,代码来源:start_challengeOLD.php

示例9: _submit

function _submit($stationTag = null)
{
    if ($stationTag === null) {
        trace("brata missing stationId", __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(400, "missing stationId");
        // doesn't return
    }
    $station = Station::getFromTag($stationTag);
    if ($station === false) {
        trace("brata can't find station stationTag=" . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(404, "can't find station stationTag=" . $stationTag);
        // doesn't return
    }
    $stationType = new StationType($station->get('typeId'), -1);
    if ($stationType === false) {
        trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
        rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
    }
    if ($stationType->get('hasrPI')) {
        $rpi = RPI::getFromStationId($station->get('OID'));
        if ($rpi === false) {
            trace("_submit can't find RPI stationTag=" . $stationTag, __FILE__, __LINE__, __METHOD__);
            rest_sendBadRequestResponse(500, "can't find RPI stationTag=" . $stationTag);
        }
    } else {
        $rpi = null;
    }
    $json = json_getObjectFromRequest("POST");
    // won't return if an error happens
    json_checkMembers("message,team_id", $json);
    $team = Team::getFromPin($json['team_id']);
    if ($team === false) {
        trace("can't find team from team " . $json['team_id']);
        rest_sendBadRequestResponse(404, "can't find team pin=" . $json['team_id']);
    }
    $count = $team->get('count');
    $isCorrect = false;
    $challengeComplete = false;
    $matches = array();
    // for regex matches
    switch ($stationType->get('typeCode')) {
        case StationType::STATION_TYPE_FSL:
            break;
        case StationType::STATION_TYPE_HMB:
            preg_match("/.*answer.*=.*(\\d)/", $json['message'], $matches);
            trace('calling handle_challenge');
            $json = $rpi->handle_submission($stationType->get('delay'), $isCorrect, $challengeComplete);
            //TODO if ($json === false) ERROR???
            //TODO json_checkMembers("message,team_id", $json);
            //$isCorrect=$json['is_correct'];
            break;
        case StationType::STATION_TYPE_EXT:
            $ext = new ExtData(1, -1);
            //TODO get from team
            $ext->submit($json['message'], $team);
            goto hack;
    }
    $count = $team->get('count');
    $points = 3 - $count;
    $team->updateScore($stationType, $points);
    if (!$json['is_correct']) {
        $count++;
        $team->set('count', $count);
        $challenge_complete = $count < 3 ? false : true;
    } else {
        $challenge_complete = true;
    }
    if ($challenge_complete) {
        $station->endChallenge();
        $team->endChallenge();
    }
    if (Event::createEvent(Event::TYPE_SUBMIT, $team, $station, $points) === false) {
        trace("can't create event object", __FILE__, __LINE__, __METHOD__);
        json_sendBadRequestResponse(500, "Can't create event object");
    }
    if ($isCorrect) {
        $msg = $stationType->get('success_msg');
    } else {
        if ($count >= 3) {
            $msg = $stationType->get('failed_msg');
        } else {
            $msg = $stationType->get('retry_msg');
        }
    }
    $msg = $team->expandMessage($msg, $parms);
    if ($GLOBALS['SYSCONFIG_ENCODE'] == 1) {
        // if not in student mode encode, if in student mode we only encrypt the even team numbers responses
        if ($GLOBALS['SYSCONFIG_STUDENT'] == 0 or $GLOBALS['SYSCONFIG_STUDENT'] == 1 and $teamPIN % 2 == 0) {
            $msg = $team->encodeText($msg);
        }
    }
    hack:
    json_sendObject(array('message' => $msg));
}
开发者ID:brata-hsdc,项目名称:brata.masterserver,代码行数:94,代码来源:submitOLD.php


注:本文中的Team::getFromPin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。