yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.51k stars 1.57k forks source link

Duplicate Nations Stack... and that's not good. #4137

Closed Caballero-Arepa closed 1 year ago

Caballero-Arepa commented 3 years ago

If you activate 2 or more mods, which have the same nation, but different uniques, they will stack, making such nation overpowered, or at least with a lot of uniques.

An example is when you activate Rekmod and Latin American civs, there, Brazil, Argentina and Mexico will stack.

One solution is to have them separatedly. Let's imagine, when you have mods that have nations that would stack, they don't. So you select Mexico, and when selecting the nation, instead of showing directly the nation traits, it will show the different leaders, and when you select one, you can pick that leader and have the correspondent uniques. So if leader A is from rekmod, and leader B is from another mod; when you select leader A you will be playing with the mexico of rekmod, but if you pick leader B, you'll play the mexico of the other mod.

Now, there is a problem, and it is when both duplicate nations have the same leader, there I don't know at the moment what could be done.

Sorry if you don't understand me, I'll try to ilustrate it, or make any questions you want!

Caballero-Arepa commented 3 years ago

Ah, this can also serve for the future when civ 6 is implemeted.

Mape6 commented 3 years ago

What about a mod sequence? The mods could be loaded in a sequence which can be adjusted by the user. The last loaded mod would then overwrite the nation's from the loaded mods before. So in your example, if you load Rekmod and after that Latin American Civs, you will play Mexico from the last loaded mod. If you change the sequence and put Rekmod in the last position, you will play Mexico from that mod. This solves the problem with stacked uniques and same leader names.

ravignir commented 3 years ago

Ah, this can also serve for the future when civ 6 is implemeted

civ6 is not going to be implemented.

What about a mod sequence? The mods could be loaded in a sequence which can be adjusted by the user. The last loaded mod would then overwrite the nation's from the loaded mods before. So in your example, if you load Rekmod and after that Latin American Civs, you will play Mexico from the last loaded mod. If you change the sequence and put Rekmod in the last position, you will play Mexico from that mod. This solves the problem with stacked uniques and same leader names.

yes, but what about the mod that wants to add new things to existing nations or modify them?.

Mape6 commented 3 years ago

yes, but what about the mod that wants to add new things to existing nations or modify them?.

The modder should then copy the nations information from Unciv into their mod and change, what they want. Then you have the original nation with new or changes attributes.

yairm210 commented 3 years ago

I understand the problem. The problem is that the nation objects override each other, but the buildings and units - which have different names - remain.

The way I can see to deal with this problem is v if there's a mod that 'adds' a nation, we will remove all unique buildings and units before adding the nation, so the last remaining will 'win'.

Caballero-Arepa commented 3 years ago

if there's a mod that 'adds' a nation, we will remove all unique buildings and units before adding the nation, so the last remaining will 'win'.

I don't understand very well.

ravignir commented 3 years ago

That is no a perfect solution, because there are mods that replace nations unique only. What about having some sort of option in ModOptions.json that will allow the mod creator to decide what to do?

Caballero-Arepa commented 3 years ago

What if you do as what I said, but instead of showing the leaders, you show the mod from which the nation comes. For example: Mexico: - From Mod1 -From Mod2

yairm210 commented 3 years ago

I don't think you understand, there can't be more than 1 Mexico per game.

yairm210 commented 3 years ago

That goes against the entire way the game is built.

Caballero-Arepa commented 3 years ago

Ok then, so after you pick one, you have chosen that Mexico and no other player can be Mexico. So if I select mexico from mod-2, that Mexico will get chosen to play, and the other mexico from mod-1 will "dissappear", making it not possible to chose more than 1 Mexico.

SomeTroglodyte commented 3 years ago

I would patch CheckModLinksResult to recognize the situation and classify it as error. Do something to prevent multiple base ruleset mods being selected - is this already in or not? Do something to prevent non-base mods meant for vanilla to be used with, say, deciv Do something to prevent mods not suitable as "permanent visual" to be selected as such

Last two of these would probably require a mod author to provide a kind of compatibility list...? ModOptions.compatibleBaseRulesets -> could make isBaseRuleset obsolete, as equivalent to empty, and a compatibility check could automatically cover case 2. Suggested minimum and default = "Civ V - Vanilla".

Caballero-Arepa commented 3 years ago

I think the mod options thing would work, but it still doesnt resolve this specific issue...

SomeTroglodyte commented 3 years ago

still doesnt resolve

A rule "A specific nation can at most appear in one non-base ruleset mod in addition to 0-1 appearances in the selected base ruleset mod" would resolve this specific issue, which is what I meant with "patch CheckModLinksResult" - on the new game screen, you would select the second Mexico-overloading mod, the check would fail, you'd get a toast describing the rule violation, and the second mod stays deselected. You would know which other mod is blocking as the toast would tell you.

