Script used for generating contents in a card booster pack in the Pack Opening Sheet.
function myboosterpackopening()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];//Clear out booster pack column
for (var y = 0; y < 15; y++)
{
var cell = sheet.getRange(3+y,2);
cell.setValue(“”);
cell.setBackground(“white”);
var cell = sheet.getRange(3+y,3);
cell.setValue(“”);
cell.setBackground(“white”);
}///Minor Block
for (var y = 0; y < sheet.getRange(“G3”).getValue(); y++)
{
var e = Math.floor(Math.random()*100+1)var cell = sheet.getRange(15,1);
cell.setValue(e); //Populate a resultif (e < sheet.getRange(“H21”).getValue()) //Pick a Standard Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D32”).getValue())+33;
var cell = sheet.getRange(“F”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=F32”);
}
else if (e < sheet.getRange(“I21”).getValue()) //Pick a Special Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D33”).getValue())+33;
var cell = sheet.getRange(“G”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=G32”);
}
else if (e < sheet.getRange(“J21”).getValue()) //Pick a Exceptional Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D34”).getValue())+33;
var cell = sheet.getRange(“H”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=H32”);
}
else if (e < sheet.getRange(“K21”).getValue()) //Pick a Epic Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D35”).getValue())+33;
var cell = sheet.getRange(“I”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=I32”);
}
}///Medium Block
for (var y = y; y < sheet.getRange(“G3”).getValue() + sheet.getRange(“G4”).getValue(); y++)
{
var e = Math.floor(Math.random()*100+1)var cell = sheet.getRange(15,1);
cell.setValue(e); //Populate a resultif (e < sheet.getRange(“H22”).getValue()) //Pick a Standard Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D32”).getValue())+33;
var cell = sheet.getRange(“F”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=F32”);
}
else if (e < sheet.getRange(“I22”).getValue()) //Pick a Special Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D33”).getValue())+33;
var cell = sheet.getRange(“G”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=G32”);
}
else if (e < sheet.getRange(“J22”).getValue()) //Pick a Exceptional Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D34”).getValue())+33;
var cell = sheet.getRange(“H”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=H32”);
}
else if (e < sheet.getRange(“K22”).getValue()) //Pick a Epic Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D35”).getValue())+33;
var cell = sheet.getRange(“I”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=I32”);
}
}///Major Block
for (var y = y; y < sheet.getRange(“G3”).getValue() + sheet.getRange(“G4”).getValue() + sheet.getRange(“G5”).getValue(); y++)
{
var e = Math.floor(Math.random()*100+1)var cell = sheet.getRange(15,1);
cell.setValue(e); //Populate a resultif (e < sheet.getRange(“H23”).getValue()) //Pick a Standard Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D32”).getValue())+33;
var cell = sheet.getRange(“F”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=F32”);
}
else if (e < sheet.getRange(“I23”).getValue()) //Pick a Special Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D33”).getValue())+33;
var cell = sheet.getRange(“G”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=G32”);
}
else if (e < sheet.getRange(“J23”).getValue()) //Pick a Exceptional Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D34”).getValue())+33;
var cell = sheet.getRange(“H”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=H32”);
}
else if (e < sheet.getRange(“K23”).getValue()) //Pick a Epic Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D35”).getValue())+33;
var cell = sheet.getRange(“I”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=I32”);
}
}//Terrain Block
for (var y = y; y < sheet.getRange(“G3”).getValue() + sheet.getRange(“G4”).getValue() + sheet.getRange(“G5”).getValue() + sheet.getRange(“G6”).getValue(); y++)
{var t = Math.floor(Math.random()*100+1)
var cell = sheet.getRange(16,1);
cell.setValue(t);//Populate a resultif (t < sheet.getRange(“H24”).getValue()) //Pick a Standard Terrain Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D36”).getValue())+33;
var cell = sheet.getRange(“J”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=J32”);
}
else if (t < sheet.getRange(“I24”).getValue()) //Pick a Special Terrain Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D37”).getValue())+33;
var cell = sheet.getRange(“K”+ n).copyTo(sheet.getRange(3+y,2))
cell = sheet.getRange(3+y,3);
cell.setValue(“=K32”);
}
else if (t < sheet.getRange(“J24”).getValue()) //Pick a Exceptional Terrain Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D38”).getValue())+33;
var cell = sheet.getRange(“L”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=L32”);
}
else if (t < sheet.getRange(“K24”).getValue()) //Pick a Epic Terrain Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D39”).getValue())+33;
var cell = sheet.getRange(“M”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=M32”);
}
}//Materia Block
for (var y = y; y < sheet.getRange(“G3”).getValue() + sheet.getRange(“G4”).getValue() + sheet.getRange(“G5”).getValue() + sheet.getRange(“G6”).getValue() + sheet.getRange(“G7”).getValue(); y++)
{var t = Math.floor(Math.random()*100+1)
var cell = sheet.getRange(16,1);
cell.setValue(t);//Populate a resultif (t < sheet.getRange(“H25”).getValue()) //Pick a Standard Materia Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D40”).getValue())+33;
var cell = sheet.getRange(“N”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=N32”);
}
else if (t < sheet.getRange(“I25”).getValue()) //Pick a Special Materia Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D41”).getValue())+33;
var cell = sheet.getRange(“O”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=O32”);
}
else if (t < sheet.getRange(“J25”).getValue()) //Pick a Exceptional Materia Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D42”).getValue())+33;
var cell = sheet.getRange(“P”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=P32”);
}
else if (t < sheet.getRange(“K25”).getValue()) //Pick a Epic Materia Card
{
var n = Math.floor(Math.random()*sheet.getRange(“D43”).getValue())+33;
var cell = sheet.getRange(“Q”+ n).copyTo(sheet.getRange(3+y,2));
cell = sheet.getRange(3+y,3);
cell.setValue(“=Q32”);
}
}//Foil Block
for (var y = 0; y < sheet.getRange(“G8”).getValue(); y++)
{
var m = Math.floor(Math.random()*100+1)
if (m < sheet.getRange(“G10”).getValue())
{
var cell = sheet.getRange(3+y,2);
cell.setBackground(“red”);
break;
}
}}