-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add itemlink module #372
Open
vstumpf
wants to merge
2
commits into
rathena:master
Choose a base branch
from
vstumpf:feature/itemlink
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add itemlink module #372
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
if (!defined('FLUX_ROOT')) exit; | ||
|
||
require_once 'Flux/TemporaryTable.php'; | ||
|
||
// change this to your packetver | ||
// values stolen from rathena, so if it doesnt work you might need to change it | ||
$packetver = 20200724; | ||
|
||
if ($packetver >= 20200724) { | ||
$cardsep = ')'; | ||
$optsep = '+'; | ||
$optparamsep = ','; | ||
$optvalsep = '-'; | ||
} else if ($packetver >= 20161116) { | ||
$cardsep = '('; | ||
$optsep = '*'; | ||
$optparamsep = '+'; | ||
$optvalsep = ','; | ||
} | ||
|
||
|
||
$itemlink = $params->get('itemlink'); | ||
|
||
$itemlink_len = strlen($itemlink); | ||
|
||
// get substring 5 characters | ||
$ret = $this->parseBase62Until($itemlink, 0, 5); | ||
$equip = $ret[0]; | ||
$idx = $ret[1]; | ||
|
||
$isequip = substr($itemlink, 5, 1); | ||
|
||
$idx = 6; | ||
|
||
// nameid | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$nameid = $ret[0]; | ||
$idx = $ret[1]; | ||
|
||
if ($server->isRenewal) { | ||
$fromTables = array("{$server->charMapDatabase}.item_db_re", "{$server->charMapDatabase}.item_db2_re"); | ||
} else { | ||
$fromTables = array("{$server->charMapDatabase}.item_db", "{$server->charMapDatabase}.item_db2"); | ||
} | ||
$tableName = "{$server->charMapDatabase}.items"; | ||
$tempTable = new Flux_TemporaryTable($server->connection, $tableName, $fromTables); | ||
$itemDescTable = Flux::config('FluxTables.ItemDescTable'); | ||
|
||
$sql = "SELECT items.id AS item_id, name_english AS name, slots "; | ||
|
||
if (Flux::config('ShowItemDesc')) { | ||
$sql .= ', itemdesc '; | ||
} | ||
|
||
$sql .= "FROM {$server->charMapDatabase}.items "; | ||
if (Flux::config('ShowItemDesc')) { | ||
$sql .= "LEFT OUTER JOIN {$server->charMapDatabase}.$itemDescTable ON $itemDescTable.itemid = items.id "; | ||
} | ||
$sql .= "WHERE items.id = ? LIMIT 1"; | ||
|
||
$sth = $server->connection->getStatement($sql); | ||
$sth->execute(array($nameid)); | ||
|
||
$item = $sth->fetch(); | ||
|
||
if (!$item) { | ||
return; | ||
} | ||
|
||
$title = "Viewing Item Link for ($item->name)"; | ||
|
||
|
||
// refines | ||
if ($itemlink[$idx] == '%') { | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$refine = $ret[0]; | ||
$idx = $ret[1]; | ||
} else { | ||
$refine = 0; | ||
} | ||
|
||
// view | ||
if ($itemlink[$idx] == '&') { | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$view = $ret[0]; | ||
$idx = $ret[1]; | ||
} else { | ||
$view = 0; | ||
} | ||
|
||
// enchantgrade | ||
if ($itemlink[$idx] == '\'') { | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$enchantgrade = $ret[0]; | ||
$idx = $ret[1]; | ||
} else { | ||
$enchantgrade = 0; | ||
} | ||
|
||
// cards | ||
$cards = []; | ||
while ($idx < $itemlink_len && $itemlink[$idx] == $cardsep) { | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
|
||
$sth = $server->connection->getStatement($sql); | ||
$sth->execute(array($ret[0])); | ||
$card = $sth->fetch(); | ||
$cards[] = $card; | ||
|
||
$idx = $ret[1]; | ||
} | ||
|
||
// options | ||
$options = []; | ||
while ($idx < $itemlink_len && $itemlink[$idx] == $optsep) { | ||
$option = []; | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$option['opt'] = $ret[0]; | ||
$idx = $ret[1]; | ||
if ($itemlink[$idx] != $optparamsep) { | ||
break; | ||
} | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$option['param'] = $ret[0]; | ||
$idx = $ret[1]; | ||
if ($itemlink[$idx] != $optvalsep) { | ||
break; | ||
} | ||
$idx++; | ||
$ret = $this->parseBase62Until($itemlink, $idx); | ||
$option['val'] = $ret[0]; | ||
$idx = $ret[1]; | ||
array_push($options, $option); | ||
} | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php if (!defined('FLUX_ROOT')) exit; ?> | ||
|
||
<?php if ($item): ?> | ||
<?php $icon = $this->iconImage($nameid); ?> | ||
<?php $image = $this->itemImage($nameid) ?> | ||
|
||
<table class="vertical-table"> | ||
<tr> | ||
<th colspan="<?php echo $image && $icon ? 1 : (($image || $icon) ? 2 : 3) ?>"> Item </th> | ||
<?php if ($icon): ?> | ||
<th><img src="<?php echo $icon ?>" /></td> | ||
<?php endif ?> | ||
<?php if ($image): ?> | ||
<td rowspan="<?php echo $isequip ? 4 : 3 ?>" style="width: 150px; text-align: center; vertical-alignment: middle"> | ||
<img src="<?php echo $image ?>" /> | ||
</td> | ||
<?php endif ?> | ||
</tr> | ||
<tr> | ||
<th> Name </th> | ||
<td> | ||
<?php $itemname = $item->name . ($isequip ? " [$item->slots]" : "") ?> | ||
<?php echo $this->linkToItem($nameid, $itemname) ?> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th> Item ID </th> | ||
<td> <?php echo htmlspecialchars($nameid) ?> </td> | ||
</tr> | ||
<tr> | ||
<th> Refine </th> | ||
<td> +<?php echo htmlspecialchars($refine) ?> </td> | ||
</tr> | ||
<?php if (Flux::config('ShowItemDesc')):?> | ||
<tr> | ||
<th> Description </th> | ||
<td> <?php echo htmlspecialchars($item->itemdesc) ?> </td> | ||
</tr> | ||
<?php endif ?> | ||
<?php if ($isequip): ?> | ||
<tr> | ||
<th colspan="<?php echo $image ? 4 : 3 ?>"> Slots </th> | ||
</tr> | ||
<?php foreach(range(1, 4) as $i): ?> | ||
<tr> | ||
<th> Slot <?php echo $i ?> </th> | ||
<?php if (count($cards) >= $i && $cards[$i - 1]): ?> | ||
<td class="display:flex, align-items: center; justify-content: center"><img src="<?php echo $this->iconImage($cards[$i - 1]->item_id) ?>" /></td> | ||
<td colspan="<?php echo $image ? 4 : 3 ?>"> | ||
<?php echo $this->linkToItem($cards[$i - 1]->item_id, $cards[$i - 1]->name) ?> | ||
</td> | ||
<?php elseif ($item->slots >= $i): ?> | ||
<td class="display:flex, align-items: center; justify-content: center"><img src="<?php echo $this->themePath('itemlink/emptysocket.png') ?>" /></td> | ||
<td><span class="not-applicable">Empty</span></td> | ||
<?php else: ?> | ||
<td class="display:flex, align-items: center; justify-content: center"><img src="<?php echo $this->themePath('itemlink/nosocket.png') ?>" /></td> | ||
<td><span class="not-applicable">None</span></td> | ||
<?php endif ?> | ||
<?php endforeach ?> | ||
<?php if (count($options) > 0): ?> | ||
<tr> | ||
<th colspan="<?php echo $image ? 4 : 3 ?>"> Options </th> | ||
</tr> | ||
<?php foreach(range(1, 5) as $i): ?> | ||
<?php if (count($options) >= $i && $options[$i - 1]): ?><tr> | ||
<td colspan="<?php echo $image ? 4 : 3 ?>"> | ||
<?php echo htmlspecialchars($this->itemRandOption($options[$i - 1]['opt'], $options[$i - 1]['val'])) ?> | ||
</td> | ||
</tr> | ||
<?php endif ?> | ||
<?php endforeach ?> | ||
<?php endif ?> | ||
<?php endif ?> | ||
</table> | ||
|
||
<?php else: ?> | ||
<p>Item not found</p> | ||
<?php endif ?> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can images go into the img/ dir please? |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can images go into the img/ dir please?