admin
發表於 2016-2-26 21:16:08
探險代碼總共不到500行
貿易系統與財團系統
的總行數都比這些多很多
把這些解讀出來不是難事
class MissionCaseExpedition extends MissionFunctions implements Mission
{
function __construct($fleet)
{
$this->_fleet = $fleet;
}
function TargetEvent()
{
$this->setState(FLEET_HOLD);
$this->SaveFleet();
}
function EndStayEvent()
{
global $pricelist, $reslist, $resource;
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$config = Config::get($this->_fleet['fleet_universe']);
$expeditionPoints = array();
foreach($reslist['fleet'] as $shipId)
{
$expeditionPoints[$shipId] = ($pricelist[$shipId]['cost'] + $pricelist[$shipId]['cost']) * 5 / 1000;
}
$fleetArray = FleetFunctions::unserialize($this->_fleet['fleet_array']);
$fleetPoints = 0;
$fleetCapacity = 0;
foreach ($fleetArray as $shipId => $shipAmount)
{
$fleetCapacity += $shipAmount * $pricelist[$shipId]['capacity'];
$fleetPoints += $shipAmount * $expeditionPoints[$shipId];
}
$fleetCapacity-= $this->_fleet['fleet_resource_metal'] + $this->_fleet['fleet_resource_crystal']
+ $this->_fleet['fleet_resource_deuterium'] + $this->_fleet['fleet_resource_darkmatter'];
$GetEvent = mt_rand(1, 9);
$Message = $LNG['sys_expe_nothing_'.mt_rand(1,8)];
switch($GetEvent)
{
case 1:
$eventSize = mt_rand(0, 100);
$factor = 0;
if(10 < $eventSize)
{
$Message = $LNG['sys_expe_found_ress_1_'.mt_rand(1,4)];
$factor = mt_rand(10, 50);
}
elseif(0 < $eventSize && 10 >= $eventSize)
{
$Message = $LNG['sys_expe_found_ress_2_'.mt_rand(1,3)];
$factor = mt_rand(50, 100);
}
elseif(0 == $eventSize)
{
$Message = $LNG['sys_expe_found_ress_3_'.mt_rand(1,2)];
$factor = mt_rand(100, 200);
}
$chanceToFound = mt_rand(1, 6);
if($chanceToFound > 3)
{
$resourceId = 901;
}
elseif($chanceToFound > 1)
{
$resourceId = 902;
$factor = $factor / 2;
}
else
{
$resourceId = 903;
$factor = $factor / 3;
}
$sql = "SELECT MAX(total_points) as total FROM %%STATPOINTS%%
WHERE `stat_type` = :type AND `universe` = :universe;";
$topPoints = Database::get()->selectSingle($sql, array(
':type' => 1,
':universe' => $this->_fleet['fleet_universe']
), 'total');
if($topPoints > 5000000)
{
$maxFactor = 12000;
}
elseif($topPoints > 1000000)
{
$maxFactor = 9000;
}
elseif($topPoints > 100000)
{
$maxFactor = 6000;
}
else
{
$maxFactor = 2400;
}
$founded = round(min($maxFactor, max(200, $factor)) * $fleetPoints);
$fleetColName = 'fleet_resource_'.$resource[$resourceId];
$this->UpdateFleet($fleetColName, $this->_fleet[$fleetColName] + $founded);
break;
case 2:
$eventSize = mt_rand(0, 100);
$Size = 0;
if(10 < $eventSize) {
$Size = mt_rand(100, 300);
$Message = $LNG['sys_expe_found_dm_1_'.mt_rand(1,5)];
} elseif(0 < $eventSize && 10 >= $eventSize) {
$Size = mt_rand(301, 600);
$Message = $LNG['sys_expe_found_dm_2_'.mt_rand(1,3)];
} elseif(0 == $eventSize) {
$Size = mt_rand(601, 3000);
$Message = $LNG['sys_expe_found_dm_3_'.mt_rand(1,2)];
}
$this->UpdateFleet('fleet_resource_darkmatter', $this->_fleet['fleet_resource_darkmatter'] + $Size);
break;
case 3:
$eventSize = mt_rand(0, 100);
$Size = 0;
$Message = "";
if(10 < $eventSize) {
$Size = mt_rand(10, 50);
$Message = $LNG['sys_expe_found_ships_1_'.mt_rand(1,4)];
} elseif(0 < $eventSize && 10 >= $eventSize) {
$Size = mt_rand(52, 100);
$Message = $LNG['sys_expe_found_ships_2_'.mt_rand(1,2)];
} elseif(0 == $eventSize) {
$Size = mt_rand(102, 200);
$Message = $LNG['sys_expe_found_ships_3_'.mt_rand(1,2)];
}
$sql = "SELECT MAX(total_points) as total FROM %%STATPOINTS%%
WHERE `stat_type` = :type AND `universe` = :universe;";
$topPoints = Database::get()->selectSingle($sql, array(
':type' => 1,
':universe' => $this->_fleet['fleet_universe']
), 'total');
$MaxPoints = ($topPoints < 5000000) ? 4500 : 6000;
$FoundShips = max(round($Size * min($fleetPoints, $MaxPoints)), 10000);
$FoundShipMess = "";
$NewFleetArray = "";
$Found = array();
foreach($reslist['fleet'] as $ID)
{
if(!isset($fleetArray[$ID]) || $ID == 208 || $ID == 209 || $ID == 214)
continue;
$MaxFound = floor($FoundShips / ($pricelist[$ID]['cost'] + $pricelist[$ID]['cost']));
if($MaxFound <= 0)
continue;
$Count = mt_rand(0, $MaxFound);
if($Count <= 0)
continue;
$Found[$ID] = $Count;
$FoundShips -= $Count * ($pricelist[$ID]['cost'] + $pricelist[$ID]['cost']);
$FoundShipMess .= '<br>'.$LNG['tech'][$ID].': '.pretty_number($Count);
if($FoundShips <= 0)
break;
}
if (empty($Found)) {
$FoundShipMess .= '<br><br>'.$LNG['sys_expe_found_ships_nothing'];
}
foreach($fleetArray as $ID => $Count)
{
if(!empty($Found[$ID]))
{
$Count += $Found[$ID];
}
$NewFleetArray .= $ID.",".floatToString($Count).';';
}
$Message .= $FoundShipMess;
$this->UpdateFleet('fleet_array', $NewFleetArray);
$this->UpdateFleet('fleet_amount', array_sum($fleetArray));
break;
case 4:
$messageHTML = <<<HTML
<div class="raportMessage">
<table>
<tr>
<td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
</tr>
<tr>
<td>%s</td><td><span class="%s">%s: %s</span> <span class="%s">%s: %s</span></td>
</tr>
<tr>
<td>%s</td><td><span>%s: <span class="raportSteal element901">%s</span> </span><span>%s: <span class="raportSteal element902">%s</span> </span><span>%s: <span class="raportSteal element903">%s</span></span></td>
</tr>
<tr>
<td>%s</td><td><span>%s: <span class="raportDebris element901">%s</span> </span><span>%s: <span class="raportDebris element902">%s</span></span></td>
</tr>
</table>
</div>
HTML;
//Minize HTML
$messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
// pirate or alien
$attackType = mt_rand(1,2);
$eventSize = mt_rand(0, 100);
$targetFleetData = array();
if($attackType == 1)
{
$techBonus = -3;
$targetName = $LNG['sys_expe_attackname_1'];
$roundFunction = 'floor';
if(10 < $eventSize)
{
$Message = $LNG['sys_expe_attack_1_1_5'];
$attackFactor = (30 + mt_rand(-3, 3)) / 100;
$targetFleetData = 5;
}
elseif(0 < $eventSize && 10 >= $eventSize)
{
$Message = $LNG['sys_expe_attack_1_2_3'];
$attackFactor = (50 + mt_rand(-5, 5)) / 100;
$targetFleetData = 3;
}
else
{
$Message = $LNG['sys_expe_attack_1_3_2'];
$attackFactor = (80 + mt_rand(-8, 8)) / 100;
$targetFleetData = 2;
}
}
else
{
$techBonus = 3;
$targetName = $LNG['sys_expe_attackname_2'];
$roundFunction = 'ceil';
if(10 < $eventSize)
{
$Message = $LNG['sys_expe_attack_1_1_5'];
$attackFactor = (40 + mt_rand(-4, 4)) / 100;
$targetFleetData = 5;
}
elseif(0 < $eventSize && 10 >= $eventSize)
{
$Message = $LNG['sys_expe_attack_1_3_3'];
$attackFactor = (60 + mt_rand(-6, 6)) / 100;
$targetFleetData = 3;
}
else
{
$Message = $LNG['sys_expe_attack_1_3_2'];
$attackFactor = (90 + mt_rand(-9, 9)) / 100;
$targetFleetData = 2;
}
}
foreach($fleetArray as $shipId => $shipAmount)
{
if(isset($targetFleetData[$shipId]))
{
$targetFleetData[$shipId] = 0;
}
$targetFleetData[$shipId] = $roundFunction($shipAmount * $attackFactor);
}
$targetFleetData = array_filter($targetFleetData);
$sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
$senderData = Database::get()->selectSingle($sql, array(
':userId' => $this->_fleet['fleet_owner']
));
$targetData = array(
'id' => 0,
'username' => $targetName,
'military_tech' => min($senderData['military_tech'] + $techBonus, 0),
'defence_tech' => min($senderData['defence_tech'] + $techBonus, 0),
'shield_tech' => min($senderData['shield_tech'] + $techBonus, 0),
'rpg_amiral' => 0,
'dm_defensive' => 0,
'dm_attack' => 0
);
$fleetID = $this->_fleet['fleet_id'];
$fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
$fleetAttack[$fleetID]['player'] = $senderData;
$fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
$fleetAttack[$fleetID]['unit'] = $fleetArray;
$fleetDefend = array();
$fleetDefend['fleetDetail'] = array(
'fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'],
'fleet_start_system' => $this->_fleet['fleet_end_system'],
'fleet_start_planet' => $this->_fleet['fleet_end_planet'],
'fleet_start_type' => 1,
'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'],
'fleet_end_system' => $this->_fleet['fleet_end_system'],
'fleet_end_planet' => $this->_fleet['fleet_end_planet'],
'fleet_end_type' => 1,
'fleet_resource_metal' => 0,
'fleet_resource_crystal' => 0,
'fleet_resource_deuterium' => 0
);
$bonusList = BuildFunctions::getBonusList();
$fleetDefend['player'] = $targetData;
$fleetDefend['player']['factor'] = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
$fleetDefend['unit'] = $targetFleetData;
require_once 'includes/classes/missions/functions/calculateAttack.php';
$combatResult = calculateAttack($fleetAttack, $fleetDefend, $config->Fleet_Cdr, $config->Defs_Cdr);
$fleetArray = '';
$totalCount = 0;
$fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount)
{
$fleetArray .= $element.','.$amount.';';
$totalCount += $amount;
}
if ($totalCount <= 0)
{
$this->KillFleet();
}
else
{
$this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
$this->UpdateFleet('fleet_amount', $totalCount);
}
require_once('includes/classes/missions/functions/GenerateReport.php');
$debrisResource = array(901, 902);
$debris = array();
foreach($debrisResource as $elementID)
{
$debris[$elementID] = 0;
}
$stealResource = array(901 => 0, 902 => 0, 903 => 0);
$reportInfo = array(
'thisFleet' => $this->_fleet,
'debris' => $debris,
'stealResource' => $stealResource,
'moonChance' => 0,
'moonDestroy' => false,
'moonName' => NULL,
'moonDestroyChance' => NULL,
'moonDestroySuccess' => NULL,
'fleetDestroyChance' => NULL,
'fleetDestroySuccess' => NULL,
);
$reportData = GenerateReport($combatResult, $reportInfo);
$reportID = md5(uniqid('', true).TIMESTAMP);
$sql = "INSERT INTO %%RW%% SET
rid = :reportId,
raport = :reportData,
time = :time,
attacker = :attacker;";
Database::get()->insert($sql, array(
':reportId' => $reportID,
':reportData' => serialize($reportData),
':time' => $this->_fleet['fleet_start_time'],
':attacker' => $this->_fleet['fleet_owner'],
));
switch($combatResult['won'])
{
case "a":
$attackClass = 'raportWin';
$defendClass = 'raportLose';
break;
case "r":
$attackClass = 'raportLose';
$defendClass = 'raportWin';
break;
default:
$attackClass = 'raportDraw';
$defendClass = 'raportDraw';
break;
}
$message = sprintf($messageHTML,
$reportID,
$attackClass,
$LNG['sys_mess_attack_report'],
sprintf(
$LNG['sys_adress_planet'],
$this->_fleet['fleet_end_galaxy'],
$this->_fleet['fleet_end_system'],
$this->_fleet['fleet_end_planet']
),
$LNG['type_planet_short'][$this->_fleet['fleet_end_type']],
$LNG['sys_lost'],
$attackClass,
$LNG['sys_attack_attacker_pos'], pretty_number($combatResult['unitLost']['attacker']),
$defendClass,
$LNG['sys_attack_defender_pos'], pretty_number($combatResult['unitLost']['defender']),
$LNG['sys_gain'],
$LNG['tech'], pretty_number($stealResource),
$LNG['tech'], pretty_number($stealResource),
$LNG['tech'], pretty_number($stealResource),
$LNG['sys_debris'],
$LNG['tech'], pretty_number($debris),
$LNG['tech'], pretty_number($debris)
);
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 3,
$LNG['sys_mess_attack_report'], $message, $this->_fleet['fleet_end_stay']);
break;
case 5:
$this->KillFleet();
$Message = $LNG['sys_expe_lost_fleet_'.mt_rand(1,4)];
break;
case 6:
# http://owiki.de/Expedition#Ver.C3.A4nderte_Flugzeit
$chance = mt_rand(0, 100);
$Wrapper = array();
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 2;
$Wrapper[] = 3;
$Wrapper[] = 3;
$Wrapper[] = 5;
if($chance < 75)
{
// More return time
$normalBackTime = $this->_fleet['fleet_end_time'] - $this->_fleet['fleet_end_stay'];
$stayTime = $this->_fleet['fleet_end_stay'] - $this->_fleet['fleet_start_time'];
$factor = $Wrapper;
$endTime = $this->_fleet['fleet_end_stay'] + $normalBackTime + $stayTime + $factor;
$this->UpdateFleet('fleet_end_time', $endTime);
$Message = $LNG['sys_expe_time_slow_'.mt_rand(1,6)];
}
else
{
$normalBackTime = $this->_fleet['fleet_end_time'] - $this->_fleet['fleet_end_stay'];
$stayTime = $this->_fleet['fleet_end_stay'] - $this->_fleet['fleet_start_time'];
$factor = $Wrapper;
$endTime = max(1, $normalBackTime - $stayTime / 3 * $factor);
$this->UpdateFleet('fleet_end_time', $endTime);
$Message = $LNG['sys_expe_time_fast_'.mt_rand(1,3)];
}
break;
}
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 15,
$LNG['sys_expe_report'], $Message, $this->_fleet['fleet_end_stay'], NULL, 1, $this->_fleet['fleet_universe']);
$this->setState(FLEET_RETURN);
$this->SaveFleet();
}
function ReturnEvent()
{
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$Message = sprintf(
$LNG['sys_expe_back_home'],
$LNG['tech'], pretty_number($this->_fleet['fleet_resource_metal']),
$LNG['tech'], pretty_number($this->_fleet['fleet_resource_crystal']),
$LNG['tech'], pretty_number($this->_fleet['fleet_resource_deuterium']),
$LNG['tech'], pretty_number($this->_fleet['fleet_resource_darkmatter'])
);
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'],
$Message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->RestoreFleet();
}
}
懒喵
發表於 2016-2-26 22:33:29
:lol:lol:lol
期待很久了哦
还有很多新的系统
感谢站长!!!!
taurids
發表於 2016-2-29 08:58:19
a950216t 發表於 2016-2-26 03:54 PM
爆發?
就是爆種,爆豆(感覺新生代估計都不知道這是啥,老年人啦{:4_201:})
話說你的minecraft服呢?
taurids
發表於 2016-2-29 09:00:06
懒喵 發表於 2016-2-26 10:33 PM
期待很久了哦
还有很多新的系统
懶喵,你的圖貼完了?
懒喵
發表於 2016-2-29 12:32:29
taurids 發表於 2016-2-29 09:00 AM
懶喵,你的圖貼完了?
在学校。。。
admin
發表於 2016-2-29 18:09:26
taurids 發表於 2016-2-29 08:58 AM
就是爆種,爆豆(感覺新生代估計都不知道這是啥,老年人啦)
話說你的minecraft服呢?
http://mcmaps.myxnova.com/
先來份地圖
{:7_1434:}
taurids
發表於 2016-3-1 09:05:24
a950216t 發表於 2016-2-29 06:09 PM
http://mcmaps.myxnova.com/
先來份地圖
If you can see this message, there is likely a problem loading the Overviewer javascript components. Check the javascript console for error messages.
什么意思?,我有Java的说。
admin
發表於 2016-3-1 10:37:19
taurids 發表於 2016-3-1 09:05 AM
If you can see this message, there is likely a problem loading the Overviewer javascript component ...
The MAP, IS USE GOOGLE API TO MAKE
IF BE BLOCKED BY GFW
WILL CAN'T SEE.
taurids
發表於 2016-3-1 11:05:22
so, is that means we don't have the chance to join this party?:'(
admin
發表於 2016-3-1 11:21:30
taurids 發表於 2016-3-1 11:05 AM
so, is that means we don't have the chance to join this party?
No
Only maps can't see.
But Can play server.
:)