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

Method bribedBy

game/state/shared/organisation.cpp:892–926  ·  view source on GitHub ↗

* The organisation is bribed by other org * @param state - GameState * @param other - other organisation * @param bribe - sum of the bribe * @return - true/false if success/fail */

Source from the content-addressed store, hash-verified

890 * @return - true/false if success/fail
891 */
892bool Organisation::bribedBy(GameState &state, StateRef<Organisation> other, int bribe)
893{
894 if (bribe <= 0 || other->balance < bribe || bribe < costOfBribeBy(state, other))
895 {
896 return false;
897 }
898
899 float improvement;
900 float x = this->getRelationTo(other);
901 if (x < -50) // Hostile
902 {
903 improvement = -50.0f - x;
904 }
905 else if (x < -25) // Unfriendly
906 {
907 improvement = -25.0f - x;
908 }
909 else if (x < 25) // Neutral
910 {
911 improvement = 25.0f - x;
912 }
913 else if (x < 75) // Friendly
914 {
915 improvement = 75.0f - x;
916 }
917 else // Allied (relationship cannot be improved)
918 {
919 return false;
920 }
921
922 balance += bribe;
923 other->balance -= bribe;
924 adjustRelationTo(state, other, improvement);
925 return true;
926}
927
928/**
929 * The organisation signs a diplomatic rift treaty (either to neutral or alliance state)

Callers 1

eventOccurredMethod · 0.80

Calls 1

getRelationToMethod · 0.95

Tested by

no test coverage detected