var currentProblem = 0; //will be randomizing which item gets pulled from math array
var previousProblem; //use this to be sure it won't duplicate twice in a row
var aBlank = new Array();
var aFinalArray = new Array();
var finalArrayLength;
var aFill0 = new Array();
var aFill1 = new Array();
aZeroAdd.On = false; //property of each array that gets changed by a button in the game
aOneAdd.On = false;
factChoiceDone = function()
{ //will go through all of the 'On' features to see which arrays the child has turned on
if(aZeroAdd.On == true)
{
aFill0 = aBlank.concat(aZeroAdd); //if it is on, add it to aFill0
}
if(aOneAdd.On == true)
{
aFill1 = aBlank.concat(aOneAdd);
}
aFinalArray = aBlank.concat(aFill0, aFill1); //combines all arrays into aFinalArray
//console.log(aFinalArray.length);
finalArrayLength = aFinalArray.length;
shuffle3(aFinalArray); //shuffles the final array
}
function shuffle3(array_arr)
{
for(var i = 0; i < array_arr.length; i++)
{
var randomNum_num = Math.floor(Math.random() * array_arr.length);
var arrayIndex = array_arr[i];
array_arr[i] = array_arr[randomNum_num];
array_arr[randomNum_num] = arrayIndex;
}
for(var j = 0; j < array_arr.length; j++)
{
console.log(j + " = " + array_arr[j]);
}
return array_arr; //returns aFinalArray shuffled
}
//this function is called whenever the character runs into an object that triggers the math problem
function showMathProblem()
{
$gameMessage.add(aFinalArray[0][0]);//adds the problem to the message
$gameMessage.setChoices([aFinalArray[0][1],aFinalArray[0][2], aFinalArray[0][3], aFinalArray[0][4], aFinalArray[0][5]], aFinalArray[0][6], -1); //sets the choices
$gameMessage.setChoiceCallback(function(choice) //when choice is selected, calls this function
{
console.log(choice); //logs the number of the choice
var currentChoice = choice + 1; //adds one to that number for easier lookup
console.log(aFinalArray[0][currentChoice]); //shows their answer
if(aFinalArray[0][currentChoice] == aFinalArray[0][6]) //compares their answer to the correct answer
{
console.log("that is the right answer"); //logs correctly
factAnswerCorrect();
}
else
{
console.log("that is not the right answer"); //logs correctly
factAnswerWrong();
}
});
};
function factAnswerCorrect()
{
console.log("Fact Answer Correct Called"); //logs correctly
$gameMessage.add("That was right!"); //NOTHING SHOWS UP
};
function factAnswerWrong()
{
$gameMessage.add("That was wrong!");//NOTHING SHOWS UP
};