Caballero-Arepa commented 3 years ago

So if I want to play with Bolivia as well, I cant, because the mod is deselected due to a duplicate nation...

SomeTroglodyte commented 3 years ago

Well if you want to have Bolivia from mod 1 and Méjico from mod 2 in one game - no problem as long as mod 1 does not try to bring along another Méjico. In that case I'd ditch mod2 and go with mod 1's Mx, or hand-edit the mods locally, or get the mod authors to talk and resolve their diverging ideas for the ideal Mx... Hay muchas posibilidades.

Anyway, that's just my idea - easy conflict prevention.

freddyhayward commented 3 years ago

Why not pass the problem back to modders? Someone already made "Mexico"? Call yours "Mexicans", "{Leader}'s Mexico", "{username}'s Mexico", "United States of Mexico".

jahodovykolac commented 3 years ago

Or, a popup would show up saying "Civilization [name] already exists!", similar to non-existing units or terrains (e.g. older popup "Unit Composite Bowman doesn't exist in ruleset!")

Caballero-Arepa commented 3 years ago

So basically, if there are 2 mexicoss in 2 mods, the mexico from the first selected mod will be the one that will prevail and be playable? This is good, but it would get very complicated if there are more duplicate nations.

About the modder solving this problem, how could this be? Because, sure, you can just name "Estados Unidos de Mexico", but there would tecnically be 2 mexicos still.

SomeTroglodyte commented 3 years ago

"first selected mod" - yes but nothing prevents you from de-selecting that first and making the other "the first". And - the "name" property in the json is the primary key which will be unique in the running game's combined ruleset nations table no matter what. So - you rename the key to anything unique, you have a new unique nation. Translation results are a different matter. Technically you could do a mexico1 and a mexico2 in json then translate both to "Mexico" - even in English.properties - and they would be playable independently, no matter which if any other properties differ or not. Just remember properties like uniqueTo are foreign keys, so if you want to have all your mexicos to have the same unique building you'd have to pull the same trick for it.

Caballero-Arepa commented 3 years ago

yes but nothing prevents you from de-selecting that first and making the other "the first".

Exactly, that way I can choose what mexico I want.

Caballero-Arepa commented 3 years ago

21 sin título_20210623221231 This my original idea. Once you select one, mexico will desappear from the list and you cant play more than two mexicos.

SomeTroglodyte commented 3 years ago

This my original idea

While I agree the 'end user' might be delighted...

You're missing something: At that point the combined ruleset has already been built and must be. So, your two Mexicos would forcibly have different names to be distinct in their containing collection - I repeat these names are logical keys. And if you modify the names while the combined ruleset is built, maybe to literally what you show up there, colon and all, then getting all this to still translate properly under all possible circumstances gets to be a nightmare. And I think I could supply at least four to five complications of high complexity after your "select one", too lazy to explain (starting with what to do with foreign keys referencing those). Simpler is better - far simpler here please. See: KISS (and by 'please' I do not mean please better efforts on your part - I think we all get the issue, and one of these days someone will have a nice eureka moment - or the chuzpah to tackle this head-on)

Caballero-Arepa commented 3 years ago

Ah, I see and comprehend.

AdityaMH commented 3 years ago

And my suggestion is, Change nation selection to leader selection. If they have different leader name but same nation, they become splitted. If they have same leader name and nation or same leader name and different nation, one of them will be removed. Then make additional code first-tag and end-tag for each civ. That's make code easily detected to remove duplicate civ by leader name.

So, civ selection not sorted or choosed by nation but by leader name.

Civ6 As you can see, some mod on civ6 intentionally making duplicate nation with different leader name.

ravignir commented 3 years ago

same as in civ5. Nations are sorted by leaders.

yairm210 commented 3 years ago

May I remind you that Civ VI also has a leader who can lead two different nations. It's a whole mess, and I'm not dealing with that.

AdityaMH commented 3 years ago

May I remind you that Civ VI also has a leader who can lead two different nations. It's a whole mess, and I'm not dealing with that.

Let's see again my suggestion:

If they have different leader name but same nation, they become splitted.

And

If they have same leader name and nation or same leader name and different nation, one of them will be removed.

So, this very different from civ 6 civ's sorting. This only avoiding from stacking nation and n̶o̶t̶ e̶x̶p̶e̶c̶t̶e̶d̶ unexpected nation because using multiple mods.

ajustsomebody commented 3 years ago

May I remind you that Civ VI also has a leader who can lead two different nations. It's a whole mess, and I'm not dealing with that.

what about just adding different nations for every leader that just happen to share the same nation name??

like:

