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


PHP Messages::sendSystemMessage方法代码示例

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


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

示例1: wonder_processTribeWonder

function wonder_processTribeWonder($caveID, $wonderID, $casterTribe, $targetTribe)
{
    global $db;
    // check if wonder exists and is TribeWonder
    if (isset($GLOBALS['wonderTypeList'][$wonderID]) || !$wonder->isTribeWonder) {
        $wonder = $GLOBALS['wonderTypeList'][$wonderID];
    } else {
        return -33;
    }
    // check if tribes exist
    $targetTribeData = tribe_getTribeByTag($targetTribe);
    $casterTribeData = tribe_getTribeByTag($casterTribe);
    if (!$targetTribeData || !$casterTribeData) {
        return -15;
    }
    // check if tribe is valid
    if (!$targetTribeData['valid']) {
        return -34;
    }
    // check if caster tribe ist valid
    if (!$casterTribeData['valid']) {
        return -35;
    }
    $targetTribeRelations = relation_getRelationsForTribe($targetTribe);
    $casterTribeRelations = relation_getRelationsForTribe($casterTribe);
    $wonderPossible = false;
    foreach ($wonder->targetsPossible as $targetsPossible) {
        // check target
        if ($targetsPossible['target'] == 'own' && strtoupper($casterTribe) != strtoupper($targetTribe)) {
            continue;
        }
        if ($targetsPossible['target'] == 'other' && strtoupper($casterTribe) == strtoupper($targetTribe)) {
            continue;
        }
        // check relation
        $check = wonder_checkRelations($targetsPossible['relation'], $targetTribe, $casterTribe, $casterTribeRelations, $targetTribeRelations);
        if ($check == true) {
            $wonderPossible = true;
            break;
        }
    }
    if ($wonderPossible == false) {
        return -37;
    }
    // take wonder Costs from TribeStorage
    $memberNumber = tribe_getNumberOfMembers($casterTribe);
    if (!processProductionCost($wonder, 0, NULL, $memberNumber, true)) {
        return -33;
    }
    // does the wonder fail?
    if ((double) rand() / (double) getRandMax() > $wonder->chance) {
        return 11;
        // wonder did fail
    }
    // schedule the wonder's impacts
    // create a random factor between -0.3 and +0.3
    $delayRandFactor = rand(0, getrandmax()) / getrandmax() * 0.6 - 0.3;
    // now calculate the delayDelta depending on the first impact's delay
    $delayDelta = $wonder->impactList[0]['delay'] * $delayRandFactor;
    // get targets
    $targets = tribe_getTribeWonderTargets($targetTribe);
    if (!$targets || sizeof($targets) == 0) {
        return -33;
    }
    $now = time();
    // loop over targets
    foreach ($targets as $target) {
        // loop over impacts
        foreach ($wonder->impactList as $impactID => $impact) {
            $delay = (int) (($delayDelta + $impact['delay']) * WONDER_TIME_BASE_FACTOR);
            $sql = $db->prepare("INSERT INTO " . EVENT_WONDER_TABLE . " (casterID, sourceID, targetID, \n                       wonderID, impactID, start, end) \n                       VALUES (:playerID, :caveID, :targetID, :wonderID, :impactID, :start, :end)");
            $sql->bindValue('playerID', 0, PDO::PARAM_INT);
            // playerID 0, for not receiving lots of wonder-end-messages
            $sql->bindValue('caveID', $caveID, PDO::PARAM_INT);
            $sql->bindValue('targetID', $target['caveID'], PDO::PARAM_INT);
            $sql->bindValue('wonderID', $wonderID, PDO::PARAM_INT);
            $sql->bindValue('impactID', $impactID, PDO::PARAM_INT);
            $sql->bindValue('start', time_toDatetime($now), PDO::PARAM_STR);
            $sql->bindValue('end', time_toDatetime($now + $delay), PDO::PARAM_STR);
            $sql->execute();
        }
        // end foreach impactList
    }
    // end foreach target
    // send caster messages
    $messageClass = new Messages();
    $sourceMessage = 'Sie haben auf den Stamm "' . $targetTribe . '" ein Stammeswunder ' . $wonder->name . ' erwirkt.';
    $messageClass->sendSystemMessage($_SESSION['player']->playerID, 9, 'Stammeswunder erwirkt auf "' . $targetTribe . '"', $sourceMessage);
    // send target messages
    $targetPlayersArray = array();
    foreach ($targets as $target) {
        if (!isset($targetPlayersArray[$target['playerID']])) {
            $targetPlayersArray[$target['playerID']] = $target;
        }
    }
    foreach ($targetPlayersArray as $target) {
        $targetMessage = 'Der Stamm "' . $casterTribe . '" hat ein Stammeswunder auf deine Höhlen gewirkt';
        $messageClass->sendSystemMessage($target['playerID'], 9, 'Stammeswunder!', $targetMessage);
    }
    return 12;
//.........这里部分代码省略.........
开发者ID:norter,项目名称:Game,代码行数:101,代码来源:wonder.inc.php

示例2: wonder_processOrder


//.........这里部分代码省略.........
        $sql->bindValue('coordY', $coordY, PDO::PARAM_INT);
        if (!$sql->execute() || !($targetData = $sql->fetch(PDO::FETCH_ASSOC))) {
            return -3;
        }
        $sql->closeCursor();
        $targetID = $targetData['caveID'];
    }
    // check, if cave allowed
    if ($GLOBALS['wonderTypeList'][$wonderID]->target == "own") {
        $allowed = $playerID == $targetData['playerID'];
    } else {
        if ($GLOBALS['wonderTypeList'][$wonderID]->target == "other") {
            $allowed = $playerID != $targetData['playerID'];
        } else {
            // $wonderTypeList[$wonderID]->target == "all"  or == "same"
            $allowed = 1;
        }
    }
    if (!$allowed) {
        return -2;
    }
    // take production costs from cave
    if (!processProductionCost($GLOBALS['wonderTypeList'][$wonderID], $caveID, $caveData)) {
        return 0;
    }
    // calculate the chance and evaluate into $chance
    if ($chance_formula = $GLOBALS['wonderTypeList'][$wonderID]->chance) {
        $chance_eval_formula = formula_parseToPHP($chance_formula, '$caveData');
        $chance_eval_formula = "\$chance={$chance_eval_formula};";
        eval($chance_eval_formula);
    }
    // if this wonder is offensive
    // calculate the wonder resistance and evaluate into $resistance
    // TODO: Wertebereich der Resistenz ist derzeit 0 - 1, also je höher desto resistenter
    if ($GLOBALS['wonderTypeList'][$wonderID]->offensiveness == "offensive") {
        $resistance_eval_formula = formula_parseToPHP(GameConstants::WONDER_RESISTANCE, '$targetData');
        $resistance_eval_formula = "\$resistance={$resistance_eval_formula};";
        eval($resistance_eval_formula);
    } else {
        $resistance = 0.0;
    }
    // does the wonder fail?
    if ((double) rand() / (double) getRandMax() > $chance - $resistance) {
        return 2;
        // wonder did fail
    }
    // schedule the wonder's impacts
    // create a random factor between -0.3 and +0.3
    $delayRandFactor = rand(0, getrandmax()) / getrandmax() * 0.6 - 0.3;
    // now calculate the delayDelta depending on the first impact's delay
    $delayDelta = $GLOBALS['wonderTypeList'][$wonderID]->impactList[0]['delay'] * $delayRandFactor;
    foreach ($GLOBALS['wonderTypeList'][$wonderID]->impactList as $impactID => $impact) {
        $delay = (int) (($delayDelta + $impact['delay']) * WONDER_TIME_BASE_FACTOR);
        $now = time();
        $sql = $db->prepare("INSERT INTO " . EVENT_WONDER_TABLE . " (casterID, sourceID, targetID, \n                     wonderID, impactID, start, end) \n                     VALUES (:playerID, :caveID, :targetID, :wonderID, :impactID, :start, :end)");
        $sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
        $sql->bindValue('caveID', $caveID, PDO::PARAM_INT);
        $sql->bindValue('targetID', $targetID, PDO::PARAM_INT);
        $sql->bindValue('wonderID', $wonderID, PDO::PARAM_INT);
        $sql->bindValue('impactID', $impactID, PDO::PARAM_INT);
        $sql->bindValue('start', time_toDatetime($now), PDO::PARAM_STR);
        $sql->bindValue('end', time_toDatetime($now + $delay), PDO::PARAM_STR);
        if (!$sql->execute()) {
            //give production costs back
            processProductionCostSetBack($GLOBALS['wonderTypeList'][$wonderID], $caveID, $caveData);
            return -1;
        }
    }
    // create messages
    $messageClass = new Messages();
    $sourceMessage = 'Sie haben auf die Höhle in ' . $coordX . '/' . $coordY . ' ein Wunder ' . $GLOBALS['wonderTypeList'][$wonderID]->name . ' erwirkt.';
    $targetMessage = 'Der Besitzer der Höhle in ' . $caveData['xCoord'] . '/' . $caveData['yCoord'] . ' hat auf Ihre Höhle in ' . $coordX . '/' . $coordY . ' ein Wunder gewirkt.';
    // create xml message
    $casterxml = new SimpleXMLElement('<?xml version=\'1.0\' encoding=\'utf-8\'?><wonderMessageCaster></wonderMessageCaster>');
    $casterxml->addChild('timestamp', time());
    $casterxml->addChild('wonderType', 'caster');
    $casterxml->addChild('source');
    $casterxml->source->addChild('xCoord', $caveData['xCoord']);
    $casterxml->source->addChild('yCoord', $caveData['yCoord']);
    $casterxml->source->addChild('caveName', $caveData['name']);
    $casterxml->addChild('target');
    $casterxml->target->addChild('xCoord', $targetData['xCoord']);
    $casterxml->target->addChild('yCoord', $targetData['yCoord']);
    $casterxml->target->addChild('caveName', $targetData['name']);
    $casterxml->addChild('wonderName', $GLOBALS['wonderTypeList'][$wonderID]->name);
    $targetxml = new SimpleXMLElement('<?xml version=\'1.0\' encoding=\'utf-8\'?><wonderMessageTarget></wonderMessageTarget>');
    $targetxml->addChild('timestamp', time());
    $targetxml->addChild('wonderType', 'target');
    $targetxml->addChild('source');
    $targetxml->source->addChild('xCoord', $caveData['xCoord']);
    $targetxml->source->addChild('yCoord', $caveData['yCoord']);
    $targetxml->source->addChild('caveName', $caveData['name']);
    $targetxml->addChild('target');
    $targetxml->target->addChild('xCoord', $targetData['xCoord']);
    $targetxml->target->addChild('yCoord', $targetData['yCoord']);
    $targetxml->target->addChild('caveName', $targetData['name']);
    $messageClass->sendSystemMessage($playerID, 9, 'Wunder erwirkt auf ' . $coordX . '/' . $coordY, $sourceMessage, $casterxml->asXML());
    $messageClass->sendSystemMessage($targetData['playerID'], 9, 'Wunder!', $targetMessage, $targetxml->asXML());
    return 1;
}
开发者ID:microlefes,项目名称:Game,代码行数:101,代码来源:wonder.inc.php

