stable
This commit is contained in:
parent
872a70ad8a
commit
8f06f025e8
2 changed files with 190 additions and 39 deletions
42
render.js
42
render.js
|
|
@ -36,12 +36,19 @@ const v = clamp(w.resource[i] / 30, 0, 1);
|
|||
color = mix([28, 36, 40], [107, 188, 85], v);
|
||||
} else if (mode === "ethnicity") {
|
||||
color = terrainInfo[w.terrain[i]].color;
|
||||
const dominant = w.dominantEthnicity?.[i] ?? -1;
|
||||
const ethnicityColor = dominant >= 0 ? sim.ethnicities.get(dominant)?.color : null;
|
||||
if (ethnicityColor) {
|
||||
const populationStrength = clamp(Math.sqrt(Math.max(0, w.population?.[i] || w.pressure[i] || 0)) / 16, 0.18, 0.68);
|
||||
const diversityDimming = clamp(w.cultureDiversity?.[i] || 0, 0, 1) * 0.18;
|
||||
color = mix(color, ethnicityColor, clamp(populationStrength - diversityDimming, 0.12, 0.64));
|
||||
const ethnicMix = sim.tileEthnicMix?.get(i);
|
||||
const population = w.population?.[i] || 0;
|
||||
if (ethnicMix && ethnicMix.size && population >= 0.25) {
|
||||
const dominant = dominantComposition(ethnicMix);
|
||||
const ethnicityColor = dominant != null ? sim.ethnicities.get(dominant)?.color : null;
|
||||
const total = compositionTotal(ethnicMix);
|
||||
if (ethnicityColor && Number.isFinite(total) && total > 0) {
|
||||
const dominantShare = (ethnicMix.get(dominant) || 0) / total;
|
||||
const popStrength = clamp(Math.log1p(population) / Math.log(80), 0.05, 0.72);
|
||||
const purity = clamp(dominantShare, 0.25, 1);
|
||||
const strength = clamp(popStrength * (0.45 + purity * 0.55), 0.04, 0.72);
|
||||
color = mix(color, ethnicityColor, strength);
|
||||
}
|
||||
}
|
||||
if (w.city[i] >= 0) {
|
||||
const city = sim.getCityById(w.city[i]);
|
||||
|
|
@ -175,10 +182,23 @@ const y = Math.floor(campaign.targetTile / w.size);
|
|||
const age = Math.max(0, sim.year - campaign.started) / Math.max(1, campaign.expires - campaign.started);
|
||||
const pulse = 0.5 + Math.sin(age * Math.PI * 8) * 0.5;
|
||||
const radius = 2.5 + clamp(campaign.progress, 0, 1) * 4 + pulse * 1.5;
|
||||
if (campaign.type === "border_war" && campaign.affectedTiles?.length) {
|
||||
ctx.globalAlpha = 0.10 + clamp(campaign.progress, 0, 1) * 0.10;
|
||||
ctx.fillStyle = "rgba(164, 76, 58, 0.9)";
|
||||
for (const tile of campaign.affectedTiles) {
|
||||
ctx.fillRect(tile % w.size, Math.floor(tile / w.size), 1, 1);
|
||||
}
|
||||
}
|
||||
ctx.globalAlpha = 0.55;
|
||||
ctx.strokeStyle = campaign.type === "border_war" ? "rgba(236, 126, 111, 0.95)" : "rgba(239, 211, 119, 0.95)";
|
||||
ctx.lineWidth = 1;
|
||||
strokeCircle(ctx, x + 0.5, y + 0.5, radius);
|
||||
strokeCircle(ctx, x + 0.5, y + 0.5, campaign.type === "border_war" ? radius + 2.5 : radius);
|
||||
if (campaign.type === "border_war" && campaign.targetCityId != null) {
|
||||
ctx.globalAlpha = 0.82;
|
||||
ctx.lineWidth = 1.4;
|
||||
ctx.strokeStyle = "rgba(255, 195, 121, 0.95)";
|
||||
strokeCircle(ctx, x + 0.5, y + 0.5, radius + 5 + pulse * 2);
|
||||
}
|
||||
ctx.globalAlpha = 0.22;
|
||||
ctx.fillStyle = campaign.type === "nonstate_subjugation" ? "rgba(180, 111, 73, 0.9)" : "rgba(239, 211, 119, 0.9)";
|
||||
fillSquare(ctx, x, y, 1);
|
||||
|
|
@ -319,7 +339,9 @@ const mismatch = agent ? sim.climateMismatch(agent.ethnicity, i) : 0;
|
|||
const polity = cityPolity(city);
|
||||
const territoryId = w.polity?.[i] ?? -1;
|
||||
const territoryPolity = territoryId >= 0 ? sim.getPolityById(territoryId) : null;
|
||||
const regionalEthnicity = w.dominantEthnicity[i] >= 0 ? `E${w.dominantEthnicity[i]}` : "-";
|
||||
const ethnicMix = sim.tileEthnicMix?.get(i);
|
||||
const tileDominantEthnicity = ethnicMix?.size ? dominantComposition(ethnicMix) : w.dominantEthnicity[i];
|
||||
const regionalEthnicity = tileDominantEthnicity != null && tileDominantEthnicity >= 0 ? `E${tileDominantEthnicity}` : "-";
|
||||
const tilePopulation = w.population?.[i] || 0;
|
||||
const nearbyCampaigns = activeCampaignsNear(i);
|
||||
els.tooltip.innerHTML = `
|
||||
|
|
@ -430,7 +452,9 @@ for (const campaign of sim.campaigns) {
|
|||
if (campaign.status !== "active" || campaign.targetTile == null) continue;
|
||||
const cx = campaign.targetTile % w.size;
|
||||
const cy = Math.floor(campaign.targetTile / w.size);
|
||||
if (Math.abs(cx - x) + Math.abs(cy - y) > 3) continue;
|
||||
const nearTarget = Math.abs(cx - x) + Math.abs(cy - y) <= 3;
|
||||
const nearFront = campaign.affectedTiles?.includes(tile);
|
||||
if (!nearTarget && !nearFront) continue;
|
||||
labels.push(`${campaign.type.replaceAll("_", " ")} ${Math.round(clamp(campaign.progress, 0, 1) * 100)}%`);
|
||||
}
|
||||
return labels.slice(0, 2).join("; ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue