Emberveil source

tests/OwnerHatBonusCheck.java

import java.util.Arrays;
public final class OwnerHatBonusCheck {
 static int checks;
 static void check(boolean b,String s){checks++;if(!b)throw new AssertionError(s);}
 static int bonus(MemberQuestsCheck.Fixture p){p.getItemAssistant().resetBonus();p.getItemAssistant().getBonus();return p.playerBonus[10];}
 public static void main(String[]args)throws Exception {
  MemberQuestsCheck.Fixture p=new MemberQuestsCheck.Fixture();Arrays.fill(p.playerEquipment,-1);p.playerName="bonds";p.playerRights=3;
  int base=bonus(p);p.playerEquipment[p.playerHat]=14999;check(bonus(p)==base+500,"bonds hat adds exactly500");check(bonus(p)==base+500,"recalculation does not accumulate");
  p.playerName="darren";check(bonus(p)==base,"co-owner does not inherit bonus");p.playerName="strelly";check(bonus(p)==base,"other players do not inherit bonus");
  p.playerName="bonds";p.playerRights=0;check(bonus(p)==base,"name alone insufficient");p.playerRights=3;p.playerEquipment[p.playerHat]=1044;check(bonus(p)==base,"other rare unaffected");
  p.playerEquipment[p.playerHat]=1038;check(bonus(p)==base,"ordinary red partyhat has no bonus");
  p.playerEquipment[p.playerHat]=-1;check(bonus(p)==base,"unequipping removes bonus");p.playerItems[0]=15000;check(bonus(p)==base,"inventory hat has no bonus");
  check(!p.getItemAssistant().tradeable(14999),"untradeable");check(!new com.rs2.game.players.Trading(p).tradeItem(14999,0,1),"owner cannot trade unique hat");check(!p.getShopAssistant().sellItem(14999,0,1),"owner cannot sell unique hat");
  check(org.apollo.cache.def.ItemDefinition.lookup(14999).getName().contains("black-gold"),"custom definition");
  p.playerName="darren";check(!p.getItemAssistant().wearItem(14999,0),"another player cannot equip owner hat");
  System.out.println("PASS "+checks+" owner-only hat bonus checks");
 }
}