package me.vudu.Conflict.util;
import java.util.HashMap;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericButton;
import org.getspout.spoutapi.gui.WidgetAnchor;
import org.getspout.spoutapi.player.SpoutPlayer;
/**
* Wrapper f�r die Buttons, um Skill-Verhalten zu implementieren
* @author vwendel
*
*/
public class SkillButton {
/**
* der zugrunde liegende Button
*/
public GenericButton button;
public SkillButton(String text, int width, int height, int marginLeft, int marginRight, int level, HashMap<String, Integer> relevantMap,
int relevantValue, HashMap<String, Integer> prereq, int prereqValue, SpoutPlayer player, String tooltip){
button = new GenericButton(text);
button.setAnchor(WidgetAnchor.TOP_LEFT);
button.setWidth(width).setHeight(height);
button.setMarginLeft(marginLeft).setMarginRight(marginRight).setFixed(true);
button.setTooltip(tooltip);
button.setResize(true);
//already taken-> gr�n
if(relevantMap.get(player.getName())>=relevantValue){
button.setColor(new Color(0.0f,1,0,1.0f));
//not taken
}else{
//voraussetzung nicht erf�llt ->disable
if(null!= prereq && prereq.get(player.getName())<prereqValue){
button.setText(button.getText()+" ("+Integer.toString(level)+")");
button.setEnabled(false);
//voraussetzung erf�llt
}else {
//level fehlen -> rot
if(player.getLevel()<level){
button.setColor(new Color(1.0f,0,0,1.0f));
}
//ben�tigte Levels anh�ngen
button.setText(button.getText()+" ("+Integer.toString(level)+")");
}
}
}
}