/** * If you try to bribe with a negative bounty, the doshin beat you up and take your money! * * @param Player $char * @return Player * @note * If the player loses a substantial enough amount, the doshin will actually decrease the bounty. */ private function doshinAttack(Player $char) { $current_bounty = $char->bounty; $doshin_takes = floor($char->gold * self::DOSHIN_CUT); // If the doshin take a lot of money, they'll // actually reduce the bounty somewhat. $bounty_reduction = (int) min($current_bounty, $doshin_takes > self::SAFE_WEALTH ? $doshin_takes / self::BRIBERY_DIVISOR : 0); if (0 < $bounty_reduction) { $char->setBounty($char->bounty - $bounty_reduction); } // Do fractional damage to the char $char->setHealth($char->health - floor($char->health * self::FAILED_BRIBERY_PAIN)); // Regardless, you lose some gold. $char->setGold($char->gold - $doshin_takes); return $char->save(); }