Anacreon Source
-
- Militia Lieutenant
- Posts: 242
- Joined: Wed Aug 10, 2016 8:35 am
Out of curiosity, inspecting the Anacreon webpage: it appears that a lot of the Anacreon base functionality, barring the Core Library on Github, is implemented in Javascript files which can just be downloaded straight from the browser. I've attached them as a zip file here for others to peruse at their leisure.
- Attachments
-
- Anacreon_files.zip
- (138.11 KiB) Downloaded 645 times
-
- Militia Lieutenant
- Posts: 242
- Joined: Wed Aug 10, 2016 8:35 am
As the Era 4 update is approaching, I thought it might be useful to peek at the source to see how stuff is implemented and identify room for improvement/new features/bugfixes etc.
I've just had a quick skim through, as an interesting example we can see how map colors are currently implemented in this function here (from galacticmap.js):
There are two "styles" for drawing territory (the circular radii around worlds): friendly or enemy, being white or red respectively. In the Era 4 Discussion Thread people expressed that different empire colors would be a useful UI improvement, as not every other player is necessarily an enemy.
Perhaps we can introduce another style: neutralBounds with Highlight and Faded variants (when the sovereign is selected on the map). A var isNeutral can be set for every existing sovereign in the sovereignList, set to False if the player had ever attacked this sovereign in the past. There are already trackers for this stuff (see how the game tracks if a social order penalty is applied to larger empires attacking smaller ones unprovoked).
Other little things like this ticket on Ministry can be quickly resolved with a simple variable change. There are hundreds of such tickets highlghting small stuff (99% of them posted by our resident bug-archiver WTV) which can be relatively easily fixed.
Replace sovereign.capitalID with sovereign.NAME for instance.
Some extra info that's not displayed in game can also be viewed, such as the secession chance percentage (per cycle?) at each level (negligible, very low, moderate etc). Looks like it's between 10% and 20% for a "high" chance which is what I'm sitting on now. Imperial Guards do help but with over 1000 worlds that risk is going to be fairly high anyway.
I suppose the community could "assist" George with development in a sense, although we'd have to wait and see if he'd be open to this kind of thing. Transcendence is already very community-friendly what with mods and extensions etc, hopefully the same is true for Anacreon.
I've just had a quick skim through, as an interesting example we can see how map colors are currently implemented in this function here (from galacticmap.js):
Code: Select all
$GalacticMap.drawTerritory = function (mapMetrics, territory, style)
// style: The style to draw the territory. One of the following:
//
// friendlyBounds: Friendly empire boundary
// friendlyAdmin: Friendly administrative boundary
// enemyBounds: Enemy empire boundary
// enemyBoundsHighlight: Enemy empire boundary
// enemyBoundsFaded: Faded boundaries (when an empire is selected)
{
var i, j;
if (style == "friendlyBounds")
{
ctx.strokeStyle = $Style.mapFriendlyTerritory;
ctx.lineWidth = 2 * mapMetrics.adjWorldSize;
}
else if (style == "friendlyAdmin")
{
ctx.strokeStyle = $Style.mapFriendlyTerritory;
ctx.lineWidth = mapMetrics.adjWorldSize;
}
else if (style == "enemyBounds")
{
ctx.strokeStyle = $Style.mapEnemyTerritory;
ctx.lineWidth = 2 * mapMetrics.adjWorldSize;
}
else if (style == "enemyBoundsHighlight")
{
ctx.strokeStyle = $Style.mapEnemyTerritoryHighlight;
ctx.lineWidth = 2 * mapMetrics.adjWorldSize;
}
else if (style == "enemyBoundsFaded")
{
ctx.strokeStyle = $Style.mapEnemyTerritory;
ctx.lineWidth = 2 * mapMetrics.adjWorldSize;
ctx.globalAlpha = 0.5;
}
for (i = 0; i < territory.length; i++)
{
// Note: We still can't put all the arcs into a single outline
// because we can't tell when an outline group beings and ends.
ctx.beginPath();
var circle = territory[i];
var center = $GalacticMap.toMapXY(mapMetrics, circle[0], circle[1]);
var radius = $GalacticMap.toMapLength(mapMetrics, circle[2]);
if (circle.length == 3)
ctx.arc(center.x, center.y, radius, 0.0, 2 * Math.PI, true);
else
{
var startAngle = (2 * Math.PI - circle[3]);
var endAngle = (2 * Math.PI - circle[4]);
ctx.arc(center.x, center.y, radius, startAngle, endAngle, true);
}
ctx.stroke();
}
ctx.globalAlpha = 1.0;
}
Perhaps we can introduce another style: neutralBounds with Highlight and Faded variants (when the sovereign is selected on the map). A var isNeutral can be set for every existing sovereign in the sovereignList, set to False if the player had ever attacked this sovereign in the past. There are already trackers for this stuff (see how the game tracks if a social order penalty is applied to larger empires attacking smaller ones unprovoked).
Other little things like this ticket on Ministry can be quickly resolved with a simple variable change. There are hundreds of such tickets highlghting small stuff (99% of them posted by our resident bug-archiver WTV) which can be relatively easily fixed.
Code: Select all
$GalacticMap.drawSovereignName = function (mapMetrics, sovereign)
{
var capital = (sovereign.capitalID ? $Anacreon.objList[sovereign.capitalID] : null);
if (capital == null)
return;
Some extra info that's not displayed in game can also be viewed, such as the secession chance percentage (per cycle?) at each level (negligible, very low, moderate etc). Looks like it's between 10% and 20% for a "high" chance which is what I'm sitting on now. Imperial Guards do help but with over 1000 worlds that risk is going to be fairly high anyway.
Code: Select all
if (sovereign.secessionChance != null)
{
var chance;
if (sovereign.secessionChance == 0)
chance = "none";
else if (sovereign.secessionChance < 0.01)
chance = "negligible";
else if (sovereign.secessionChance < 0.02)
chance = "very low";
else if (sovereign.secessionChance < 0.05)
chance = "low";
else if (sovereign.secessionChance < 0.1)
chance = "elevated";
else if (sovereign.secessionChance < 0.2)
chance = "high";
else if (sovereign.secessionChance < 0.5)
chance = "very high";
else
chance = "certain";
paintLine("risk of secession", chance);
}