connect_errno) {
$output = "Connect failed: " . $mysqli->connect_error;
}
else {
$query = "SELECT * FROM civbe_virtues ORDER BY id ASC";
if ($virtues = $mysqli->query($query)) {
$query = "SELECT * FROM civbe_synergies ORDER BY id ASC";
if ($synergies = $mysqli->query($query)) {
$output = apDisplayVirtuePicker($virtues,$synergies);
$synergies->free();
}
/* free result set */
$virtues->free();
}
}
$mysqli->close();
//file_put_contents($file, $output);
}
else
$output = file_get_contents($file);
return $output;
function apDisplayVirtuePicker($virtues, $synergies) {
$width = 1006;
$height = 653;
$treeWidth = 230;
$tierHeight = 182;
$firstX = 119;
$firstY = 114;
$firstTopSynergyX = 115;
$firstTopSynergyY = 69;
$firstSideSynergyX = 44;
$firstSideSynergyY = 94;
$synergyX = 75;
$synergyY = 9;
$normalX = 60;
$normalY = 62;
$virtueWidth = 45;
$virtueHeight = 43;
$synergyWidth = 24;
$synergyHeight = 24;
$firstTierCounterY = 105;
$firstTierCounterX = 70;
$tierCounterHeight = 9;
$tierCounterWidth = 16;
$tierHeight = 182;
$tierWidth = 16;
$tierGap = 3;
$firstCatCounterX = 89;
$firstCatCounterY = 95;
$catCounterWidth = 15;
$catCounterHeight = 11;
$catWidth = 225;
$catHeight = 11;
$catGap = 5;
$output = '
';
//$virtuesEnabled = array();
$virtuesLeadTo = array();
$virtuesPrereq = array();
$virtuesLookup = array();
$virtueOutput = '';
while ($virtue = $virtues->fetch_assoc()) {
//$virtuesEnabled['virtue' . $virtue['id']] = $virtue['enabled'];
$virtuesLeadTo['virtue' . $virtue['id']] = $virtue['enables'];
$virtuesPrereq['virtue' . $virtue['id']] = $virtue['prereqs'];
$virtuesLookup[$virtue['virtue']] = 'virtue' . $virtue['id'];
$category = strtolower($virtue['cat']);
if($category === 'might')
$tree = 0;
else if($category === 'prosperity')
$tree = 1;
else if($category === 'knowledge')
$tree = 2;
else if($category === 'industry')
$tree = 3;
if($virtue['tier'] === '3')
$tierClass = ' tier3';
else if($virtue['tier'] === '2')
$tierClass = ' tier2';
else if($virtue['tier'] === '1')
$tierClass = ' tier1';
else
$tierClass = '';
$treeOffset = $firstX + ($tree * $treeWidth);
$tierOffset = $firstY + (($virtue['tier'] - 1) * $tierHeight);
$xPos = $treeOffset + (($virtue['col'] - 1) * $normalX);
$yPos = $tierOffset + (($virtue['row'] - ((($virtue['tier'] - 1) * 3)) - 1) * $normalY);
//echo $virtue['virtue'] . ' yPos(' . $yPos . '): toff(' . $tierOffset . ') + (row(' . $virtue['row'] . ') - (((tier(' . $tierOffset . ' - 1) * 3)) - 1) * normalY(' . $normalY . ')
'; if($virtue['num'] === '1') $isEnabled = ' class="glowBorderEnabled"'; else $isEnabled = ''; $virtueOutput .= ' '; } $synergyOutput = ''; while ($synergy = $synergies->fetch_assoc()) { $type = strtolower($synergy['type']); if($type === 'tier') $num = $synergy['tier']; else $num = ''; $yPos = $firstTopSynergyY; if($type === 'tier') { $xPos = $firstSideSynergyX; $yPos = $firstSideSynergyY + (($synergy['tier'] - 1) * ($tierHeight + 2)) + (($synergy['num'] - ($synergy['virtues'] / 2)) * $synergyY); } else if ($type === 'might') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX); } else if ($type === 'prosperity') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + $treeWidth; } else if ($type === 'knowledge') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + (2 * $treeWidth); } else if ($type === 'industry') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + (3 * $treeWidth); } if($synergy['tier'] == 3) $tierClass = ' tier3'; else $tierClass = ''; $synergyOutput .= ' '; } $output .= '
';
$output .= $virtueOutput . $synergyOutput . '
';
return $output;
}
function apConvertLeadsTo($array,$lookup) {
$newArray = array();
foreach($array as $key => $val) {
if($val != '') {
$virtues = explode(',',$val);
$newArray[$key] = '';
$comma = '';
foreach($virtues as $virtue) {
$newArray[$key] .= $comma . $lookup[$virtue];
$comma = ',';
}
}
else {
$newArray[$key] = '';
}
}
return apArrayToJsArray($newArray);
}
function apArrayToJsArray($array) {
$output = '{';
$comma = '';
foreach($array as $key => $val) {
$output .= $comma . "'" . $key . "': '" . $val . "'";
$comma = ', ';
}
$output .= '};';
return $output;
}
function apBaseUrl() {
return 'http://cache.apolyton.net/';
//return 'http://127.0.0.1/apolyton.net/';
}
?>
Features:
- Culture Counters for Total and Next Cost.
- Synergy counters keep track of progress towards synergies
- Number overlay keeps track of the order of virtues picked
- Hover text provides Virtue information
- Highlight (Chrome, Opera) and glowing borders (All) for Virtues selected.
- Highlight for Virtues with prerequisites selected. (Chrome, Opera)
- Highlight for Synergies reached. (Chrome, Opera)
- Responsive to theme width at page load. (Not all cases)
In the Works:
- Hover text formatting as in-game.
- Text output of choices.
- Firefox and Internet Explorer compatibility.
- Fully responsive design.
- Embedding for 3rd party sites.
- Screencapture and image link.
- Social sharing options.
... and more
'; if($virtue['num'] === '1') $isEnabled = ' class="glowBorderEnabled"'; else $isEnabled = ''; $virtueOutput .= ' '; } $synergyOutput = ''; while ($synergy = $synergies->fetch_assoc()) { $type = strtolower($synergy['type']); if($type === 'tier') $num = $synergy['tier']; else $num = ''; $yPos = $firstTopSynergyY; if($type === 'tier') { $xPos = $firstSideSynergyX; $yPos = $firstSideSynergyY + (($synergy['tier'] - 1) * ($tierHeight + 2)) + (($synergy['num'] - ($synergy['virtues'] / 2)) * $synergyY); } else if ($type === 'might') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX); } else if ($type === 'prosperity') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + $treeWidth; } else if ($type === 'knowledge') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + (2 * $treeWidth); } else if ($type === 'industry') { $xPos = $firstTopSynergyX + (($synergy['tier'] - 1) * $synergyX) + (3 * $treeWidth); } if($synergy['tier'] == 3) $tierClass = ' tier3'; else $tierClass = ''; $synergyOutput .= ' '; } $output .= '
Total:
0
Next:
20
Features:
- Culture Counters for Total and Next Cost.
- Synergy counters keep track of progress towards synergies
- Number overlay keeps track of the order of virtues picked
- Hover text provides Virtue information
- Highlight (Chrome, Opera) and glowing borders (All) for Virtues selected.
- Highlight for Virtues with prerequisites selected. (Chrome, Opera)
- Highlight for Synergies reached. (Chrome, Opera)
- Responsive to theme width at page load. (Not all cases)
In the Works:
- Hover text formatting as in-game.
- Text output of choices.
- Firefox and Internet Explorer compatibility.
- Fully responsive design.
- Embedding for 3rd party sites.
- Screencapture and image link.
- Social sharing options.
... and more
Comment