name: abc civ leader: a leader name: def civ leader: a leader

jahodovykolac commented 3 years ago

If I remember, in older versions, the list was not like France, Denmark, Germany etc., but Napoleon Bonaparte of France, Harald Bluetooth of Denmark, Otto von Bismarck of Germany etc. That could solve this problem, because you wouldn't choose a nation with a leader, not a leader leading a nation, but a combination of leader and nation.

ajustsomebody commented 3 years ago

yep, they should be added as (different nations in code) different nations with the same name but with different leaders and bonuses, what do you think @yairm210

SomeTroglodyte commented 3 years ago

C'mon guys, forget that. None of us is going to redesign key data structures that much in the foreseeable future. :dog2: :meat_on_bone: :persevere: ("a pack of dogs persevere in picking the meat off a carcass")

I'll code something when I have time to move some responsibility back to the modders, that should be enough. I'm thinking of a compatibility property in ModOptions.json, and unless that explicitly says otherwise, two nations with the same name (not counting vanilla ruleset) will simply not be allowed. You want it anyway, you fork the mod and do it yourself. Pondered the idea for a few weeks now and still think it's sound.

Leaving nation name technically as is and just fill it with "Evil Tyrant of Nowhere at all" - and leadername = "Evil Tyrant" - mod away, no problem. Once someone does that and complains where the leader name is duplicated in an offensive manner, we could consider patching the leader display code. Maybe not too shabby - I'll let the idea stew.

ajustsomebody commented 3 years ago

idea on how to fix some incompatibilities

say there are two mods using the same civilization name: they will be shown as for instance Iroquois (rekmod) and İroques (somemod) and when you select one the other(s) get de activated, so nobody can ever select them

another hypotatical situation would be that two mods using same civ name and same leader name, in which case the same conditions apply in the first one,

but say a mod1 adds 1 civ, 2 leaders and mod2 adds 1 civ 1 leader of the same civilization, in this case the ones with the same leader name should be blacked out if one is chosen, but the other leader name should stay as it is basically another civilization

ravignir commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

ajustsomebody commented 3 years ago

no idea

Caballero-Arepa commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

Then it should have a different name.

ravignir commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

Then it should have a different name.

Then there is no problem at all :D

ajustsomebody commented 3 years ago

so this could be implemented

xlenstra commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

Then it should have a different name.

True, but that would be the responsibility of the mod makers and we can't enforce that. If mod makers do make two nations with the same name, we still have this exact problem.

ajustsomebody commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

Then it should have a different name.

True, but that would be the responsibility of the mod makers and we can't enforce that. If mod makers do make two nations with the same name, we still have this exact problem.

just add leader (modname) or civilization (modname) to their names if there are more than 1 of the same civ

Caballero-Arepa commented 3 years ago

I still push for separating the nations, not by civ name, but by leader name.

xlenstra commented 3 years ago

But what if mod B adds extra things to a civ from mod A, which also exists in mod C, but is a completely different civ, so mod B is not supposed to affect it?

Then it should have a different name.

True, but that would be the responsibility of the mod makers and we can't enforce that. If mod makers do make two nations with the same name, we still have this exact problem.

just add leader (modname) or civilization (modname) to their names if there are more than 1 of the same civ

But then you can't have mods adding abilities to civilizations of other mods

xlenstra commented 3 years ago

I still push for separating the nations, not by civ name, but by leader name.

Then you would still have the same problem, but with leader names instead of civilization names

SomeTroglodyte commented 3 years ago

I say: If you shoot yourself in the knee, you've earned your pain. Mod and moron user problem, not an Unciv problem.

ajustsomebody commented 3 years ago

But then you can't have mods adding abilities to civilizations of other mods

just add a tag per civilization in nations.json "changesOriginalStats", dont know what happens if 2 mods try to change 1 mod though

Caballero-Arepa commented 3 years ago

But then you can't have mods adding abilities to civilizations of other mods

I dont think thats important nor used a lot.

Then you would still have the same problem, but with leader names instead of civilization names

But there are more leaders for a civ. There a re more leaders of Poland than Polands.

will-ca commented 3 years ago

The display name shouldn't be the internal ID. Mods that change existing civs, including civs from other mods, should deliberately use colliding IDs; Everything else should have a unique identifier that's separate from the displayed name.

ravignir commented 3 years ago

Yes, but what if two mods happen to use the same ID by accident?

ajustsomebody commented 3 years ago

Yes, but what if two mods happen to use the same ID by accident?

bro damn

xlenstra commented 3 years ago

Yes, but what if two mods happen to use the same ID by accident?

If we go this route, I would make this the responsibility of the modder, and throw an error when trying to load in two mods with nations with the same ID and different names.