Allows player at the start of each round to generate a risk free position by setting [`accumulatedPointsPerFighter`](https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L479) greater than 0 by winning a few battles.
Audit: 2024-02-ai-arena-findings
Severity: HIGH

# Lines of code

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L479


# Vulnerability details

## Impact
Allows player at the start of each round to generate a risk free position by setting [`accumulatedPointsPerFighter`](https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L479) greater than 0 by winning a few battles.


## Description
The [`accumulatedPointsPerFighter`](https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L527) stores points accumulated by the fighter when the fighter wins a battle.


If we have a closer look at the the [`_addResultPoints`](https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L479) function, inside the condition where the fighter loses the battle, there's a [`if block`](https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L479) which checks if the `accumulatedPointsPerFighter` is greater than 0.


```solidity
File: src/RankedBattle.sol


479:          if (accumulatedPointsPerFighter[tokenId][roundId] > 0) {
480:                /// If the fighter has a positive point balance for this round, deduct points
481:                points = stakingFactor[tokenId] * eloFactor;
482:                if (points > accumulatedPointsPerFighter[tokenId][roundId]) {
483:                    points = accumulatedPointsPerFighter[tokenId][roundId];
484:                }
485:                accumulatedPointsPerFighter[tokenId][roundId] -= points;
486:                accumulatedPointsPerAddress[fighterOwner][roundId] -= points;
487:               totalAccumulatedPoints[roundId] -= points;
488:                if (points > 0) {
489:                    emit PointsChanged(tokenId, points, false);
490:                }
491:            } else {


```


This can be used as a way to gamify the points system, where a player would stake a very minimal amount of NRN and all he needs to do is gain a positive `accumulatedPointsPerFighter` which can be achieved by playing a few battles.


Once the `accumulatedPointsPerFighter` is greater than 0, the player would stake a very high amount of NRNs by using the `RankedBattle::stakeNRN` function.
The next round for the player is essentially a risk free game, in case the player loses the next battle, that would result in a very minimal point loss as the points earned were on the basis of previous staked amount.


But, if he wins, his [`stakingFactor`](https://github.com/code-423n4/2024-02-ai-arena/blame/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L258C13-L258C26) would be too large and as soon as the battle was finished, the player can choose to immediately unstake his NRNs and leave, also unlocks the potential mis-use of this by using several accounts to play the game where the NR