import java.util.*; public class Confuse2 extends Illusions { String target; String spellName= "Mislead"; int manaCost = 20; int level = 3; String[] targets = {"dragon"}; String description= "Cast it on a dragon and it will go to a place that is in the same general region of the land. Sometimes the dragon may go very far away from its original destination."; /** * Should as the string argument take city#cityname or dragon#dragonname */ public void cast(Fod game, int playerNr, String arg) { System.out.println("Player "+playerNr+" casts "+spellName+" on "+arg); Object o = game.dragons.get(arg); if(o!=null){ Dragon d = (Dragon)o; d.Looks[1] = 4; Area dest = d.getDestination(game.Map); //Sätt om drakens destination; boolean ready = false; while(!ready){ int x_mis = 5-Dice.rand(10); int y_mis = 5-Dice.rand(10); if(dest.x + x_mis >= 0 && dest.x +x_mis <= game.world.X_SIZE -1){ d.X_destination = (short)(dest.x+x_mis); ready = true; }else{ ready = false; } if(dest.y + y_mis >= 0 && dest.y +y_mis <= game.world.Y_SIZE -1){ d.Y_destination = (short)(dest.y+y_mis); ready = ready && true; }else{ ready = false; } } } } ////Primitves public String getSpellName(){ return spellName; } public String getDescription(){ return description; } public int getManaCost(){ return manaCost; } public int getLevel(){ return level; } public String[] getTargetProfile(){ return targets; } public String getTarget(){ return target; } public String setTarget(String t){ target = t; return target; } }