예제 #1
0
 function UnionProcess()
 {
     if ($this->CanUnionBattle() !== true) {
         $host = $_SERVER['HTTP_HOST'];
         $uri = rtrim(dirname($_SERVER['PHP_SELF']));
         $extra = INDEX;
         header("Location: http://{$host}{$uri}/{$extra}?hunt");
         exit;
     }
     if (!$_POST["union_battle"]) {
         return false;
     }
     $Union = new union();
     // 倒されているか、存在しない場合。
     if (!$Union->UnionNumber($_GET["union"]) || !$Union->is_Alive()) {
         return false;
     }
     // ユニオンモンスターのデータ
     $UnionMob = CreateMonster($Union->MonsterNumber);
     $this->MemorizeParty();
     //パーティー記憶
     // 自分パーティー
     foreach ($this->char as $key => $val) {
         //チェックされたやつリスト
         if ($_POST["char_" . $key]) {
             $MyParty[] = $this->char[$key];
             $TotalLevel += $this->char[$key]->level;
             //自分PTの合計レベル
         }
     }
     // 合計レベル制限
     if ($UnionMob["LevelLimit"] < $TotalLevel) {
         ShowError('合计级别水平(' . $TotalLevel . '/' . $UnionMob["LevelLimit"] . ')', "margin15");
         return false;
     }
     if (count($MyParty) === 0) {
         ShowError('战斗至少要一个人参加', "margin15");
         return false;
     } else {
         if (5 < count($MyParty)) {
             ShowError('战斗最多只能上五个人', "margin15");
             return false;
         }
     }
     if (!$this->WasteTime(UNION_BATTLE_TIME)) {
         ShowError('Time Shortage.', "margin15");
         return false;
     }
     // 敵PT数
     // ランダム敵パーティー
     if ($UnionMob["SlaveAmount"]) {
         $EneNum = $UnionMob["SlaveAmount"] + 1;
     } else {
         $EneNum = 5;
     }
     // Union含めて5に固定する。
     if ($UnionMob["SlaveSpecify"]) {
         $EnemyParty = $this->EnemyParty($EneNum - 1, $Union->Slave, $UnionMob["SlaveSpecify"]);
     } else {
         $EnemyParty = $this->EnemyParty($EneNum - 1, $Union->Slave, $UnionMob["SlaveSpecify"]);
     }
     // unionMobを配列のおよそ中央に入れる
     array_splice($EnemyParty, floor(count($EnemyParty) / 2), 0, array($Union));
     $this->UnionSetTime();
     include CLASS_BATTLE;
     $battle = new battle($MyParty, $EnemyParty);
     $battle->SetUnionBattle();
     $battle->SetBackGround($Union->UnionLand);
     //背景
     //$battle->SetTeamName($this->name,"Union:".$Union->Name());
     $battle->SetTeamName($this->name, $UnionMob["UnionName"]);
     $battle->Process();
     //戦闘開始
     $battle->SaveCharacters();
     //キャラデータ保存
     list($UserMoney) = $battle->ReturnMoney();
     //戦闘で得た合計金額
     $this->GetMoney($UserMoney);
     //お金を増やす
     $battle->RecordLog("UNION");
     // 道具を受け取る
     if ($itemdrop = $battle->ReturnItemGet(0)) {
         $this->LoadUserItem();
         foreach ($itemdrop as $itemno => $amount) {
             $this->AddItem($itemno, $amount);
         }
         $this->SaveUserItem();
     }
     return true;
 }