/
com/planet_ink/coffee_mud/Abilities/
com/planet_ink/coffee_mud/Abilities/Common/
com/planet_ink/coffee_mud/Abilities/Diseases/
com/planet_ink/coffee_mud/Abilities/Druid/
com/planet_ink/coffee_mud/Abilities/Fighter/
com/planet_ink/coffee_mud/Abilities/Prayers/
com/planet_ink/coffee_mud/Abilities/Properties/
com/planet_ink/coffee_mud/Abilities/Skills/
com/planet_ink/coffee_mud/Abilities/Songs/
com/planet_ink/coffee_mud/Abilities/Spells/
com/planet_ink/coffee_mud/Abilities/Thief/
com/planet_ink/coffee_mud/Abilities/Traps/
com/planet_ink/coffee_mud/Areas/interfaces/
com/planet_ink/coffee_mud/Behaviors/
com/planet_ink/coffee_mud/CharClasses/interfaces/
com/planet_ink/coffee_mud/Commands/
com/planet_ink/coffee_mud/Commands/interfaces/
com/planet_ink/coffee_mud/Exits/interfaces/
com/planet_ink/coffee_mud/Items/Armor/
com/planet_ink/coffee_mud/Items/Basic/
com/planet_ink/coffee_mud/Items/MiscMagic/
com/planet_ink/coffee_mud/Items/Software/
com/planet_ink/coffee_mud/Items/Weapons/
com/planet_ink/coffee_mud/Libraries/interfaces/
com/planet_ink/coffee_mud/Locales/
com/planet_ink/coffee_mud/Locales/interfaces/
com/planet_ink/coffee_mud/MOBS/
com/planet_ink/coffee_mud/MOBS/interfaces/
com/planet_ink/coffee_mud/Races/
com/planet_ink/coffee_mud/Races/interfaces/
com/planet_ink/coffee_mud/WebMacros/
com/planet_ink/coffee_mud/WebMacros/interfaces/
com/planet_ink/coffee_mud/application/
com/planet_ink/coffee_mud/core/smtp/
com/planet_ink/siplet/applet/
lib/
resources/examples/
resources/fakedb/
resources/quests/delivery/
resources/quests/diseased/
resources/quests/drowning/
resources/quests/gobwar/
resources/quests/holidays/
resources/quests/robbed/
resources/quests/smurfocide/
resources/quests/stolen/
resources/quests/templates/
resources/quests/treasurehunt/
resources/quests/vengeance/
web/
web/admin.templates/
web/admin/images/
web/pub.templates/
web/pub/images/mxp/
web/pub/sounds/
package com.planet_ink.coffee_mud.Abilities.Thief;

import java.util.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.Ability;
import com.planet_ink.coffee_mud.Common.interfaces.CMMsg;
import com.planet_ink.coffee_mud.Items.interfaces.Coins;
import com.planet_ink.coffee_mud.Items.interfaces.Item;
import com.planet_ink.coffee_mud.MOBS.interfaces.MOB;
import com.planet_ink.coffee_mud.core.CMClass;
import com.planet_ink.coffee_mud.core.CMLib;
import com.planet_ink.coffee_mud.core.CMParms;
import com.planet_ink.coffee_mud.core.interfaces.Environmental;
import com.planet_ink.coffee_mud.core.interfaces.MudHost;
import com.planet_ink.coffee_mud.core.interfaces.Tickable;

