DogeEnricoDandolo
King
- Joined
- Dec 29, 2017
- Messages
- 932
I didn't play on an island map, I have lots of huge cities right next to my capital.The requirements seem to be related to size and location - when on island maps if my capital was the only settlement on its island than I got no choices, when I had 2 other settlements on my island they were both options.
not sure that is the right word... even if it is technically correct.The game only lets you move the capital to the same landmass, I also think population is a factor, there's deffniately logic in how they get picked.
What?not sure that is the right word... even if it is technically correct.
The "logic" seems both unpredictable and largely irrelevant. I'm sure it's there but it's poorly documented enough to be considered a bug.What?
function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}
And the logic of that is not made apparent to the Player anywhere, instead as far as they can tell randomly get some number (including 0) of capital switching options... basically its a bug.Spoiler Code :
function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}
This is the code for determining what gets chosen as the options for capital.
Cool. In short it cycles through all settlements ordered by population and picks first 2 which are connected by land with the current capital. Pretty simple.Spoiler Code :
function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}
This is the code for determining what gets chosen as the options for capital.
Connections are probably bugged, but the rest is not a bug, its incomplete documentation. Other than potential connection issue the code clearly should work as intended.And the logic of that is not made apparent to the Player anywhere, instead as far as they can tell randomly get some number (including 0) of capital switching options... basically its a bug.
(and the fact that it is partially based on connections makes it even worse since connections are bugged even worse)
What language is that?Spoiler Code :
function changeCapitalCards(iPlayer) {
const capitalOptions = 2;
const player = Players.get(iPlayer);
let playerSettlements = player?.Cities?.getCityIds();
let currentPlayerCapitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const currentPlayerCapital = player?.Cities?.getCapital();
if (currentPlayerCapital != null) {
currentPlayerCapitalName = currentPlayerCapital.name;
}
if (player != null && playerSettlements != null) {
playerSettlements = playerSettlements.sort((a, b) => {
const popA = Cities.get(a)?.population;
const popB = Cities.get(b)?.population;
if (popA == null)
return 1;
if (popB == null)
return -1;
return popB - popA;
});
let capitalName = "LOC_ERROR_NO_CAPITAL_NAME";
const civ = GameInfo.Civilizations.lookup(player.civilizationType);
if (civ != null) {
capitalName = civ.CapitalName;
}
let cardsGenerated = 0;
for (let i = 0; i < playerSettlements.length && cardsGenerated < capitalOptions; i++) {
const settlement = Cities.get(playerSettlements[i]);
if (settlement != null) {
if (!settlement.isCapital && settlement.Trade != null && settlement.Trade.isConnectedToOwnersCapitalByLand()) {
let card = {
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
name: "LOC_CARD_AT_CHANGE_CAPITAL",
description: "LOC_CARD_AT_CHANGE_CAPITAL_DESCRIPTION\\" + settlement.name + "\\" + capitalName + "\\" + currentPlayerCapitalName,
tooltip: "",
iconOverride: "",
limitID: "CARD_AT_CHANGE_CAPITAL_0",
individualLimit: 1,
groupLimit: 1,
categorySortOrder: 100,
cost: [
{ category: CardCategories.CARD_CATEGORY_WILDCARD, value: 0 }
],
effects: [{
id: "CARD_AT_CHANGE_CAPITAL_" + cardsGenerated,
type: "CARD_AT_CHANGE_CAPITAL",
name: "",
description: "",
amount: 1,
special: 0,
metadata: {
Type: DynamicCardTypes.Capital,
SettlementId: settlement.id.id
}
}],
aiModifierLists: []
};
Players.AdvancedStart.get(iPlayer)?.addDynamicAvailableCard(card);
cardsGenerated += 1;
}
}
}
}
}
This is the code for determining what gets chosen as the options for capital.
I'm also unsure if the Trade pointer is a generic manager (like GetPlayerTechs() ) or if it's a city connection pointer, haven't verified.Connections are probably bugged, but the rest is not a bug, its incomplete documentation. Other than potential connection issue the code clearly should work as intended.
Yes, I'm surprised you can change this if you want, it's nice.Cool. In short it cycles through all settlements ordered by population and picks first 2 which are connected by land with the current capital. Pretty simple.
Also it's good to see those things fully exposed for modding.
I believe it's JavaScript? All UIs and scripts use this, the entire logic for the age transition is now located in a file you can modify.What language is that?
Interesting. I thought it was JavaScript myself checked by the AI and it told me the same thing. I myself without the AI couldn't believe it but I guess it is.I believe it's JavaScript? All UIs and scripts use this, the entire logic for the age transition is now located in a file you can modify.
They dropped Lua for 7, and use JS (at least I think it's JavaScript, I extrapolated that through the js file extension)Interesting. I thought it was JavaScript myself checked by the AI and it told me the same thing. I myself without the AI couldn't believe it but I guess it is.
That's understandable as there are much more JS programmers than people knowing Lua - this affects both hiring process for the company itself and modding accessibility. However, from performance point of view Lua is better as it's specifically designed to be the scripting language.They dropped Lua for 7, and use JS (at least I think it's JavaScript, I extrapolated that through the js file extension)