Vulnerability: _killWoundedAgents
Severity: high

Description:
The `_killWoundedAgents` function only checks the status of the agent, not when it was wounded.\\n```\\n    function _killWoundedAgents(\\n        uint256 roundId,\\n        uint256 currentRoundAgentsAlive\\n    ) private returns (uint256 deadAgentsCount) {\\n        // rest of code\\n        for (uint256 i; i < woundedAgentIdsCount; ) {\\n            uint256 woundedAgentId = woundedAgentIdsInRound[i.unsafeAdd(1)];\\n\\n            uint256 index = agentIndex(woundedAgentId);\\n          if (agents[index].status == AgentStatus.Wounded) {\\n                // rest of code\\n            }\\n\\n            // rest of code\\n        }\\n\\n        emit Killed(roundId, woundedAgentIds);\\n    }\\n```\\n\\nSo when `fulfillRandomWords` kills agents that were wounded and unhealed at round `currentRoundId - ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD`, it will also kill the agent who was healed and wounded again after that round.\\nAlso, since `fulfillRandomWords` first draws the new wounded agents before kills agents, in the worst case scenario, agent could die immediately after being wounded in this round.\\n```\\nif (activeAgents > NUMBER_OF_SECONDARY_PRIZE_POOL_WINNERS) {\\n  uint256 woundedAgents = _woundRequestFulfilled(\\n        currentRoundId,\\n        currentRoundAgentsAlive,\\n        activeAgents,\\n        currentRandomWord\\n    );\\n\\n    uint256 deadAgentsFromKilling;\\n    if (currentRoundId > ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD) {\\n      deadAgentsFromKilling = _killWoundedAgents({\\n            roundId: currentRoundId.unsafeSubtract(ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD),\\n            currentRoundAgentsAlive: currentRoundAgentsAlive\\n        });\\n    }\\n```\\n\\nThis is the PoC test code. You can add it to the Infiltration.fulfillRandomWords.t.sol file and run it.\\n```\\nfunction test_poc() public {\\n\\n    _startGameAndDrawOneRound();\\n\\n    uint256[] memory randomWords = _randomWords();\\n    uint256[] memory woundedAgentIds;\\n\\n    for (uint256 roundId = 2; roundId <= ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD + 1; roundId++) {\\n\\n        if(roundId == 2) { // heal agent. only woundedAgentIds[0] dead.\\n            (woundedAgentIds, ) = infiltration.getRoundInfo({roundId: 1});\\n            assertEq(woundedAgentIds.length, 20);\\n\\n            _drawXRounds(1);\\n\\n            _heal({roundId: 3, woundedAgentIds: woundedAgentIds});\\n\\n            _startNewRound();\\n\\n            // everyone except woundedAgentIds[0] is healed\\n            uint256 agentIdThatWasKilled = woundedAgentIds[0];\\n\\n            IInfiltration.HealResult[] memory healResults = new IInfiltration.HealResult[](20);\\n            for (uint256 i; i < 20; i++) {\\n                healResults[i].agentId = woundedAgentIds[i];\\n\\n                if (woundedAgentIds[i] == agentIdThatWasKilled) {\\n                    healResults[i].outcome = IInfiltration.HealOutcome.Killed;\\n                } else {\\n                    healResults[i].outcome = IInfiltration.HealOutcome.Healed;\\n                }\\n            }\\n\\n            expectEmitCheckAll();\\n            emit HealRequestFulfilled(3, healResults);\\n\\n            expectEmitCheckAll();\\n            emit RoundStarted(4);\\n\\n            randomWords[0] = (69 * 10_000_000_000) + 9_900_000_000; // survival rate 99%, first one gets killed\\n\\n            vm.prank(VRF_COORDINATOR);\\n            VRFConsumerBaseV2(address(infiltration)).rawFulfillRandomWords(_computeVrfRequestId(3), randomWords);\\n\\n            for (uint256 i; i < woundedAgentIds.length; i++) {\\n                if (woundedAgentIds[i] != agentIdThatWasKilled) {\\n                    _assertHealedAgent(woundedAgentIds[i]);\\n                }\\n            }\\n\\n            roundId += 2; // round 2, 3 used for healing\\n        }\\n\\n        _startNewRound();\\n\\n        // Just so that each round has different random words\\n        randomWords[0] += roundId;\\n\\n        if (roundId == ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD + 1) { // wounded agents at round 1 are healed, only woundedAgentIds[0] was dead.\\n            (uint256[] memory woundedAgentIdsFromRound, ) = infiltration.getRoundInfo({\\n                roundId: uint40(roundId - ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD)\\n            });\\n\\n            // find re-wounded agent after healed\\n            uint256[] memory woundedAfterHeal = new uint256[](woundedAgentIds.length);\\n            uint256 totalWoundedAfterHeal;\\n            for (uint256 i; i < woundedAgentIds.length; i ++){\\n                uint256 index = infiltration.agentIndex(woundedAgentIds[i]);\\n                IInfiltration.Agent memory agent = infiltration.getAgent(index);\\n                if (agent.status == IInfiltration.AgentStatus.Wounded) {\\n                    woundedAfterHeal[i] = woundedAgentIds[i]; // re-wounded agent will be killed\\n                    totalWoundedAfterHeal++;\\n                }\\n                else{\\n                    woundedAfterHeal[i] = 0; // set not wounded again 0\\n                }\\n\\n            }\\n            expectEmitCheckAll();\\n            emit Killed(roundId - ROUNDS_TO_BE_WOUNDED_BEFORE_DEAD, woundedAfterHeal);\\n        }\\n\\n        expectEmitCheckAll();\\n        emit RoundStarted(roundId + 1);\\n\\n        uint256 requestId = _computeVrfRequestId(uint64(roundId));\\n        vm.prank(VRF_COORDINATOR);\\n        VRFConsumerBaseV2(address(infiltration)).rawFulfillRandomWords(requestId, randomWords);\\n    }\\n}\\n```\\n

Impact:
The user pays tokens to keep the agent alive, but agent will die even if agent success to healed. The user has lost tokens and is forced out of the game.

Recommended mitigation:
Check woundedAt at `_killWoundedAgents`\\n```\\n    function _killWoundedAgents(\\n        uint256 roundId,\\n        uint256 currentRoundAgentsAlive\\n    ) private returns (uint256 deadAgentsCount) {\\n        // rest of code\\n        for (uint256 i; i < woundedAgentIdsCount; ) {\\n            uint256 woundedAgentId = woundedAgentIdsInRound[i.unsafeAdd(1)];\\n\\n            uint256 index = agentIndex(woundedAgentId);\\n// Remove the line below\\n           if (agents[index].status == AgentStatus.Wounded) {\\n// Add the line below\\n           if (agents[index].status == AgentStatus.Wounded && agents[index].woundedAt == roundId) {\\n                // rest of code\\n            }\\n\\n            // rest of code\\n        }\\n\\n        emit Killed(roundId, woundedAgentIds);\\n    }\\n```\\n