let difficulty=0;
if(GetCommonData("Difficulty")==1){ difficulty=1; }
if(GetCommonData("Difficulty")==2){ difficulty=2; }
if(GetCommonData("Difficulty")==3){ difficulty=3; }
if(GetCommonData("Difficulty")==4){ difficulty=4; }
let difficultyname="a";
if(GetCommonData("Difficulty")==1){ difficultyname="Easy"; }
if(GetCommonData("Difficulty")==2){ difficultyname="Normal"; }
if(GetCommonData("Difficulty")==3){ difficultyname="Hard"; }
if(GetCommonData("Difficulty")==4){ difficultyname="Lunatic"; }

SetCommonData("SpellcardPractise",1);
if(GetPlayerLife<3){ ExtendPlayer(1); }


if(GetCommonData("PauseSpellcardPractise")==0){
let i=1;
	loop(18){
		if(GetCommonData("NewTrumpCardsUnlocked")[i]>0){
			SPtime=-10;
			SPpagetime=-70;
			BGfade=0;
			SPplayspellcard=1;

			CreateEnemyFromFile("script/Functions/Main Menu/Unlock.txt",cx,cy,0,0,i);
			SetCommonData("PauseSpellcardPractise",1);

			let spellcarddataarray=GetCommonData("NewTrumpCardsUnlocked");
			spellcarddataarray[i]=0;
			SetCommonData("NewTrumpCardsUnlocked",spellcarddataarray);

			break;
		}
	i++;
	}
}

if(GetCommonDataDefault("BackToSpellcardPractise",0)==1 && GetCommonDataDefault("PauseSpellcardPractise",0)==0){
	SetCommonData("BackToSpellcardPractise",0);
	SaveCommonData;
	SetCommonData("BlackScreenFade",255);
	SPtime=-120;
	SPpagetime=-180;
	BGfade=0;
	SPplayspellcard=0;
}


if(SPpagetime==0 && SPplayspellcard==0){
	let trumpcardhighscore=GetCommonData("HighScoreTrumpCards");
	trumpcardhighscore[GetCommonDataDefault("LastTrumpCard",0)]=GetScore;
	if(GetScore>GetCommonData("HighScoreTrumpCards")[GetCommonDataDefault("LastTrumpCard",0)]){
	SetCommonData("HighScoreTrumpCards",trumpcardhighscore);
	}
	if(GetScore>0){ AddScore(-GetScore); }
	if(GetGraze>0){ AddGraze(-GetGraze); }
}

if(SPplayspellcard==0){

SetCommonData("InEvent",1); 

if(SPtime>=0){ SetPlayerX(cx); SetPlayerY(400); }

if(SPtime==0){

let xsize=640;
let ysize=480;
	BGback1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGback1,320,240);
	ObjEffect_SetScale(BGback1,1,1);
	ObjEffect_SetLayer(BGback1,8); ObjEffect_SetTexture(BGback1,BGbackgraphic1); ObjEffect_SetRenderState(BGback1,ALPHA);
	ObjEffect_SetPrimitiveType(BGback1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGback1,4);
	ObjEffect_SetVertexXY(BGback1,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGback1,0,0,0);
	ObjEffect_SetVertexXY(BGback1,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGback1,1,xsize,0);
	ObjEffect_SetVertexXY(BGback1,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGback1,2,0,ysize);
	ObjEffect_SetVertexXY(BGback1,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGback1,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGback1,0,255,255,255,255); ObjEffect_SetVertexColor(BGback1,1,255,255,255,255);
	ObjEffect_SetVertexColor(BGback1,2,255,255,255,255); ObjEffect_SetVertexColor(BGback1,3,255,255,255,255);

	BGback2=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGback2,320,240);
	ObjEffect_SetScale(BGback2,1,1);
	ObjEffect_SetLayer(BGback2,8); ObjEffect_SetTexture(BGback2,BGbackgraphic2); ObjEffect_SetRenderState(BGback2,ALPHA);
	ObjEffect_SetPrimitiveType(BGback2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGback2,4);
	ObjEffect_SetVertexXY(BGback2,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGback2,0,0,0);
	ObjEffect_SetVertexXY(BGback2,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGback2,1,xsize,0);
	ObjEffect_SetVertexXY(BGback2,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGback2,2,0,ysize);
	ObjEffect_SetVertexXY(BGback2,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGback2,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGback2,0,0,255,255,255); ObjEffect_SetVertexColor(BGback2,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGback2,2,0,255,255,255); ObjEffect_SetVertexColor(BGback2,3,0,255,255,255);

	BGback3=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGback3,320,240);
	ObjEffect_SetScale(BGback3,1,1);
	ObjEffect_SetLayer(BGback3,8); ObjEffect_SetTexture(BGback3,BGbackgraphic3); ObjEffect_SetRenderState(BGback3,ALPHA);
	ObjEffect_SetPrimitiveType(BGback3,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGback3,4);
	ObjEffect_SetVertexXY(BGback3,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGback3,0,0,0);
	ObjEffect_SetVertexXY(BGback3,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGback3,1,xsize,0);
	ObjEffect_SetVertexXY(BGback3,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGback3,2,0,ysize);
	ObjEffect_SetVertexXY(BGback3,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGback3,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGback3,0,0,255,255,255); ObjEffect_SetVertexColor(BGback3,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGback3,2,0,255,255,255); ObjEffect_SetVertexColor(BGback3,3,0,255,255,255);

let xsize=122;
let ysize=36;
	BGselection1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGselection1,140,26);
	ObjEffect_SetScale(BGselection1,1,1);
	ObjEffect_SetLayer(BGselection1,8); ObjEffect_SetTexture(BGselection1,BGselectiongraphic1); ObjEffect_SetRenderState(BGselection1,ALPHA);
	ObjEffect_SetPrimitiveType(BGselection1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGselection1,4);
	ObjEffect_SetVertexXY(BGselection1,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGselection1,0,0,0);
	ObjEffect_SetVertexXY(BGselection1,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGselection1,1,xsize,0);
	ObjEffect_SetVertexXY(BGselection1,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGselection1,2,0,ysize);
	ObjEffect_SetVertexXY(BGselection1,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGselection1,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGselection1,0,0,255,255,255); ObjEffect_SetVertexColor(BGselection1,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGselection1,2,0,255,255,255); ObjEffect_SetVertexColor(BGselection1,3,0,255,255,255);

let xsize=400;
let ysize=26;
	BGselection2=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGselection2,320,240);
	ObjEffect_SetScale(BGselection2,1,1);
	ObjEffect_SetLayer(BGselection2,8); ObjEffect_SetTexture(BGselection2,BGselectiongraphic2); ObjEffect_SetRenderState(BGselection2,ALPHA);
	ObjEffect_SetPrimitiveType(BGselection2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGselection2,4);
	ObjEffect_SetVertexXY(BGselection2,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGselection2,0,0,0);
	ObjEffect_SetVertexXY(BGselection2,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGselection2,1,xsize,0);
	ObjEffect_SetVertexXY(BGselection2,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGselection2,2,0,ysize);
	ObjEffect_SetVertexXY(BGselection2,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGselection2,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGselection2,0,0,255,255,255); ObjEffect_SetVertexColor(BGselection2,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGselection2,2,0,255,255,255); ObjEffect_SetVertexColor(BGselection2,3,0,255,255,255);

