import java.util.*; import java.awt.*; // // End point of memory // // public class object12 extends object{ // calculate the random cards private static Random random = new Random(); int state=0; long oldtime=0; Image oldimage; // When card is turned it should be put back public object12(){ objnumber=12; methods[0]="hit"; methods[1]="resetevent"; methods[2]="event"; } public void init(Global glbl){ global=glbl; //System.out.println("object 12 init!"); if(image == null){ image=global.loadImage(global.Server, global.Directory+"12"+global.Extention, global.show); oldimage=image; for(int i=0; i< 32; i++){ //System.out.println("loading image: 11_"+i); global.memory_img[i]=global.loadImage(global.Server, global.Directory+"11_"+(i+1)+global.Extention, global.show); //System.out.println("?Image: "+global.memory_img[i]); } } sound=global.loadSound(global.Server, global.Directory+"11.au"); Date d=new Date(); oldtime=(long)d.getTime(); husle(); } public void execute(){ if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("hit")==0){ hit(); return; } } // Hit the crate/wood public void hit(){ } public void event(){ //System.out.println("object12.event"); } public void resetevent(){ System.out.println("Resetevent on object12"); husle(); } // Display public void display(){ global.boardrow=-1; global.boardcol=-1; global.doboard=true; } // random change cards public void husle(){ //System.out.println("husle!"); // Set the item int free[]=new int[32]; for(int i=0;i<32;i++) free[i]=0; global.cards=new Hashtable(); for(int x=2; x < global.WIDTH-2; x++){ for(int y=2; y < global.HEIGHT-2; y+=2){ boolean ok=false; Integer check=new Integer(0); try{ check=(Integer)global.cards.get((String)(""+x*global.STEPP+","+y*global.STEPP)); if(check.intValue() > 0) ok=true; }catch(Exception g){ } while(!ok){ Integer I=new Integer(rnd(31)); int i=I.intValue(); global.cards.put((String)(""+x*global.STEPP+","+y*global.STEPP), new Integer(I.toString())); global.grid.setxy(x*global.STEPP,y*global.STEPP, 11); // search next available object boolean found=false; while(!found){ Integer X=new Integer(rnd(global.WIDTH)); Integer Y=new Integer(rnd(global.HEIGHT)); if(X.intValue() > 1 && X.intValue() < global.WIDTH-2 && Y.intValue() > 1 && Y.intValue() < global.HEIGHT-2 && Y.intValue()%2 == 0){ Integer C=new Integer(0); try{ C=(Integer)global.cards.get( (String) (""+(X.intValue()*global.STEPP)+","+(Y.intValue()*global.STEPP))); if(C==null) C=new Integer(0); }catch(Exception gg){C=new Integer(0);} if(C.intValue() == 0){ found=true; global.cards.put((String)(""+(X.intValue()*global.STEPP)+","+(Y.intValue()*global.STEPP)), new Integer(I.toString())); global.grid.setxy(X.intValue()*global.STEPP,Y.intValue()*global.STEPP, 11); ok=true; } } } // while !found } // while } // for y } // for x int twelve=global.grid.next(0,0,12); global.grid.set(twelve, 109); state=1; global.selected=0; display(); } public int rnd(int rr){ return rand(rr); } public int rand(int seed){ int retval=random.nextInt(seed)+1; return retval; } }