本文整理汇总了PHP中Weapon类的典型用法代码示例。如果您正苦于以下问题:PHP Weapon类的具体用法?PHP Weapon怎么用?PHP Weapon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Weapon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(\Weapon $weapon, \Armor $armor, array $rings = [], $hp = 100)
{
$this->hp = $hp;
$this->damage = $weapon->getDamage();
$this->cost += $weapon->getCost();
$this->armor = $armor->getArmor();
$this->cost += $armor->getCost();
foreach ($rings as $ring) {
$this->damage += $ring->getDamage();
$this->armor += $ring->getArmor();
$this->cost += $ring->getCost();
}
}
示例2: create_object
public function create_object($data)
{
$data = \Core\Dict::create($data);
$assassin = Agent::mapper()->create_object(array('id' => $data->assassin, 'alias' => $data->assassin_agent_alias));
$target = Agent::mapper()->create_object(array('id' => $data->target, 'alias' => $data->target_agent_alias));
$weapon = Weapon::mapper()->create_object(array('id' => $data->weapon_id, 'name' => $data->weapon_name));
return Kill::create(array('id' => $data->id, 'description' => $data->description, 'assassin' => $assassin, 'target' => $target, 'weapon' => $weapon, 'game' => $game, 'when_happened' => new \DateTime($data->when_happened)), True);
}
示例3: shoot
public function shoot(Ship $target, Weapon $weapon)
{
if ($weapon->getCharges() > 1) {
$dice = rand(1, 6);
$range = $this->check_range($target, $weapon);
if ($range == 1 && $dice >= 4) {
$target->receive_dmg();
} else {
if ($range == 2 && $dice >= 5) {
$target->receive_dmg();
} else {
if ($range == 3 && $dice >= 6) {
$target->receive_dmg();
}
}
}
$weapon->subCharge();
}
}
示例4: check_range
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;
}
}
}
}
}
示例5: getAll
function getAll()
{
$db = DB::GetConn();
$getQuery = "SELECT * FROM `Weapon`;";
$res = $db->query($getQuery);
//execute query
$returnWeapons = array();
while ($obj = $res->fetchObject()) {
array_push($returnWeapons, Weapon::loadWeaponFromObject($obj));
}
return $returnWeapons;
}
示例6: loadSaleFromObject
function loadSaleFromObject($obj)
{
$returnSale = new Sale();
$returnSale->ID = $obj->ID;
$returnSale->SellerID = $obj->SellerID;
$returnSale->ItemType = $obj->ItemType;
$returnSale->ItemID = $obj->ItemID;
$returnSale->Price = $obj->Price;
$returnSale->Created = new DateTime($obj->Created);
//load the actual object for sale
if ($returnSale->ItemType == "Weapon") {
$returnSale->Item = Weapon::loadWeapon($returnSale->ItemID);
}
return $returnSale;
}
示例7: array
<?php
if (Weapon::exist('article_footer')) {
?>
<div><?php
Weapon::fire('article_footer', array($article));
?>
</div>
<?php
}
示例8: array
?>
<?php
Shield::chunk('comment.form.message');
?>
<?php
Weapon::fire('comment_form_textarea_after', $hooks);
?>
<?php
Shield::chunk('comment.form.math');
?>
<div class="grid-group">
<span class="grid span-1"></span>
<div class="grid span-5">
<p>
<?php
Weapon::fire('comment_form_button_before', $hooks);
?>
<?php
echo Form::button($speak->publish, null, 'submit', null, array('class' => array('btn', 'btn-construct')));
?>
<?php
Weapon::fire('comment_form_button_after', $hooks);
?>
</p>
<p><?php
echo $speak->comment_wizard;
?>
</p>
</div>
</div>
</form>
示例9: Get_Item_Information
public function Get_Item_Information($itemtypeid)
{
$itemtypeid = urldecode($itemtypeid);
if (!is_numeric($itemtypeid)) {
return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
}
if (strlen($itemtypeid) > 8) {
return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
}
//check the cache
if (Cache::has($this->class_name . "_" . $itemtypeid)) {
//pull from cache
$itemtypeid_info = Cache::get($this->class_name . "_" . $itemtypeid);
return json_encode($itemtypeid_info);
}
$basic_info = hWebIcon::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->first(array('asset_path', 'abilitymodule_id', 'backpack_id', 'basic_id', 'blueprint_id', 'chassis_id', 'consumable_id', 'craftingcomponent_id', 'craftingstation_id', 'craftingsubcomponent_id', 'framemodule_id', 'palettemodule_id', 'powerup_id', 'resourceitem_id', 'scopemodule_id', 'weapon_id', 'weaponmodule_id'));
if (empty($basic_info)) {
return Response::json(array('status' => 'error', 'error' => 'ItemTypeID not found in db.'));
}
//break up the types
$detailed_info = array();
$constraint_info = array();
$weapon_info = array();
if ($basic_info['abilitymodule_id'] != "") {
$detailed_info = AbilityModule::where('id', '=', $basic_info['abilitymodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
$constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->first(array('cpu', 'mass', 'power'));
}
if ($basic_info['basic_id'] != "") {
$detailed_info = Basic::where('id', '=', $basic_info['basic_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
}
if ($basic_info['blueprint_id'] != "") {
//Note -> blueprint_id = recipe_id
}
if ($basic_info['chassis_id'] != "") {
//Note -> links to hattributes
$detailed_info = Chassis::where('id', '=', $basic_info['chassis_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'progression_item_id', 'progression_resource_id'));
$chassis_info = hAttributes::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->get(array('description', 'display_name', 'value', 'stat_id'));
}
if ($basic_info['consumable_id'] != "") {
$detailed_info = Consumable::where('id', '=', $basic_info['consumable_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'powerLevel', 'name', 'rarity'));
}
if ($basic_info['craftingcomponent_id'] != "") {
$detailed_info = CraftingComponent::where('id', '=', $basic_info['craftingcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
}
if ($basic_info['craftingsubcomponent_id'] != "") {
$detailed_info = CraftingSubcomponent::where('id', '=', $basic_info['craftingsubcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
}
if ($basic_info['framemodule_id'] != "") {
$detailed_info = FrameModule::where('id', '=', $basic_info['framemodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
$constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->first(array('cpu', 'mass', 'power'));
}
if ($basic_info['palletmodule_id'] != "") {
$detailed_info = PaletteModule::where('id', '=', $basic_info['palettemodule_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
}
if ($basic_info['powerup_id'] != "") {
$detailed_info = Powerup::where('id', '=', $basic_info['powerup_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
}
if ($basic_info['resourceitem_id'] != "") {
$detailed_info = ResourceItem::where('id', '=', $basic_info['resourceitem_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'resource_color'));
}
if ($basic_info['weapon_id'] != "") {
//weapons have hstats also!
$detailed_info = Weapon::where('id', '=', $basic_info['weapon_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'durability'));
$constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->first(array('cpu', 'mass', 'power'));
$weapon_info = hStat::where(function ($query) use($itemtypeid) {
$query->where('itemTypeId', '=', $itemtypeid);
$query->where('version', '=', $this->version);
})->first(array('ammoPerBurst', 'clipSize', 'damagePerRound', 'damagePerSecond', 'healthPerRound', 'maxAmmo', 'range', 'reloadTime', 'roundsPerBurst', 'roundsPerMinute', 'splashRadius', 'spread'));
}
if (empty($detailed_info)) {
return Response::json(array('status' => 'error', 'error' => 'error getting detailed information for this itemtypeid.'));
}
$detailed_info = $detailed_info->toArray();
$detailed_info['asset_path'] = $basic_info['asset_path'];
//add contstraint details
if (!empty($constraint_info)) {
$constraint_info = $constraint_info->toArray();
$detailed_info['cpu'] = $constraint_info['cpu'];
$detailed_info['mass'] = $constraint_info['mass'];
$detailed_info['power'] = $constraint_info['power'];
}
if (!empty($weapon_info)) {
$weapon_info = $weapon_info->toArray();
foreach ($weapon_info as $key => $data) {
$detailed_info[$key] = $data;
//.........这里部分代码省略.........
示例10:
} else {
if ($_REQUEST['action'] == "changeWeapon") {
$weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
// @TODO also check that weapon is currently unassigned,
// so people like me cannot cheat and assign a weapon twice
if ($weapon->UserID == $currentUID) {
$hero->Weapon = $weapon;
$hero->SaveHero();
$smarty->assign("hero", $hero);
$smarty->assign("message", $hero->Name . " has equipped " . $weapon->Name);
} else {
$smarty->assign("error", "That does not belong to you.");
}
} else {
if ($_REQUEST['action'] == "editWeaponName") {
$weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
if ($weapon->UserID == $currentUID) {
$oldName = $weapon->Name;
$weapon->Name = $_REQUEST['weaponName'];
$weapon->save();
$smarty->assign("message", $oldName . " was renamed to " . $weapon->Name);
$hero->Weapon = $weapon;
$smarty->assign("hero", $hero);
} else {
$smarty->assign("error", "You can't rename what does not belong to you.");
}
} else {
if ($_REQUEST['action'] == "levelUp") {
if ($hero->canLevelUp()) {
if ($hero->Status == "") {
$hero->Status = "Level Up";
示例11: function
if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
$articles = Mecha::walk($articles, function ($path) use($excludes) {
return Get::article($path, $excludes);
});
} else {
$articles = false;
}
Filter::add('pager:url', function ($url) {
return Filter::apply('index:url', $url);
});
Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
Shield::attach('page-home');
}, 110);
/**
* Route Hook: after
* -----------------
*/
Weapon::fire('routes_after');
/**
* Do Routing
* ----------
*/
Route::execute();
/**
* 404 Page
* --------
*
* Fallback to 404 page if nothing matched.
*
*/
Shield::abort();
示例12: array
<time datetime="<?php
echo $page->date->W3C;
?>
"><?php
echo $page->date->FORMAT_3;
?>
</time>
</span>
</div>
<div class="page-body"><?php
echo $page->description;
?>
</div>
<div class="page-footer">
<?php
Weapon::fire('page_footer', array($page));
?>
</div>
</li>
<?php
}
?>
</ol>
<?php
include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
?>
<p><?php
echo Config::speak('notify_empty', strtolower($speak->pages));
?>
</p>
示例13: function
<?php
/**
* Shortcode Manager
* -----------------
*/
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$shortcodes = Get::state_shortcode(null, array(), false);
$G = array('data' => $shortcodes);
Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__shortcode', $request);
Guardian::checkToken($request['token']);
$data = array();
for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
if (trim($keys[$i]) !== "") {
$data[$keys[$i]] = $request['value'][$i];
}
}
$P = array('data' => $data);
File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
Weapon::fire('on_shortcode_update', array($G, $P));
Guardian::kick($config->url_current);
}
Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
示例14: function
<?php
Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) {
if ($config->is->post && ($post = $G['data'][$config->page_type])) {
$c = $config->states->{'plugin_' . md5(File::B(__DIR__))};
$title = $post['title'];
$url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U'));
$topic = sprintf($c->subject, $title, $url);
$parser = Request::post('content_type', $config->html_parser->active);
$message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>';
$message .= '<h3>' . $P['data']['name'] . '</h3>';
$message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message'];
$message .= '<p>';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>';
$message .= ' / ';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>';
$message .= '</p>';
// Sending email notification ...
if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) {
Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message));
}
}
});
示例15: function
<?php
/**
* Error Log
* ---------
*/
Route::accept($config->manager->slug . '/error', function () use($config, $speak) {
Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php'));
Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager');
});
/**
* Error Log Killer
* ----------------
*/
Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$errors = LOG . DS . 'errors.log';
$G = array('data' => array('content' => File::open($errors)->read()));
File::open($errors)->delete();
Weapon::fire('on_error_destruct', array($G, $G));
Notify::success(Config::speak('notify_success_deleted', $speak->file));
Guardian::kick(File::D($config->url_current));
});