let xsize=250;
let ysize=60;
	BGstages1=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGstages1,390,30);
	ObjEffect_SetScale(BGstages1,1,1);
	ObjEffect_SetLayer(BGstages1,8); ObjEffect_SetTexture(BGstages1,BGstagesgraphic1); ObjEffect_SetRenderState(BGstages1,ALPHA);
	ObjEffect_SetPrimitiveType(BGstages1,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGstages1,4);
	ObjEffect_SetVertexXY(BGstages1,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGstages1,0,0,0);
	ObjEffect_SetVertexXY(BGstages1,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGstages1,1,xsize,0);
	ObjEffect_SetVertexXY(BGstages1,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGstages1,2,0,ysize);
	ObjEffect_SetVertexXY(BGstages1,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGstages1,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGstages1,0,255,255,255,255); ObjEffect_SetVertexColor(BGstages1,1,255,255,255,255);
	ObjEffect_SetVertexColor(BGstages1,2,255,255,255,255); ObjEffect_SetVertexColor(BGstages1,3,255,255,255,255);

let xsize=400;
let ysize=60;
	BGstages2=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGstages2,320,30);
	ObjEffect_SetScale(BGstages2,1,1);
	ObjEffect_SetLayer(BGstages2,8); ObjEffect_SetTexture(BGstages2,BGstagesgraphic2); ObjEffect_SetRenderState(BGstages2,ALPHA);
	ObjEffect_SetPrimitiveType(BGstages2,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGstages2,4);
	ObjEffect_SetVertexXY(BGstages2,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGstages2,0,0,0);
	ObjEffect_SetVertexXY(BGstages2,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGstages2,1,xsize,0);
	ObjEffect_SetVertexXY(BGstages2,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGstages2,2,0,ysize);
	ObjEffect_SetVertexXY(BGstages2,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGstages2,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGstages2,0,255,255,255,255); ObjEffect_SetVertexColor(BGstages2,1,255,255,255,255);
	ObjEffect_SetVertexColor(BGstages2,2,255,255,255,255); ObjEffect_SetVertexColor(BGstages2,3,255,255,255,255);

let xsize=120;
let ysize=36;
	BGdifficulty=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGdifficulty,140,27);
	ObjEffect_SetScale(BGdifficulty,1,1);
	ObjEffect_SetLayer(BGdifficulty,8); ObjEffect_SetTexture(BGdifficulty,BGdifficultygraphic); ObjEffect_SetRenderState(BGdifficulty,ALPHA);
	ObjEffect_SetPrimitiveType(BGdifficulty,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGdifficulty,4);
	ObjEffect_SetVertexXY(BGdifficulty,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGdifficulty,0,0,0);
	ObjEffect_SetVertexXY(BGdifficulty,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGdifficulty,1,xsize,0);
	ObjEffect_SetVertexXY(BGdifficulty,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGdifficulty,2,0,ysize);
	ObjEffect_SetVertexXY(BGdifficulty,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGdifficulty,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGdifficulty,0,0,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGdifficulty,2,0,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,3,0,255,255,255);

let xsize=200;
let ysize=24;
	BGpoints=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGpoints,145,462);
	ObjEffect_SetScale(BGpoints,1,1);
	ObjEffect_SetLayer(BGpoints,8); ObjEffect_SetTexture(BGpoints,BGpointsgraphic); ObjEffect_SetRenderState(BGpoints,ALPHA);
	ObjEffect_SetPrimitiveType(BGpoints,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGpoints,4);
	ObjEffect_SetVertexXY(BGpoints,0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGpoints,0,0,0);
	ObjEffect_SetVertexXY(BGpoints,1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGpoints,1,xsize,0);
	ObjEffect_SetVertexXY(BGpoints,2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGpoints,2,0,ysize);
	ObjEffect_SetVertexXY(BGpoints,3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGpoints,3,xsize,ysize);
	ObjEffect_SetVertexColor(BGpoints,0,0,255,255,255); ObjEffect_SetVertexColor(BGpoints,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGpoints,2,0,255,255,255); ObjEffect_SetVertexColor(BGpoints,3,0,255,255,255);

let xsize=20;
let ysize=24;
let i=0;
let numberxpos=0;
	loop(3){
	BGpointsnumbers[i]=(Obj_Create(OBJ_EFFECT));
	Obj_SetPosition(BGpointsnumbers[i],250+numberxpos,461);
	ObjEffect_SetScale(BGpointsnumbers[i],1,1);
	ObjEffect_SetLayer(BGpointsnumbers[i],8); ObjEffect_SetTexture(BGpointsnumbers[i],BGpointsgraphic); ObjEffect_SetRenderState(BGpointsnumbers[i],ALPHA);
	ObjEffect_SetPrimitiveType(BGpointsnumbers[i],PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(BGpointsnumbers[i],4);
	ObjEffect_SetVertexXY(BGpointsnumbers[i],0,-(xsize/2),-(ysize/2)); ObjEffect_SetVertexUV(BGpointsnumbers[i],0,0,24);
	ObjEffect_SetVertexXY(BGpointsnumbers[i],1,xsize/2,-(ysize/2)); ObjEffect_SetVertexUV(BGpointsnumbers[i],1,xsize,24);
	ObjEffect_SetVertexXY(BGpointsnumbers[i],2,-(xsize/2),ysize/2); ObjEffect_SetVertexUV(BGpointsnumbers[i],2,0,24+ysize);
	ObjEffect_SetVertexXY(BGpointsnumbers[i],3,xsize/2,ysize/2); ObjEffect_SetVertexUV(BGpointsnumbers[i],3,xsize,24+ysize);
	ObjEffect_SetVertexColor(BGpointsnumbers[i],0,0,255,255,255); ObjEffect_SetVertexColor(BGpointsnumbers[i],1,0,255,255,255);
	ObjEffect_SetVertexColor(BGpointsnumbers[i],2,0,255,255,255); ObjEffect_SetVertexColor(BGpointsnumbers[i],3,0,255,255,255);
	numberxpos+=15;
	i++
	}
}

if(SPtime>10){ SetCommonData("PlayMusic",10); }


if(BGfade<255 && SPtime>=0){ BGfade+=255/60; }
if(SPtime==120){ BGfade=255; }

	ObjEffect_SetVertexColor(BGback2,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback2,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGback2,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback2,3,BGfade,255,255,255);
	
	ObjEffect_SetVertexColor(BGback3,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback3,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGback3,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback3,3,BGfade,255,255,255);

	ObjEffect_SetVertexColor(BGpoints,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGpoints,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGpoints,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGpoints,3,BGfade,255,255,255);
	