示例3: processWonder

 public static function processWonder($wonderID, $casterTribeData, $targetTribeName)
 {
     global $db;
     if ($wonderID < 0 || empty($casterTribeData) || empty($targetTribeName)) {
         return -30;
     }
     // check if wonder exists and is TribeWonder
     if (isset($GLOBALS['wonderTypeList'][$wonderID]) || !$wonder->isTribeWonder) {
         $wonder = $GLOBALS['wonderTypeList'][$wonderID];
     } else {
         return -33;
     }
     // check if tribes exist
     $targetTribeData = Tribe::getID($targetTribeName, true);
     if (empty($targetTribeData)) {
         return -15;
     }
     $casterTribeID = $casterTribeData['tribeID'];
     $targetTribeID = $targetTribeData['tribeID'];
     // check if tribe is valid
     if (!$targetTribeData['valid']) {
         return -34;
     }
     // check if caster tribe ist valid
     if (!$casterTribeData['valid']) {
         return -35;
     }
     $casterTribeRelations = TribeRelation::getRelations($casterTribeID);
     $targetTribeRelations = TribeRelation::getRelations($targetTribeID);
     $wonderPossible = false;
     foreach ($wonder->targetsPossible as $targetsPossible) {
         // check target
         if ($targetsPossible['target'] == 'own' && $casterTribeID !== $targetTribeID) {
             continue;
         }
         if ($targetsPossible['target'] == 'other' && $casterTribeID === $targetTribeID) {
             continue;
         }
         // check relation
         $check = self::checkRelations($targetsPossible['relation'], $targetTribeID, $casterTribeID, $casterTribeRelations, $targetTribeRelations);
         if ($check == true) {
             $wonderPossible = true;
             break;
         }
     }
     if ($wonderPossible == false) {
         return -37;
     }
     // take wonder Costs from TribeStorage
     $memberNumber = Tribe::getMemberCount($casterTribeID);
     if (!processProductionCost($wonder, 0, NULL, $memberNumber, true)) {
         return -33;
     }
     // does the wonder fail?
     if ((double) rand() / (double) getRandMax() > $wonder->chance) {
         return 11;
         // wonder did fail
     }
     // schedule the wonder's impacts
     // create a random factor between -0.3 and +0.3
     $delayRandFactor = rand(0, getrandmax()) / getrandmax() * 0.6 - 0.3;
     // now calculate the delayDelta depending on the first impact's delay
     $delayDelta = $wonder->impactList[0]['delay'] * $delayRandFactor;
     // get targets
     $targets = Tribe::getPlayerList($targetTribeID, false, true);
     if (sizeof($targets) == 0) {
         return -33;
     }
     $now = time();
     // loop over targets
     foreach ($targets as $playerID => $playerData) {
         foreach ($playerData['caves'] as $caveID => $caveData) {
             // loop over impacts
             foreach ($wonder->impactList as $impactID => $impact) {
                 $delay = (int) (($delayDelta + $impact['delay']) * WONDER_TIME_BASE_FACTOR);
                 $sql = $db->prepare("INSERT INTO " . EVENT_WONDER_TABLE . "\n                                (casterID, sourceID, targetID, wonderID, impactID, start, end)\n                               VALUES\n                                 (:playerID, :caveID, :targetID, :wonderID, :impactID, :start, :end)");
                 $sql->bindValue('playerID', 0, PDO::PARAM_INT);
                 // playerID 0, for not receiving lots of wonder-end-messages
                 $sql->bindValue('caveID', $casterTribeID, PDO::PARAM_INT);
                 $sql->bindValue('targetID', $caveID, PDO::PARAM_INT);
                 $sql->bindValue('wonderID', $wonderID, PDO::PARAM_INT);
                 $sql->bindValue('impactID', $impactID, PDO::PARAM_INT);
                 $sql->bindValue('start', time_toDatetime($now), PDO::PARAM_STR);
                 $sql->bindValue('end', time_toDatetime($now + $delay), PDO::PARAM_STR);
                 $sql->execute();
             }
             // end foreach impactList
         }
     }
     // end foreach target
     // send caster messages
     $messageClass = new Messages();
     $messageClass->sendSystemMessage($_SESSION['player']->playerID, 9, sprintf(_("Stammeswunder erwirkt auf %s"), $targetTribeData['tag']), sprintf(_("Sie haben auf den Stamm %s ein Stammeswunder %s erwirkt."), $targetTribeData['tag'], $wonder->name));
     // send target messages
     $targetPlayersArray = array();
     foreach ($targets as $target) {
         if (!isset($targetPlayersArray[$target['playerID']])) {
             $targetPlayersArray[$target['playerID']] = $target;
         }
     }
//.........这里部分代码省略.........
开发者ID:microlefes,项目名称:Game,代码行数:101,代码来源:tribes.inc.php

示例4: tribe_processKickMember

function tribe_processKickMember($playerID, $tag)
{
    if (empty($playerID)) {
        return -38;
    }
    if (tribe_isLeader($playerID, $tag)) {
        return -39;
    }
    // do not kick in wartime
    if (!relation_leaveTribeAllowed($tag)) {
        return -40;
    }
    // blocked
    if (!tribe_changeTribeAllowedForPlayerID($playerID)) {
        return -3;
    }
    // get player
    $player = getPlayerByID($playerID);
    // no such player
    if (!$player) {
        return -41;
    }
    // remove player
    if (!tribe_leaveTribe($playerID, $tag)) {
        return -41;
    }
    Player::addHistoryEntry($playerID, sprintf(_("wird aus dem Stamm '%s' geworfen"), $tag));
    // block player
    tribe_setBlockingPeriodPlayerID($playerID);
    tribe_sendTribeMessage($tag, TRIBE_MESSAGE_MEMBER, "Spieler rausgeschmissen", "Der Spieler {$player['name']} wurde soeben vom Anführer aus dem Stamm ausgeschlossen.");
    $messagesClass = new Messages();
    $messagesClass->sendSystemMessage($playerID, 8, "Stammausschluss.", "Sie wurden aus dem Stamm {$tag} ausgeschlossen. Bitte loggen Sie sich aus und melden Sie sich wieder an, damit das Stammesmenü bei Ihnen wieder richtig funktioniert.");
    return 13;
}
开发者ID:norter,项目名称:Game,代码行数:34,代码来源:tribes.inc.php


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