コード例 #1
0
 public function handleEmbassy()
 {
     if (0 < intval($this->data['alliance_id'])) {
     } else {
         $this->embassyProperty = array("level" => $this->buildings[$this->buildingIndex]['level'], "invites" => NULL, "error" => 0, "ally1" => "", "ally2" => "");
         $maxPlayers = $this->gameMetadata['items'][18]['levels'][$this->embassyProperty['level'] - 1]['value'];
         $this->embassyProperty['ally1'] = $ally1 = trim($_POST['ally1']);
         $this->embassyProperty['ally2'] = $ally2 = trim($_POST['ally2']);
         if ($ally1 == "" || $ally2 == "") {
             $this->embassyProperty['error'] = $ally1 == "" && $ally2 == "" ? 3 : $ally1 == "" ? 1 : 2;
         } else {
             $m = new BuildModel();
             if (!$m->allianceExists($this->embassyProperty['ally1'])) {
                 $this->data['alliance_name'] = $this->embassyProperty['ally1'];
                 $this->data['alliance_id'] = $m->createAlliance($this->player->playerId, $this->embassyProperty['ally1'], $this->embassyProperty['ally2'], $maxPlayers);
                 $m->dispose();
             } else {
                 $this->embassyProperty['error'] = 4;
                 $m->dispose();
             }
         }
         $invites_alliance_ids = trim($this->data['invites_alliance_ids']);
         $this->embassyProperty['invites'] = array();
         if ($invites_alliance_ids != "") {
             $_arr = explode("\n", $invites_alliance_ids);
             foreach ($_arr as $_s) {
                 $allianceName = explode(" ", $_s, 2);
                 $allianceId = explode(" ", $_s, 2);
                 list($allianceId, $allianceName) = $allianceId;
                 $this->embassyProperty['invites'][$allianceId] = $allianceName;
             }
         }
         if (!$this->isPost()) {
             if (isset($_GET['a']) && 0 < intval($_GET['a'])) {
                 $allianceId = intval($_GET['a']);
                 if (isset($this->embassyProperty['invites'][$allianceId])) {
                     $m = new BuildModel();
                     $acceptResult = $m->acceptAllianceJoining($this->player->playerId, $allianceId);
                     if ($acceptResult == 2) {
                         $this->data['alliance_name'] = $this->embassyProperty['invites'][$allianceId];
                         $this->data['alliance_id'] = $allianceId;
                         unset($Var_4320['invites'][$allianceId]);
                         $m->removeAllianceInvites($this->player->playerId, $allianceId);
                     } else {
                         if ($acceptResult == 1) {
                             $this->embassyProperty['error'] = 15;
                         }
                     }
                     $m->dispose();
                 }
             } else {
                 if (isset($_GET['d']) && 0 < intval($_GET['d'])) {
                     $allianceId = intval($_GET['d']);
                     if (isset($this->embassyProperty['invites'][$allianceId])) {
                         unset($Var_5112['invites'][$allianceId]);
                         $m = new BuildModel();
                         $m->removeAllianceInvites($this->player->playerId, $allianceId);
                         $m->dispose();
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: build.php プロジェクト: halshaman/TravianDboor
    function handleEmbassy()
    {
        if (0 < intval($this->data['alliance_id'])) {
            return null;
        }
        $this->embassyProperty = array('level' => $this->buildings[$this->buildingIndex]['level'], 'invites' => NULL, 'error' => 0, 'ally1' => '', 'ally2' => '');
        $maxPlayers = $this->gameMetadata['items'][18]['levels'][$this->embassyProperty['level'] - 1]['value'];
        if ($this->isPost() && 3 <= $this->embassyProperty['level'] && isset($_POST['ally1']) && isset($_POST['ally2'])) {
            $this->embassyProperty['ally1'] = $ally1 = trim($_POST['ally1']);
            $this->embassyProperty['ally2'] = $ally2 = trim($_POST['ally2']);
            if ($ally1 == '' || $ally2 == '') {
                $this->embassyProperty['error'] = $ally1 == '' && $ally2 == '' ? 3 : ($ally1 == '' ? 1 : 2);
            } else {
                $m = new BuildModel();
                if (!$m->allianceExists($this->embassyProperty['ally1'])) {
                    $this->data['alliance_name'] = $this->embassyProperty['ally1'];
                    $this->data['alliance_id'] = $m->createAlliance($this->player->playerId, $this->embassyProperty['ally1'], $this->embassyProperty['ally2'], $maxPlayers);
                    $m->dispose();
                    return null;
                }
                $this->embassyProperty['error'] = 4;
                $m->dispose();
            }
        }
        $invites_alliance_ids = trim($this->data['invites_alliance_ids']);
        $this->embassyProperty['invites'] = array();
        if ($invites_alliance_ids != '') {
            $_arr = explode('
', $invites_alliance_ids);
            foreach ($_arr as $_s) {
                list($allianceId, $allianceName) = explode(' ', $_s, 2);
                $this->embassyProperty['invites'][$allianceId] = $allianceName;
            }
        }
        if (!$this->isPost()) {
            if (isset($_GET['a']) && 0 < intval($_GET['a'])) {
                $allianceId = intval($_GET['a']);
                if (isset($this->embassyProperty['invites'][$allianceId])) {
                    $m = new BuildModel();
                    $acceptResult = $m->acceptAllianceJoining($this->player->playerId, $allianceId);
                    if ($acceptResult == 2) {
                        $this->data['alliance_name'] = $this->embassyProperty['invites'][$allianceId];
                        $this->data['alliance_id'] = $allianceId;
                        unset($this->embassyProperty['invites'][$allianceId]);
                        $m->removeAllianceInvites($this->player->playerId, $allianceId);
                    } else {
                        if ($acceptResult == 1) {
                            $this->embassyProperty['error'] = 15;
                        }
                    }
                    $m->dispose();
                    return null;
                }
            } else {
                if (isset($_GET['d']) && 0 < intval($_GET['d'])) {
                    $allianceId = intval($_GET['d']);
                    if (isset($this->embassyProperty['invites'][$allianceId])) {
                        unset($this->embassyProperty['invites'][$allianceId]);
                        $m = new BuildModel();
                        $m->removeAllianceInvites($this->player->playerId, $allianceId);
                        $m->dispose();
                    }
                }
            }
        }
    }