let i=0;
	loop(3){
	ObjEffect_SetVertexColor(BGpointsnumbers[i],0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGpointsnumbers[i],1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGpointsnumbers[i],2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGpointsnumbers[i],3,BGfade,255,255,255);
	i++;
	}

	ObjEffect_SetVertexUV(BGdifficulty,0,0,0+(difficulty*36)-36);
	ObjEffect_SetVertexUV(BGdifficulty,1,120,0+(difficulty*36)-36);
	ObjEffect_SetVertexUV(BGdifficulty,2,0,36+(difficulty*36)-36);
	ObjEffect_SetVertexUV(BGdifficulty,3,120,36+(difficulty*36)-36);

	
	ObjEffect_SetVertexUV(BGstages1,0,0,0+(SPpage*60)-60); ObjEffect_SetVertexUV(BGstages1,1,249,0+(SPpage*60)-60);
	ObjEffect_SetVertexUV(BGstages1,2,0,60+(SPpage*60)-60); ObjEffect_SetVertexUV(BGstages1,3,249,60+(SPpage*60)-60);

	ObjEffect_SetVertexUV(BGstages2,0,0,0+(SPpage*60)-420); ObjEffect_SetVertexUV(BGstages2,1,399,0+(SPpage*60)-420);
	ObjEffect_SetVertexUV(BGstages2,2,0,60+(SPpage*60)-420); ObjEffect_SetVertexUV(BGstages2,3,399,60+(SPpage*60)-420);

let number=GetCommonData("SpellcardPoints");
let i=0;
let digit=0;
	loop(3){
		if(i==2){ digit=floor(number)%10; }
		if(i==1){ digit=floor(number/10)%10; }
		if(i==0){ digit=floor(number/100)%10; }
	ObjEffect_SetVertexUV(BGpointsnumbers[i],0,0+(digit*20),24); ObjEffect_SetVertexUV(BGpointsnumbers[i],1,20+(digit*20),24);
	ObjEffect_SetVertexUV(BGpointsnumbers[i],2,0+(digit*20),48); ObjEffect_SetVertexUV(BGpointsnumbers[i],3,20+(digit*20),48);
	i++;
	}

if(SPpage<7){
	ObjEffect_SetVertexColor(BGback3,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback3,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGback3,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGback3,3,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGdifficulty,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGdifficulty,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,3,BGfade,255,255,255);
}
else{
	ObjEffect_SetVertexColor(BGback3,0,0,255,255,255); ObjEffect_SetVertexColor(BGback3,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGback3,2,0,255,255,255); ObjEffect_SetVertexColor(BGback3,3,0,255,255,255);
	ObjEffect_SetVertexColor(BGdifficulty,0,0,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGdifficulty,2,0,255,255,255); ObjEffect_SetVertexColor(BGdifficulty,3,0,255,255,255);
}


if(SPscroll>0){
	Obj_SetPosition(BGselection2,270,miny+39+(SPscroll*SPverticalscroll));
	ObjEffect_SetVertexColor(BGselection1,0,0,255,255,255); ObjEffect_SetVertexColor(BGselection1,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGselection1,2,0,255,255,255); ObjEffect_SetVertexColor(BGselection1,3,0,255,255,255);
	ObjEffect_SetVertexColor(BGselection2,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGselection2,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGselection2,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGselection2,3,BGfade,255,255,255);
}
else{
	Obj_SetPosition(BGselection2,270,miny+39+(SPscroll*SPverticalscroll));
	ObjEffect_SetVertexColor(BGselection1,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGselection1,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGselection1,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGselection1,3,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGselection2,0,0,255,255,255); ObjEffect_SetVertexColor(BGselection2,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGselection2,2,0,255,255,255); ObjEffect_SetVertexColor(BGselection2,3,0,255,255,255);
}

if(SPpage<7){
	ObjEffect_SetVertexColor(BGstages1,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGstages1,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGstages1,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGstages1,3,BGfade,255,255,255);
}
else{
	ObjEffect_SetVertexColor(BGstages1,0,0,255,255,255); ObjEffect_SetVertexColor(BGstages1,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGstages1,2,0,255,255,255); ObjEffect_SetVertexColor(BGstages1,3,0,255,255,255);
}
if(SPpage>=7){
	ObjEffect_SetVertexColor(BGstages2,0,BGfade,255,255,255); ObjEffect_SetVertexColor(BGstages2,1,BGfade,255,255,255);
	ObjEffect_SetVertexColor(BGstages2,2,BGfade,255,255,255); ObjEffect_SetVertexColor(BGstages2,3,BGfade,255,255,255);
}
else{
	ObjEffect_SetVertexColor(BGstages2,0,0,255,255,255); ObjEffect_SetVertexColor(BGstages2,1,0,255,255,255);
	ObjEffect_SetVertexColor(BGstages2,2,0,255,255,255); ObjEffect_SetVertexColor(BGstages2,3,0,255,255,255);
}


if(BGfade>=255){
if(GetKeyState(VK_DOWN)==KEY_PUSH && SPtime>=0 && SPscrolltime<=0){ SPscroll++; SPscrolltime=5; PlaySE(SEmenumove1); }
if(GetKeyState(VK_UP)==KEY_PUSH && SPtime>=0 && SPscrolltime<=0){ SPscroll--; SPscrolltime=5; PlaySE(SEmenumove1); }

if(GetKeyState(VK_RIGHT)==KEY_PUSH && SPtime>=0 && SPscroll==0 && SPpage<7){ SetCommonData("Difficulty",GetCommonData("Difficulty")+1); PlaySE(SEmenumove1); }
if(GetKeyState(VK_LEFT)==KEY_PUSH && SPtime>=0 && SPscroll==0 && SPpage<7){ SetCommonData("Difficulty",GetCommonData("Difficulty")-1); PlaySE(SEmenumove1); }
if(GetCommonData("Difficulty")<1){ SetCommonData("Difficulty",4); }
if(GetCommonData("Difficulty")>4){ SetCommonData("Difficulty",1); }
difficulty=GetCommonData("Difficulty");
}


if(GetKeyState(VK_RIGHT)==KEY_PUSH && SPtime>=0 && SPscrolltime<=0){
	SPrememberscroll[SPpage]=SPscroll; SPpagetime=0; SPscrolltime=5;
	if(SPscroll>0){ SPpage++; }
	if(SPpage==7 && GetCommonDataDefault("ExtraUnlocked",false)==false){ SPpage++; }
	if(SPpage==8 && GetCommonDataDefault("NightmareUnlocked",false)==false){ SPpage++; }
	if(SPpage==9 && GetCommonDataDefault("TrumpCardsUnlocked",false)==false){ SPpage++; }
		let i=0;
		while(i<length(letters)){
		Obj_Delete(letters[i]);
		i++;
		}
PlaySE(SEmenumove1);
}
if(GetKeyState(VK_LEFT)==KEY_PUSH && SPtime>=0 && SPscrolltime<=0){
	SPrememberscroll[SPpage]=SPscroll; SPpagetime=0; SPscrolltime=5;
	if(SPscroll>0){ SPpage--; }
	if(SPpage<1){ SPpage=9; }
	SPrememberscroll[SPpage]=SPscroll; SPpagetime=0; SPscrolltime=5;
	if(SPpage==9 && GetCommonDataDefault("TrumpCardsUnlocked",false)==false){ SPpage--; }
	SPrememberscroll[SPpage]=SPscroll; SPpagetime=0; SPscrolltime=5;
	if(SPpage==8 && GetCommonDataDefault("NightmareUnlocked",false)==false){ SPpage--; }
	SPrememberscroll[SPpage]=SPscroll; SPpagetime=0; SPscrolltime=5;
	if(SPpage==7 && GetCommonDataDefault("ExtraUnlocked",false)==false){ SPpage--; }
	let i=0;
		while(i<length(letters)){
		Obj_Delete(letters[i]);
		i++;
		}
PlaySE(SEmenumove1);
}
if(SPscrolltime>0){ SPscrolltime--; }


