mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-16 01:26:07 +00:00
Fix T4 hero Adventure & Auction by tribe
Fix T4 hero Adventure & Auction by tribe
This commit is contained in:
@@ -305,3 +305,19 @@ if (!function_exists('heroItemName')) {
|
|||||||
return isset($heroItemCatalog[$itemid]['name']) ? $heroItemCatalog[$itemid]['name'] : 'Unknown item';
|
return isset($heroItemCatalog[$itemid]['name']) ? $heroItemCatalog[$itemid]['name'] : 'Unknown item';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tribe an item belongs to: 0 = universal (helmets, armors, boots, etc.),
|
||||||
|
* 1/2/3 = Romans/Teutons/Gauls for the unit-bound right-hand weapons
|
||||||
|
* (u1-10 -> 1, u11-20 -> 2, u21-30 -> 3). Single source for both the
|
||||||
|
* adventure drop filter and the tribe-filtered auction listing.
|
||||||
|
*/
|
||||||
|
if (!function_exists('heroItemTribe')) {
|
||||||
|
function heroItemTribe($itemid) {
|
||||||
|
global $heroItemCatalog;
|
||||||
|
if (!isset($heroItemCatalog[$itemid]['unit'])) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return intdiv((int) $heroItemCatalog[$itemid]['unit'] - 1, 10) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ class HeroAdventure
|
|||||||
// if no gear dropped, roll the consumable pool. One item max.
|
// if no gear dropped, roll the consumable pool. One item max.
|
||||||
$itemId = 0; $itemQty = 0;
|
$itemId = 0; $itemQty = 0;
|
||||||
if (mt_rand(1, 100) <= (int) ($cfg['equip_chance'] ?? 0)) {
|
if (mt_rand(1, 100) <= (int) ($cfg['equip_chance'] ?? 0)) {
|
||||||
$itemId = $this->rollEquipment();
|
$itemId = $this->rollEquipment($uid);
|
||||||
$itemQty = ($itemId > 0) ? 1 : 0;
|
$itemQty = ($itemId > 0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
if ($itemId === 0 && mt_rand(1, 100) <= (int) $cfg['item_chance']) {
|
if ($itemId === 0 && mt_rand(1, 100) <= (int) $cfg['item_chance']) {
|
||||||
@@ -531,16 +531,19 @@ class HeroAdventure
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Roll one random piece of EQUIPMENT (any non-bag catalog item, including
|
* Roll one random piece of EQUIPMENT. Universal gear (helmets, armors,
|
||||||
* weapons for other tribes - unusable finds feed the auction house, same
|
* boots, horses, left-hand) drops for everyone; right-hand WEAPONS only
|
||||||
* as T4). Tier picked by 'equip_tier_weights' (T1 common, T3 very rare),
|
* drop for the owner's own tribe (T4 behavior - a Roman never finds a
|
||||||
* then a uniform pick inside that tier. Returns an itemid, or 0 if the
|
* Teuton club). Tier picked by 'equip_tier_weights' (T1 common, T3 very
|
||||||
* rolled tier happens to be empty (defensive; never true with the
|
* rare), then a uniform pick inside that tier. Returns an itemid, or 0
|
||||||
* shipped catalog).
|
* if the rolled tier happens to be empty (defensive; never true with
|
||||||
|
* the shipped catalog).
|
||||||
*/
|
*/
|
||||||
public function rollEquipment()
|
public function rollEquipment($uid = 0)
|
||||||
{
|
{
|
||||||
global $heroItemCatalog, $heroAdventureConfig;
|
global $database, $heroItemCatalog, $heroAdventureConfig;
|
||||||
|
|
||||||
|
$tribe = ((int) $uid > 0) ? (int) $database->getUserField((int) $uid, 'tribe', 0) : 0;
|
||||||
|
|
||||||
$weights = $heroAdventureConfig['equip_tier_weights'];
|
$weights = $heroAdventureConfig['equip_tier_weights'];
|
||||||
$roll = mt_rand(1, 100); $acc = 0; $tier = 1;
|
$roll = mt_rand(1, 100); $acc = 0; $tier = 1;
|
||||||
@@ -551,9 +554,14 @@ class HeroAdventure
|
|||||||
|
|
||||||
$pool = array();
|
$pool = array();
|
||||||
foreach ($heroItemCatalog as $iid => $def) {
|
foreach ($heroItemCatalog as $iid => $def) {
|
||||||
if ((int) $def['slot'] !== HSLOT_BAG && (int) $def['tier'] === $tier) {
|
if ((int) $def['slot'] === HSLOT_BAG || (int) $def['tier'] !== $tier) {
|
||||||
$pool[] = $iid;
|
continue;
|
||||||
}
|
}
|
||||||
|
$itemTribe = heroItemTribe($iid);
|
||||||
|
if ($itemTribe !== 0 && $tribe > 0 && $itemTribe !== $tribe) {
|
||||||
|
continue; // foreign-tribe weapon
|
||||||
|
}
|
||||||
|
$pool[] = $iid;
|
||||||
}
|
}
|
||||||
return count($pool) ? (int) $pool[array_rand($pool)] : 0;
|
return count($pool) ? (int) $pool[array_rand($pool)] : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,10 +83,22 @@ class HeroAuction
|
|||||||
* READS
|
* READS
|
||||||
* ===================================================================== */
|
* ===================================================================== */
|
||||||
|
|
||||||
/** All open, unexpired auctions (newest ending first optional; default: ending soonest). */
|
/**
|
||||||
public function getOpenAuctions($limit = 50)
|
* All open, unexpired auctions, ending soonest first.
|
||||||
|
* When $viewerUid is given, right-hand WEAPONS of other tribes are
|
||||||
|
* hidden (T4 behavior: a Roman only sees Roman weapon lots). Universal
|
||||||
|
* gear and consumables are always shown. The SQL over-fetches slightly
|
||||||
|
* so the filter still fills the page.
|
||||||
|
*/
|
||||||
|
public function getOpenAuctions($limit = 50, $viewerUid = 0)
|
||||||
{
|
{
|
||||||
|
global $database;
|
||||||
$now = time(); $limit = max(1, (int) $limit);
|
$now = time(); $limit = max(1, (int) $limit);
|
||||||
|
|
||||||
|
$viewerTribe = ((int) $viewerUid > 0)
|
||||||
|
? (int) $database->getUserField((int) $viewerUid, 'tribe', 0) : 0;
|
||||||
|
$fetch = $viewerTribe > 0 ? $limit * 2 : $limit;
|
||||||
|
|
||||||
$stmt = $this->db->prepare(
|
$stmt = $this->db->prepare(
|
||||||
"SELECT id, seller, itemid, slot, stat_value, quantity,
|
"SELECT id, seller, itemid, slot, stat_value, quantity,
|
||||||
silver_start, silver_current, bidder, created, time_end, status
|
silver_start, silver_current, bidder, created, time_end, status
|
||||||
@@ -94,14 +106,23 @@ class HeroAuction
|
|||||||
WHERE status = " . self::ST_OPEN . " AND time_end > ?
|
WHERE status = " . self::ST_OPEN . " AND time_end > ?
|
||||||
ORDER BY time_end ASC LIMIT ?"
|
ORDER BY time_end ASC LIMIT ?"
|
||||||
);
|
);
|
||||||
$stmt->bind_param('ii', $now, $limit);
|
$stmt->bind_param('ii', $now, $fetch);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$res = $stmt->get_result();
|
$res = $stmt->get_result();
|
||||||
$out = array();
|
$out = array();
|
||||||
while ($row = $res->fetch_assoc()) {
|
while ($row = $res->fetch_assoc()) {
|
||||||
|
if ($viewerTribe > 0) {
|
||||||
|
$itemTribe = heroItemTribe($row['itemid']);
|
||||||
|
if ($itemTribe !== 0 && $itemTribe !== $viewerTribe) {
|
||||||
|
continue; // foreign-tribe weapon lot
|
||||||
|
}
|
||||||
|
}
|
||||||
$row['name'] = heroItemName($row['itemid']);
|
$row['name'] = heroItemName($row['itemid']);
|
||||||
// bid_max intentionally NOT selected - it's the bidder's secret.
|
// bid_max intentionally NOT selected - it's the bidder's secret.
|
||||||
$out[] = $row;
|
$out[] = $row;
|
||||||
|
if (count($out) >= $limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
return $out;
|
return $out;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ if (isset($_POST['t4action'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$t4Open = $t4Auction->getOpenAuctions();
|
$t4Open = $t4Auction->getOpenAuctions(50, $session->uid);
|
||||||
$t4MyBids = $t4Auction->getMyBids($session->uid);
|
$t4MyBids = $t4Auction->getMyBids($session->uid);
|
||||||
$t4MySales = $t4Auction->getMySales($session->uid);
|
$t4MySales = $t4Auction->getMySales($session->uid);
|
||||||
$t4Now = time();
|
$t4Now = time();
|
||||||
|
|||||||
Reference in New Issue
Block a user