コード例 #1
0
	function RankBattle($ChallengerID,$DefendID) {
		$challenger	= new user($ChallengerID);
		$challenger->CharDataLoadAll();
		$defender	= new user($DefendID);
		$defender->CharDataLoadAll();
		//print($ChallengerID."<br>".$DefendID."<br>");

		$Party_Challenger	= $challenger->RankParty();
		$Party_Defender		= $defender->RankParty();
		if($Party_Defender == "NOID") {//ユーザ自体が既に存在しない場合
			$message	= "No USER...<br />(win a game by default)";
			$this->DeleteRank($DefendID);
			$this->SaveRanking();
			return array($message,true);
		}

		// 返値
		// array(メッセージ,戦闘があったか,勝敗)

		// ランク用パーティーがありません!!!
		if($Party_Challenger === false) {
			$message	= "Set Team for Battle!<br />(Your Rank will be removed if challenged by someone)";
			return array($message,true);
		}
		// ランク用パーティーがありません!!!
		if($Party_Defender === false) {
			$this->DeleteRank($DefendID);
			$this->SaveRanking();
			$message	= "{$defender->name} has no Teams for Rank<br />(win a game by default)";
			return array($message,true);
		}

		//dump($Party_Challenger);
		//dump($Party_Defender);
		include(CLASS_BATTLE);
		$battle	= new battle($Party_Challenger,$Party_Defender);
		$battle->SetBackGround("colosseum");
		$battle->SetTeamName($challenger->name,$defender->name);
		$battle->Process();//戦闘開始
		$battle->RecordLog("RANK");
		return array("Battle",$battle->isChallengerWin());
	}
コード例 #2
0
ファイル: class.main.php プロジェクト: skyser2003/hof
 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;
 }
コード例 #3
0
ファイル: class.rank.php プロジェクト: skyser2003/hof
 function RankBattle($ChallengerID, $DefendID)
 {
     $challenger = new user($ChallengerID);
     $challenger->CharDataLoadAll();
     $defender = new user($DefendID);
     $defender->CharDataLoadAll();
     //print($ChallengerID."<br>".$DefendID."<br>");
     $Party_Challenger = $challenger->RankParty();
     $Party_Defender = $defender->RankParty();
     if ($Party_Defender == "NOID") {
         //ユーザ自体が既に存在しない場合
         $message = "没有用户...<br />(自动胜利)";
         $this->DeleteRank($DefendID);
         $this->SaveRanking();
         return array($message, true);
     }
     // 返値
     // array(メッセージ,戦闘があったか,勝敗)
     // ランク用パーティーがありません!!!
     if ($Party_Challenger === false) {
         $message = "设置战斗队伍!<br />(如果被挑下马的话排名也就没了)";
         return array($message, true);
     }
     // ランク用パーティーがありません!!!
     if ($Party_Defender === false) {
         $this->DeleteRank($DefendID);
         $this->SaveRanking();
         $message = "{$defender->name} 没有排名战队伍<br />(自动胜利)";
         return array($message, true);
     }
     //dump($Party_Challenger);
     //dump($Party_Defender);
     include CLASS_BATTLE;
     $battle = new battle($Party_Challenger, $Party_Defender);
     $battle->SetBackGround("colosseum");
     $battle->SetTeamName($challenger->name, $defender->name);
     $battle->Process();
     //戦闘開始
     $battle->RecordLog("RANK");
     return array("Battle", $battle->isChallengerWin());
 }
