Add T4 Hero System (configurable on install)

Add T4 Hero System (configurable on install with TRUE/FALS) part of #285

-Adventures
-Merchants
-Equipment
This commit is contained in:
novgorodschi catalin
2026-07-10 09:15:42 +03:00
parent ed325b6d99
commit 3c99623a33
46 changed files with 4367 additions and 32 deletions
+1
View File
@@ -118,6 +118,7 @@ $editIcon = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke=
<tr><td>Special Medals<em class="tooltip">?<span class="classic">Special Medals</span></em></td><td><?php echo NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM ? "<span class='badge green'>Enabled</span>" : "<span class='badge red'>Disabled</span>"; ?></td></tr>
<tr><td>Server Milestones<em class="tooltip">?<span class="classic">Server Milestones</span></em></td><td><?php echo NEW_FUNCTIONS_MILESTONES ? "<span class='badge green'>Enabled</span>" : "<span class='badge red'>Disabled</span>"; ?></td></tr>
<tr><td>Server Medal Reset Timer<em class="tooltip">?<span class="classic">Server Medal Reset Timer</span></em></td><td><?php echo NEW_FUNCTIONS_MEDAL_RESET ? "<span class='badge green'>Enabled</span>" : "<span class='badge red'>Disabled</span>"; ?></td></tr>
<tr><td>T4 Hero (items, adventures, auction)<em class="tooltip">?<span class="classic">T4 Hero (items, adventures, auction)</span></em></td><td><?php echo NEW_FUNCTIONS_HERO_T4 ? "<span class='badge green'>Enabled</span>" : "<span class='badge red'>Disabled</span>"; ?></td></tr>
</table>
</div>
+185
View File
@@ -0,0 +1,185 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename : editHeroT4.tpl ##
## Type : Admin Panel Frontend - T4 hero port controls ##
## --------------------------------------------------------------------------- ##
## Refactored by : Shadow ##
## Project : TravianZ ##
## GitHub : https://github.com/Shadowss/TravianZ ##
## --------------------------------------------------------------------------- ##
## License : TravianZ Project ##
## Copyright : TravianZ (c) 2010-2026. All rights reserved. ##
## --------------------------------------------------------------------------- ##
#################################################################################
if (!isset($_GET['uid'])) { echo '<p>Missing uid.</p>'; return; }
$id = (int) $_GET['uid'];
include_once("../GameEngine/Data/hero_items.php");
include_once("../GameEngine/HeroItems.php");
include_once("../GameEngine/HeroAuction.php");
include_once("../GameEngine/HeroAdventure.php");
$t4HeroItems = new HeroItems();
$t4Auction = new HeroAuction();
$t4Adv = new HeroAdventure();
$t4Silver = $t4HeroItems->getSilver($id);
$t4Inventory = $t4HeroItems->getInventory($id);
$t4Sales = $t4Auction->getMySales($id);
$t4Bids = $t4Auction->getMyBids($id);
$t4Offers = $t4Adv->getOffers($id);
$t4Running = $t4Adv->getRunning($id);
$t4SlotNames = [1=>'Helmet',2=>'Body',3=>'Right hand',4=>'Left hand',5=>'Shoes',6=>'Horse',7=>'Bag'];
?>
<style>
.t4a-card{background:#fff;border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.04);margin-bottom:12px;}
.t4a-card h3{margin:0;padding:9px 14px;background:#f8fafc;border-bottom:1px solid #e5e7eb;font-size:12px;text-transform:uppercase;color:#475569;letter-spacing:.4px;font-weight:600;}
.t4a-card .body{padding:14px;}
.t4a-table{width:100%;border-collapse:collapse;font-size:13px;}
.t4a-table th{background:#f8fafc;padding:8px 10px;font-size:11px;text-transform:uppercase;color:#64748b;text-align:left;border-bottom:1px solid #e5e7eb;}
.t4a-table td{padding:8px 10px;border-bottom:1px solid #f1f5f9;vertical-align:middle;}
.t4a-table tr:last-child td{border-bottom:0;}
.t4a-btn{padding:5px 12px;border-radius:6px;border:1px solid #cbd5e1;background:#fff;cursor:pointer;font-size:12px;font-weight:600;color:#475569;}
.t4a-btn:hover{background:#66CCCC;color:#fff;border-color:#66CCCC;}
.t4a-btn.danger:hover{background:#dc2626;border-color:#dc2626;}
.t4a-inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.t4a-inline input[type=text],.t4a-inline select{padding:6px 8px;border:1px solid #cbd5e1;border-radius:6px;font-size:13px;}
.t4a-msg{padding:8px 12px;border-radius:8px;margin-bottom:12px;font-size:13px;font-weight:600;}
.t4a-msg.ok{background:#ecfdf5;color:#047857;border:1px solid #a7f3d0;}
.t4a-msg.err{background:#fef2f2;color:#b91c1c;border:1px solid #fecaca;}
</style>
<h2>T4 Hero controls — user #<?php echo $id; ?>
<small><a href="admin.php?p=editHero&uid=<?php echo $id; ?>">&laquo; classic hero editor</a></small>
</h2>
<?php if (isset($_GET['ok'])) { ?><div class="t4a-msg ok">Action completed.</div><?php } ?>
<?php if (isset($_GET['e'])) { ?><div class="t4a-msg err">Action failed (check the values and try again).</div><?php } ?>
<div class="t4a-card">
<h3>Silver</h3>
<div class="body">
<form action="../GameEngine/Admin/Mods/editHeroT4.php" method="POST" class="t4a-inline">
<?php echo csrf_field(); ?>
<input type="hidden" name="t4admin" value="setsilver">
<input type="hidden" name="uid" value="<?php echo $id; ?>">
<input type="text" name="silver" value="<?php echo $t4Silver; ?>" size="10" style="text-align:right;">
<button type="submit" class="t4a-btn">Set balance</button>
</form>
</div>
</div>
<div class="t4a-card">
<h3>Grant item</h3>
<div class="body">
<form action="../GameEngine/Admin/Mods/editHeroT4.php" method="POST" class="t4a-inline">
<?php echo csrf_field(); ?>
<input type="hidden" name="t4admin" value="giveitem">
<input type="hidden" name="uid" value="<?php echo $id; ?>">
<select name="itemid">
<?php foreach ($heroItemCatalog as $t4Iid => $t4Def) { ?>
<option value="<?php echo $t4Iid; ?>">#<?php echo $t4Iid; ?> <?php echo $t4Def['name']; ?> (T<?php echo $t4Def['tier']; ?>, <?php echo $t4SlotNames[$t4Def['slot']]; ?>)</option>
<?php } ?>
</select>
Qty: <input type="text" name="qty" value="1" size="3" style="text-align:center;">
<button type="submit" class="t4a-btn">Grant</button>
</form>
</div>
</div>
<div class="t4a-card">
<h3>Inventory (<?php echo count($t4Inventory); ?>)</h3>
<div class="body">
<?php if (count($t4Inventory)) { ?>
<table class="t4a-table">
<tr><th>Row</th><th>Item</th><th>Slot</th><th>Qty</th><th>Equipped</th><th></th></tr>
<?php foreach ($t4Inventory as $t4Row) { ?>
<tr>
<td>#<?php echo (int) $t4Row['id']; ?></td>
<td><?php echo $t4Row['name']; ?><?php if ($t4Row['orphan']) echo ' <b style="color:#b91c1c;">(orphan itemid ' . (int) $t4Row['itemid'] . ')</b>'; ?></td>
<td><?php echo $t4SlotNames[(int) $t4Row['slot']] ?? (int) $t4Row['slot']; ?></td>
<td><?php echo (int) $t4Row['quantity']; ?></td>
<td><?php echo $t4Row['equipped'] ? 'yes' : '-'; ?></td>
<td>
<form action="../GameEngine/Admin/Mods/editHeroT4.php" method="POST" style="margin:0;"
onsubmit="return confirm('Delete this item row permanently?');">
<?php echo csrf_field(); ?>
<input type="hidden" name="t4admin" value="delitem">
<input type="hidden" name="uid" value="<?php echo $id; ?>">
<input type="hidden" name="rowid" value="<?php echo (int) $t4Row['id']; ?>">
<button type="submit" class="t4a-btn danger">Delete</button>
</form>
</td>
</tr>
<?php } ?>
</table>
<?php } else { ?>No items.<?php } ?>
</div>
</div>
<div class="t4a-card">
<h3>Open auctions by this player (<?php echo count($t4Sales); ?>) / bids (<?php echo count($t4Bids); ?>)</h3>
<div class="body">
<?php if (count($t4Sales) || count($t4Bids)) { ?>
<table class="t4a-table">
<tr><th>Auction</th><th>Role</th><th>Item</th><th>Price</th><th>Ends</th><th></th></tr>
<?php foreach ([['rows' => $t4Sales, 'role' => 'seller'], ['rows' => $t4Bids, 'role' => 'top bidder']] as $t4Group) { ?>
<?php foreach ($t4Group['rows'] as $t4A) { ?>
<tr>
<td>#<?php echo (int) $t4A['id']; ?></td>
<td><?php echo $t4Group['role']; ?></td>
<td><?php echo $t4A['name']; ?> (<?php echo (int) $t4A['quantity']; ?>x)</td>
<td><?php echo number_format((int) $t4A['silver_current']); ?></td>
<td><?php echo date('d.m H:i', (int) $t4A['time_end']); ?></td>
<td>
<form action="../GameEngine/Admin/Mods/editHeroT4.php" method="POST" style="margin:0;"
onsubmit="return confirm('Cancel this auction? Bidder is refunded, item returns to the seller.');">
<?php echo csrf_field(); ?>
<input type="hidden" name="t4admin" value="cancelauction">
<input type="hidden" name="uid" value="<?php echo $id; ?>">
<input type="hidden" name="aucid" value="<?php echo (int) $t4A['id']; ?>">
<button type="submit" class="t4a-btn danger">Cancel</button>
</form>
</td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php } else { ?>No open auction involvement.<?php } ?>
</div>
</div>
<div class="t4a-card">
<h3>Adventures</h3>
<div class="body">
<?php if ($t4Running) { ?>
<p><b>Running:</b> adventure #<?php echo (int) $t4Running['id']; ?>,
difficulty <?php echo (int) $t4Running['difficulty'] === 1 ? 'hard' : 'normal'; ?>,
arrives <?php echo date('d.m H:i:s', (int) $t4Running['endtime']); ?> (do not delete running adventures).</p>
<?php } ?>
<?php if (count($t4Offers)) { ?>
<table class="t4a-table">
<tr><th>Offer</th><th>Difficulty</th><th>Duration</th><th>Expires</th><th></th></tr>
<?php foreach ($t4Offers as $t4O) { ?>
<tr>
<td>#<?php echo (int) $t4O['id']; ?></td>
<td><?php echo (int) $t4O['difficulty'] === 1 ? 'hard' : 'normal'; ?></td>
<td><?php echo gmdate('H:i:s', (int) $t4O['duration']); ?></td>
<td><?php echo date('d.m H:i', (int) $t4O['expire']); ?></td>
<td>
<form action="../GameEngine/Admin/Mods/editHeroT4.php" method="POST" style="margin:0;">
<?php echo csrf_field(); ?>
<input type="hidden" name="t4admin" value="deladventure">
<input type="hidden" name="uid" value="<?php echo $id; ?>">
<input type="hidden" name="advid" value="<?php echo (int) $t4O['id']; ?>">
<button type="submit" class="t4a-btn danger">Remove</button>
</form>
</td>
</tr>
<?php } ?>
</table>
<?php } else { ?>No available offers.<?php } ?>
</div>
</div>
+11
View File
@@ -232,6 +232,17 @@ if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
<option value="False" <?php if(!defined('NEW_FUNCTIONS_MEDAL_RESET') || NEW_FUNCTIONS_MEDAL_RESET == false) echo "selected";?>>False</option>
</select>
</td>
</tr>
<tr>
<td class="b">T4 Hero (items, adventures, auction) <em class="tooltip">?<span class="classic">Enable (Disable) the "T4 Hero (items, adventures, auction)" System</span></em>
<?php if (!defined('NEW_FUNCTIONS_HERO_T4')): ?><br><span style="color:#c0392b;font-size:11px;font-weight:normal;text-transform:none;">Not present in config.php yet &mdash; saving this form once will add it (defaults to False until then).</span><?php endif; ?>
</td>
<td>
<select name="new_functions_hero_t4">
<option value="True" <?php if(defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4 == true) echo "selected";?>>True</option>
<option value="False" <?php if(!defined('NEW_FUNCTIONS_HERO_T4') || NEW_FUNCTIONS_HERO_T4 == false) echo "selected";?>>False</option>
</select>
</td>
</tr>
</tbody>
</table>
+1 -1
View File
@@ -173,7 +173,7 @@ body{margin:0;background:#f1f5f9;font-family:system-ui,-apple-system,Segoe UI,Ro
<?php
if ($criteria!= "") {
$artifactsEffect = ['-', VILLAGE_EFFECT, ACCOUNT_EFFECT, UNIQUE_EFFECT];
$array_tribe = ['-', TRIBE1, TRIBE2, TRIBE3, TRIBE4, TRIBE5, TRIBE6];
$array_tribe = ['-', TRIBE1, TRIBE2, TRIBE3, TRIBE4, TRIBE5];
$q = "SELECT v.wref, v.owner, v.name, v.capital, v.pop, u.username, u.tribe, u.access, w.x, w.y"
. ($includeSize? ", a.size" : "")
. " FROM ".TB_PREFIX."vdata AS v"
+5
View File
@@ -109,6 +109,11 @@ if ($hero !== false) {
<a class="hero-icon edit" href='admin.php?p=editHero&uid=<?php echo $id; ?>&amp;hid=<?php echo $h['heroid'] ?>' title="Edit">
<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>
</a>
<?php if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4) { ?>
<a class="hero-icon edit" href='admin.php?p=editHeroT4&uid=<?php echo $id; ?>' title="T4 items / silver / auctions">
<svg viewBox="0 0 24 24"><path d="M6 2l1.5 4h9L18 2"/><path d="M4 6h16l-2 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L4 6z"/></svg>
</a>
<?php } ?>
<a class="hero-icon kill" href='?action=killHero&uid=<?php echo $id; ?>' title="Kill">
<svg viewBox="0 0 24 24"><path d="M3 6h18M8 6V4h8v2m-1 0v14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V6h10z"/></svg>
</a>
+11 -1
View File
@@ -91,7 +91,7 @@ function admin_validated_page(string $raw): string
'editExtraSet', 'editAdminInfo', 'resetServer', 'player', 'editUser',
'deletion', 'Newmessage', 'editPlus', 'editSitter', 'editPassword',
'editProtection', 'editOverall',
'editWeek', 'userlogin', 'userillegallog', 'editHero', 'editAdditional',
'editWeek', 'userlogin', 'userillegallog', 'editHero', 'editHeroT4', 'editAdditional',
'village', 'editResources', 'addTroops', 'addABTroops', 'editVillage',
'villagelog', 'techlog', 'msg',
'alliance', 'editAli', 'delAli','editNewFunctions',
@@ -433,6 +433,16 @@ if ($page !== '') {
}
break;
case 'editHeroT4':
$uid = admin_input_id($_GET, 'uid');
if ($uid !== null) {
$user = $database->getUserArray($uid, 1);
$subpage = 'T4 Hero Controls (' . e($user['username']) . ')';
} else {
$subpage = 'T4 Hero Controls';
}
break;
case 'editAdditional':
$uid = admin_input_id($_GET, 'uid');
if ($uid !== null) {