/*
 * Copyright 2000-2006 Bo Zimmerman, Lee Fox Licensed under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
 * or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
public class Thief_Racketeer extends ThiefSkill
{
    public int classificationCode(){return Ability.ACODE_THIEF_SKILL|Ability.DOMAIN_CRIMINAL;}
    public String ID()
    {
        return "Thief_Racketeer";
    }

    public String name()
    {
        return "Racketeer";
    }

    public String displayText()
    {
        return "";
    }

    protected int canAffectCode()
    {
        return CAN_MOBS;
    }

    protected int canTargetCode()
    {
        return CAN_MOBS;
    }

    public int abstractQuality()
    {
        return Ability.QUALITY_MALICIOUS;
    }
    private static final String[] triggerStrings={"RACKETEER"};

    public String[] triggerStrings()
    {
        return triggerStrings;
    }

    protected boolean disregardsArmorCheck(MOB mob)
    {
        return true;
    }
    public Vector mobs=new Vector();

    public boolean okMessage(Environmental myHost, CMMsg msg)
    {
        if(!super.okMessage(myHost,msg))
        {
            return false;
        }
        MOB source=msg.source();
        if((!msg.source().Name().equals(text()))&&((msg.source().getClanID().length()==0)||(!msg.source().getClanID().equals(text())))
                &&(msg.tool() instanceof Ability)&&(msg.target()==affected)
                &&((((Ability)msg.tool()).classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_THIEF_SKILL))
        {
            if(invoker()==source)
            {
                source.tell(msg.target().name()+" is currently under your protection.");
            }else
            {
                source.tell(msg.target().name()+" is under "+invoker().name()+"'s protection.");
                invoker().tell("Word on the street is that "+source.name()+" is hassling "+msg.target().name()+" who is under your protection.");
            }
            return false;
        }
        return true;
    }

    public boolean invoke(MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel)
    {
        if((commands.size()<1)&&(givenTarget==null))
        {
            mob.tell("Get protection money from whom?");
            return false;
        }
        MOB target=mob.location().fetchInhabitant(CMParms.combine(commands,0));
        if((target==null)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget;
        if((target==null)||(target.amDead())||(!CMLib.flags().canBeSeenBy(target,mob)))
        {
            mob.tell("You don't see '"+CMParms.combine(commands,1)+"' here.");
            return false;
        }
        if((CMLib.coffeeShops().getShopKeeper(target)==null)&&(target.fetchBehavior("MoneyChanger")==null)
                &&(target.fetchBehavior("ItemMender")==null)&&(target.fetchBehavior("ItemIdentifier")==null)
                &&(target.fetchBehavior("ItemRefitter")==null))
        {
            mob.tell("You can't get protection money from "+target.name()+".");
            return false;
        }
        Ability A=target.fetchEffect(ID());
        if(A!=null)
        {
            if(A.invoker()==mob)
                mob.tell(target.name()+" has already been extracted from today.");
            else
            {
                mob.tell(target.name()+" is already under "+A.invoker().name()+"'s protection.");
                A.invoker().tell("Word on the street is that "+mob.name()+" is trying to push into your business with "
                                    +target.name()+".");
            }
            return false;
        }
        int levelDiff=target.envStats().level()-(mob.envStats().level()+(2*super.getXLEVELLevel(mob)));
        if(!target.mayIFight(mob))
        {
            mob.tell("You cannot racketeer "+target.charStats().himher()+".");
            return false;
        }
        if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false;
        double amount=new Long(CMLib.dice().roll(proficiency(),target.envStats().level(),0)).doubleValue();
        boolean success=proficiencyCheck(mob,-(levelDiff),auto);
        if(success)
        {
            CMMsg msg=CMClass.getMsg(mob,target,this,(auto?CMMsg.MASK_ALWAYS:0)|CMMsg.MSG_THIEF_ACT,"<S-NAME> extract(s) "
                    +CMLib.beanCounter().nameCurrencyShort(target,amount)+" of protection money from <T-NAME>.");
            if(mob.location().okMessage(mob,msg))
            {
                mob.location().send(mob,msg);
                beneficialAffect(mob,target,asLevel,new Long(
                        ((Tickable.TIME_MILIS_PER_MUDHOUR*mob.location().getArea().getTimeObj().getHoursInDay()*mob.location().getArea().getTimeObj()
                                .getDaysInMonth())/Tickable.TIME_TICK)).intValue());
                Coins C=CMLib.beanCounter().makeBestCurrency(mob,amount);
                if(C!=null)
                {
                    mob.location().addItemRefuse(C,Item.REFUSE_PLAYER_DROP);
                    CMLib.commands().postGet(mob,null,C,true);
                }
            }
        }else
            maliciousFizzle(mob,target,"<T-NAME> seem(s) unintimidated by <S-NAME>.");
        return success;
    }
}