所以我的游戏中有一个攻击系统,玩家使用他们购买的武器,可以相互攻击。好吧,他们也有朋友,他们一起战斗,你在游戏中升级。对于每个级别,你可以与另外5个人战斗,所以它是这样的:等级* 5 =暴徒可用例如:我是5级,有100个朋友;我可以与25个朋友一起战斗,并在每个类别中使用25个武器。这里是一个ScreenShot所以在近战类别中说,我有10把刀,5个棒球棒和10个轴。我如何设置它以使用最好的攻击武器?这是我现在用来限制和选择1件武器的代码:
if($level >= 100) {
if($mob_size >=500) {
$a_melee_avail = 500 + $hired_guns;
}
else {
$a_melee_avail = $total_mob;
}
}
if($level < 100) {
if($mob_size > $level * 5) {
$a_melee_avail = $level * 5;
}
else {
$a_melee_avail = $mob_size;
}
}
$check_a_melee = mysql_query("SELECT * FROM weapons WHERE owner_id=".$id." AND type='melee' AND owned>=".$a_melee_avail." LIMIT 1");
$check_a_mel_info = mysql_fetch_array($check_a_melee);
$a_mel_limit_plus1 = ($check_a_mel_info['id'] + 1);
// Checking melee owned
if(mysql_num_rows($check_a_melee) == 0) {
$a_get_melee = mysql_query("SELECT * FROM weapons WHERE owner_id=".$id." AND type='melee' AND owned<=".$a_melee_avail." ORDER BY attack DESC LIMIT 1");
}
if(mysql_num_rows($check_a_melee) == 1) {
$a_get_melee = mysql_query("SELECT * FROM weapons WHERE owner_id=".$id." AND type='melee' AND owned>=".$a_melee_avail." ORDER BY attack DESC LIMIT 1");
}
$a_melee = mysql_fetch_array($a_get_melee);
$a_melee_name = $a_melee['name'];
$a_melee_attack = $a_melee['attack'];
$a_melee_owned = $a_melee['owned'];
// Checking Availability
if($a_melee_owned >= $a_melee_avail) {
$a_melee_used = $a_melee_avail;
}
if($a_melee_owned < $a_melee_avail) {
$a_melee_used = $a_melee_owned;
}
$a_melee_damage = $a_melee_attack * $a_melee_used;
但是,根据攻击选择1种最好的武器,我怎样才能将它设置为使用所有可用武器的地方?
答案 0 :(得分:0)
你能使用sortfeild
吗?function __construct($ sortField) { $ this-&gt; sortField = $ sortField; }
public function compare($a, $b)
{
return strnatcmp($b[$this->sortField], $a[$this->sortField]);
}
}
您的数组可以在列表中使用吗?