rkury14 Posted January 23, 2015 Share Posted January 23, 2015 Help! I need some kind of Rule that will help me create a ticket scratch off with 12 random slots with one image included. The prizes are: 3 spots are the “Lucky Symbol” 6 spots are $20 1 spot is $25 1 spot is $50 1 spot is $75 I can't upload an image of the ticket to show, but basically it says to "Reveal 3" of a kind to win. There are 12 four leaf clovers where the prizes are under and they get scratched off. How can I create a rule to generate these prizes including an image randomly in 12 places? Please respond asap. Thanks for your help. Rayed Quote Link to comment Share on other sites More sharing options...
rkury14 Posted January 23, 2015 Author Share Posted January 23, 2015 Here is an example of a BINGO card generating random numbers, could I use this and modify it for the ticket numbers? //This rule will typeset the bingo card as a FusionPro table //onto the card. //Call the number shuffler rule to shuffle our numbers temp = Rule("Number Shuffler"); //At this point, our numbers for this record are all shuffled. //It's BINGO time! //Here's some global settings on the table. columnWidth = 4050; columnHeight = 45; numberHeight = 23; //We define the basic table layout. Note the first column. We will use //that column to control the height of each row tableMarkup = '<table columns=6 margins="top:0;bottom:0;left:0;right:0" alignment="center">'; tableMarkup += '<column width=1>'; tableMarkup += '<column width=' + columnWidth + '>'; tableMarkup += '<column width=' + columnWidth + '>'; tableMarkup += '<column width=' + columnWidth + '>'; tableMarkup += '<column width=' + columnWidth + '>'; tableMarkup += '<column width=' + columnWidth + '>'; //The following "outer loop" will count through the rows in the table for (rowCounter = 1; rowCounter <=5; rowCounter++) { //We define the table markup for the row here plus that first column. //Note how we use the character at a given pointsize to set //the height of the row tableMarkup += '<row><cell><z newsize=' + columnHeight + '><setwidth newsize=".01"> '; tableMarkup += '<z newsize=' + numberHeight + '><setwidth newsize="' + numberHeight + '">'; //The following "inner loop" will count through the remaining cells on this row. for (columnCounter = 1; columnCounter <= 5; columnCounter++) { tableMarkup += '<cell rulings="left:medium,asu black;right:medium,asu black">'; //We use some math below to figure out which array element to include //for this cell. This is required because we typeset tables 1 row at //a time but our array is configured in a "vertical" manner with the //appropriate numbers in it. arrayPosition = ((columnCounter-1) * 5) + rowCounter; tableMarkup += finalNumberArray[arrayPosition]; } } //Close off this table with the end table tag. tableMarkup += '</table>'; return tableMarkup; Quote Link to comment Share on other sites More sharing options...
rkury14 Posted January 23, 2015 Author Share Posted January 23, 2015 I realized that I would need two lists for this because this job is actually a MAILER trifold 10.5 x 17.75 that also has a panel that is a scratch-off. Quote Link to comment Share on other sites More sharing options...
rkury14 Posted January 24, 2015 Author Share Posted January 24, 2015 Okay, Here is another question, How do I apply The prizes are: 3 spots are the “Lucky Symbol” 6 spots are $20 1 spot is $25 1 spot is $50 1 spot is $75 To the Number Shuffle Rule below? //The printed numbers on the card correspond to the following arrangement: // 1 to 15 in the B column //16 to 30 in the I column //31 to 45 in the N column //46 to 60 in the G column //61 to 75 in the O column //A variable to enable the free space in the center of the card //is set here. Setting this to false will make the center space //have a number instead of being free. enableFreeSpace = true; //A randomizerSetting variable is set. The higher this number, the more //shuffled the numbers will be in the card. Higher values will lead to //longer composition times, though. Setting of at least 1000 is recommended randomizerSetting = 5000; //Create an array object that will hold all of the numbers finalNumberArray = new Array(); //The array will have all 25 numbers for the Bingo card //Even though the first element in any array is the "0 element", //we will use numbers 1 through 25 to signify our numbers. //Technically, then, there are 26 elements in this array but we //will ignore the "0 element". //Create a shuffler array that will hold the numbers 1 through 15 shufflerArray = new Array(); //This shufflerArray will be randomly sorted for each column. //After it is randomly sorted, we will pick the first 5 elements //in this array and multiply by a factor to get the correct number //range for each column. For example, a "6" for the "B" column or a //"63" for the O column. The multiplier factor will be as follows: //((columnNumber - 1) * 15) + arrayNumber //Let's fill the shufflerArray with the numbers 1 through 15 for (x=0; x<15; x++) { shufflerArray[x] = x+1; } //Variable that will be used to point to the appropriate location //in the finalNumberArray is set. cellCounter = 1; for (columnCounter = 1; columnCounter<=5; columnCounter++) { //shuffle the array for(shufflerCounter = 0; shufflerCounter < randomizerSetting; shufflerCounter++) { position1 = Round((Math.random() * 14),0); position2 = Round((Math.random() * 14),0); tempNumHolder = shufflerArray[position1]; shufflerArray[position1] = shufflerArray[position2]; shufflerArray[position2] = tempNumHolder; } //assign each spot in the finalNumberArray with a number from the array //note that each number will also be multiplied by a factor to //yield an appropriate number for each column for (count = 0; count < 5; count++) { finalNumberArray[cellCounter] = ((columnCounter - 1) * 15) + shufflerArray[count]; cellCounter += 1; } } //Enter the "FREE SPACE" text if the enableFreeSpace flag is set if (enableFreeSpace == false) { finalNumberArray[13] = "<span><z newsize=12><br>FREE<BR>SPACE</span>"; } return 0; Quote Link to comment Share on other sites More sharing options...
step Posted January 27, 2015 Share Posted January 27, 2015 (edited) For your scratch off ticket, I would add your prize elements to an array (image included), shuffle the elements in the array, and build a table of the prizes. I've put together an example here: /* ------------------------------------------------- // Function for shuffling array elements // + Jonas Raoni Soares Silva // @ http://jsfromhell.com/array/shuffle [v1.0] // -------------------------------------------------*/ function Shuffle(o){ for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); return o; } // Table Settings var numberOfColumns = 4; var numberOfRows = 3; var columnWidth = 1; // in inches var rowHeight = 1; // in inches // Lucky Symbol Settings var luckySymbol = { path: "/Path/to/luckySymbol.pdf", // Path to lucky symbol graphic width: 0.25, // in inches height: 0.25 // in inches } // Array of prizes (3 lucky symbols, 6 $20, 1 $25, 1 $50, 1 $75) var prizes = [luckySymbol.path,luckySymbol.path,luckySymbol.path,"$20","$20","$20","$20","$20","$20","$25","$50","$75"]; // Randomly shuffle the prizes prizes = Shuffle(prizes); var rows = []; // Array to hold rows // Start building table var table = '<table columns=' + numberOfColumns + '>'; // Add column tags for the specified amount of columns for (var i=0; i<numberOfColumns; i++){ table += '<column width=' + columnWidth*7200 + '>'; } // Add cell tags for each prize prizes.forEach(function(val){rows.push('<cell><p quad="C">' + val.replace(luckySymbol.path, '<graphic file="' + luckySymbol.path + '" height=' + luckySymbol.height*7200 + ' width=' + luckySymbol.width*7200 + '>'));}); // Create the specified amount of rows for (var n=0; n<numberOfRows; n++){1 var row = rows.splice(0,numberOfColumns); table += '<row minHeight=' + rowHeight*7200 + '>' + row.join(''); } // Close table tag table += '</table>'; return table; I imagine the scratch off image would have to be printed after the table is printed (as just a static image). Anyway, I hope that helps get you started. For more information on adjusting the table properties, check out page 27 of the TagRefGuide.pdf in the FusionPro documentation. Edited January 27, 2015 by step Quote Link to comment Share on other sites More sharing options...
rkury14 Posted January 27, 2015 Author Share Posted January 27, 2015 Ste, Thank you so much. I will get this going and test it out. Much appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.