if(SPpage==1 || SPpage>9){ SPpagemaxscroll=4; if(difficulty>=4){ SPpagemaxscroll++; } }
if(SPpage==2){ SPpagemaxscroll=4; if(difficulty>=4){ SPpagemaxscroll++; } }
if(SPpage==3){ SPpagemaxscroll=6; if(difficulty>=3){ SPpagemaxscroll++; } }
if(SPpage==4){ SPpagemaxscroll=7; if(difficulty>=3){ SPpagemaxscroll++; } }
if(SPpage==5){ SPpagemaxscroll=7; if(difficulty>=2){ SPpagemaxscroll++; } }
if(SPpage==6){ SPpagemaxscroll=8; if(difficulty>=2){ SPpagemaxscroll++; } }
if(SPpage==7){ SPpagemaxscroll=15; SetCommonData("Difficulty",5); }
if(SPpage==8){ SPpagemaxscroll=10; SetCommonData("Difficulty",6); }
if(SPpage==9 || SPpage<1){ SetCommonData("Difficulty",7); SPpagemaxscroll=18; }

if(SPscroll<0 && SPpage==1){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==1){ SPscroll=0; SPspellnr=1; }
if(SPscroll<0 && SPpage==2){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==2){ SPscroll=0; SPspellnr=6; }
if(SPscroll<0 && SPpage==3){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==3){ SPscroll=0; SPspellnr=11; }
if(SPscroll<0 && SPpage==4){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==4){ SPscroll=0; SPspellnr=18; }
if(SPscroll<0 && SPpage==5){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==5){ SPscroll=0; SPspellnr=26; }
if(SPscroll<0 && SPpage==6){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==6){ SPscroll=0; SPspellnr=34; }
if(SPscroll<1 && SPpage==7){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==7){ SPscroll=1; SPspellnr=43; }
if(SPscroll<1 && SPpage==8){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==8){ SPscroll=1; SPspellnr=58; }
if(SPscroll<1 && SPpage==9){ SPscroll=SPpagemaxscroll; } if(SPscroll>SPpagemaxscroll && SPpage==9){ SPscroll=1; SPspellnr=68; }
if(SPpage<1){ SPpage=9; SPscroll=SPrememberscroll[1]; }
if(SPpage>9){ SPpage=1; SPscroll=SPrememberscroll[9]; }

