<commit_before>
// Design Basic Game Solo Challenge

// This is a solo challenge

// Your mission description: Battleship! To destroy opponents ship first. 
// Overall mission:
// Goals:
// Characters: Two battleships
// Objects: two battleships
// Functions:

// Pseudocode
//create two battleship objects
//place them randomly on board
//
//
//

// Initial Code






// Refactored Code






// Reflection
//
//
//
//
//
//
//
//

 
var yourBase = {

  posX: Math.floor((Math.random()*10)+1),
  posY: Math.floor((Math.random()*10)+1),
  destroyed: false,

  fire: function(x, y) {
    if(x === enemyBase.posX && y === enemyBase.posY) {
      console.log("You hit the enemy base!");
    }
    else  {
      console.log("You are at x: " + yourBase.posX + " and y: " + yourBase.posY);
    }
 }  
};

var enemyBase = {
  posX: Math.floor((Math.random()*10)+1),
  posY: Math.floor((Math.random()*10)+1),
  destroyed: false,

  

   fire: function() {

  var fireBackX = Math.floor((Math.random()*10)+1);
  var fireBackY = Math.floor((Math.random()*10)+1);

    if(enemyBase.fireBackX === yourBase.posX && enemyBase.fireBackY === yourBase.posY) {
      console.log("You've been hit!");
    }
    else {
      //console.log("The enemy is at x: " + yourBase.posX + " and y: " + yourBase.posY);
    }
 } 

  
};


yourBase.fire(2,4);

console.log(enemyBase.fire()); 
// yourBase.fire(4,4);
// yourBase.fire(3,4);


<commit_msg>before adding do to while loop<commit_after>
 
var myBase = {

  posX: Math.floor((Math.random()*5)+1),
  posY: Math.floor((Math.random()*5)+1),
  health: 5
 };

var enemyBase = {
  posX: Math.floor((Math.random()*5)+1),
  posY: Math.floor((Math.random()*5)+1),
  health: 5
};

//Reveals base locations
// var myPosition = myBase.posX;
// for(var x in myBase) {
// 	console.log(myBase[x]);
// }

// var enemyPosition = enemyBase.posX;
// for(var x in enemyBase) {
// 	console.log(enemyBase[x]);
// }

var launch = function(x, y) {
	if(x === enemyBase.posX && x === enemyBase.posY) {
		enemyBase.health -= 1; 
		console.log("You hit the base!");
	} else {
		console.log("You missed!"); 
	}
};

var enemyLaunch = function() {

	enemyLaunchCordX = Math.floor((Math.random()*5)+1);
	enemyLaunchCordY = Math.floor((Math.random()*5)+1);

	if(enemyLaunchCordX === myBase.posX && enemyLaunchCordY === myBase.posY) {
		myBase.health -= 1;
		console.log("You've been hit!");
	} else {
		console.log("That was a close one!"); 
	}
};

var counter = 0;
do {
	
	myBase.posX = Math.floor((Math.random()*5)+1);
	myBase.posY = Math.floor((Math.random()*5)+1);

	enemyBase.posX = Math.floor((Math.random()*5)+1);
	enemyBase.posY = Math.floor((Math.random()*5)+1);
}

while ( myBase.health > 0 && enemyBase.health > 0) {
	
	launch(2,5); 
	enemyLaunch();
	counter += 1;

}



console.log(counter);
// launch(2,5); 
// enemyLaunch();
// console.log(myBase);
// console.log(enemyBase);















{'fraction_non_alphanumeric': 0.19903414970679545, 'fraction_numerical': 0.019317005864091064, 'mean_word_length': 3.101838755304102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3253814', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1092, 'n_words': 217}