* 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 */
| 890 | * @return - true/false if success/fail |
| 891 | */ |
| 892 | bool 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) |
no test coverage detected