if((GetKeyState(VK_SHOT)==KEY_PUSH && GetCommonDataDefault("PauseSpellcardPractise",0)==0 && SPtime>=0 && SPscroll>0 && time>0) || GetCommonDataDefault("RetrySpellcard",0)==1 && SPtime>=0){

if(GetScore>0){ AddScore(-GetScore); }
if(GetGraze>0){ AddGraze(-GetGraze); }

	if(SPpage==1){
if(SPscroll==1 && GetCommonData("SpellcardData")[1]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 1/Tomoko - Circle Of Life - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",30); SetCommonData("PlayMusic",1); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[2]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 1/Setsuko - Unwritten Code Of Ethics - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",60); SetCommonData("PlayMusic",1); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[3]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 1/Shinichi - Suppressive Fire - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",60); SetCommonData("PlayMusic",1); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[4]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 1/Setsuko-Shinichi - Good Cop Bad Cop - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",60); SetCommonData("PlayMusic",1); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && difficulty>=4 && GetCommonData("SpellcardData")[5]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 1/Setsuko-Shinichi - Speaking Is Silver, Silence Is Golden - Lunatic.txt",cx,miny+80,0,0,0); SetCommonData("PlayMusic",1); SetCommonData("Power",60); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}
	
	if(SPpage==2){
if(SPscroll==1 && GetCommonData("SpellcardData")[6]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Youko - Blazing Photosphere - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",90); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && difficulty==1 && GetCommonData("SpellcardData")[7]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Tides - Slack Water - Easy.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && difficulty==2 && GetCommonData("SpellcardData")[7]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Tides - Neap Tide - Normal.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && difficulty==3 && GetCommonData("SpellcardData")[7]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Tides - Spring Tide - Hard.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && difficulty==4 && GetCommonData("SpellcardData")[7]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Tides - Perigean Spring Tide - Lunatic.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && difficulty==1 && GetCommonData("SpellcardData")[8]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - The Moon Is Green - Easy.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && difficulty==2 && GetCommonData("SpellcardData")[8]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - The Moon Is Yellow - Normal.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && difficulty==3 && GetCommonData("SpellcardData")[8]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - The Moon Is White - Hard.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && difficulty==4 && GetCommonData("SpellcardData")[8]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - The Moon Is Orange - Lunatic.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[9]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Once In A Blue Moon - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && difficulty>=4 && GetCommonData("SpellcardData")[10]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 2/Amaya - Lunacy - Lunatic.txt",cx,miny+80,0,0,0); SetCommonData("Power",120); SetCommonData("PlayMusic",2); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==3){
if(SPscroll==1 && GetCommonData("SpellcardData")[11]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Ayano - Katorisenko - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[12]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Ayano - Yellow Empress - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[13]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Sayuri-Mai - Optical Illusion - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[14]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Mai - Dancing Furin - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[15]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Sayuri - Bizarre Magic - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[16]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Sayuri-Mai - Terminal Velocity - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && difficulty>=3 && GetCommonData("SpellcardData")[17]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 3/Sayuri-Mai - Phantom Ringing - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",3); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==4){
if(SPscroll==1 && GetCommonData("SpellcardData")[18]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Ryo - Backstabber - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[19]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Ryo - Concealing Wall Of Smoke - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[20]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Hotaru - Heatwave - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[21]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Kurumi - Coercion - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[22]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Hotaru - Bomb Shelter - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[23]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Kurumi - Oppression - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("SpellcardData")[24]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Kurumi-Hotaru - Firebreak - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty>=3 && GetCommonData("SpellcardData")[25]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 4/Kurumi-Hotaru - Fire Whirl - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",4); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==5){
if(SPscroll==1 && GetCommonData("SpellcardData")[26]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Midori - Fear Of Forests - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[27]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Midori - Fear Of Spiders - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[28]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Takeo - Foam Party - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[29]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi - Gambler's Conceit - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[30]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Takeo - Humidity Control - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[31]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi - Monte Carlo Fallacy - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("SpellcardData")[32]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi-Takeo - Splashing The Pot - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty==2 && GetCommonData("SpellcardData")[33]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi-Takeo - Flush - Normal.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty==3 && GetCommonData("SpellcardData")[33]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi-Takeo - Straight Flush - Hard.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty==4 && GetCommonData("SpellcardData")[33]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 5/Tomomi-Takeo - Royal Flush - Lunatic.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",5); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==6){
if(SPscroll==1 && GetCommonData("SpellcardData")[34]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Haruna - Mind-Blindness - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[35]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Haruna - Empathic Distress - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[36]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - Primordial Soup - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[37]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - Genetic Drift - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[38]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - Extinction - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[39]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - The Butterfly Effect - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("SpellcardData")[40]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - Tree Of Life - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty>1 && GetCommonData("SpellcardData")[41]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - Evolution Of Danmaku - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && difficulty==1 && GetCommonData("SpellcardData")[42]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - The Meaning Of Life - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==9 && difficulty>1 && GetCommonData("SpellcardData")[42]>0){ CreateEnemyBossFromFile("script/Spellcards/Stage 6/Tomoko - The Meaning Of Life - "~difficultyname~".txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",6); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==7){
SetCommonData("Difficulty",5);
if(SPscroll==1 && GetCommonData("SpellcardData")[43]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Nanami - Spaghetti With Meatballs.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[44]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Nanami - Pizza Margherita.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[45]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Nanami - All Flavors Of Gelato.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[46]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Youko - Solar Flare.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[47]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Hotaru - The Fire Tetrahedron.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[48]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Mai - Sonar.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("SpellcardData")[49]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Amaya - Full Thunder Moon.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && GetCommonData("SpellcardData")[50]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Ayano - Suikawari.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==9 && GetCommonData("SpellcardData")[51]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Midori - Fear Of Waves.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==10 && GetCommonData("SpellcardData")[52]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Tomomi - Red Snake Roulette Bet.txt",cx,miny+80,0,0,0); SetCommonData("PlayMusic",7); SetCommonData("Power",160); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==11 && GetCommonData("SpellcardData")[53]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Kurumi - Mind Crusher.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==12 && GetCommonData("SpellcardData")[54]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Setsuko - Egalitarianism.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==13 && GetCommonData("SpellcardData")[55]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Sayuri - Devil's Torture Chamber.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==14 && GetCommonData("SpellcardData")[56]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Haruna - Altered State Of Consciousness.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==15 && GetCommonData("SpellcardData")[57]>0){ CreateEnemyBossFromFile("script/Spellcards/Extra/Tomoko - Circle Of Life And Death.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",7); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==8){
SetCommonData("Difficulty",6);
if(SPscroll==1 && GetCommonData("SpellcardData")[58]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/1 - Polysomnography.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("SpellcardData")[59]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/2 - Slow Wave Sleep.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("SpellcardData")[60]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/3 - K-Complex.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("SpellcardData")[61]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/4 - Kanashibari.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("SpellcardData")[62]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/5 - Shared Dream.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("SpellcardData")[63]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/6 - Zhuangzi Dreamed He Was A Butterfly.txt",cx,miny+80,0,0,0); SetCommonData("PlayMusic",8); SetCommonData("Power",160); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("SpellcardData")[64]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/7 - Dreamcatcher.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && GetCommonData("SpellcardData")[65]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/8 - Reality Check.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==9 && GetCommonData("SpellcardData")[66]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/9 - False Awakening.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==10 && GetCommonData("SpellcardData")[67]>0){ CreateEnemyBossFromFile("script/Spellcards/Nightmare/10 - Night Terror.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",8); SPplayspellcard=1; SetCommonData("InEvent",0); }
	}

	if(SPpage==9){
SetCommonData("Difficulty",7);
if(SPscroll==1 && GetCommonData("TrumpCardUnlocked")[1]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Kurumi - Superficial Charm.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==2 && GetCommonData("TrumpCardUnlocked")[2]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Hotaru - Flashover.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9); SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==3 && GetCommonData("TrumpCardUnlocked")[3]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Tomoko - Monolith.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==4 && GetCommonData("TrumpCardUnlocked")[4]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Setsuko - Last Word.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==5 && GetCommonData("TrumpCardUnlocked")[5]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Ayano - Vermilion Bird of the South.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==6 && GetCommonData("TrumpCardUnlocked")[6]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Midori - Fear Of Falling In Love.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==7 && GetCommonData("TrumpCardUnlocked")[7]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Tomomi - Three Card Monte.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==8 && GetCommonData("TrumpCardUnlocked")[8]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Youko - Yasakani No Magatama.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==9 && GetCommonData("TrumpCardUnlocked")[9]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Amaya - Yata No Kagami.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==10 && GetCommonData("TrumpCardUnlocked")[10]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Sayuri - Sucker Effect.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==11 && GetCommonData("TrumpCardUnlocked")[11]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Mai - Musical Score.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==12 && GetCommonData("TrumpCardUnlocked")[12]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Haruna - Clairvoyance.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==13 && GetCommonData("TrumpCardUnlocked")[13]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Takeo - Kusanagi No Tsurugi.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==14 && GetCommonData("TrumpCardUnlocked")[14]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Masahiro - Panacea.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==15 && GetCommonData("TrumpCardUnlocked")[15]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Ryo - Shadow Clone.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==16 && GetCommonData("TrumpCardUnlocked")[16]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Shinichi - Lock On And Terminate The Target.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==17 && GetCommonData("TrumpCardUnlocked")[17]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Nanami - La Tomatina.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }
if(SPscroll==18 && GetCommonData("TrumpCardUnlocked")[18]==2){ CreateEnemyBossFromFile("script/Spellcards/Trump Cards/Witches - Eternal Recurrence.txt",cx,miny+80,0,0,0); SetCommonData("Power",160); SetCommonData("PlayMusic",9);  SPplayspellcard=1; SetCommonData("InEvent",0); }

if(SPscroll==1 && GetCommonData("TrumpCardUnlocked")[1]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,1); }
if(SPscroll==2 && GetCommonData("TrumpCardUnlocked")[2]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,2); }
if(SPscroll==3 && GetCommonData("TrumpCardUnlocked")[3]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,3); }
if(SPscroll==4 && GetCommonData("TrumpCardUnlocked")[4]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,4); }
if(SPscroll==5 && GetCommonData("TrumpCardUnlocked")[5]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,5); }
if(SPscroll==6 && GetCommonData("TrumpCardUnlocked")[6]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,6); }
if(SPscroll==7 && GetCommonData("TrumpCardUnlocked")[7]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,7); }
if(SPscroll==8 && GetCommonData("TrumpCardUnlocked")[8]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,8); }
if(SPscroll==9 && GetCommonData("TrumpCardUnlocked")[9]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,9); }
if(SPscroll==10 && GetCommonData("TrumpCardUnlocked")[10]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,10); }
if(SPscroll==11 && GetCommonData("TrumpCardUnlocked")[11]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,11); }
if(SPscroll==12 && GetCommonData("TrumpCardUnlocked")[12]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,12); }
if(SPscroll==13 && GetCommonData("TrumpCardUnlocked")[13]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,13); }
if(SPscroll==14 && GetCommonData("TrumpCardUnlocked")[14]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,14); }
if(SPscroll==15 && GetCommonData("TrumpCardUnlocked")[15]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,15); }
if(SPscroll==16 && GetCommonData("TrumpCardUnlocked")[16]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,16); }
if(SPscroll==17 && GetCommonData("TrumpCardUnlocked")[17]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,17); }
if(SPscroll==18 && GetCommonData("TrumpCardUnlocked")[18]==0){ CreateEnemyBossFromFile("script/Functions/Main Menu/UnlockRequirements.txt",cx,miny+80,0,0,18); }
	}

