public function getShips() { $ships = array(); $ship = new Ship('Jedi Starfighter'); $ship->setWeaponPower(5); $ship->setJediFactor(15); $ship->setStrength(30); $ships['starfighter'] = $ship; $ship2 = new Ship('CloakShape Fighter'); $ship2->setWeaponPower(2); $ship2->setJediFactor(2); $ship2->setStrength(70); $ships['cloakshape_fighter'] = $ship2; $ship3 = new Ship('Super Star Destroyer'); $ship3->setWeaponPower(70); $ship3->setJediFactor(0); $ship3->setStrength(500); $ships['super_star_destroyer'] = $ship3; $ship4 = new Ship('RZ-1 A-wing interceptor'); $ship4->setWeaponPower(4); $ship4->setJediFactor(4); $ship4->setStrength(50); $ships['rz1_a_wing_interceptor'] = $ship4; return $ships; }
/** * Add ship to map * * @param Ship $ship */ private function addShip(Ship $ship) { $position = $ship->getPosition(); foreach ($position as $pos => $_val) { $this->data['ships'][$pos] = $ship; } $this->data['ships_left']++; }
/** * @param Ship $someShip */ function printShipSummary($someShip) { echo 'Ship Name: ' . $someShip->getName(); echo '<hr/>'; $someShip->sayHello(); echo '<hr/>'; echo $someShip->getNameAndSpecs(false); echo '<hr/>'; echo $someShip->getNameAndSpecs(true); }
function details() { global $smarty; $item = new dogma($this->typeID); if (!$item->isValid()) { $this->page->setTitle('Error'); return 'This ID is not a valid dogma ID.'; } $this->page->setTitle('Item details - ' . $item->get('typeName')); $this->page->addHeader('<meta name="robots" content="noindex, nofollow" />'); $smarty->assignByRef('item', $item); if ($item->get('itt_cat') == 6) { //we have a ship, so get it from the db $ship = Ship::getByID($item->get('typeID')); $smarty->assign('shipImage', $ship->getImage(64)); $smarty->assign('armour', array('armorHP', 'armorEmDamageResonance', 'armorExplosiveDamageResonance', 'armorKineticDamageResonance', 'armorThermalDamageResonance')); $smarty->assign('shield', array('shieldCapacity', 'shieldRechargeRate', 'shieldEmDamageResonance', 'shieldExplosiveDamageResonance', 'shieldKineticDamageResonance', 'shieldThermalDamageResonance')); $smarty->assign('propulsion', array('maxVelocity', 'agility', 'droneCapacity', 'capacitorCapacity', 'rechargeRate')); $smarty->assign('fitting', array('hiSlots', 'medSlots', 'lowSlots', 'rigSlots', 'upgradeCapacity', 'droneBandwidth', 'launcherSlotsLeft', 'turretSlotsLeft', 'powerOutput', 'cpuOutput')); $smarty->assign('targetting', array('maxTargetRange', 'scanResolution', 'maxLockedTargets', 'scanRadarStrength', 'scanLadarStrength', 'scanMagnetometricStrength', 'scanGravimetricStrength', 'signatureRadius')); $smarty->assign('miscellaneous', array('techLevel', 'propulsionFusionStrength', 'propulsionIonStrength', 'propulsionMagpulseStrength', 'propulsionPlasmaStrength')); $html = $smarty->fetch(get_tpl('invtype_ship')); } else { $i = new Item($this->typeID); $smarty->assign('itemImage', $i->getIcon(64, false)); $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false); $html = $smarty->fetch(get_tpl('invtype_item')); } return $html; }
function generate() { global $smarty; $this->toplist->generate(); $i = 1; $rows = array(); while ($row = $this->toplist->getRow()) { $pilot = Pilot::getByID($row['plt_id']); $uri = edkURI::build(array('a', 'kill_detail', true), array('kll_id', $row['kll_id'], true)); if ($row['plt_externalid']) { $img = imageURL::getURL('Pilot', $row['plt_externalid'], 32); } else { $img = $pilot->getPortraitURL(32); } $ship = Ship::getByID($row['ship']); $shipUri = edkURI::build(array('a', 'invtype', true), array('id', $row['ship'], true)); if ((int) number_format($row["isk"], 0, "", "") > 1000000000) { $isk = number_format($row["isk"] / 1000000000, 2, ".", "") . " b"; } elseif ((int) number_format($row["isk"], 0, "", "") > 1000000) { $isk = number_format($row["isk"] / 1000000, 2, ".", "") . " M"; } else { $isk = number_format($row["isk"], 0, ".", ","); } $rows[] = array('rank' => $i, 'name' => $pilot->getName(), 'uri' => $uri, 'portrait' => $img, 'shipImage' => $ship->getImage(32), 'shipName' => $ship->getName(), 'shipId' => $row['ship'], 'shipURI' => $shipUri, 'isk' => $isk); $i++; } $smarty->assign('tl_name', 'Pilot'); $smarty->assign('tl_type', $this->entity_); $smarty->assignByRef('tl_rows', $rows); return $smarty->fetch(getcwd() . '/mods/most_expensive_toplist/templates/toplisttable_expensive.tpl'); }
/** * @test */ public function it_shoots_a_field_which_already_been_hit() { $data = ['startPoint' => ['x' => 2, 'y' => 2], 'endPoint' => ['x' => 2, 'y' => 4], 'hits' => 2]; $ship = Ship::fromArray($data); $field = Field::generate(1, 1); $field->shoot(); $field->place($ship); $this->setExpectedException(FieldAlreadyBeenShotException::class); $field->shoot(); }
/** * @test */ public function it_hits_a_sunken_ship() { $data = ['startPoint' => ['x' => 2, 'y' => 2], 'endPoint' => ['x' => 2, 'y' => 4], 'hits' => 0]; $ship = Ship::fromArray($data); $ship->hit(); $ship->hit(); $ship->hit(); $ship->hit(); $this->assertTrue($ship->hasSunk()); }
protected function check_range(Ship $target, Weapon $weapon) { $x = $target->getPos()['x'] - $this->getPos()['x']; $y = $target->getPos()['y'] - $this->getPos()['y']; $distance = sqrt(pow($x, 2) + pow($y, 2)); if ($distance != 0) { if ($distance < $weapon->getRange()['short']) { return 1; } else { if ($distance < $weapon->getRange()['mid']) { return 2; } else { if ($distance < $weapon->getRange()['long']) { return 3; } else { return 0; } } } } }
public function __construct(array $pos) { $this->_posX = $pos['x']; $this->_posY = $pos['y']; parent::__construct($pos); $this->_name = 'Honorable Duty'; $this->_sizeY = 1; $this->_sizeX = 3; $this->_maxlife = $this->_life = 4; $this->_pp = 10; $this->_speed = 18; $this->_maniability = 3; $this->_shield = 0; }
function generate() { global $smarty; $this->toplist->generate(); while ($row = $this->toplist->getRow()) { $ship = Ship::getByID($row['shp_id']); $shipclass = $ship->getClass(); $shipclass->getName(); $rows[] = array('rank' => false, 'name' => $ship->getName(), 'subname' => $shipclass->getName(), 'uri' => edkURI::page('invtype', $ship->getID()), 'portrait' => $ship->getImage(32), 'count' => $row['cnt']); } $smarty->assign('tl_name', Language::get('ship')); $smarty->assign('tl_type', Language::get('kills')); $smarty->assignByRef('tl_rows', $rows); return $smarty->fetch(get_tpl('toplisttable')); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://www.aerth.fr/useless/necron/Necron_Night_Shroud.jpg'; $value['pv'] = Shroud::PV; $value['cm'] = 18; $value['pp'] = Shroud::PP; $value['maneuver'] = 1; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 1; $value['size']['height'] = 2; $value['name'] = 'Night Shroud'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://wh40k.lexicanum.com/mediawiki/images/1/11/FirestormFrigate.jpg'; $value['pv'] = Firestorm::PV; $value['cm'] = 18; $value['pp'] = Firestorm::PP; $value['maneuver'] = 1; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 1; $value['size']['height'] = 2; $value['name'] = 'Firestorm Frigate'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://i57.servimg.com/u/f57/16/63/10/54/517.jpg'; $value['pv'] = Ore::PV; $value['cm'] = 10; $value['pp'] = Ore::PP; $value['maneuver'] = 5; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 3; $value['size']['height'] = 7; $value['name'] = 'Or\'es El\'leath Class Battleship'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://vignette1.wikia.nocookie.net/warhammer40k/images/0/06/Vengance_Class_Grand_Cruiser.jpg/revision/latest?cb=20110719060347'; $value['pv'] = Exorcistclass::PV; $value['cm'] = 15; $value['pp'] = Exorcistclass::PP; $value['maneuver'] = 3; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 2; $value['size']['height'] = 4; $value['name'] = 'Exorcist-class Grand Cruiser'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://wh40k-fr.lexicanum.com/mediawiki/images/8/89/Raider_Jackal.jpg'; $value['pv'] = Jackal::PV; $value['cm'] = 15; $value['pp'] = Jackal::PP; $value['maneuver'] = 3; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 2; $value['size']['height'] = 4; $value['name'] = 'Raider Jackal'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct($owner) { $this->_name = "Sword Of Absolution"; $this->_spriteSrc = "img/sprite/ImperialDestroyer.jpg"; $this->_size['L'] = 3; $this->_size['l'] = 1; $this->_maneuvreInit = 3; $this->_speedInit = 18; $this->_PpInit = 10; $this->_PvInit = 4; $this->_PsInit = 0; $weapon = new HeavyMachineGun(); $this->_weapons[] = $weapon; $this->_weapons[] = clone $weapon; parent::__construct($owner); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://wh40k.lexicanum.com/mediawiki/images/2/28/TigerSharkArt.jpg'; $value['pv'] = Tiger::PV; $value['cm'] = 18; $value['pp'] = Tiger::PP; $value['maneuver'] = 1; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 1; $value['size']['height'] = 2; $value['name'] = 'Tiger Shark'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://wh40k-fr.lexicanum.com/mediawiki/images/9/92/Vaisseau-Tombe_Cairn.jpg'; $value['pv'] = Cairn::PV; $value['cm'] = 10; $value['pp'] = Cairn::PP; $value['maneuver'] = 5; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 3; $value['size']['height'] = 7; $value['name'] = 'Cairn-class Tomb Ship'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
public function __construct(array $kwargs) { $value = array(); $value['sprite'] = 'http://wh40k.lexicanum.com/mediawiki/images/6/6d/OberonClassBattleship.JPG'; $value['pv'] = Oberon::PV; $value['cm'] = 10; $value['pp'] = Oberon::PP; $value['maneuver'] = 5; $value['weapons']['1'] = new navalspear(); $value['weapons']['2'] = new navalspear(); $value['size']['width'] = 3; $value['size']['height'] = 7; $value['name'] = 'Oberon Battleship'; $value['pos'] = $kwargs['pos']; parent::__construct($value); }
private function createShipFromData(array $shipData) { if ($shipData['team'] == 'rebel') { $ship = new RebelShip($shipData['name']); } else { $ship = new Ship($shipData['name']); $ship->setJediFactor($shipData['jedi_factor']); } $ship->setId($shipData['id']); $ship->setWeaponPower($shipData['weapon_power']); $ship->setStrength($shipData['strength']); return $ship; }
public static function checkLogin(\PDO $pdo_db, string $lang, Reg $tkireg, Smarty $template) : bool { // Database driven language entries $langvars = Translate::load($pdo_db, $lang, array('login', 'global_funcs', 'common', 'footer', 'self_destruct')); // Check if game is closed - Ignore the false return if it is open Game::isGameClosed($pdo_db, $tkireg, $lang, $template, $langvars); // Handle authentication check - Will die if fails, or return correct playerinfo $playerinfo = Player::handleAuth($pdo_db, $lang, $langvars, $tkireg, $template); // Establish timestamp for interval in checking bans $stamp = date('Y-m-d H:i:s'); $timestamp = array(); $timestamp['now'] = (int) strtotime($stamp); $timestamp['last'] = (int) strtotime($playerinfo['last_login']); // Check for ban - Ignore the false return if not Player::handleBan($pdo_db, $lang, $timestamp, $template, $playerinfo, $langvars, $tkireg); // Check for destroyed ship - Ignore the false return if not Ship::isDestroyed($pdo_db, $lang, $tkireg, $langvars, $template, $playerinfo); return true; }
public function __construct(array $pos) { $this->_posX = $pos['x']; $this->_posY = $pos['y']; if (array_key_exists("sY", $pos)) { $this->_sizeY = $pos['sY']; } else { $this->_sizeY = 2; } if (array_key_exists("sX", $pos)) { $this->_sizeX = $pos['sX']; } else { $this->_sizeX = 7; } parent::__construct($pos); $this->_name = 'Honorable Duty'; $this->_life = 5; $this->_pp = 10; $this->_speed = 10; $this->_maniability = 4; $this->_shield = 0; }
function posship(Ship $ship, $key) { $pos = $ship->getPos(); $size = $ship->getSize(); $x = $pos['x'] * 10 + 2 * $pos['x']; $y = $pos['y'] * 10 + 2 * $pos['y']; $width = $size['height'] * 10 + 2 * $size['height']; if ($ship->getDirection() == Ship::SOUTH) { $rotate = 'transform-origin: 50% 50%;transform : rotate(90deg);'; } else { if ($ship->getDirection() == Ship::NORTH) { $rotate = 'transform-origin: 50% 50%;transform : rotate(270deg);'; } else { if ($ship->getDirection() == Ship::WEST) { $rotate = 'transform-origin: 50% 50%;transform : rotateY(180deg);'; } else { $rotate = ""; } } } echo '<div style=" ' . $rotate . 'position: absolute; left:' . $x . '; top:' . $y . ';"> <img src="' . $ship->getSprite() . '" width ="' . $width . 'px" data-ship="' . $key . '" class="ship"></div>'; }
public function actionMyFightsComplete() { $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id)); $ship = Ship::model()->findByAttributes(array('id' => $player->id)); $criteria = new CDbCriteria(); $criteria->condition = 'id_player = :id_player AND ( status = :die OR status = :win OR status = :nothing )'; $criteria->params = array(':id_player' => $player->id, ':die' => ArenaJoiners::$STATUS_LOOSE, ':win' => ArenaJoiners::$STATUS_WIN, ':nothing' => ArenaJoiners::$STATUS_NOTHING); $joins = ArenaJoiners::model()->findAll($criteria); $pks = []; foreach ($joins as $join) { array_push($pks, $join->id_room); } $rooms = ArenaRoom::model()->findAllByPk($pks); if ($rooms != null) { foreach ($rooms as $key => $game) { $winner_ship = null; if ($game->winner_id != 0) { $winner_ship = Ship::model()->findByAttributes(array('id' => $game->winner_id)); } //////////////////////////////////////////////////////////////////// // Если игрок продал корабль или НИЧЬЯ //////////////////////////////////////////////////////////////////// $game->winner_ship = $winner_ship; } } $this->render('show_my_fights', array('player' => $player, 'ship' => $ship, 'joins' => $joins, 'rooms' => $rooms)); }
/** * Return the victim's Ship. * @return Ship */ function getVictimShip() { return Ship::getByID($this->victimshipid); }
<?php include "Transport.php"; include "Car.php"; include "Plane.php"; include "Ship.php"; include "Train.php"; include "Bike.php"; $car = new Car(); $car->go(); $plane = new Plane(); $plane->go(); $train = new Train(); $train->go(); $car = new Ship(); $car->go(); $bike = new Bike(); $bike->go();
public function getshipJoiner() { $ship = Ship::model()->findByAttributes(array('id' => $this->id_player)); $this->ship = $ship; }
/** * Places a ship on the board * @param \Model\Ship $ship * @return \Model\Ship */ protected function placeShip(Ship $ship) { $length = $ship->getLengh(); while (!$ship->isPlaced()) { //TODO: optimize $direction = rand(0, 1) ? Ship::DIRECTION_HORIZONTAL : Ship::DIRECTION_VERTICAL; $row = rand(1, self::ROWS); $col = rand(1, self::COLS); $points = $this->generateShipPoints($length, $direction, $row, $col); if (!$this->hasCollision($points)) { $ship->setPoints($points); } } return $ship; }
/** * * @global array $destroyed * @global <type> $pilots * @global array $pods * @param Kill $kill * @param <type> $side * @return <type> */ function handle_destroyed($kill, $side, &$destroyed, &$pilots, $sideAssignmentMap = array(), $completeInformation = FALSE) { // ------------------------------------------------------------------------- // FIX BATTLE REPORT a little by Evoke. Salvoxia // BEGIN // ------------------------------------------------------------------------- // we don't want losses of our own corp/ally as losses on the enemy's side if ($side == 'e') { if (config::get('cfg_corpid')) { $corpId = config::get('cfg_corpid'); $corpId = $corpId[0]; if ($kill->getVictimCorpID() == $corpId) { return; } } elseif (config::get('cfg_allianceid')) { $allianceId = config::get('cfg_allianceid'); $allianceId = $allianceId[0]; if ($kill->getVictimAllianceID() == $allianceId) { return; } } } // ------------------------------------------------------------------------- // FIX BATTLE REPORT a little by Evoke. Salvoxia // END // ------------------------------------------------------------------------- if ($completeInformation && !is_null($destroyed) && is_array($destroyed)) { $destroyed[$kill->getID()] = $kill->getVictimID(); } if (config::get('fleet_battles_mod_sideassign')) { // determine whether the pilot is member of an alliance if ($kill->getVictimAllianceName() == "None") { $entityType = "corp"; $entityId = $kill->getVictimCorpID(); } else { $entityType = "alliance"; $entityId = $kill->getVictimAllianceID(); } if (isset($sideAssignmentMap[$entityType][$entityId])) { $pilotSide = $sideAssignmentMap[$entityType][$entityId]; } else { $pilotSide = $side; } } else { $pilotSide = $side; } $ship = Ship::lookup($kill->getVictimShipName()); $shipc = $ship->getClass(); $ts = strtotime($kill->getTimeStamp()); // mark the pilot as podded if ($shipc->getID() == 18 || $shipc->getID() == 2) { // increase the timestamp of a podkill by 1 so its after the shipkill $ts++; } // search for ships with the same id if (isset($pilots[$pilotSide][$kill->getVictimId()]) && is_array($pilots[$pilotSide][$kill->getVictimId()])) { foreach ($pilots[$pilotSide][$kill->getVictimId()] as $id => $_ship) { if ($ship->getID() == $_ship['sid']) { $pilots[$pilotSide][$kill->getVictimId()][$id]['destroyed'] = true; if (!isset($pilots[$pilotSide][$kill->getVictimId()][$id]['kll_id'])) { $pilots[$pilotSide][$kill->getVictimId()][$id]['kll_id'] = $kill->getID(); $pilots[$pilotSide][$kill->getVictimId()][$id]['kll_url'] = edkURI::page('kill_detail', $kill->getID(), "kll_id"); } //$pilots[$side][$kill->getVictimId()][0]["times"] +=1; return; } } } if ($completeInformation) { $pilots[$pilotSide][$kill->getVictimId()][] = array('name' => $kill->getVictimName(), 'plt_url' => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), 'kll_id' => $kill->getID(), 'kll_url' => edkURI::page('kill_detail', $kill->getID(), "kll_id"), 'spic' => imageURL::getURL('Ship', $ship->getID(), 32), 'scl' => $shipc->getPoints(), 'destroyed' => true, 'corp' => $kill->getVictimCorpName(), 'alliance' => $kill->getVictimAllianceName(), 'aid' => $kill->getVictimAllianceID(), 'alliance_url' => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), 'ship' => $kill->getVictimShipname(), 'shipClass' => $shipc->getName(), 'shipClassObject' => $shipc, 'sid' => $ship->getID(), 'cid' => $kill->getVictimCorpID(), 'crp_url' => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), 'ts' => $ts, 'times' => 0, 'color' => getColorClassByClass($shipc)); } else { $pilots[$pilotSide][$kill->getVictimId()] = 1; } }
private function didJediDestroyShipUsingTheForce(Ship $ship) { $jediHeroProbability = $ship->getJediFactor() / 100; return mt_rand(1, 100) <= $jediHeroProbability * 100; }