コード例 #4
0
ファイル: class.rank2.php プロジェクト: skyser2003/hof
 function RankBattle(&$user, &$Rival, $UserPlace, $RivalPlace)
 {
     $UserPlace = "[" . ($UserPlace + 1) . "位]";
     $RivalPlace = "[" . ($RivalPlace + 1) . "位]";
     /*
     	■ 相手のユーザ自体が既に存在しない場合の処理
     	アカウントが削除処理された時にランキングからも消えるようにしたから
     	本来出ないエラーかもしれない。
     */
     if ($Rival->is_exist() == false) {
         ShowError("对手不存在(不战而胜)");
         $this->DeleteRank($DefendID);
         $this->SaveRanking();
         //return array(true);
         return "DEFENDER_NO_ID";
     }
     // お互いのランキンぐ用のパーティーを読み込む
     $Party_Challenger = $user->RankParty();
     $Party_Defender = $Rival->RankParty();
     // ランク用パーティーがありません!!!
     if ($Party_Challenger === false) {
         ShowError("戦うメンバーがいません(?)。");
         return "CHALLENGER_NO_PARTY";
     }
     // ランク用パーティーがありません!!!
     if ($Party_Defender === false) {
         //$defender->RankRecord(0,"DEFEND",$DefendMatch);
         //$defender->SaveData();
         ShowError($Rival->name . " 对战的人物还未决定<br />(不战而胜)");
         return "DEFENDER_NO_PARTY";
         //不战而胜とする
     }
     //dump($Party_Challenger);
     //dump($Party_Defender);
     include CLASS_BATTLE;
     $battle = new battle($Party_Challenger, $Party_Defender);
     $battle->SetBackGround("colosseum");
     $battle->SetResultType(1);
     // 決着つかない場合は生存者の数で決めるようにする
     $battle->SetTeamName($user->name . $UserPlace, $Rival->name . $RivalPlace);
     $battle->Process();
     //戦闘開始
     $battle->RecordLog("RANK");
     $Result = $battle->ReturnBattleResult();
     // 戦闘結果
     // 戦闘を受けて立った側の成績はここで変える。
     //$defender->RankRecord($Result,"DEFEND",$DefendMatch);
     //$defender->SaveData();
     //return array("Battle",$Result);
     if ($Result === TEAM_0) {
         return "CHALLENGER_WIN";
     } else {
         if ($Result === TEAM_1) {
             return "DEFENDER_WIN";
         } else {
             if ($Result === DRAW) {
                 return "DRAW_GAME";
             } else {
                 return "DRAW_GAME";
                 //(エラー)予定では出ないエラー(回避用)
             }
         }
     }
 }
コード例 #5
0
ファイル: 1072.php プロジェクト: rwruss/ib3
<?php

include './slotFunctions.php';
include './unitClass.php';
echo 'Join battle ' . $postVals[1] . ' on side ' . $postVals[2];
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
$slotFile = fopen($gamePath . '/gameSlots.slt', 'r+b');
$mapSlotFile = fopen($gamePath . '/mapSlotFile.slt', 'r+b');
$baseUnit = new warband($_SESSION['selectedUnit'], $unitFile, 400);
$thisBattle = new battle($postVals[1], $unitFile, 100);
// Verify that unit can join battle
// Update unit status and save the battle ID to the unit
$baseUnit->set('status', 2);
$baseUnit->set('battleID', $postVals[1]);
// Remove the unit from the map
$mapSlotNum = floor($baseUnit->get('yLoc') / 120) * 120 + floor($baseUnit->get('xLoc') / 120);
$mapSlotItem = new itemSlot($mapSlotNum, $mapSlotFile, 404);
$location = array_search($_SESSION['selectedUnit'], $mapSlotItem->slotData);
if ($location) {
    $mapSlotItem->deleteItem($location, $mapSlotFile);
}
// Add the unit to the battle list for the selected side
$battleList = new itemSlot($thisBattle->get('sideList_1'), $slotFile, 40);
$battleList->addItem($_SESSION['selectedUnit'], $slotFile);
fclose($unitFile);
fclose($slotFile);
fclose($mapSlotFile);
コード例 #6
0
ファイル: simple.php プロジェクト: bgrgicak/WarGame
<?php

require_once 'bin/battle.php';
if (isset($_GET['army1']) && isset($_GET['army2']) && is_numeric($_GET['army1']) && is_numeric($_GET['army2'])) {
    $battle = new battle(array($_GET['army1'], $_GET['army2']));
    //start battle
    echo 'Army' . $battle->winner() . ' won';
} else {
    echo "Set army1 and army2 query string (number)";
}
コード例 #7
0
ファイル: index.php プロジェクト: bgrgicak/WarGame
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script type="text/javascript"
          src="https://www.google.com/jsapi?autoload={
            'modules':[{
              'name':'visualization',
              'version':'1',
              'packages':['corechart']
            }]
          }">
	</script>
  </head>
  <body>
	<?php 
$time_start = microtime(true);
if (isset($_GET['army1']) && isset($_GET['army2']) && is_numeric($_GET['army1']) && is_numeric($_GET['army2'])) {
    $battle = new battle(array($_GET['army1'], $_GET['army2']));
    //start battle
    $time_end = microtime(true);
    $execution_time = (int) (($time_end - $time_start) * 1000);
    ?>
		<div id="score">
			<p class="title">
				Army<?php 
    echo $battle->winner();
    ?>
 won
			</p>
			<p class="text">
				<?php 
    echo $battle->winnerCount();
    ?>