/***Script exécuté lorsqu'on finit une partie à la galerie de tir***/

pinv = player.getInventory();

if(typeof bestscore == "undefined") {
	bestscore = 0;
}

if(score > bestscore && score <= 60)
{
	bestscore = score;
}


pinv.emptySlot(26);
pinv.setSlot(26, Item(262, nbfleche));
player.setPosition(264, 47,-378);
player.setStunned(0);
playGame = 0;
sound.playSoundUI("sound.whistle");
sound.playSoundUI("sound.habitantc");
chat.print("Nami : It is finished !");
time.sleep(1.5);
chat.print("Nami : I hope you enjoyed the game.");
sound.playSoundUI("sound.dialogue next");
time.sleep(1.5);
chat.print("Nami : Your score is " + score);
sound.playSoundUI("sound.dialogue next");

if(score <= 30)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Only " + score + " points...");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : It is really bad, you should train at shooting.");
}
else if(score <= 40)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : It isn't an incredible score, but it is pretty good.");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Take those 5 rupees.");
	nbrub = pinv.getItemInSlot(35).getQuantity();
	pinv.emptySlot(35);
	pinv.setSlot(35, Item(266, nbrub+5));
	sound.playSoundUI("sound.get rupee");
}
else if(score <= 50)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Nice score !");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : You deserve those 10 rupees.");
	nbrub = pinv.getItemInSlot(35).getQuantity();
	pinv.emptySlot(35);
	pinv.setSlot(35, Item(266, nbrub+10));
	sound.playSoundUI("sound.get rupee");
}
else if(score < 55)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Wow ! Very nice score !");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Special price for you, 15 rupees !");
	nbrub = pinv.getItemInSlot(35).getQuantity();
	pinv.emptySlot(35);	
	pinv.setSlot(35, Item(266, nbrub+15));
	sound.playSoundUI("sound.get rupee");
}
else if(score < 60)
{	
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : " + score + " points ! Amazing !");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	if(pinv.getSlotContainingItem(318) != -1)
	{
		chat.print("Nami : 20 rupees for this awesome score !");
		nbrub = pinv.getItemInSlot(35).getQuantity();
		pinv.emptySlot(35);
		pinv.setSlot(35, Item(266, nbrub+20));
		sound.playSoundUI("sound.get rupee");
	}
	else
	{
		chat.print("Nami : You deserve to take this quiver. It's yours.");
		time.sleep(3.5);
		sound.playSoundUI("sound.dialogue next");
		chat.print("Nami : With this quiver, you'll be able to have until 500 arrow !");
		pinv.addItem(Item(318));
		sound.playSoundUI("sound.fanfare item");
	}
}
else if(score == 60)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : AWESOME ! 60 points, the best score it is possible to do !");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : It is the first time someone does this score.");
	
	if(pinv.getSlotContainingItem(318) != -1)
	{
		time.sleep(3.5);
		sound.playSoundUI("sound.dialogue next");
		chat.print("Nami : A BIG price for a big score, 30 rupees !");
		nbrub = pinv.getItemInSlot(35).getQuantity();
		pinv.emptySlot(35);
		pinv.setSlot(35, Item(266, nbrub+30));
		sound.playSoundUI("sound.get rupee");
	}
	else
	{
		chat.print("Nami : You deserve to take this quiver. It's yours.");
		time.sleep(3.5);
		sound.playSoundUI("sound.dialogue next");
		chat.print("Nami : With this quiver, you'll be able to have until 500 arrow !");
		pinv.addItem(Item(318));
		sound.playSoundUI("sound.fanfare item");
	}
}
else if(score > 60)
{
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Hum... Very strange, you have a better score thah it is possible to do.");
	time.sleep(3.5);
	sound.playSoundUI("sound.dialogue next");
	chat.print("Nami : Did you cheat ?! There is no price for cheaters.");
}



entitySearch = player.getEntitiesWithinRange(50);
for(i=0 ; i < entitySearch.length ; i++ ) {
	entF = entitySearch[i];
	if(entF.getClassType() == "Arrow") {
		entF.setDead();	
	}
}	
		