<commit_before>#include "BAMap.h"
#include <Arduboy.h>
#include "BAGlobal.h"
#include "ABMapSprites.h"

void drawMap(BAPlayer *player){

  // flip for watrer animation
  bool waterAnimationStepped = arduboy.everyXFrames(30);
  
    for(byte mapPosY = 0; mapPosY < GAME_BOARD_SIZE_HEIGHT; mapPosY++){
      for(byte mapPosX = 0; mapPosX < GAME_BOARD_SIZE_WIDTH; mapPosX++){

        int currentMapIndex = player->playerBoard[mapPosY][mapPosX];
        
          //=======================================
        // If it's a ship
        if(currentMapIndex >= 0){
           // get actual ship from player
           BAShip currentShip = player->shipAtIndex(currentMapIndex);

           ABPoint shipPosition = currentShip.position;
           shipPosition.x = shipPosition.x*8 + MENU_WIDTH;
           shipPosition.y = shipPosition.y*8;
           
           if(currentShip.horizontal)
            drawHorizontalShip(shipPosition, currentShip.fullLength, WHITE);
           else
            drawVerticalShip(shipPosition, currentShip.fullLength, WHITE);
        }

        //=======================================
        // If it's a Mountain
        else if(currentMapIndex == BAMapTileTypeMountain){
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Mountain, 8, 8, WHITE);
        }

        
        //=======================================
        // If it's a water sprite
        else if(currentMapIndex == BAMapTileTypeWater1){
           arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water1, 8, 8, WHITE);
           
           if(waterAnimationStepped) // set to next frame
             currentMapIndex = BAMapTileTypeWater2;
        }
        else if(currentMapIndex == BAMapTileTypeWater2){
           arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water2, 8, 8, WHITE);
           
           if(waterAnimationStepped) // set to next frame
             currentMapIndex = BAMapTileTypeWater3;
        }
        else if(currentMapIndex == BAMapTileTypeWater3){
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water3, 8, 8, WHITE);
          
           if(waterAnimationStepped) // set to next frame
             currentMapIndex = BAMapTileTypeWater0;
        }

        //=======================================
        // If it's a destroyed ship overdraw the field
        if(currentMapIndex == BAMapTileTypeDestroyedShip){
          arduboy.fillRect(MENU_WIDTH+mapPosX*8, mapPosY*8, 8, 8, BLACK);
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Mountain, 8, 8, WHITE);
        }
        
        //=======================================
        // animate water
        if(currentMapIndex == BAMapTileTypeWater0 && waterAnimationStepped){
          // check probability for new water
          if(random(100) < 1)
            currentMapIndex = BAMapTileTypeWater1;
        }

      }
    }
}<commit_msg>fixed display of water<commit_after>#include "BAMap.h"
#include <Arduboy.h>
#include "BAGlobal.h"
#include "ABMapSprites.h"

#include <math.h>

void drawMap(BAPlayer *player){

  // flip for watrer animation
  bool waterAnimationStepped = arduboy.everyXFrames(30);
  
    for(byte mapPosY = 0; mapPosY < GAME_BOARD_SIZE_HEIGHT; mapPosY++){
      for(byte mapPosX = 0; mapPosX < GAME_BOARD_SIZE_WIDTH; mapPosX++){

        int currentMapIndex = player->playerBoard[mapPosY][mapPosX];
        
          //=======================================
        // If it's a ship
        if(currentMapIndex >= 0){
           // get actual ship from player
           BAShip currentShip = player->shipAtIndex(currentMapIndex);

           ABPoint shipPosition = currentShip.position;
           shipPosition.x = shipPosition.x*8 + MENU_WIDTH;
           shipPosition.y = shipPosition.y*8;
           
           if(currentShip.horizontal)
            drawHorizontalShip(shipPosition, currentShip.fullLength, WHITE);
           else
            drawVerticalShip(shipPosition, currentShip.fullLength, WHITE);
        }

        //=======================================
        // If it's a Mountain
        else if(currentMapIndex == BAMapTileTypeMountain){
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Mountain, 8, 8, WHITE);
        }
        
        //=======================================
        // If it's a water sprite
        else if(currentMapIndex == BAMapTileTypeWater1){
           arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water1, 8, 8, WHITE);
           
           if(waterAnimationStepped) // set to next frame
             player->playerBoard[mapPosY][mapPosX] = BAMapTileTypeWater2;
        }
        else if(currentMapIndex == BAMapTileTypeWater2){
           arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water2, 8, 8, WHITE);
           
           if(waterAnimationStepped) // set to next frame
             player->playerBoard[mapPosY][mapPosX] = BAMapTileTypeWater3;
        }
        else if(currentMapIndex == BAMapTileTypeWater3){
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Water3, 8, 8, WHITE);
          
           if(waterAnimationStepped) // set to next frame
             player->playerBoard[mapPosY][mapPosX] = BAMapTileTypeWater0;
        }
        
        //=======================================
        // animate water
        if(currentMapIndex == BAMapTileTypeWater0 && waterAnimationStepped){
          // check probability for new water
          if(random(100) < 1)
            player->playerBoard[mapPosY][mapPosX] = BAMapTileTypeWater1;
        }

        //=======================================
        // If it's a destroyed ship overdraw the field
        if(currentMapIndex == BAMapTileTypeDestroyedShip){
          arduboy.fillRect(MENU_WIDTH+mapPosX*8, mapPosY*8, 8, 8, BLACK);
          arduboy.drawBitmap(MENU_WIDTH+mapPosX*8, mapPosY*8, BAMap_Sprite_Mountain, 8, 8, WHITE);
        }

      }
    }
}
{'fraction_non_alphanumeric': 0.1570785392696348, 'fraction_numerical': 0.01534100383525096, 'mean_word_length': 2.5303119482048264, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3280830', 'n_tokens_mistral': 1884, 'n_tokens_neox': 1827, 'n_words': 333}