MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / signTreatyWith

Method signTreatyWith

game/state/shared/organisation.cpp:934–954  ·  view source on GitHub ↗

* The organisation signs a diplomatic rift treaty (either to neutral or alliance state) * @param other - other organisation * @param bribe - sum of the bribe by other org * @param forceAlliance - whenether relationships go straight to maximum */

Source from the content-addressed store, hash-verified

932 * @param forceAlliance - whenether relationships go straight to maximum
933 */
934void Organisation::signTreatyWith(GameState &state, StateRef<Organisation> other, int bribe,
935 bool forceAlliance)
936{
937 // it's either an alliance offer or we have some sort of bribe
938 if (bribe <= 0 && !forceAlliance)
939 {
940 return;
941 }
942
943 StateRef<Organisation> currentOrg{&state, id};
944 const float myRelation = this->getRelationTo(other);
945 const float newValue = (forceAlliance) ? 100.0f
946 : (myRelation > 0) ? std::max(myRelation + 25, 100.0f)
947 : 0;
948
949 current_relations[other] = newValue;
950 other->current_relations[currentOrg] = std::max(newValue, other->getRelationTo(currentOrg));
951
952 balance += bribe;
953 other->balance -= bribe;
954}
955
956template <>
957sp<Organisation> StateObject<Organisation>::get(const GameState &state, const UString &id)

Callers 1

eventOccurredMethod · 0.80

Calls 1

getRelationToMethod · 0.95

Tested by

no test coverage detected