-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel the chain reaction of defense pact #12703
Conversation
…ct with other civilizations will no longer be chained.
.map { it.otherCiv() }) | ||
|
||
// Defensive pact chains are not allowed now | ||
var listIndex = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to have this by index instead of 'for civ in othercovdefensivepactlist'?
I know this was here before you, but if we can improve readability, why not :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we're doing indexing at all on a list and not using for ((index, civ) in otherCivDefensivePactList.withIndexed())
? Like, "withIndexed" is explicitly in the Kotlin library so we don't need to do while loops for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me there was - the list was modified within the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, but now it is no longer modified, so we can move to the more readable format
We don't even use the index anymore, just the civ
/* | ||
// Add their defensive pact allies | ||
otherCivDefensivePactList.addAll(otherCivDefensivePactList[listIndex].diplomacy.values | ||
.filter { diploChain -> diploChain.diplomaticStatus == DiplomaticStatus.DefensivePact | ||
&& !otherCivDefensivePactList.contains(diploChain.otherCiv()) | ||
&& diploChain.otherCiv() != viewingCiv && diploChain.otherCiv() != otherCiv | ||
&& !diploChain.otherCiv().isAtWarWith(viewingCiv) } | ||
.map { it.otherCiv() }) | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also delete this, there's no reason to have dead code in comments, if we want it we can get it back from git :)
Simplify the loop and delete dead code
Got it! I removed dead code and simplified the loop. Although I started playing this game several years ago, I am new here to contributing :) |
I noticed the discussion in Discord about whether to cancel the chain reaction of defense pact. Based on this, I made some corresponding changes. Before a civilization calls a defense pact ally, it will check the Type of the war it is participating in. If it is already a DefensivePactWar, it will not continue to call allies.
Resolves #12564