{"record":{"id":"c0cd0925a9b9f1d9","repo":"geekcomputers/Python","slug":"not-enough-chips-can-t-do-double","errorCode":null,"errorMessage":"Not enough chips || CAN'T DO DOUBLE","messagePattern":"Not enough chips \\|\\| CAN'T DO DOUBLE","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"BlackJack_game/blackjack_simulate.py","lineNumber":166,"sourceCode":"        try:\n            value = int(value)\n        except ValueError:\n            raise ValueError(Chips.get_tips(type_tips))\n        else:\n            if not isinstance(value, int):\n                raise ValueError(Chips.get_tips(type_tips))\n            if (value <= 0) or (value > self.amount):\n                raise ValueError(Chips.get_tips(amount_tips))\n            self._bet_amount = value\n\n    def double_bet(self):\n        if self.can_double():\n            self._bet_amount *= 2\n            self.is_double = True\n        else:\n            over_tips = \"Not enough chips || \"\n            cannot_double = \"CAN'T DO DOUBLE\"\n            raise ValueError(Chips.get_tips(over_tips + cannot_double))\n\n    @property\n    def insurance(self):\n        return self._insurance\n\n    @insurance.setter\n    def insurance(self, value):\n        if self.amount - value < 0:\n            over_tips = \"Not enough chips\"\n            raise ValueError(Chips.get_tips(over_tips))\n        self._insurance = value\n        self.is_insurance = True\n\n    def current_amount(self):\n        return self.amount - self.bet_amount - self.insurance\n\n    def reset_chip(self):\n        self._bet_amount = 0","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/geekcomputers/Python/blob/40f4cd2652d75ef8e49d76e5c4d431d458712719/BlackJack_game/blackjack_simulate.py#L148-L184","documentation":"ValueError raised by Chips.double_bet() when can_double() returns False — the player's chips cannot cover doubling the current bet. The method refuses to double instead of silently clamping.","triggerScenarios":"Calling double_bet() when bet_amount * 2 > amount, e.g. bet 60 with 100 chips; typically invoked from chips_manage after a double-down decision.","commonSituations":"Auto-double strategies that don't check chip count, doubling after a string of losses depleted the stack, or bet_amount not synced with amount after payouts.","solutions":["Guard with can_double() before calling: if chips.can_double(): chips.double_bet()","Otherwise re-bet a smaller amount or skip doubling","Ensure amount/bet_amount stay in sync after win/loss settlement"],"exampleFix":"# before\nchips.double_bet()\n# after\nif chips.can_double():\n    chips.double_bet()\nelse:\n    print(\"cannot double, insufficient chips\")","handlingStrategy":"type-guard","validationCode":"if chips.can_double():\n    chips.double_bet()\nelse:\n    print('insufficient chips to double')","typeGuard":"def can_double(chips) -> bool:\n    return chips.amount >= chips.bet_amount * 2","tryCatchPattern":"try:\n    chips.double_bet()\nexcept ValueError as e:\n    if \"CAN'T DO DOUBLE\" in str(e):\n        pass  # skip doubling, keep original bet\n    else:\n        raise","preventionTips":["Always call can_double() before double_bet()","Keep amount and bet_amount synchronized after payouts","Cap bet sizing to half the stack if you plan to double"],"tags":["python","blackjack","betting","insufficient-funds"],"backgroundTag":"insufficient-funds","analyzedSha":"40f4cd2652d75ef8e49d76e5c4d431d458712719","analyzedAt":"2026-08-27T11:12:20.313Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}