Emberveil sourcetests/FlameCrownCheck.java
import java.io.*;
import java.util.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class FlameCrownCheck {
static int checks;
static void check(boolean value,String label){checks++;if(!value)throw new AssertionError(label);}
static int[] render(Background crown,long frame){int[] pixels=new int[32*28];Arrays.fill(pixels,0x36312b);DrawingArea.initDrawingArea(28,32,pixels);ChatCrowns.drawOwner(crown,8,10,frame*120);return pixels;}
public static void main(String[] args)throws Exception {
String root="runtime/ammunition-stage/cache/";
try(RandomAccessFile dat=new RandomAccessFile(root+"main_file_cache.dat","r");RandomAccessFile idx=new RandomAccessFile(root+"main_file_cache.idx0","r")){
StreamLoader media=new StreamLoader(new Decompressor(dat,idx,1).decompress(4));
Background gold=new Background(media,"mod_icons",1), silver=new Background(media,"mod_icons",0), crown=ChatCrowns.owner(media);
check(crown.ownerFlame&&!gold.ownerFlame&&!silver.ownerFlame,"only owner enables effects");
check(Arrays.equals(crown.aByteArray1450,gold.aByteArray1450),"original crown silhouette unchanged");
check(crown.anInt1452<=14,"icon stays within reserved name space");
int[] a=render(crown,0),b=render(crown,1);check(!Arrays.equals(a,b),"flames visibly animate between frames");
int top=10+crown.anInt1455, left=8+crown.anInt1454, flame=0,halo=0,red=0;
for(int y=0;y<28;y++)for(int x=0;x<32;x++){
int rgb=a[x+y*32];if(rgb==0x36312b)continue;
if(y<top)flame++;
if(x==left-1||x==left+crown.anInt1452)halo++;
if((rgb>>16&255)>2*(rgb>>8&255))red++;
check(x>=left-1 && x<=left+crown.anInt1452 && y>=top-3 && y<=top+crown.anInt1453,"effect confined to icon area");
}
check(flame>=5,"visible tongues above crown");check(halo>0,"visible blended halo outside crown");check(red>20,"predominantly flame red");
int[] clipped=new int[100];Arrays.fill(clipped,0x123456);DrawingArea.initDrawingArea(10,10,clipped);DrawingArea.setDrawingArea(7,3,7,3);ChatCrowns.drawOwner(crown,-2,-2,0);
for(int y=0;y<10;y++)for(int x=0;x<10;x++)if(x<3||x>=7||y<3||y>=7)check(clipped[x+y*10]==0x123456,"respects drawing clip");
check(ChatCrowns.hasOwner(new String[]{"@cr3@Bonds"},new String[]{"Hello"}),"owner triggers chat animation");
check(!ChatCrowns.hasOwner(new String[]{"@cr2@Admin","Bonds"},new String[]{"Hello","Hi"}),"ordinary and staff chat do not animate");
check(!ChatCrowns.hasOwner(new String[]{"@cr3@Bonds"},new String[]{null}),"empty history does not animate");
BufferedImage proof=new BufferedImage(32*6,28,BufferedImage.TYPE_INT_RGB);
for(int f=0;f<6;f++)proof.setRGB(f*32,0,32,28,render(crown,f),0,32);
ImageIO.write(proof,"png",new File("runtime/owner-flame-frames.png"));
BufferedImage enlarged=new BufferedImage(32*6*4,28*4,BufferedImage.TYPE_INT_RGB);
for(int y=0;y<enlarged.getHeight();y++)for(int x=0;x<enlarged.getWidth();x++)enlarged.setRGB(x,y,proof.getRGB(x/4,y/4));
ImageIO.write(enlarged,"png",new File("runtime/owner-flame-frames-enlarged.png"));
System.out.println("PASS "+checks+" animation, clipping, staff isolation and halo checks; crown "+crown.anInt1452+"x"+crown.anInt1453);
}
}
}