if(GetCommonData("InEvent")==0){
	SetCommonData("BlackScreenFade",0);
	SetCommonData("Boss1X",cx); SetCommonData("Boss1Y",miny+80);
	SetCommonData("Boss2X",cx); SetCommonData("Boss2Y",miny+40);
	SetCommonData("Destination1X",cx); SetCommonData("Destination1Y",miny+80);
	SetCommonData("Destination2X",cx); SetCommonData("Destination2Y",miny+40);
	SetShotColor(255,255,255);
	SetCommonData("Points",0);
	SetCommonData("InSpellcardPractise",1);
	SetCommonData("RetrySpellcard",0);
}

} // push Z

if(GetCommonData("InEvent")==1){ SetCommonData("InSpellcardPractise",0); }


if(SPpage==1){ //Stage 1
spellcardnumber=1;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==1){ SpellcardName("Birth [Circle Of Life]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==2){ SpellcardName("Morality [Unwritten Code Of Ethics]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==3){ SpellcardName("Tactics [Suppressive Fire]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==4){ SpellcardName("Authority [Good Cop, Bad Cop]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==5 && difficulty>=4){ SpellcardName("[Speaking Is Silver, Silence Is Golden]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==2){ //Stage 2
spellcardnumber=6;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==6){ SpellcardName("Corona [Blazing Photosphere]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==7 && difficulty==1){ SpellcardName("Tidal Force [Slack Water]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==7 && difficulty==2){ SpellcardName("Tidal Force [Neap Tide]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==7 && difficulty==3){ SpellcardName("Tidal Force [Spring Tide]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==7 && difficulty==4){ SpellcardName("Tidal Force [Perigean Spring Tide]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==8 && difficulty==1){ SpellcardName("[The Moon Is Green Because...]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==8 && difficulty==2){ SpellcardName("[The Moon Is Yellow Because...]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==8 && difficulty==3){ SpellcardName("[The Moon Is White Because...]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==8 && difficulty==4){ SpellcardName("[The Moon Is Orange Because...]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==9){ SpellcardName("[Once In A Blue Moon]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==10 && difficulty>=4){ SpellcardName("[Lunacy]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==3){ //Stage 3
spellcardnumber=11;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==11){ SpellcardName("Summer [Katorisenko]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==12){ SpellcardName("Summer [Yellow Empress]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==13){ SpellcardName("Gimmick [Optical Illusion]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==14){ SpellcardName("Summer Breeze [Dancing Furin]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==15){ SpellcardName("Impromptu [Bizarre Magic]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==16){ SpellcardName("Misdirection [Terminal Velocity]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==17 && difficulty>=3){ SpellcardName("Psychoacoustics [Phantom Ringing]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==4){ //Stage 4
spellcardnumber=18;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==18){ SpellcardName("Yoji Gakure [Backstabber]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==19){ SpellcardName("Metsubushi [Concealing Wall Of Smoke]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==20){ SpellcardName("Hyperthermia [Heatwave]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==21){ SpellcardName("Intimidation [Coercion]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==22){ SpellcardName("Pyromania [Bomb Shelter]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==23){ SpellcardName("Tyrannization [Oppression]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==24){ SpellcardName("Intimidation [Firebreak]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==25 && difficulty>=3){ SpellcardName("Pressure [Fire Whirl]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==5){ //Stage 5
spellcardnumber=26;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==26){ SpellcardName("[Fear Of Forests At Night]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==27){ SpellcardName("Arachnophobia [Fear of Spiders]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==28){ SpellcardName("[Foam Party]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==29){ SpellcardName("One Armed Bandit [Gambler's Conceit]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==30){ SpellcardName("Condensation [Humidity Control]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==31){ SpellcardName("Roulette [Monte Carlo Fallacy]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==32){ SpellcardName("Faux Pas [Splashing The Pot]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==33 && difficulty==2){ SpellcardName("Cold Deck [Flush]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==33 && difficulty==3){ SpellcardName("Cold Deck [Straight Flush]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==33 && difficulty==4){ SpellcardName("Cold Deck [Royal Flush]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==6){ //Stage 6
spellcardnumber=34;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==34){ SpellcardName("Psychoanalysis [Mind-blindness]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==35){ SpellcardName("Theory of Mind [Empathic Distress]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==36){ SpellcardName("Heredity [Primordial Soup]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==37){ SpellcardName("Evolutionary Variation [Genetic Drift]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==38){ SpellcardName("Natural Selection [Extinction]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==39){ SpellcardName("Determinism [The Butterfly Effect]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==40){ SpellcardName("[Tree of Life]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==41 && difficulty>1){ SpellcardName("[Evolution Of Danmaku]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==41 && difficulty==1){ SpellcardName("[The Meaning Of Life]",spellcardnumber+1,nameypos,lockstatus); }
	if(spellcardnumber==42 && difficulty>1){ SpellcardName("[The Meaning Of Life]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==7){ // Extra
spellcardnumber=43;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==43){ SpellcardName("Appetizer [Spaghetti With Meatballs]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==44){ SpellcardName("Main Dish [Pizza Margherita]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==45){ SpellcardName("Dessert [All Flavors Of Gelato]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==46){ SpellcardName("Prominence [Solar Flare]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==47){ SpellcardName("Ignition [The Fire Tetrahedron]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==48){ SpellcardName("Echolocation [Sonar]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==49){ SpellcardName("[Full Thunder Moon]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==50){ SpellcardName("Summer [Suikawari]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==51){ SpellcardName("Kymophobia [Fear of Waves]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==52){ SpellcardName("[Red Snake Roulette Bet]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==53){ SpellcardName("Pressure [Mind Crusher]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==54){ SpellcardName("Justice [Egalitarianism]",spellcardnumber,nameypos,lockstatus); }	
	if(spellcardnumber==55){ SpellcardName("[Devil's Torture Chamber]",spellcardnumber,nameypos,lockstatus); }	
	if(spellcardnumber==56){ SpellcardName("[Altered State Of Consciousness]",spellcardnumber,nameypos,lockstatus); }	
	if(spellcardnumber==57){ SpellcardName("[Circle Of Life And Death]",spellcardnumber,nameypos,lockstatus); }	
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==8){ // Nightmare
spellcardnumber=58;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==58){ SpellcardName("Oneirology [Polysomnography]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==59){ SpellcardName("Oneirology [Slow Wave Sleep]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==60){ SpellcardName("Non Rapid Eye Movement [K-Complex]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==61){ SpellcardName("Sleep Paralysis [Kanashibari]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==62){ SpellcardName("Embodied Imagination [Shared Dream]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==63){ SpellcardName("[Zhuangzi Dreamed He Was A Butterfly]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==64){ SpellcardName("[Dreamcatcher]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==65){ SpellcardName("Lucid Dream [Reality Check]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==66){ SpellcardName("Lucid Dream [False Awakening]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==67){ SpellcardName("Parasomnia [Night Terror]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}
if(SPpage==9){ // Trump Cards
spellcardnumber=68;
let nameypos=miny+60;
let lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	loop(SPpagemaxscroll){
	lockstatus=GetCommonData("SpellcardData")[spellcardnumber];
	if(spellcardnumber==68){ SpellcardName("Kurumi - Influence [Superficial Charm]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==69){ SpellcardName("Hotaru - Pyromania [Flashover]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==70){ SpellcardName("Tomoko - Artificial Evolution [Monolith]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==71){ SpellcardName("Setsuko - Verdict [Last Word]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==72){ SpellcardName("Ayano - Summer [Vermilion Bird Of The South]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==73){ SpellcardName("Midori - Philophobia [Fear Of Falling In Love]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==74){ SpellcardName("Tomomi - [Three Card Monte]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==75){ SpellcardName("Youko - [Yasakani No Magatama]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==76){ SpellcardName("Amaya - [Yata No Kagami]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==77){ SpellcardName("Sayuri - Equivocation [Sucker Effect]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==78){ SpellcardName("Mai - Virtuoso [Musical Score]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==79){ SpellcardName("Haruna - Extra Sensory Perception [Clairvoyance]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==80){ SpellcardName("Takeo - [Kusanagi No Tsurugi]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==81){ SpellcardName("Masahiro - Philosopher's Stone [Panacea]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==82){ SpellcardName("Ryo - Ninpou [Shadow Clone]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==83){ SpellcardName("Shinichi - [Lock On And Terminate The Target]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==84){ SpellcardName("Nanami - Food Fight [La Tomatina]",spellcardnumber,nameypos,lockstatus); }
	if(spellcardnumber==85){ SpellcardName("??? - [Eternal Recurrence]",spellcardnumber,nameypos,lockstatus); }
	spellcardnumber++;
	nameypos+=SPverticalscroll;
	}
}


function SpellcardName(name,number,line,locked){

if(SPpagetime==0){
	let i=0;
	let wordsize=0;
	let newword=0;
		while(i<(length(name))){
		
		let letterwidth=[0,0,0];
		if(name[i]=='a'){ letterwidth=[1,11,8]; } if(name[i]=='A'){ letterwidth=[249,261,11]; }
		if(name[i]=='b'){ letterwidth=[11,21,9]; } if(name[i]=='B'){ letterwidth=[262,274,10]; }
		if(name[i]=='c'){ letterwidth=[21,29,7]; } if(name[i]=='C'){ letterwidth=[274,284,9]; }
		if(name[i]=='d'){ letterwidth=[30,40,9]; } if(name[i]=='D'){ letterwidth=[285,297,12]; }
		if(name[i]=='e'){ letterwidth=[40,48,8]; } if(name[i]=='E'){ letterwidth=[298,308,10]; }
		if(name[i]=='f'){ letterwidth=[49,57,7]; } if(name[i]=='F'){ letterwidth=[309,319,8]; }	
		if(name[i]=='g'){ letterwidth=[58,68,9]; } if(name[i]=='G'){ letterwidth=[319,329,10]; }
		if(name[i]=='h'){ letterwidth=[68,78,9]; } if(name[i]=='H'){ letterwidth=[330,340,11]; }
		if(name[i]=='i'){ letterwidth=[79,85,4]; } if(name[i]=='I'){ letterwidth=[341,347,4]; }	
		if(name[i]=='j'){ letterwidth=[85,93,8]; } if(name[i]=='J'){ letterwidth=[347,355,8]; }
		if(name[i]=='k'){ letterwidth=[94,102,8]; } if(name[i]=='K'){ letterwidth=[356,366,10]; }
		if(name[i]=='l'){ letterwidth=[103,109,5]; } if(name[i]=='L'){ letterwidth=[367,377,9]; }
		if(name[i]=='m'){ letterwidth=[110,124,13]; } if(name[i]=='M'){ letterwidth=[377,391,12]; }
		if(name[i]=='n'){ letterwidth=[124,134,9]; } if(name[i]=='N'){ letterwidth=[391,403,11]; }
		if(name[i]=='o'){ letterwidth=[134,142,8]; } if(name[i]=='O'){ letterwidth=[403,415,10]; }
		if(name[i]=='p'){ letterwidth=[143,153,9]; } if(name[i]=='P'){ letterwidth=[415,425,9]; }
		if(name[i]=='q'){ letterwidth=[154,164,9]; } if(name[i]=='Q'){ letterwidth=[426,438,11]; }
		if(name[i]=='r'){ letterwidth=[164,172,7]; } if(name[i]=='R'){ letterwidth=[438,450,10]; }
		if(name[i]=='s'){ letterwidth=[172,180,7]; } if(name[i]=='S'){ letterwidth=[450,460,9]; }
		if(name[i]=='t'){ letterwidth=[180,188,7]; } if(name[i]=='T'){ letterwidth=[461,471,9]; }
		if(name[i]=='u'){ letterwidth=[188,196,8]; } if(name[i]=='U'){ letterwidth=[471,483,11]; }
		if(name[i]=='v'){ letterwidth=[197,207,9]; } if(name[i]=='V'){ letterwidth=[483,495,10]; }
		if(name[i]=='w'){ letterwidth=[207,221,12]; } if(name[i]=='W'){ letterwidth=[495,511,14]; }
		if(name[i]=='x'){ letterwidth=[221,231,8]; } if(name[i]=='X'){ letterwidth=[511,523,11]; }
		if(name[i]=='y'){ letterwidth=[231,239,8]; } if(name[i]=='Y'){ letterwidth=[523,535,10]; }
		if(name[i]=='z'){ letterwidth=[240,248,8]; } if(name[i]=='Z'){ letterwidth=[535,545,9]; }

		if(name[i]=='1'){ letterwidth=[545,551,6]; } if(name[i]=='2'){ letterwidth=[552,562,9]; }
		if(name[i]=='3'){ letterwidth=[562,572,9]; } if(name[i]=='4'){ letterwidth=[572,582,10]; }
		if(name[i]=='5'){ letterwidth=[583,591,8]; } if(name[i]=='6'){ letterwidth=[592,602,10]; }
		if(name[i]=='7'){ letterwidth=[603,611,8]; } if(name[i]=='8'){ letterwidth=[612,622,10]; }
		if(name[i]=='9'){ letterwidth=[623,633,9]; } if(name[i]=='0'){ letterwidth=[633,643,10]; }

		if(name[i]=='?'){ letterwidth=[644,654,9]; } if(name[i]=='!'){ letterwidth=[654,658,4]; } // ? !
		if(name[i]=='.'){ letterwidth=[659,663,3]; } if(name[i]==','){ letterwidth=[663,667,3]; } // . ,
		if(name[i]==':'){ letterwidth=[667,671,4]; } if(name[i]=='`'){ letterwidth=[672,676,3]; } // : '
		if(name[i]=='['){ letterwidth=[676,682,5]; } if(name[i]==']'){ letterwidth=[683,689,6]; } // " x2
		if(name[i]=='@'){ letterwidth=[690,702,12]; } if(name[i]=='#'){ letterwidth=[703,711,8]; } // @ #
		if(name[i]=='%'){ letterwidth=[712,728,15]; } if(name[i]=='&'){ letterwidth=[728,742,13]; } // % &
		if(name[i]=='('){ letterwidth=[754,760,6]; } if(name[i]==')'){ letterwidth=[761,767,5]; } // ( )
		if(name[i]=='<'){ letterwidth=[767,777,9]; } if(name[i]=='>'){ letterwidth=[777,787,9]; } // < >
		if(name[i]=='*'){ letterwidth=[742,754,11]; } if(name[i]=='-'){ letterwidth=[787,795,9]; } // * -

		if(name[i]=='+'){ letterwidth=[0,0,5]; newword=1; wordsize=300; } // Enter
		if(name[i]==' '){ letterwidth=[0,0,5]; newword=1; } // Space

		let xsize=letterwidth[1]-letterwidth[0];
		let ysize=18;
		let scale=1;
		let letterfade=255;

		let skiprest=0;
		if(locked==0){ namered=180; namegreen=180; nameblue=180; skiprest=1; }

		let diffi=GetCommonData("Difficulty");
		number=GetCommonData("SpellcardData")[spellcardnumber];
		
	if(spellcardnumber==41 && difficulty==1){ number=GetCommonData("SpellcardData")[42]; }
	if(spellcardnumber==42 && difficulty>1){ number=GetCommonData("SpellcardData")[42]; }
		
		if(diffi<=number && skiprest==0){ locked=2; skiprest=1; }
		if(diffi>number && skiprest==0){ locked=1; skiprest=1; }
		
		if(locked>0 && locked<=1){ namered=255; namegreen=180; nameblue=180; }
		if(locked==2){ namered=180; namegreen=255; nameblue=180; }
		
		letter=(Obj_Create(OBJ_EFFECT));
		Obj_SetPosition(letter,namexpos+wordsize,line); ObjEffect_SetScale(letter,scale,scale);
		ObjEffect_SetLayer(letter,8); ObjEffect_SetTexture(letter,EFsptext); ObjEffect_SetRenderState(letter,ALPHA);
		ObjEffect_SetPrimitiveType(letter,PRIMITIVE_TRIANGLESTRIP); ObjEffect_CreateVertex(letter,4);
		ObjEffect_SetVertexXY(letter,0,0,-(ysize/2)); ObjEffect_SetVertexUV(letter,0,letterwidth[0],0);
		ObjEffect_SetVertexXY(letter,1,xsize,-(ysize/2)); ObjEffect_SetVertexUV(letter,1,letterwidth[1],0);
		ObjEffect_SetVertexXY(letter,2,0,ysize/2); ObjEffect_SetVertexUV(letter,2,letterwidth[0],ysize);
		ObjEffect_SetVertexXY(letter,3,xsize,ysize/2); ObjEffect_SetVertexUV(letter,3,letterwidth[1],ysize);
		ObjEffect_SetVertexColor(letter,0,letterfade,namered,namegreen,nameblue); ObjEffect_SetVertexColor(letter,1,letterfade,namered,namegreen,nameblue);
		ObjEffect_SetVertexColor(letter,2,letterfade,namered,namegreen,nameblue); ObjEffect_SetVertexColor(letter,3,letterfade,namered,namegreen,nameblue);
		letters=letters~[letter];
		wordsize+=letterwidth[2];
		newword=0;
		
		i++;
		}
}

} // text drawing function

} // play spellcard==0

if(GetKeyState(VK_BOMB)==KEY_PUSH && GetCommonDataDefault("PauseSpellcardPractise",0)==0 && SPplayspellcard==0 && SPtime>=10 && time>0){
	mainmenu=2;
	time=-1;
	frame=-1;
}

if(SPplayspellcard==1 || mainmenu!=3){
	Obj_Delete(BGback1); Obj_Delete(BGback2); Obj_Delete(BGback3);
	Obj_Delete(BGselection1); Obj_Delete(BGselection2);
	Obj_Delete(BGstages1); Obj_Delete(BGstages2);
	Obj_Delete(BGdifficulty); Obj_Delete(BGpoints);
	Obj_Delete(BGpointsnumbers[0]); Obj_Delete(BGpointsnumbers[1]); Obj_Delete(BGpointsnumbers[2]);

	let i=0; while(i<length(letters)){ Obj_Delete(letters[i]); i++; }
	while(length(letters)>0){ letters=erase(letters,0); }
	
if(mainmenu!=3){
	spellcardnumber=1;
	SPpoints=GetCommonDataDefault("SpellcardPoints",0);
	SPtime=0;
	SPscroll=1;
	SPspellnr=0;
	SPverticalscroll=20;
	SPscrolltime=0;
	SPpagetime=-60;
	SPpagemaxscroll=0;
	SPrememberscroll=[0,0,0,0,0,0,0,0,0,0];
	SPplayspellcard=0;
	
	SetCommonData("BackToSpellcardPractise",0);
	SetCommonData("SpellcardPractise",0);
	SetCommonData("PauseSpellcardPractise",0);
	SetCommonData("InSpellcardPractise",0); 
	SetCommonData("InEvent",1);
	SPtime=-1;
	SPpagetime=-61;
	BGfade=0;
	SPplayspellcard=0;
	
	ForbidBomb(false);
	
	SetCommonData("BlackScreenFade",255);
}

if(SPplayspellcard==1){ SPplayspellcard=2; }
}


if(GetCommonDataDefault("SpellcardPoints",0)>=100 && GetCommonData("TrumpCardUnlocked")[5]==0){
//Ayano's
	let spellcarddataarray=GetCommonData("NewTrumpCardsUnlocked");
	spellcarddataarray[5]=1;
	SetCommonData("NewTrumpCardsUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("TrumpCardUnlocked");
	spellcarddataarray[5]=1;
	SetCommonData("TrumpCardUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("SpellcardData");
	spellcarddataarray[72]=0.5;
	SetCommonData("SpellcardData",spellcarddataarray);

	SaveCommonData;
}
if(GetCommonDataDefault("SpellcardPoints",0)>=200 && GetCommonData("TrumpCardUnlocked")[8]==0){
//Youko's
	let spellcarddataarray=GetCommonData("NewTrumpCardsUnlocked");
	spellcarddataarray[8]=1;
	SetCommonData("NewTrumpCardsUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("TrumpCardUnlocked");
	spellcarddataarray[8]=1;
	SetCommonData("TrumpCardUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("SpellcardData");
	spellcarddataarray[75]=0.5;
	SetCommonData("SpellcardData",spellcarddataarray);

	SaveCommonData;
}

if(GetCommonData("TrumpCardsUnlocked")==true && GetCommonDataDefault("ReachedNightmareBattle",0)==1 && GetCommonData("TrumpCardUnlocked")[11]==0){
//Mai's
	let spellcarddataarray=GetCommonData("NewTrumpCardsUnlocked");
	spellcarddataarray[11]=1;
	SetCommonData("NewTrumpCardsUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("TrumpCardUnlocked");
	spellcarddataarray[11]=1;
	SetCommonData("TrumpCardUnlocked",spellcarddataarray);

	let spellcarddataarray=GetCommonData("SpellcardData");
	spellcarddataarray[78]=0.5;
	SetCommonData("SpellcardData",spellcarddataarray);

	SaveCommonData;
}


SPpagetime++;
SPtime++;