This repository was archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUnderboss.user.js
More file actions
15 lines (15 loc) · 78.8 KB
/
Underboss.user.js
File metadata and controls
15 lines (15 loc) · 78.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ==UserScript==
// @name The Underboss
// @namespace Underboss
// @author MrAnderson
// @description A bot for the game The Godfather from kabam.com
// @include https://apps.facebook.com/play_godfather*
// @include https://*godfather.*.com/platforms/facebook/game*
// @version 2.2.8
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @downloadURL https://raw.githubusercontent.com/AndreasBomholtz/Underboss/master/Underboss.user.js
// ==/UserScript==
function combine(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];if(void 0!==i)for(var s=Object.keys(i),o=0;o<s.length;o++){var a=s[o];e[a]=i[a]}}return e}function convertToSource(e){var t,i=[],s=[];if("object"==typeof e&&void 0==e.join){i.push("{");for(t in e)s.push(t+": "+convertToSource(e[t]));i.push(s.join(",")),i.push("}")}else if("object"==typeof e&&void 0!=e.join){i.push("[");for(var o=0;o<e.length;o++)s.push("'"+e[o]+"'");i.push(s.join(",")),i.push("]")}else if("function"==typeof e){var a=e.toString();-1!=a.indexOf("random")||i.push(a)}else i.push(JSON.stringify(e));return i.join("")}function setup_facebook(){var e=document.getElementById("iframe_canvas");if(e){for(e.style.width="100%";null!==(e=e.parentNode);)"DIV"==e.tagName&&(e.style.width="100%");$("rightCol").style.display="none"}else setTimeout(setup_facebook,1e3)}function inject(e){var t=document.createElement("script");t.innerHTML=e,t.type="text/javascript",document.getElementsByTagName("head")[0].appendChild(t)}var attackUnits={Thug:{type:"Basic",city:"All",trainable:!0,cost:{cash:750,food:281,steel:563,cement:281,influence:10},bailout:2250},Arsonist:{type:"Basic",city:"All",trainable:!0,requirement:{research:{Logistics:1},build:{Hideout:2}},cost:{cash:1100,food:825,steel:413,cement:413,influence:10},bailout:3300},Demolitionist:{type:"Intermediate",city:"All",trainable:!0,requirement:{research:{Proficiency:4},build:{Garage:3,Hideout:3}},cost:{cash:1700,food:638,steel:1274,cement:638,influence:20},bailout:5100},Bruiser:{type:"Intermediate",city:"All",trainable:!0,requirement:{research:{Corruption:6},build:{Workshop:3,Hideout:4}},cost:{cash:2700,food:2025,steel:1013,cement:1013,influence:20},bailout:8100},Hitman:{type:"Advanced",city:"All",trainable:!0,requirement:{research:{Corruption:7,Proficiency:7},build:{Hideout:6,Workshop:5,Garage:5}},cost:{cash:3800,food:1900,steel:1900,cement:1900,influence:30},bailout:11172},Enforcer:{type:"Advanced",city:"All",trainable:!0,requirement:{research:{Proficiency:8},build:{Garage:6,Hideout:7}},cost:{cash:5700,food:2138,steel:4250,cement:2138,influence:30},bailout:17100},TommyGunner:{type:"Expert",city:"All",trainable:!0,requirement:{research:{Corruption:10},build:{Workshop:6,Hideout:8}},cost:{cash:8500,food:6375,steel:3188,cement:3188,influence:40},bailout:25500},Professional:{type:"Expert",city:"All",trainable:!0,requirement:{research:{Proficiency:12},build:{Garage:9,Hideout:9}},cost:{cash:13e3,food:4875,steel:9750,cement:4875,influence:40},bailout:39e3},Sniper:{type:"Elite",city:"All",trainable:!0,requirement:{research:{Corruption:14,Proficiency:14},build:{Hideout:9,Workshop:9,Garage:9}},cost:{cash:15600,food:7800,steel:7800,cement:7800,influence:40},bailout:46800},Butcher:{type:"Elite",city:"All",trainable:!0,requirement:{research:{Corruption:16,Cooking:17},build:{Workshop:9,Hideout:9}},cost:{cash:17160,food:12870,steel:6435,cement:6435,influence:35},bailout:51480},BlackWidow:{type:"Femme Fatale",city:"All",trainable:!0,requirement:{research:{Corruption:17},build:{Hideout:9,Workshop:9}},cost:{cash:18876,food:14157,steel:7079,cement:7079,influence:35},bailout:56628},Assassin:{type:"Femme Fatale",city:"All",trainable:!0,requirement:{research:{Proficiency:17},build:{Hideout:9,Garage:9}},cost:{cash:18876,food:7079,steel:14157,cement:7079,influence:35},bailout:56628},Courier:{type:"Normal",city:"All",trainable:!0,cost:{cash:500,food:188,steel:188,cement:375,influence:10}},DeliveryTruck:{type:"Normal",city:"All",trainable:!0,requirement:{research:{Mechanics:6,Capacity:8},build:{Hideout:5,Garage:2}},cost:{cash:3800,food:1425,steel:1425,cement:2850,influence:15}},Heavyweight:{type:"Pulitori",city:"LittleItaly",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Foreman:{type:"Pulitori",city:"Queens",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Smuggler:{type:"Pulitori",city:"GreenwichVillage",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Undertaker:{type:"Pulitori",city:"Brooklyn",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Doctor:{type:"Pulitori",city:"ParkAve",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Loanshark:{type:"Pulitori",city:"AtlanticCity",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},HatchetMan:{type:"Pulitori",city:"Chinatown",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},TriggerMan:{type:"Pulitori",city:"Capital",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Bartender:{type:"Pulitori",city:"Harlem",trainable:!0,requirement:{research:{Medicine:12,Muscle:12},build:{Hideout:9}},bailout:62292},Hardliner:{type:"Johnney Law",trainable:!0,city:"Queens",requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},CrookedCop:{type:"Johnney Law",trainable:!0,city:"GreenwichVillage",requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},Captain:{type:"Johnney Law",trainable:!0,city:"LittleItaly",requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},DRC:{type:"Johnney Law",city:"Brooklyn",trainable:!0,requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},PIG:{type:"Johnney Law",city:"ParkAve",trainable:!0,requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},Highbinder:{type:"Johnney Law",city:"Chinatown",trainable:!0,requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},Gman:{type:"Johnney Law",trainable:!0,city:"AtlanticCity",requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},Bookie:{type:"Johnney Law",city:"Harlem",trainable:!0,requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,Workshop:10,Garage:10}},bailout:68250},MisterSnip:{type:"Clean-up Crew",bailout:64388},MisterHaul:{type:"Clean-up Crew",bailout:64482},MisterFixit:{type:"Clean-up Crew",bailout:64388},MissesNeat:{type:"Clean-up Crew",bailout:100530},MisusPatch:{type:"Clean-up Crew",bailout:100530},MisterSplit:{type:"Clean-up Crew",bailout:53478},MisterKippy:{type:"Clean-up Crew",bailout:64388},MisterPao:{type:"Clean-up Crew",bailout:64482},Freighttrain:{trainable:!1},Hitsquad:{trainable:!1},Deathsquad:{trainable:!1},Deliverybomber:{trainable:!1},Medicalcourier:{trainable:!1},Frontman:{trainable:!1,bailout:103020},Skinner:{trainable:!1,bailout:103020},Bassist:{trainable:!1,bailout:103020},Clyde:{trainable:!1,bailout:128775},Bonnie:{trainable:!1,bailout:128775},Romeo:{trainable:!1,bailout:103020},Maneater:{trainable:!1,bailout:103020},Carbomber:{trainable:!1,bailout:103020},Bootlegger:{bailout:161700},Gravedigger:{bailout:161700},SquadLeader:{bailout:154530},CollasMen:{bailout:150795},GateawayDriver:{bailout:125663},JazzMan:{bailout:100530}},buildings={SteelMill:{buildNew:1,cost:{cash:600,food:200,steel:200,cement:500}},Restaurant:{buildNew:1,cost:{cash:600,food:200,steel:500,cement:200}},CementFactory:{buildNew:1,cost:{cash:600,food:500,steel:200,cement:200}},Apartment:{buildNew:6,cost:{cash:500,food:100,steel:100,cement:100}},Hideout:{buildNew:-1,cost:{cash:1200,food:500,steel:500,cement:500}},Mansion:{priority:1,requirement:{build:{5:{Wall:5},7:{Wall:7},8:{Wall:8}}},cost:{cash:2500,food:300,steel:300,cement:300}},Library:{priority:2,cost:{cash:2500,food:1500,steel:200,cement:200}},Warehouse:{requirement:{gangster:4},cost:{cash:1500,food:1e3,steel:300,cement:300}},Garage:{requirement:{build:{2:{Restaurant:5}},gangster:9},cost:{cash:2e3,food:300,steel:1e3,cement:300}},Armory:{requirement:{gangster:3},cost:{cash:3e3,food:300,steel:300,cement:1e3}},Workshop:{requirement:{gangster:7},cost:{cash:3e3,food:300,steel:1e3,cement:300}},GuestHouse:{requirement:{gangster:6},cost:{cash:2e3,food:500,steel:300,cement:300}},Wall:{cost:{cash:6e3,food:1e3,steel:1e3,cement:1e3}},GuardPost:{requirement:{build:{0:{SteelMill:3}},gangster:8},cost:{cash:1500,food:300,steel:300,cement:1e3}},Vault:{requirement:{gangster:3},cost:{cash:3e3,food:300,steel:300,cement:1e3}},FrontGate:{requirement:{gangster:5},cost:{cash:1500,food:500,steel:1500,cement:500}},Exchange:{priority:2,requirement:{build:{2:{GuestHouse:3}}},cost:{cash:3e3,food:300,steel:300,cement:1e3}},Condo:{skip:!0},CrewBank:{offset:{cash:146286,res:38152},requirement:{alliance:!0},cost:{cash:43885,food:11445,steel:11445,cement:11445}},CrewBankBranch:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},FinanciersOffice:{offset:{cash:146286,res:38152},cost:{cash:43885,food:11445,steel:11445,cement:11445}},BlackMarket:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Haberdashery:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Pharmacy:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Hotel:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Gym:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Morgue:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Laundromat:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},DeputyMayorsOffice:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},FerrisWheel:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},GasStation:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Headquarters:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},Hospital:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},ClipJoint:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},ShootingRange:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},KreuserHomeRepair:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},LawFirm:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457}},SafeHouse:{offset:{cash:146286,res:38152},cost:{cash:438857,food:114457,steel:114457,cement:114457},maxlevel:23}},defenseUnits={BarbedWire:{city:"All",trainable:!0,requirement:{research:{Logistics:4},build:{GuardPost:2,Wall:2}},cost:{cash:1700,food:638,steel:638,cement:1275}},BoobyTrap:{city:"All",trainable:!0,requirement:{research:{Logistics:8},build:{GuardPost:4,Wall:4}},cost:{cash:2700,food:1013,steel:1013,cement:2025}},GuardDog:{city:"All",trainable:!0,requirement:{research:{Logistics:12},build:{GuardPost:6,Wall:6}},cost:{cash:8e3,food:6e3,steel:4e3,cement:1e3}},ArmedGuard:{city:"All",trainable:!0,requirement:{research:{Logistics:14},build:{GuardPost:7,Wall:7},cost:{cash:1e4,food:1600,steel:4e3,cement:8e3}}},Bodyguard:{city:"All",trainable:!0,requirement:{research:{Logistics:16},build:{GuardPost:8,Wall:8}},cost:{cash:17160,food:6435,steel:6435,cement:12870}},UnnamedDefender:{city:"All",trainable:!0,requirement:{research:{Logistics:18},build:{GuardPost:9,Wall:9}},cost:{cash:18876,food:7049,steel:7049,cement:14157}},Moneyman:{city:"Capital",trainable:!0,requirement:{research:{Medicine:16,Muscle:16},build:{Hideout:10,GuardPost:10,Wall:10}},cost:{cash:23e3,food:15e3,steel:15e3,cement:15e3}},LeatherHead:{trainable:!1},Mastermind:{trainable:!1},DonCompanion:{trainable:!1}},items={SpeedUp1Minute:{cost:1},SpeedUp5Minute:{cost:3},SpeedUp15Minute:{cost:5},SpeedUp1Hour:{cost:10},SpeedUp2HalfHour:{cost:15},SpeedUp8Hour:{cost:40},SpeedUp15Hour:{cost:65},SpeedUp24Hour:{cost:95},AttackBoost24Hour:{cost:10},SteelBoost24Hour:{cost:7},CementBoost24Hour:{cost:7},FoodBoost24Hour:{cost:7},CashBoost24Hour:{cost:35},SpeedUpTraining30Percent:{cost:35},SteelBoost1Week:{cost:40},FoodBoost1Week:{cost:40},CementBoost1Week:{cost:40},OliveBranch12Hour:{cost:25},OliveBranch24Hour:{cost:40},HealthBoost24Hour:{cost:10},AttackBoost7Day:{cost:35},HealthBoost7Day:{cost:35},RelocationProgram:{cost:30},WreckingBall:{cost:7},ChangeEstateName:{cost:9},Perfume:{cost:25},Energizer:{cost:5},SlickStitch:{cost:10},BoxingTicket:{cost:2},TokenOfServitude:{cost:10},GreenwichVillageDeed:{cost:150},ParkAveDeed:{cost:300},BrooklynDeed:{cost:300},AtlanticCityDeed:{cost:35},ChinatownDeed:{cost:35},RookieBundle:{cost:40},DonsBlessing:{cost:40},DonsBlessing11:{cost:40},ZoningPermit:{cost:40},ContractBundle100:{cost:1,autoCollect:!1},ContractBundle500:{cost:2,autoCollect:!1},ContractBundle1000:{cost:5,autoCollect:!1},FavorBundle100:{cost:1,autoCollect:!1},FavorBundle250:{cost:2,autoCollect:!1},FavorBundle500:{cost:2,autoCollect:!1},FavorBundle1000:{cost:5,autoCollect:!1},FavorBundle3000:{cost:9,autoCollect:!1},KickbackBundle100:{cost:1,autoCollect:!1},KickbackBundle250:{cost:1,autoCollect:!1},KickbackBundle500:{cost:3,autoCollect:!1},KickbackBundle1000:{cost:5,autoCollect:!1},KickbackBundle3000:{cost:6,autoCollect:!1},AppointmentBundle100:{cost:1,autoCollect:!1},AppointmentBundle250:{cost:2,autoCollect:!1},AppointmentBundle500:{cost:3,autoCollect:!1},AppointmentBundle1000:{cost:4,autoCollect:!1},AppointmentBundle3000:{cost:5,autoCollect:!1},ThugBundle25:{cost:5},ArsonistBundle25:{cost:5},ArsonistBundle400:{cost:100},BruiserBundle25:{cost:5},EnforcerBundle25:{cost:5},DemolitionistBundle25:{cost:5},ArmedGuardBundle100:{cost:5},ArmedGuardBundle500:{cost:25},SniperBundle25:{cost:5},ButcherBundle25:{cost:5},TommyGunnerBundle25:{cost:5},HitmanBundle25:{cost:5},AssassinBundle25:{cost:5},GuardDogBundle100:{cost:5},ProfessionalBundle25:{cost:5},BlackWidowBundle25:{cost:5},BlackWidowBundle100:{cost:20},AssassinBundle100:{cost:20},UnnamedDefenderBundle100:{cost:5},BodyguardBundle100:{cost:5},BodyguardBundle500:{cost:25},LesserAttireMedallion:{cost:40},GreaterAttireMedallion:{cost:95},GreaterLuckyToken:{cost:12},PoisonHealth10Percent10Minutes:{cost:10},PoisonHealth25Percent10Minutes:{cost:20},ColesMotorOil:{cost:35},BronzeToolbox:{cost:40},GoldToolbox:{cost:75},Antidote:{cost:35},BronzeBuildingPermit:{cost:40},SilverBuildingPermit:{cost:60},GoldBuildingPermit:{cost:75},UpgradeGuarantee5:{cost:30},UpgradeGuarantee7:{cost:30},PromoteGuarantee1:{cost:30},PromoteGuarantee2:{cost:30},PromoteGuarantee3:{cost:30},PromoteGuarantee4:{cost:30},PromoteGuarantee5:{cost:30},PromoteGuarantee6:{cost:30},PromoteGuarantee7:{cost:30},BankHeistStamp:{cost:30},TributeTicketBundle10:{cost:5,autoCollect:!0},InitiateBundle:{cost:10,autoCollect:!0},AssortedResourcesBundle:{cost:9,autoCollect:!0},AssortedResources250KBundle:{cost:9,autoCollect:!0},PromotionBundle1000:{cost:40},BootleggerBundle25:{cost:10},AddiopizzoBundle10:{cost:10},AddiopizzoBundle50:{cost:50},AddiopizzoBundle100:{cost:100},BonnieBundle250:{cost:200},BrassManBundle500:{cost:250},MastermindBundle500:{cost:250},MissusPatchBundle500:{cost:250},FrontManBundle500:{cost:250},BassistBundle500:{cost:250},MisterHaulBundle500:{cost:250},JazzManBundle500:{cost:250},DeathSquadBundle500:{cost:250},GManBundle500:{cost:250},MisterSplitBundle500:{cost:250},BookieBundle500:{cost:250},PIGBundle500:{cost:250},HitSquadBundle500:{cost:250},MisterKippyBundle500:{cost:250},AssassinBundle500:{cost:250},HatchetManBundle500:{cost:250},BlackWidowBundle500:{cost:250},DeliveryBomberBundle500:{cost:250},MisterFixitBundle500:{cost:250},UndertakerBundle500:{cost:250},TriggerManBundle500:{cost:250},PromotionBundle500:{cost:250},GuardDogBundle500:{cost:100},HardlinerBundle500:{cost:250},MissesNeatBundle500:{cost:250},MoneyManBundle500:{cost:250},LeatherHeadBundle500:{cost:250},DRCBundle500:{cost:250},BartenderBundle500:{cost:250},SkinnerBundle500:{cost:250},SniperBundle500:{cost:250},GetawayDriverBundle500:{cost:250},MisterSnipBundle500:{cost:250},MedicalCourierBundle500:{cost:250},HighbinderBundle500:{cost:250},AddiopizzoBundle25:{cost:5},LoansharkBundle500:{cost:250},HeavyweightBundle500:{cost:250},TributeTicket:{cost:1},MisterPaoBundle500:{cost:250},AddiopizzoBundle5:{cost:1},UnnamedDefenderBundle500:{cost:250},ForemanBundle500:{cost:250},ButcherBundle500:{cost:250},BasicCUCMysteryBox:{autoCollect:!0},BassistMysteryBox:{autoCollect:!0},BearerBondMysteryBox:{autoCollect:!0},BronzeBandMysteryBox:{autoCollect:!0},BronzeCUCMysteryBox:{autoCollect:!0},BronzeTier7MysteryBox:{autoCollect:!0},ConselofElitesMysteryBox:{autoCollect:!0},DefendersMysteryBox:{autoCollect:!0},DonsAssentBundle:{autoCollect:!0},DonsAssentBundle5:{autoCollect:!0},DonsBlessing11Bundle5:{autoCollect:!0},DonsGateMysteryBox:{autoCollect:!0},DonsPermitBundle:{autoCollect:!0},DonsPrivilegeBundle:{autoCollect:!0},DonsRansomBundle:{autoCollect:!0},ExpressBundle:{autoCollect:!0},GoldBandMysteryBox:{autoCollect:!0},GoldCUCMysteryBox:{autoCollect:!0},GoldLuckyTokenMysteryBox:{autoCollect:!0},GoldPulitoriMysteryBox:{autoCollect:!0},GoldTier7MysteryBox:{autoCollect:!0},HolidayBox:{autoCollect:!0},JackpotBundle:{autoCollect:!0},JackpotMysteryBox:{autoCollect:!0},Level10ImperialStateMysteryBox:{autoCollect:!0},MisterFixitBundle250:{autoCollect:!0},PincherMysteryBox:{autoCollect:!0},PitStopMysteryBox:{autoCollect:!0},PlatinumCUCMysteryBox:{autoCollect:!0},PlatinumTier7MysteryBox:{autoCollect:!0},PrimoJackpotBundle:{autoCollect:!0},PrimoJackpotMysteryBox:{autoCollect:!0},ScrappersMysteryBox:{autoCollect:!0},SilverBandMysteryBox:{autoCollect:!0},SilverCUCMysteryBox:{autoCollect:!0},SilverPulitoriMysteryBox:{autoCollect:!0},SilverTier7MysteryBox:{autoCollect:!0},SkinnerMysteryBox:{autoCollect:!0},StrongmansGoldBox:{autoCollect:!0},SuperShiftBundle:{autoCollect:!0},WelcomeBundle:{autoCollect:!0},WesternBundle:{autoCollect:!0},WildWestMysteryBox:{autoCollect:!0},WitnessProtectionBundle:{autoCollect:!0},armorysyndicatebox:{autoCollect:!0},asquadmysterybox:{autoCollect:!0},associatesmysterybox:{autoCollect:!0},babyfacemysterybox:{autoCollect:!0},bountymysterybox:{autoCollect:!0},boxcarmysterybox:{autoCollect:!0},brickandmortarmysterybox:{autoCollect:!0},bronzetokenbundle5:{autoCollect:!0},brooklynwestmysterybox:{autoCollect:!0},buriedtreasure:{autoCollect:!0},carbombermysterybox:{autoCollect:!0},dualbountymysterybox:{autoCollect:!0},funtimesmysterybox:{autoCollect:!0},giadaadvisordecreebox:{autoCollect:!0},gunslingermysterybox2:{autoCollect:!0},gvwestmysterybox:{autoCollect:!0},jamieadvisordecreebox:{autoCollect:!0},kingpinarmorymysterybox:{autoCollect:!0},lucky14mysterybox:{autoCollect:!0},lucky16mysterybox:{autoCollect:!0},lucky17mysterybox:{autoCollect:!0},lucky18mysterybox:{autoCollect:!0},lucky19mysterybox:{autoCollect:!0},lucky21mysterybox:{autoCollect:!0},lucky22mysterybox:{autoCollect:!0},luckyboosterbundle:{autoCollect:!0},lutheradvisordecreebox:{autoCollect:!0},markadvisordecreebox:{autoCollect:!0},mightymysterybox:{autoCollect:!0},recruitsmysterybox:{autoCollect:!0},reinforcedmysterybox:{autoCollect:!0},rogeradvisordecreebox:{autoCollect:!0},rumrunnersmysterybox:{autoCollect:!0},seducermysterybox:{autoCollect:!0}},research={Capacity:{priority:4,requirement:{research:["Cooking","Cementing","Steelwork"]},cost:{cash:250,food:175,steel:175,cement:175}},Carjacking:{priority:5,requirement:{research:["Capacity"],build:"Garage"},cost:{cash:400,food:200,steel:200,cement:200}},Cementing:{priority:2,requirement:{research:["Logistics"],build:"CementFactory"},cost:{cash:150,food:100,steel:100,cement:200}},Construction:{priority:4,requirement:{research:["Maneuver"]},cost:{cash:400,food:200,steel:200,cement:200}},Cooking:{priority:2,requirement:{research:["Logistics"],build:"Restaurant"},cost:{cash:150,food:200,steel:100,cement:100}},Corruption:{priority:5,requirement:{research:["Capacity"],build:"Hideout"},cost:{cash:400,food:200,steel:200,cement:200}},Logistics:{priority:1,requirement:{research:[],build:"Library"},cost:{cash:225,food:150,steel:300,cement:150}},Maneuver:{priority:3,requirement:{research:["Spying"],build:"Garage"},cost:{cash:250,food:175,steel:175,cement:175}},Mechanics:{priority:4,requirement:{research:["Trafficking"],build:"Wall"},cost:{cash:250,food:175,steel:175,cement:175}},Medicine:{priority:6,requirement:{research:["Construction","Corruption"]},cost:{cash:500,food:250,steel:250,cement:250}},Muscle:{priority:6,requirement:{research:["Proficiency","Mechanics"],build:"GaurdPost"},cost:{cash:500,food:250,steel:250,cement:250}},Proficiency:{priority:5,requirement:{research:["Mechanics"],build:"Workshop"},cost:{cash:400,food:200,steel:200,cement:200}},Spying:{priority:2,requirement:{research:["Logistics"]},cost:{cash:200,food:150,steel:150,cement:150}},Steelwork:{priority:2,requirement:{research:["Logistics"],build:"SteelMill"},cost:{cash:150,food:100,steel:200,cement:100}},Trafficking:{priority:3,requirement:{research:["Cooking","Cementing","Steelwork"]},cost:{cash:200,food:150,steel:150,cement:150}},Barricade:{priority:6,requirement:{research:["Construction","Medicine"],city:"Queens"},cost:{cash:5e3,food:2500,steel:2500,cement:2500}},Quickdraw:{priority:6,requirement:{offset:21,research:["Construction","Carjacking"],city:"LittleItaly"},cost:{cash:25313,food:12656,steel:12656,cement:12656}},Bureaucracy:{priority:7,requirement:{offset:21,research:["Muscle","Medicine"]},cost:{cash:3052563,food:1526346,steel:1526281,cement:1526281}},Blackmail:{priority:7,requirement:{offset:21,research:["Muscle","Medicine"]},cost:{cash:3052563,food:1526346,steel:1526281,cement:1526281}}},css=".panel,.hiddenPanel{background-color:red;background-image:url('/images/banner/TGFF_banner_bg.jpg');border:1px solid darkred;color:white;position:absolute;top:0;right:0;width:400px;height:688px;z-index:10}.hiddenPanel{height:25px}.header{background-color:darkred;color:white;width:100%;height:25px;text-align:center;font-size:150%;font-weight:bold;margin:0}.header #version{font-size:75%}.info{width:300px;height:500px}.textinfo{width:300px;height:95px}.prize_info{width:300px;height:500px}table{color:white}div.option{width:110px;float:left}div.stats{width:50%;text-align:left}input.button{background-color:darkred;color:white;border-color:red}.build_order{width:30px}.button_large{width:140px}.tab-box{border-bottom:1px solid darkred;padding-bottom:5px;margin-top:5px}.tab-box a{border:1px solid red;color:white;padding:5px 5px;text-decoration:none;background-color:darkred}.tab-box a.activeLink{background-color:red;border-bottom:0;padding:6px 5px;border-color:darkred}.tabcontent{border:1px solid darkred;border-top:0;overflow-y:auto;height:560px;overflow:auto}.tabcontent p{margin:0}.hide{display:none}.unit_count{width:50px}input.number{width:35px;margin-right:5px}h7{font-weight:bold;display:block}.overlay{position:absolute;top:50%;left:50%;width:930px;height:640px;margin-left:-1120px;margin-top:-335px;background-color:red;background-image:url('/images/banner/TGFF_banner_bg.jpg');color:white;text-align:center;border-radius:5px;z-index:20;box-shadow:0 0 0 9999px rgba(0,0,0,0.5)}#overview_table{width:100%;text-align:left}#overview_table th{font-weight:bold}#overview #total{border-top:double;border-bottom:solid}input.close{position:absolute;top:0;right:0}",ajaxBot={ajax_send:function(e,t,i,s,o,a){void 0===a&&(a=!0);var n=this,r=new XMLHttpRequest;"GET"==s&&(e+="?"+o),r.open(s,e,a),r.onreadystatechange=function(){4==r.readyState&&(200==r.status?t.call(n,r.responseText):i.call(n,r.status,r.responseText))},"POST"==s&&r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(o)}},armorBot={doArmor:function(){this.trace(),this.eachCity(this.doArmorEvent)},doArmorEvent:function(e){if(this.trace(),!e||e.armory)return void this.debugArmor("City do not have armor",e);for(var t=0;t<e.armor.length;t++){var i=e.armor[t].equipped_armory_item.item_id;this.debugArmor("Has item id "+i,e);var s=this.mapIdToName(i);s?this.debugArmor(s[0]+" ("+s[1]+") Lvl "+s[2]):this.debugArmor(i+" not found",e)}},mapIdToName:function(e){return this.trace(),31>e?e>20?["Piano Wire","Gold",e-19]:e>10?["Stilettos","Silver",e-9]:["Bat","Bronze",e]:61>e?e>50?["Tommy Gun","Gold",e-49]:e>40?["Magnum","Silver",e-39]:["Molotov","Bronze",e-29]:91>e?e>80?["Italian Suit","Gold",e-79]:e>70?["Fedora","Silver",e-69]:["Scarf","Bronze",e-59]:e>110?["Caddy","Gold",e-109]:e>100?["Speedster","Silver",e-99]:["Motorcycle","Bronze",e-89]}},attackBot={resetMap:function(){this.trace(),this.options.map_size=3,this.options.map_loaded={},this.updateMap()},updateMap:function(e){if(e||(e=this),e.trace(),!e.cities||!e.cities[0])return void setTimeout(e.updateMap,1e3,e);e.options.map_size+=2;var t=10*((e.options.map_size-1)/2);e.options.map_loaded||(e.options.map_loaded={}),e.eachCity(function(i){var s=i.x-t;0>s&&(s=750+s);var o=i.y-t;0>o&&(o=750+o);for(var a=0;a<e.options.map_size;a++)for(var n=0;n<e.options.map_size;n++){var r=(s+10*a)%750,l=(o+10*n)%750;e.options.map_loaded[r]||(e.options.map_loaded[r]={}),e.options.map_loaded[r][l]?e.debugAttack("Not reloading ("+r+","+l+")"):(e.options.map_loaded[r][l]=!0,e.debugAttack("Get map ("+r+","+l+")"),e.sendSlowGetCommand("Get map ("+r+","+l+")","map.json","x="+r+"&y="+l,i))}}),e.saveOptions()},findBestGang:function(e,t){this.trace(),this.debugAttack("FindBestGang for "+e.type+" with lvl "+t);var i=new Date,s={lvl:0},o=1e3;for(var a in this.options.map)for(var n in this.options.map[a]){var r=this.options.map[a][n];if(r.lvl!=t&&t>1&&r.lvl!=t-1)this.debugAttack("Gang has wrong level ("+r.lvl+" != "+t,e);else if(s.lvl>r.lvl)this.debugAttack("Selected gang is better ("+s.lvl+" > "+r.lvl+")",e);else if(r.attacked&&r.attacked>=i.getTime())this.debugAttack("Gang already attacked",e);else{var l=Math.abs(a-e.x);l>250&&(l=Math.abs(750-l));var d=Math.abs(n-e.y);d>250&&(d=Math.abs(750-d)),l+d>o&&s.lvl===r.lvl?this.debugAttack("Selected gang is closer",e):(o=l+d,s=r,this.debugAttack("Found better Gang "+s.lvl+" at ("+a+","+n+") with dist ("+l+" + "+d+") = "+o,e))}}return s},doAttack:function(){this.trace();var e=6e4,t=new Date;return this.options.map?this.cities&&this.options.attackOrders?(this.eachCity(function(i){if(i.energy<=1)return void this.debugAttack("No more energy",i);if("DoriaAirport"==i.type)return void this.debugAttack(i.type+" can't attack",i);for(var s={gang:0},o=0;o<this.options.attackOrders.length;o++){var a=this.options.attackOrders[o];if(this.debugAttack("Order: "+a.gang+" City: "+a.city+" Units: "+a.units,i),a.city&&"all"!=a.city&&a.city!=i.type)this.debugAttack("Wrong city ("+a.city+" != "+i.type+")",i);else{var n=!0,r=JSON.parse(a.units);if(i.units){for(var l in r)if(!i.units[l]||i.units[l]<r[l]){this.debugAttack("Do not have "+l+" ("+r[l]+")",i),n=!1;break}}else n=!1,this.debugAttack("Missing units in city",i);if(n){var d=parseInt(s.gang,10),c=parseInt(a.gang,10);c>d&&(s=a)}}}if(s.units){var u=this.findBestGang(i,s.gang);if(0===u.lvl)return void this.debugAttack("Failed to find a gang to attack",i);this.debugAttack("Attack "+u.lvl+" Gang at ("+u.x+","+u.y+")",i),u.lvl<=10&&(u.attacked=t.getTime()+18e5);var h=s.units;s.use_all&&(h=this.getAttackUnits(i)),this.attack(u.x,u.y,h,i),e=6e5,this.saveOptions()}}),e):(this.debugAttack("City or orders not ready"),1e4):(this.updateMap(),1e4)},getAttackUnits:function(e){if(this.trace(),e&&e.units){var t=this.clone(e.units);for(var i in this.defenseUnits)t[i]&&delete t[i];var s=0;for(var o in t)s>=e.maximum_troops?delete t[o]:(t[o]>e.maximum_troops-s&&(t[o]=e.maximum_troops-s),this.debugAttack("Add attack units "+o+" => "+t[o]+" ("+s+"/"+e.maximum_troops+")",e),s+=t[o]);return JSON.stringify(t)}return""},attack:function(e,t,i,s){this.trace(),this.sendCommand("Attack ("+e+","+t+") from "+s.type,"cities/"+s.id+"/marches.json","_method=post&march[x]="+e+"&march[y]="+t+"&march[units]="+i,s),this.addStat("Attack",1)}},bailoutBot={doBailout:function(){this.trace(),this.eachCity(function(e){"DoriaAirport"!=e.type&&this.sendGetCommand("Update bail in "+e.name,"cities/"+e.id+"/cash_jail.json","",e)})},getBailoutUnits:function(e){if(this.trace(),!e||!e.bailout)return this.debugBailout("No city or bailout",e),["",""];if(!e.resources)return this.debugBailout("No resources",e),["",""];var t="",i="",s=0,o=parseInt(e.resources.cash,10);for(var a in e.bailout)if(this.attackUnits[a]&&this.attackUnits[a].bailout){var n=this.attackUnits[a].bailout,r=parseInt(e.bailout[a],10),l=n*r;this.debugBailout(a+" costs "+l+" and all units costs "+s+" and I have "+o,e);var d=parseInt((o-s)/n,10);if(d>0){d=d>r?r:d;var c=d*n;this.debugBailout("I can affort "+d+" "+a+" because it cost "+c+" and I have "+(o-s)+" ("+o+")",e),s+=c,t+="&units["+a+"]="+d,i+=d+" "+a+", "}else this.debugBailout("Can't affort "+a+" because it cost "+n+" and I have "+(o-s)+" ("+o+")",e)}else this.debug("Missing bailout for "+a,e);return e.bailout={},[i,t]},payBailout:function(e){this.trace();var t=this.getBailoutUnits(e);""!==t[1]?(this.debugBailout(t[0],e),this.sendCommand("Pay Bailout in "+e.type,"cities/"+e.id+"/cash_jail/bail.json","payment_method=cash"+t[1],e)):this.debugBailout("No bailout data to send",e)}},bondsBot={doBonds:function(){if(this.debugBonds("Get Bonds"),this.cities){var e=this.cities[0];this.sendGetCommand("Get Bonds","bonds.json","action=index",e)}},handleBonds:function(){if(this.debugBonds("Handle bonds"),this.cities){var e=this.cities[0];this.sendCommand("Collect Bonds","bonds/redeem.json","action=index",e)}}},bot={autoFunctions:{Collect:{},Build:{},Research:{},Attack:{},Bailout:{},Train:{},Defense:{},Prize:{},LoyaltyToken:{},Cityscape:{},Exchange:{},Items:{event:"player:items"},Report:{},Bonds:{},Quests:{},Armor:{event:"city:armor:update"},Financier:{}},generateChangeEnable:function(e){this["changeEnable"+e]=function(){this.options["enable"+e]=$("#enable_"+e).is(":checked"),this.saveOptions(),this.debug("Enable "+e+": "+this.options["enable"+e])}},generateAutoThread:function(e,t){if(void 0===this.options["enable"+e]&&(this.options["enable"+e]=!0,this.saveOptions()),t.event){if(void 0===this["do"+e+"Event"])return void this.debug("Missing function: do"+e+"Event");this.listen(t.event,function(t,i){this.cities&&this.options["enable"+e]&&this["do"+e+"Event"](i,t)})}else{if(void 0===this["do"+e])return void this.debug("Missing function: do"+e);this["auto"+e+"Thread"]=function(t){t.trace_r("auto"+e+"Thread");var i=6e4;if(t.cities&&t.options["enable"+e])if(t.enablePause)t.debug("Do not "+e+" because we are on pause"),i=1e4;else{var s=t["do"+e]();s&&(i=s)}setTimeout(t["auto"+e+"Thread"],i,t)},this["auto"+e+"Thread"](this)}},getCity:function(e){if(!this.cities)return void 0;for(var t=0;t<this.cities.length;t++)if(this.cities[t].id==e)return this.cities[t];return void 0},addStat:function(e,t){this.options.stats||(this.options.stats={}),this.options.stats[e]||(this.options.stats[e]=0),this.options.stats[e]+=t,this.saveOptions(),this.signal("stats:update")},checkCityQueue:function(e,t,i){if(this.trace(),!e||!e.jobs)return!1;for(var s=!0,o=0;o<e.jobs.length;o++)if(void 0===i){if(e.jobs[o].queue&&e.jobs[o].queue===t){s=!1;break}}else if(e.jobs[o].city_building_id&&e.jobs[o].city_building_id===i){s=!1;break}if(s){var a=new Date,n=a.getTime(),r={run_at:n};void 0===i?r.queue=t:r.city_building_id=i,e.jobs.push(r)}return s},loadCityData:function(e){if(this.trace(),e&&e.id){var t="unknown";e.type&&(t=e.type),this.sendDataGetCommand("Load city "+t,"cities/"+e.id+".json","",e),this.sendDataGetCommand("Load city "+t+" neighborhood","cities/"+e.id+"/neighborhood_buildings.json","",e);var i=new Date;e.lastUpdate=i.getTime()}},loadCitiesData:function(){this.trace(),this.eachCity(function(e){this.loadCityData(e)})},autoLoadCities:function(e){return e.trace(),e.enablePause?void e.debug("Do not load cities, because we are on pause"):void e.eachCity(function(t){var i=new Date;(!t.lastUpdate||t.lastUpdate<i.getTime()+300)&&e.loadCityData(t);
})},loadGameLoadedData:function(e){e.trace(),e.sendDataCommand("Load Game Data","player/game_loaded.json","_method=put",e.cities[0]),e.loadCitiesData()},loadPlayerData:function(){this.trace(),this.sendDataGetCommand("Load Player","player.json")},loadPlayerDataInit:function(){this.trace(),this.sendDataGetCommand("Load Player Init","player.json","",void 0,this.loadGameLoadedData)},handleQueueComplete:function(e){this.trace(),"building"==e&&this.options.enableBuild?this.loadCitiesData():"research"==e&&this.options.enableResearch?this.doResearch():"units"==e&&this.options.enableTrain?this.doTrain():"defense_units"==e&&this.options.enableDefense?this.doDefense():-1!=e.indexOf("collect")&&this.options.enableCollect&&this.doCollect()},updateJobs:function(e){var t=1e3;if(e.cities)for(var i=new Date,s=i.getTime()/1e3,o=0;o<e.cities.length;o++){var a=e.cities[o];if(a&&a.jobs)for(var n=0;n<a.jobs.length;n++){var r=a.jobs[n],l=r.run_at+e.time_diff;if(s>=l){e.loadCityData(a),a.jobs.splice(n,1),t=1e4,e.handleQueueComplete(r.queue);break}}}setTimeout(e.updateJobs,t,e)},init:function(e){this.loadOptions(),this.queue=[],this.data_queue=[],this.slow_queue=[],this.queue_type="data",this.html={},this.enableTrace=!1,this.enablePause=!1,this.debug(e),this.server=e.apiServer.replace("http","https")+"/",this.player=e.playerId,this.session=e.sessionId,this.user=e.userId,this.gangster=e.gangster;for(var t in this.autoFunctions)this.generateAutoThread(t,this.autoFunctions[t]),this.generateChangeEnable(t),this.generateDebugEnable(t),this.generateDebugFunction(t);this.loadPlayerDataInit(),this.initGUI&&this.initGUI(),void 0===this.options.queue_interval&&(this.options.queue_interval=800,this.saveOptions()),setInterval(this.sendQueue,this.options.queue_interval,this),setInterval(this.autoLoadCities,6e4,this),this.updateJobs(this),this.showMissingPrizeInfo()},start:function(e){e||(e=this),"undefined"!=typeof C?e.init(C.attrs):window.setTimeout(e.start,1e3,e)}},buildBot={findBuildingLevel:function(e,t){this.trace();var i=0;return this.eachNeighborhood(function(t,s){if(s.buildings)for(var o=s.buildings,a=0;a<o.length;a++)o[a].type==e&&i<o[a].level&&(i=o[a].level)},t),i},countBuilding:function(e,t){this.trace();var i=0;if(e&&e.buildings)for(var s=e.buildings,o=0;o<s.length;o++)"neighborhood"==s[o].location&&(void 0!==t||s[o].hasOwnProperty("unlocked")||"Exchange"==s[o].type?s[o].type==t&&i++:i++);return i},findBuildingSlot:function(e,t){this.trace();var i=e.id;this.options.reserved_slots||(this.options.reserved_slots={}),this.options.reserved_slots[i]||(this.options.reserved_slots[i]={});var s=[],o=0;for(o=0;t>o;o++)"reserved"===this.options.reserved_slots[i][o]?s[o]=!1:s[o]=!0;if(e&&e.buildings)for(var a=e.buildings,n=0;n<a.length;n++)a[n].hasOwnProperty("slot")&&"neighborhood"==a[n].location&&(s[a[n].slot]=!1);for(o=0;o<s.length;o++)if(s[o])return o;return 0},calcBuldingCost:function(e,t){return 1==e?t:t*Math.pow(2,e)},hasResources:function(e,t,i,s,o,a){var n;if(n=void 0===o?this.debugTrain:o==this.calcBuldingCost?this.debugBuild:this.debugResearch,i&&e&&e.resources){var r=e.resources;for(var l in i){var d=0;if(d=a?a[l]?i[l]+a[l]*(s-1):i[l]+a.res*(s-1):o?o(parseInt(s,10),i[l]):i[l]*s,d>parseInt(r[l],10))return n("Can't affort "+t+" because "+l+" ("+d+") is more then "+r[l],e),!1;n("I have "+r[l]+" "+l+" and "+t+" costs "+d,e)}}else n(i?"Missing city data":"Missing cost for "+t);return!0},buildNewBuilding:function(e){if(this.trace(),e&&e.buildings&&e.city){var t=e.city;if("DoriaAirport"==t.type)return this.debugBuild("Do not build new building in Doria Airport",t,e),!1;var i=this.findBuildingLevel("Mansion",e.city),s=e.max_slot_number,o=this.countBuilding(e);if(this.debugBuild("Man Level: "+i+" Total building: "+o+" => "+s,t,e),s>o){var a=this.findBuildingSlot(e,s);if(0===a)return this.debugBuild("Failed to find a valid slot",t,e),!1;var n,r="Hideout";if(this.options.build||(this.options.build={}),this.options.build[t.type])for(n in this.options.build[t.type])if(-1==this.options.build[t.type][n]){this.debugBuild("Set default building to "+n,t,e),r=n;break}var l=this.buildings[r].cost;if(!this.hasResources(t,r,l,1,this.calcBuldingCost))return this.debugBuild("Can't build new "+r+", can't afford it",t,e),!1;for(n in this.buildings){var d=this.buildings[n],c=0;if(this.options.build[t.type]&&this.options.build[t.type][n]?c=this.options.build[t.type][n]:d.buildNew&&(c=d.buildNew),c>0){var u=this.countBuilding(e,n);if(c>u){if(l=d.cost,!this.hasResources(t,n,l,1,this.calcBuldingCost))continue;r=n;break}}}this.info("Build new "+r+" at slot "+a,t,"build",e);var h="_method=post&city_building[building_type]="+r;return h+="&city_building[include_requirements]=false&city_building[instant_build]=false",h+="&city_building[neighborhood_id]="+e.id+"&city_building[slot]="+a,this.sendCommand("Build new "+r+" at slot "+a+" in "+t.type+" ("+e.id+")","cities/"+t.id+"/buildings.json",h,t,void 0,e,{slot:a}),this.addStat("Build",1),e.buildings.push({slot:a,location:"neighborhood",type:r}),!0}this.debugBuild("No more slots for new buildings ("+s+")",t,e)}else this.debugBuild("Can't find neighborhood or buildings",t,e);return!1},upgradeImportentBuilding:function(e,t){this.trace();for(var i=["Hideout","Apartment"],s=0;s<i.length;s++){var o=i[s],a=this.findBuildingLevel(o,e.city);if(9>a&&e&&e.buildings)for(var n=e.buildings,r=0;r<n.length;r++){var l=n[r];if(l.type==o&&l.level==a)return t.lvl=l.level,t.id=l.id,t.name=l.type,t.location=l.location,this.debugBuild("Build Importent "+t.name,e.city),t}}return this.debugBuild("Failed to find impotent building",e.city),t},upgradeLowestBuilding:function(e){if(this.trace(),this.buildNewBuilding(e))return!0;if(!e||!e.buildings)return!1;for(var t={lvl:1e3},i=e.buildings,s=e.city,o=0;o<i.length;o++){var a=i[o];if(!(a.hasOwnProperty("unlocked")||a.level>=9)){var n=!0,r=this.buildings[a.type];if(r||(this.debug("Missing data for "+a.type,s,"Build",e),r={}),r.skip)this.debugBuild("Skipping "+a.type,s,e);else{if(r.requirement){var l=r.requirement;if(l.build){var d=l.build[a.level];if(d)for(var c in d){var u=this.findBuildingLevel(c,e.city);if(u<d[c]){this.debugBuild("Can't build "+a.type+" because "+c+" is not "+d[c],s,e),n=!1;break}this.debugBuild(a.type+" has req "+c+" ("+d[c]+") and it is "+u,s,e)}}if(l.gangster){if(l.gangster>this.player_level){this.debugBuild("Can't build "+a.type+" because gangster is not "+l.gangster,s,e),n=!1;break}this.debugBuild(a.type+" has gangster "+l.gangster+" and we are "+this.player_level,s,e)}if(l.alliance&&!this.alliance){this.debugBuild(a.type+" has alliance as a requirement and we are not part of a Crew: "+this.alliance,s,e),n=!1;break}}else this.debugBuild(a.type+" has no requirements",s,e);n&&r.cost?this.hasResources(s,a.type,r.cost,a.level,this.calcBuldingCost,r.offset)?this.debugBuild("Lots of resources",s,e):n=!1:n&&this.debugBuild("Not cost info for "+a.type,s,e),n&&(t.lvl>a.level||a.level>3&&t.lvl==a.level&&"neighborhood"==t.location)&&(t.lvl=a.level,t.id=a.id,t.name=a.type,t.location=a.location,t.building=a)}}}if(1e3!=t.lvl){if(t.lvl>5){var h=this.upgradeImportentBuilding(e,t);if(!h)return this.debugBuild("Faild to find a building",s,e),!1;this.buildings[h.name]?this.hasResources(s,h.name,this.buildings[h.name].cost,h.lvl,this.calcBuldingCost)?t=h:this.debugBuild("Do not upgrade importent building, not egnogh rescources",s,e):this.debug("Missing info for: "+h.name,s,e)}return this.info("Build "+t.name+" "+(t.lvl+1),s,"build",e),this.sendCommand("Build "+t.name+" "+(t.lvl+1)+" in "+s.type,"cities/"+s.id+"/buildings/"+t.id+".json","_method=put",s,void 0,e),t.building.level++,!0}return!1},doBuild:function(){if(this.trace(),this.cities)for(var e=0;e<this.cities.length;e++){var t=this.cities[e],i=this.checkCityQueue(t,"building");if(i)if(t.neighborhood)for(var s=0;s<t.neighborhood.length&&!this.upgradeLowestBuilding(t.neighborhood[s]);s++);else this.debugBuild("Neighborhood not ready",t);else this.debugBuild("Build queue not ready",t)}else this.debugBuild("Cities not ready")}},cityscapeBot={doCityscape:function(){if(this.trace(),!this.cities)return this.debugCityscape("Cities not ready"),5e3;for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if(t&&t.wildernesses)for(var i=0;i<t.wildernesses.length;i++){var s=t.wildernesses[i];if(s)if("CityScape"==s.type){var o=new Date,a=o.getTime()/1e3,n=a-s.last_collected_at,r=21600;n>=r?(this.debugCityscape("Collect cityscapes",t),this.sendCommand("Collect Cityscape in "+t.type,"cities/"+t.id+"/wildernesses/collect_all.json","",t),this.addStat("CityScape",1)):this.debugCityscape("Diff is "+n+" < "+r)}else this.debugCityscape("Wild is "+s.type,t);else this.debugCityscape("Wild "+i+" is empty",t)}else this.debugCityscape("Wilderness is not ready",t)}return 36e5}},collectBot={doCollect:function(){if(this.trace(),!this.cities)return this.debugCollect("Cities is not ready"),5e3;for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if(t&&t.neighborhood)for(var i=0;i<t.neighborhood.length;i++){var s=t.neighborhood[i];if(s&&s.buildings)for(var o=s.buildings,a=0;a<o.length;a++){var n=o[a];if(n.hasOwnProperty("unlocked")&&n.unlocked){var r=this.checkCityQueue(s.city,void 0,n.id);if(r){this.debugCollect("Collect "+n.type,t);var l="cities/"+s.city.id+"/npc_buildings/"+n.id+".json",d="_method=put&city_building_id="+n.id;this.sendCommand("Collect "+n.type+" in "+t.type,l,d,s.city),this.addStat("Collect",1)}}else this.debugCollect(n.type+" is not unlocked",t)}else this.debugCollect("Building not ready",t)}else this.debugCollect("Neighborhood not ready",t)}return 6e4},doExchange:function(){if(this.trace(),!(this.cities&&this.cities[0]&&this.cities[0].neighborhood&&this.cities[0].neighborhood.length))return this.debugCollect("Neighborhood not ready"),0;var e=this.cities[0];if(e&&e.neighborhood&&e.neighborhood.length)for(var t=0;t<this.cities[0].neighborhood.length;t++){var i=this.cities[0].neighborhood[t];if(i&&i.buildings){for(var s=0;s<i.buildings.length;s++)if("Exchange"==i.buildings[s].type){if(!i.buildings[s].free_ticket){this.debugExchange("No free ticket",e);break}var o="cities/"+e.city_id+"/exchanges/"+i.buildings[s].id+"/collect.json",a="_method=put&_action=collect&city_building_id="+i.buildings[s].id;return this.sendCommand("Collect Exchange",o,a,this.cities[0]),i.buildings[s].free_ticket=!1,this.info("Collect Exchange",e,"collect",i),this.addStat("Exchange",1),36e5}}else this.debugCollect("Building not ready",e)}return 0},doLoyaltyToken:function(){return this.trace(),this.cities&&this.cities[0]&&(this.debugLoyaltyToken("Checking token"),this.sendGetCommand("Update tokes","loyalty_tokens.json","",this.cities[0],this.checkLoyalyToken)),36e5},checkLoyalyToken:function(e){if(e.trace(),!e.tokens)return void e.debugLoyaltyToken("No tokens");for(var t=0;t<e.tokens.length;t++)e.tokens[t].collectable&&(e.debugLoyaltyToken("Collect token: "+e.tokens[t].type+" ("+t+")"),e.sendCommand("Collect token","loyalty_tokens/collect.json","type="+e.tokens[t].type,e.cities[0]),e.addStat("Token",1))},doQuests:function(){if(this.trace(),!this.quests)return void this.debugQuests("No Quests yet");if(!this.quests.Completed)return void this.debugQuests("No Completed Quests");var e=this.quests.Completed[0].name;this.debugQuests("Collect quest: "+e),this.sendCommand("Collect Quest","player_quests/claim.json","quest_name="+e+"&_method=put",this.cities[0])}},debugBot={trace:function(){this.trace_r(arguments.callee.caller.name)},trace_r:function(e){this.enableTrace&&this.debug(e)},setDebugCity:function(e){this.debugCity=e},log_format:function(e,t,i,s){if(t&&this.debugCity&&"All"!=this.debugCity&&this.debugCity!=t.type)return"";if("object"==typeof e)return e;var o=new Date;return t&&t.type&&(e=s&&s.id?t.type+" ("+s.id+"): "+e:t.type+": "+e),i&&(e=i+": "+e),e=o.toLocaleTimeString()+": "+e},log:function(e,t,i,s,o){var a=this.log_format(t,i,s,o);""!==a&&e(a)},debug:function(e,t,i,s){this.log(console.debug,e,t,i,s)},info:function e(t,i,e,s){this.log(console.info,t,i,e,s),this.updateInfo&&this.updateInfo(t,i)},generateDebugFunction:function(e){this["enableDebug"+e]=!1,this["debug"+e]=function(t,i,s){this["enableDebug"+e]&&this.debug(t,i,e,s)},this["info"+e]=function(t,i,s){this.info(t,i,e,s)}},generateDebugEnable:function(e){this["changeDebugEnable"+e]=function(){this["enableDebug"+e]=$("#enable_debug_"+e).is(":checked"),this.debug("Enable Debug "+e+": "+this["enableDebug"+e])}},toggleTrace:function(){this.enableTrace=!this.enableTrace},togglePause:function(){this.enablePause=!this.enablePause},executeCMD:function executeCMD(){var cmd=window.prompt("Enter CMD","");try{var res=eval(cmd);res&&this.debug(res)}catch(e){alert(e)}}},financierBot={doFinancier:function(){if(this.debugFinancier("Get Financier Office"),this.cities){for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if("Queens"===t.type)return this.sendGetCommand("Get Financier Office","financiers_office/show.json","",t),6e5}this.debugFinancier("Failed to find Queens")}},handleFinancier:function(){if(this.financier_trades>0&&this.options.financier_order){for(var e=0;e<this.options.financier_order.length;e++){var t=this.options.financier_order[e];if(this.my_items[t])return this.debugFinancier("Selling "+t+" because there is "+this.my_items[t]),void this.sellFinancierItem(t)}this.debugFinancier("Failed to find an item to sell")}else this.debugFinancier("Missing Financier trades or Financier orders")},sellFinancierItem:function(e){if(this.debugFinancier("Handle Financier Office"),this.cities){for(var t=0;t<this.cities.length;t++){var i=this.cities[t];if("Queens"===i.type)return this.debugFinancier("Sell Financier Item: "+e,i),this.financier_trades-=1,this.my_items[e]-=1,this.addStat("Financier",1),this.sendCommand("Sell Financier Item: "+e,"financiers_office/exchange.json","item="+e,i),void this.signal("financier:sold")}this.debugFinancier("Failed to find Queens")}}},itemBot={doItems:function(){this.doItemsEvent()},doItemsEvent:function(){if(!this.my_items)return void this.debugItems("Items is not ready");if(!this.cities)return void this.debugItems("Cities is not ready");var e=this.cities[0];for(var t in this.items)this.items[t].autoCollect&&this.my_items[t]?(this.infoItems("Use item "+t),this.debugItems(t+": "+this.my_items[t]),this.my_items[t]--,this.sendCommand("Use "+t,"player_items/"+t+".json","_method=delete",e),this.addStat("Item",1)):this.debugItems("Can't find "+t+" in items",e)}},optionsBot={saveOptions:function(){localStorage.setItem("gfb_options",JSON.stringify(this.options))},loadOptions:function(){var e=localStorage.getItem("gfb_options");if(e?this.options=JSON.parse(e):this.options={},!this.options.attackOrders){var t={};t.gang=10,t.units="",t.city="all",t.use_all=!0}}},parserBot={parseData:function(e){this.trace();var t,i,s;if(e){if(e="string"==typeof e?JSON.parse(e):this.clone(e),e.timestamp){var o=new Date,a=o.getTime()/1e3;this.time_diff=a-e.timestamp}if(e.cities&&e.cities[0]&&e.cities[0].id&&(this.cities||(this.cities=e.cities,this.signal("cities:update"))),e.player_armory_items&&(this.player_armory_items=e.player_armory_items,this.signal("player:armor:update")),e.alliance&&(this.alliance=e.alliance),e.neighborhoods)for(s in e.neighborhoods){var n=e.neighborhoods[s];if(n&&n.buildings&&n.buildings.length){var r=n.buildings;if(r[0]&&r[0].city_id&&(i=this.getCity(e.neighborhoods.neighborhood.buildings[0].city_id))){i.neighborhood||(i.neighborhood=[]);var l=!0;for(t=0;t<i.neighborhood.length;t++)if(i.neighborhood[t].id==n.id){l=!1;break}l&&(n.city=i,i.neighborhood.push(n))}}}if(e.city&&(i=this.getCity(e.city.id))){if(i.type||(i.type=e.city.type),i.jobs&&e.city.jobs)for(t=0;t<i.jobs.length;t++){var d=!1;for(s=0;s<e.city.jobs.length;s++)if(i.jobs[t].queue==e.city.jobs[s].queue){d=!0;break}!d&&i.jobs[t].queue&&i.jobs[t].id&&this.handleQueueComplete(i.jobs[t].queue)}e.city.units&&(i.units=e.city.units,this.signal("units:update")),e.city.research&&(i.research=e.city.research,this.signal("research:update")),e.city.resources&&(i.resources=e.city.resources,this.signal("resources:update")),e.city.figures&&e.city.figures.marches&&(i.maximum_troops=e.city.figures.marches.maximum_troops),e.city.wildernesses&&(i.wildernesses=e.city.wildernesses),e.city.jobs&&(i.jobs=e.city.jobs,this.signal("jobs:update")),e.city.equipped_armory_items&&(i.armor=e.city.equipped_armory_items,this.signal("city:armor:update",i))}if(e.terrain){this.options.map||(this.options.map={});var c=e.terrain;for(var u in c){var h=c[u];for(var p in h){var f=h[p];("Gang"==f[0]||"BossGang"==f[0])&&(this.options.map[f[2]]||(this.options.map[f[2]]={}),this.options.map[f[2]][f[3]]||(this.options.map[f[2]][f[3]]={}),this.options.map[f[2]][f[3]].lvl="Gang"==f[0]?f[1]:parseInt(f[1],10)+10,this.options.map[f[2]][f[3]].x=f[2],this.options.map[f[2]][f[3]].y=f[3])}}this.signal("map:update")}if(e.has_free_ticket&&(this.free_ticket=e.has_free_ticket),e.items&&(this.my_items=e.items,this.signal("player:items")),e.quests&&(this.quests=e.quests,this.signal("player:quests")),e.level&&(this.player_level=e.level,this.signal("player:level")),e.result){var m=e.result;if(e.result.prize_list)this.prizeList=m.prize_list,this.minigame_timestamp=m.minigame_timestamp;else if(e.result.item_won)for(var b in e.result.item_won)this.cities?this.updatePrizeInfo("Won: "+b,this.cities[0]):this.updatePrizeInfo("Won: "+b);if(e.result.prize)if(i=this.getCity(e.result.city_id),e.result.prize.prize_type)this.updatePrizeInfo("Won: "+e.result.prize.prize_type,i);else for(var g in e.result.prize)"cash_multiplier"!=g&&this.updatePrizeInfo("Won: "+g+" "+e.result.prize[g],i);if(e.result.job&&(i=this.getCity(e.result.job.city_id),i&&(i.jobs||(i.jobs=[]),i.jobs.push(e.result.job),this.signal("jobs:update"))),this.lastCommand&&this.lastCommand.city&&e.result.units&&(this.lastCommand.city.bailout=e.result.units,this.payBailout(this.lastCommand.city)),e.result.tokens&&(this.tokens=e.result.tokens),e.result.report_notifications&&(this.debugReport("Update reports"),this.reports={},this.reports.total=parseInt(e.result.total,10),this.reports.reports=e.result.report_notifications,this.signal("report:update")),e.result.bonds_list)for(t=0;t<e.result.bonds_list.length;t++){var y=e.result.bonds_list[t];"BearerBond"==y.name&&100==y.quantity&&this.handleBonds()}e.result.financiers_office&&(e.result.financiers_office.remaining_trades&&(this.financier_trades=e.result.financiers_office.remaining_trades),this.handleFinancier())}e.energy&&this.lastCommand&&this.lastCommand.city&&(this.lastCommand.city.energy=e.energy)}}},prizeBot={getPrize:function(){this.trace(),this.cities&&this.cities[0]&&this.minigame_timestamp&&(this.debugPrize("Get Prize"),this.sendCommand("Get Prize","minigames/save_result.json","minigame_timestamp="+this.minigame_timestamp,this.cities[0]),this.addStat("Prize",1))},doPrize:function(){if(this.trace(),this.cities&&this.cities[0]){if(!(this.free_ticket||this.items&&this.items.DailyChance&&this.items.DailyChance>0))return this.debugPrize("No prize ticket - Update player data"),this.loadPlayerData(),3e5;this.debugPrize("Update Prize"),this.sendGetCommand("Update Prize","minigames/index.json","",this.cities[0],this.updatePrizeList)}else this.debugPrize("Cities not ready");return 0},updatePrizeList:function(e){e.trace();var t={cost:1e3,name:""};if(e.prizeList&&e.prizeList.length){for(var i=0;i<e.prizeList.length;i++)if(e.items[e.prizeList[i].type]){var s=e.items[e.prizeList[i].type];t.cost>s.cost&&(t.cost=s.cost,t.name=e.prizeList[i].type)}else e.updatePrizeInfo(e.prizeList[i].type+" is unknown"),e.addMissingPrizeInfo(e.prizeList[i].type);t.cost>=10&&(e.getPrize(),e.free_ticket?e.free_ticket=!1:e.items&&e.items.DailyChance&&e.items.DailyChance>0&&e.items.DailyChance--,e.loadPlayerData())}},addMissingPrizeInfo:function(e){this.options.missing_prize||(this.options.missing_prize=[]),this.options.missing_prize.push(e),this.saveOptions()},showMissingPrizeInfo:function(){if(this.trace(),this.options.missing_prize){for(var e=0;e<this.options.missing_prize.length;e++){var t=this.options.missing_prize[e];this.items[t]?this.options.missing_prize.splice(e,1):this.debug("Missing prize info: "+t)}this.saveOptions()}}},queueBot={Command:function(){},enqueCommand:function(e,t,i,s,o,a,n,r,l){this.trace(),void 0!==o&&(i=""!==i?"city_id="+o.id+"&"+i:"city_id="+o.id);var d=new this.Command;d.name=e,d.type=s,d.url=this.server+t,d.city=o,d.neighborhood=r,d.data="_session_id="+this.session+"&gangster="+this.gangster+"&user_id="+this.user+"&"+i,d.callback=a,d.custom=l,"slow"===n?this.addToQueue(this.slow_queue,d):"data"===n?this.addToQueue(this.data_queue,d):(this.enableHTTP&&(d.url=d.url.replace("https","http")),this.addToQueue(this.queue,d))},addToQueue:function(e,t){for(var i=0;i<e.length;i++)if(e[i].url==t.url&&e[i].data==t.data&&-1==t.name.indexOf("Collect "))return void this.debug("Dropping double command: "+t.name,t.city);e.push(t),this.signal("queue:update")},sendCommand:function(e,t,i,s,o,a,n){this.enqueCommand(e,t,i,"POST",s,o,"cmd",a,n)},sendGetCommand:function(e,t,i,s,o,a,n){""!==i&&(i+="&"),i+="cachebreaker="+(parseInt((new Date).getTime()/1e3,10)+this.time_diff),this.enqueCommand(e,t,i,"GET",s,o,"cmd",a,n)},sendSlowCommand:function(e,t,i,s,o,a,n){this.enqueCommand(e,t,i,"POST",s,o,"slow",a,n)},sendSlowGetCommand:function(e,t,i,s,o,a,n){this.enqueCommand(e,t,i,"GET",s,o,"slow",a,n)},sendDataCommand:function(e,t,i,s,o,a,n){this.enqueCommand(e,t,i,"POST",s,o,"data",a,n)},sendDataGetCommand:function(e,t,i,s,o,a,n){this.enqueCommand(e,t,i,"GET",s,o,"data",a,n)},sendQueue:function(e){return e.queue_busy?void 0:e.lastCommand?(e.debug("Resending last command: "+e.lastCommand.name,e.lastCommand.city),e.debug(e.lastCommand),void e.executeCommand(e.lastCommand)):void("data"===e.queue_type?e.data_queue.length?e.executeCommand(e.data_queue.shift()):e.queue.length?(e.executeCommand(e.queue.shift()),e.queue_type="cmd",e.signal("queue:change")):e.slow_queue.length&&e.executeCommand(e.slow_queue.shift()):e.queue.length?e.executeCommand(e.queue.shift()):e.data_queue.length?(e.executeCommand(e.data_queue.shift()),e.queue_type="data",e.signal("queue:change")):e.slow_queue.length&&e.executeCommand(e.slow_queue.shift()))},executeCommand:function(e){function t(e,t,i){e||200!=t.statusCode?s.errorCommand(t.statusCode,i):s.revCommand(i)}if(void 0!==e){if(e.resends>2)return this.debug("Last command has been send 3 times: "+this.lastCommand.name,this.lastCommand.city),void(this.lastCommand=void 0);if(this.debug(e.name),"undefined"!=typeof $)"undefined"!=typeof GM_xmlhttpRequest?GM_xmlhttpRequest({method:e.type,url:e.url,data:"POST"===e.type?e.data:null,headers:e.headers,ontimeout:e.timeoutSecs?1e3*e.timeoutSecs:0,onreadystatechange:function(e){4===e.readyState&&(e.status>=200&&e.status<300||304===e.status?s.revCommand(e.responseText):s.errorCommand(e.status,e.responseText))}}):this.ajax_send(e.url,this.revCommand,this.errorCommand,e.type,e.data,!0);else{this.request||(this.request=require("request"));var i={method:e.type,url:e.url,body:e.data,headers:{Origin:"https://c1.godfather.rykaiju.com","User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140","Content-Type":"application/x-www-form-urlencoded",Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","Cache-Control":"max-age=0",Referer:"https://c1.godfather.rykaiju.com/platforms/facebook/",Connection:"keep-alive","X-Requested-With":"ShockwaveFlash/28.0.0.126"}},s=this;this.request(i,t)}this.queue_busy=!0,e.resends=e.resends+1||1,this.lastCommand=e,this.signal("queue:update")}},errorCommand:function(e,t){this.queue_busy=!1;var i="";if(404!=e){if("string"==typeof t)try{t=JSON.parse(t)}catch(e){return this.debug("Recevied invalid JSON in error handler: "+this.lastCommand.name,this.lastCommand.city),void this.debug(e)}i=t.responseText?t.responseText:t}else i=t;this.debug("Error sending command: "+i),this.debug(this.lastCommand),this.lastCommand&&void 0!==this.lastCommand.callback&&this.lastCommand.callback(this)},revCommand:function(e){if(this.queue_busy=!1,"string"==typeof e)try{e=JSON.parse(e)}catch(e){return this.debug("Received invalid JSON for command: "+this.lastCommand.name),this.debug(e),void(this.lastCommand=void 0)}if(e&&e.result&&!e.result.success&&(this.debug("Command send Error: "+e.result.errors[0]),this.debug(this.lastCommand),"Slot is reserved"===e.result.errors[0]))if(this.debug("Slot is reserved"),this.lastCommand.neighborhood&&this.lastCommand.custom&&this.lastCommand.custom.slot){this.debug("Setting slot");var t=this.lastCommand.neighborhood.id,i=this.lastCommand.custom.slot;this.options.reserved_slots||(this.options.reserved_slots={}),this.options.reserved_slots[t]||(this.options.reserved_slots[t]={}),this.debug(this.options.reserved_slots),this.options.reserved_slots[t][i]="reserved",this.debug(this.options.reserved_slots),this.saveOptions()}else this.debug("Missing neighborhood or custom slot to handle error");this.parseData(e),this.lastCommand&&(void 0!==this.lastCommand.callback&&this.lastCommand.callback(this),this.lastCommand=void 0)}},reportBot={doReport:function(){this.debugReport("Do Reports"),this.sendGetCommand("Reports","reports.json","count=18&page=1&category=reports")},handleReport:function(){if(this.debugReport("Handle Reports"),this.reports&&this.reports.reports){for(var e="",t=0;t<this.reports.reports.length;t++){var i=this.reports.reports[t];"attacking"==i.battle_side&&"Won"==i.battle_result&&null===i.read_at&&(e+=i.id+"|")}this.debugReport("Ids: "+e),""!==e&&this.sendCommand("Delete reports","reports/bulk_delete.json","_method=delete&ids="+e)}}},researchBot={calcReseachCost:function(e,t){for(var i=t,s=1;e>s;s++)10>s?i=Math.ceil(1.5*i):15>s?i=Math.ceil(1.71*i):15==s?i=Math.ceil(2.7*i):20>=s&&(i=Math.ceil(1.34*i));return i},checkResearchBuild:function(e,t,i,s){this.trace();var o=this.findBuildingLevel(s,e);return this.debugResearch(t+" ("+i+"/"+(i-4)+") has req "+s+" and it is "+o+" ("+4*o+")",e),"Garage"==s||"Workshop"==s||"GuardPost"==s?i>=20?o*=2:5>=i?o=5:o*=3:o*=2,0===o||i>1&&i>=o?(this.debugResearch("skip because "+o+" is less then "+i,e),!1):!0},researchLowest:function(e){this.trace();var t={lvl:1e3,pri:1e3,id:""};if(!e)return void this.debugResearch("No city");if(!e.research)return void this.debugResearch("Missing research",e);if(!e.neighborhood)return void this.debugResearch("Missing neighborhood",e);for(var i in this.research){var s=this.research[i],o=(e.research[i]||0)+1,a=!1,n=s.requirement;if(n){if(n.city&&n.city!==e.type){this.debugResearch("Skip "+i+" in "+e.name,e);continue}if(n.build&&!this.checkResearchBuild(e,i,o,n.build))continue;if(n.research){for(var r=0;r<n.research.length;r++){var l=n.research[r],d=e.research[l]||0,c=o;if(n.offset&&(c+=n.offset),this.debugResearch(i+" has req "+l+" and it is "+d,e),c>d){this.debugResearch("Skip because "+d+" is less then "+c,e),a=!0;break}}if(a)continue}}this.hasResources(e,i,s.cost,o,this.calcReseachCost)?(t.lvl>o||t.lvl==o&&t.pri>this.research[i].priority)&&(t.lvl=o,t.name=i,t.pri=this.research[i].priority):this.debugResearch("Skip because we can't affort it",e)}1e3!=t.lvl&&(this.info("Research "+t.name+" lvl "+t.lvl,e,"research"),this.sendCommand("Research "+t.name+" lvl "+t.lvl+" in "+e.type,"cities/"+e.id+"/researches.json","research[research_type]="+t.name,e),this.addStat("Research",1),e.research[t.name]=t.lvl)},doResearch:function(){if(this.trace(),!this.cities)return void this.debugResearch("Cities not ready");for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if("DoriaAirport"!=t.type){var i=this.checkCityQueue(t,"research");i?this.researchLowest(t):this.debugResearch("Already researching",t)}else this.debugResearch("Can't research in "+t.type,t)}}},trainBot={checkRequirements:function(e,t,i,s){if(this.trace(),t&&t.build)for(var o in t.build){var a=this.findBuildingLevel(o,i);if(this["debug"+s](e+" has build req "+o+" of "+t.build[o]+" and it is "+a,i),a<t.build[o])return this["debug"+s]("Skipping "+e,i),!1}if(t&&t.research)for(var n in t.research){var r=i.research[n];if(void 0===r&&(r=0),this["debug"+s](e+" has req "+n+" of "+t.research[n]+" and it is "+r,i),r<t.research[n])return this["debug"+s]("Skiping "+e,i),!1}return!0},doTrain:function(){if(this.trace(),!this.cities)return void this.debugTrain("Cities is not ready");if(!this.options.trainOrders)return void this.debugTrain("Train data is not ready");this.debugTrain(this.options.trainOrders);for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if(t&&"DoriaAirport"!=t.type)if(t.units)for(var i in this.attackUnits){var s=this.attackUnits[i];if(s.trainable)if(s.city&&"All"!=s.city&&s.city!=t.type)this.debugTrain(i+" can't be trained in "+t.type+" only in "+s.city);else{var o=this.options.trainOrders[i];if(o){t.units||this.debugTrain("city.units is missing",t);var a=s.requirement;if(this.checkRequirements(i,a,t,"Train")){var n=10,r=0,l=s.cost;if(t.units[i]&&(r=t.units[i]),r>=o)this.debugTrain("Do not train "+i+", there is "+r,t);else if(this.checkCityQueue(t,"units")){if(void 0===l||this.hasResources(t,i,l,n,void 0)){this.debugTrain("Train "+n+" "+i,t),this.sendTrainOrders(i,n,t),this.addStat("Train",n);break}}else this.debugTrain("Already training units",t)}}else this.debugTrain("Do not train "+o+" "+i,t)}else this.debugTrain(i+" is not trainable",t)}else this.debugTrain("Missing units in city",t)}},doDefense:function(){if(this.trace(),!this.cities)return void this.debugDefense("Cities not ready");for(var e=0;e<this.cities.length;e++){var t=this.cities[e];if("DoriaAirport"!=t.type)if(this.checkCityQueue(t,"defense_units")){var i=void 0,s=10;for(var o in this.defenseUnits){var a=this.defenseUnits[o];if(a.trainable)if(a.city&&"All"!=a.city&&a.city!=t.type)this.debugDefense(o+" can't be trained in "+t.type+" only in "+a.city);else{var n=this.defenseUnits[o].requirement;if(this.checkRequirements(o,n,t,"Defense")){var r=this.defenseUnits[o].cost;(!r||this.hasResources(t,o,r,s,void 0))&&(i=o,this.debugDefense("Can build "+o,t))}}else this.debugDefense(o+" is not trainable",t)}i?(this.sendTrainOrders(i,s,t),this.debugTrain("Train "+s+" "+o,t),this.addStat("Defense",s)):this.debugDefense("Failed to find a unit to train",t)}else this.debugDefense("Already training defense units",t)}},sendTrainOrders:function(e,t,i){this.sendCommand("Train "+t+" "+e+" in "+i.type,"cities/"+i.id+"/units.json","_method=post&units[include_requirements]=false&units[quantity]="+t+"&units[unit_type]="+e,i)}},utilBot={bind:function(e){var t=this;return function(){return e.apply(t,arguments)}},handlers:{},signal:function(e,t){if(this.handlers[e])for(var i=0;i<this.handlers[e].length;i++)void 0===t?this.handlers[e][i].call(this):this.handlers[e][i].call(this,t)},listen:function(e,t){this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].push(t)},numberToString:function(e){return e=parseInt(e,10),e>=1e9?(e=Math.floor(e/1e8),e/=10,e+=" B"):e>=1e6?(e=Math.floor(e/1e5),e/=10,e+=" M"):e>=1e3&&(e=Math.floor(e/100),e/=10,e+=" K"),e},eachCity:function(e){if(this.cities)for(var t=0;t<this.cities.length;t++)this.cities[t]&&this.cities[t].id&&e.call(this,this.cities[t])},eachNeighborhood:function(e,t){var i=function(t){if(t.neighborhood&&t.neighborhood.length)for(var i=0;i<t.neighborhood.length;i++){var s=t.neighborhood[i];s&&e.call(this,t,s)}};void 0===t?this.eachCity(i):i(t)},clone:function(e){return JSON.parse(JSON.stringify(e))}},guiBot={initGUI:function(){var e=$("<div id='panel' class='panel' />");$(document.body).append(e);var t=$("<p class='header'><span>The Underboss</span> <span id='version'>v1.1.1</span>");t.click(function(){$("#panel").hasClass("panel")?($("#panel").removeClass("panel").addClass("hiddenPanel"),$("#mainPanel").hide()):($("#panel").removeClass("hiddenPanel").addClass("panel"),$("#mainPanel").show())});var i=$("<div id='mainPanel' />"),s=$("<div id='infoPanel'/>");e.append(t),e.append(i),$(i).append(s);var o=$("<div class='tab-box' />");
s.append(o);for(var a=["Overview","Prizes","Armor","Training","Options"],n=0;n<a.length;n++)this.createDialog(a[n].toLowerCase()+"_view",a[n]),this["create"+a[n]+"View"]?this["create"+a[n]+"View"]():this.debug("create"+a[n]+"View function is missing!"),this["show"+a[n]]=this.generateShowView(a[n]);for(var r=["Control","Info","Prizes","Attack","Map","Build","Financier","Debug"],l=0;l<r.length;l++){o.append(this.drawTab("info-"+(l+1),r[l]));var d=this.drawTabData("info-"+(l+1));s.append(d),this["draw"+r[l]+"Tab"]&&this["draw"+r[l]+"Tab"](d)}$("#info-1").addClass("activeLink"),$("#info-1_data").removeClass("hide")},generateShowView:function(e){return function(){$("#"+e.toLowerCase()+"_view").show()}},drawOption:function(e,t){var i=this.drawGenericOption(e,t,"enable_","changeEnable",this.options["enable"+e]),s=document.createElement("span");s.innerHTML=" - ",i.appendChild(s),this.drawButton(e+" Now",this["do"+e],i,"button_large")},drawDebugOption:function(e,t){this.drawGenericOption(e,t,"enable_debug_","changeDebugEnable",!1)},drawGenericOption:function(e,t,i,s,o){var a=document.createElement("div");t.appendChild(a);var n=document.createElement("div");n.className="option",n.innerHTML=e+": ",a.appendChild(n);var r=this,l=document.createElement("input");return l.type="checkbox",l.name=i+e,l.id=i+e,l.checked=o,l.onclick=function(){r[s+e]()},a.appendChild(l),a},drawButton:function(e,t,i,s){var o=this;void 0===s&&(s="");var a=$("<button class='"+s+"'/>").html(e).click(function(){t.call(o)});$(i).append(a)},drawTab:function(e,t){var i=document.createElement("a");return i.href="javascript:;",i.className="tabLink",i.id=e,i.innerHTML=t,i.onclick=function(){var e=$(this).attr("id");return $(".tabLink").removeClass("activeLink"),$(this).addClass("activeLink"),$(".tabcontent").addClass("hide"),$("#"+e+"_data").removeClass("hide"),!1},i},drawTabData:function(e){var t=document.createElement("div");return t.id=e+"_data",t.className="tabcontent",1!=e&&(t.className+=" hide"),t},drawDebugTab:function(e){$(e).html("<h7>Debug Info</h7>").append($("<div/>").attr("id","debug_queue")),this.drawButton("Update Jobs",this.loadCitiesData,e),this.drawButton("Execute",this.executeCMD,e),this.drawButton("Trace",this.toggleTrace,e),this.drawButton("Pause",this.togglePause,e),$(e).append("<select id='debug_city' />");var t=this;$("#debug_city").change(function(){t.changeDebugCity()});for(var i in this.autoFunctions)this.drawDebugOption(i,e);this.listen("queue:update",this.updateDebugQueue),this.listen("queue:change",this.updateDebugQueue),this.listen("cities:update",this.updateDebugCities),this.listen("report:update",this.handleReport)},changeDebugCity:function(){this.debugCity=$("#debug_city").val()},updateDebugCities:function(){$("#debug_city").html("").append("<option value='All'>All</option>");for(var e=0;e<this.cities.length;e++){var t=this.cities[e];t&&t.type&&$("#debug_city").append("<option value='"+t.type+"'>"+t.type+"</option>")}},updateDebugQueue:function(){$("#debug_queue").html("<h7>CMD Queue: "+this.queue.length+"</h7><h7>Data Queue: "+this.data_queue.length+"</h7><h7>Slow Queue: "+this.slow_queue.length+"</h7><h7>Queue Type: "+this.queue_type+"</h7>")},drawBuildTab:function(e){this.options.build||(this.options.build={}),$(e).append("<h7>Build Options</h7>"),$(e).append("<p>Upgrade builing above level 9? <input type='checkbox' id='build_above_level_9' />"),$(e).append("<br /><h7>Build Orders</h7>"),$(e).append("<p>Build this amount of buildings. If you set it to -1 it will keep building that building.</p>"),$(e).append("<select id='build_order_city' />"),this.buildOrderCity="Capital";var t=this;$("#build_order_city").change(function(){t.changeBuildOrderCity()});var i=$("<table/>");$(e).append(i);for(var s in this.buildings)if(this.buildings[s].buildNew){var o=$("<input class='build_order' id='build_"+s+"' />");this.addTableRow(i,s,o)}this.drawButton("Save",this.saveBuildOrder,e),this.changeBuildOrder(),this.listen("cities:update",this.updateBuildOrderCities)},changeBuildOrder:function(){for(var e in this.buildings)if(this.buildings[e].buildNew){var t=$("#build_"+e);this.options.build[this.buildOrderCity]&&this.options.build[this.buildOrderCity][e]&&"number"==typeof this.options.build[this.buildOrderCity][e]?t.val(this.options.build[this.buildOrderCity][e]):t.val(this.buildings[e].buildNew)}},changeBuildOrderCity:function(){this.buildOrderCity=$("#build_order_city").val(),this.changeBuildOrder()},updateBuildOrderCities:function(){$("#build_order_city").html("");for(var e=0;e<this.cities.length;e++){var t=this.cities[e];t&&t.type&&$("#build_order_city").append("<option value='"+t.type+"'>"+t.type+"</option>")}},saveBuildOrder:function(){this.options.build[this.buildOrderCity]={};for(var e in this.buildings)this.buildings[e].buildNew&&(this.options.build[this.buildOrderCity][e]=parseInt($("#build_"+e).val(),10));this.saveOptions()},drawMapTab:function(e){this.options.map_size||(this.options.map_size=2,this.updateMap()),e.innerHTML="<h7>Map</h7>",this.drawButton("Update Map",this.updateMap,e),this.drawButton("Reset Map",this.resetMap,e),$(e).append("<p id='scan-size'>Scan size: "+this.options.map_size+"</span>");var t;for(t=1;10>=t;t++)$(e).append("<p>Lvl "+t+" Gangs: <span id='gang_"+t+"'>0</span></p>");for(t=1;5>=t;t++)$(e).append("<p>Murder Inc. "+t+": <span id='gang_"+(10+t)+"'>0</span></p>");this.updateMapInfo(),this.listen("map:update",this.updateMapInfo)},updateMapInfo:function(){$("#scan_size").text("Scan size: "+this.options.map_size);var e,t,i={};for(t in this.options.map)for(var s in this.options.map[t]){var o=this.options.map[t][s];i[o.lvl]||(i[o.lvl]=0),i[o.lvl]++}for(e=1;15>=e;e++)i[e]&&$("#gang_"+e).text(i[e])},drawAttackTab:function(e){e.innerHTML="<h7>Attack Orders</h7>",$("<div>City:</div>").append($('<select id="select_attack_city"></select>')).appendTo($(e)),this.listen("cities:update",function(){var e=$("#select_attack_city");if(e.empty(),e.append($('<option value="all">All</option>')),this.cities)for(var t=0;t<this.cities.length;t++)e.append($('<option value="'+this.cities[t].type+'">'+this.cities[t].type+"</option>"))}),$("<div>Gang Level:</div>").append($('<select id="select_gang"></select>')).appendTo($(e));var t,i=$("#select_gang");for(t=1;10>=t;t++)i.append($('<option value="'+t+'">Gang Level '+t+"</option>"));for(t=1;5>=t;t++)i.append($('<option value="'+(10+t)+'">Murder Inc '+t+"</option>"));$('<div id="units_p">Units:</div>').append($('<select id="select_units"></select>')).appendTo($(e));var s=$("#select_units");for(var o in this.attackUnits)s.append($('<option value="'+o+'">'+o+"</option>"));$('<input type="text" id="unit_count" value="0" class="unit_count" />').appendTo($("#units_p")),this.drawButton("Add",this.addUnitToAttackOrder,document.getElementById("units_p")),$("<div>Use All:</div>").append('<input type="checkbox" id="check_attack_all" value="all"/>').appendTo($(e)),$('<textarea id="total_units" class="textinfo"></textarea><br />').appendTo($(e)),this.drawButton("Save",this.saveAttackOrder,e),this.drawButton("Clear",this.clearAttackOrder,e);var a=document.createElement("hr");e.appendChild(a),$(e).append("<select id='order_list' size='10' width='100%' /><br />"),this.drawButton("Delete",this.deleteAttackOrder,e),this.updateAttackOrders()},deleteAttackOrder:function(){var e=$("#order_list").val();this.options.attackOrders.splice(e,1),this.updateAttackOrders()},updateAttackOrders:function(){if($("#order_list").empty(),this.options.attackOrders)for(var e=0;e<this.options.attackOrders.length;e++){var t=this.options.attackOrders[e];t.city||(t.city="all"),t.use_all||(t.use_all=!1);var i=t.city+" | "+t.gang+" | "+(t.use_all?"t":"f")+" | "+t.units;$("#order_list").append("<option value='"+e+"'>"+i+"</option>")}},addUnitToAttackOrder:function(){var e=$("#total_units");""!==e.val()&&e.val(e.val()+","),e.val(e.val()+'"'+$("#select_units").val()+'":'+$("#unit_count").val())},saveAttackOrder:function(){var e={};e.gang=parseInt($("#select_gang").val(),10),e.units="{"+$("#total_units").val()+"}",e.city=$("#select_attack_city").val(),e.use_all=$("#check_attack_all").is(":checked"),this.options.attackOrders||(this.options.attackOrders=[]),this.options.attackOrders.push(e),this.saveOptions(),this.clearAttackOrder(),this.updateAttackOrders()},clearAttackOrder:function(){$("#total_units").val("")},updateStats:function(){var e=$("#stats").html("<h3><u>Stats</u></h3>");if(this.options.stats)for(var t in this.options.stats)e.append($("<p>"+t+": "+this.options.stats[t]+"</p>"))},drawFinancierTab:function(e){if($(e).append("<h7>Financiers Office</h7>").append("<p>Select items that should be sold</p>"),$(e).append("<p>There is <span id='financier_stats_items'>0</span> items to sell and <span id='financier_stats_trades'>0</span> trades left</p>"),$(e).append("<select id='financier_all_items' />"),this.my_items)for(var t in this.my_items)this.my_items.hasOwnProperty(t)&&$("#financier_all_items").append("<option value='"+t+"'>"+t+"</option>");if(this.listen("player:items",this.updateFinancierItems),this.drawButton("Add item",this.addFinancierItem,e),$(e).append("<br />"),$(e).append("<select id='financier_order' size='10' width='100%' />"),this.drawButton("Remove item",this.removeFinancierItem,e),this.options.financier_order)for(var i=0;i<this.options.financier_order.length;i++){var s=this.options.financier_order[i];$("#financier_order").append("<option value='"+s+"'>"+s+"</option>")}$(e).append("<br />"),this.listen("financier:sold",this.updateFinancierStats)},updateFinancierItems:function(){if($("#financier_all_items").empty(),this.my_items){var e=Object.keys(this.my_items).sort();for(var t in e)e.hasOwnProperty(t)&&$("#financier_all_items").append("<option value='"+e[t]+"'>"+e[t]+"</option>")}this.updateFinancierStats()},updateFinancierStats:function(){var e=0;if(this.options.financier_order)for(var t=0;t<this.options.financier_order.length;t++){var i=this.options.financier_order[t];e+=parseInt(this.my_items[i],10)}$("#financier_stats_items").html(e),$("#financier_stats_trades").html(this.financier_trades)},addFinancierItem:function(){var e=$("#financier_all_items").val();$("#financier_order").append("<option value='"+e+"'>"+e+"</option>"),this.saveFinancierOrder(),this.updateFinancierStats()},removeFinancierItem:function(){$("#financier_order :selected").remove(),this.saveFinancierOrder(),this.updateFinancierStats()},saveFinancierOrder:function(){this.options.financier_order=$("select#financier_order option").map(function(){return $(this).val()}).get(),this.saveOptions()},drawInfoTab:function(e){this.drawButton("Overview",this.showOverview,e),this.drawButton("Traning",this.showTraining,e),$(e).append("<br />"),$(e).append($("<textarea></textarea>").addClass("info").attr("id","debug_info"))},drawControlTab:function(e){for(var t in this.autoFunctions)this.drawOption(t,e)},drawPrizesTab:function(e){$(e).html("<h7>Prizes</h7>").append("<p>Prize Info:</p>").append($("<textarea/>").addClass("prize_info"))},updateInfo:function(e,t){var i=$("#debug_info").text().split("\n")||[];i=i.slice(0,100).join("\n"),$("#debug_info").text(this.log_format(e,t)+"\n"+i)},updatePrizeInfo:function(e,t){var i=$(".prize_info").text().split("\n")||[];i=i.slice(0,100).join("\n"),$(".prize_info").text(this.log_format(e,t)+"\n"+i)},createDialog:function(e,t){$("#panel").append("<dialog id='"+e+"' class='overlay'><h1>"+t+"</h1><button class='close' id='"+e+"_close'>Close</button></dialog>"),$("#"+e+"_close").click(function(){$("#"+e).hide()}),this["show"+e]=function(){$("#"+e).show()}},createArmorView:function(){},createPrizesView:function(){},addTableRow:function(e,t,i){var s=$("<td/>").append(t),o=$("<td/>").append(i);e.append($("<tr/>").append(s,o))},createOptionsView:function(){var e=$("#options_view");e.append("<h7>Options</h7>");var t=$("<table/>");e.append(t),this.addTableRow(t,"Reload Time",""),this.addTableRow(t,"Underboss Size",""),this.addTableRow(t,"Queue Send Interval",""),this.addTableRow(t,"Hide side panel",""),this.addTableRow(t,"",""),this.drawButton("Save",this.saveOptionsPage,e)},saveOptionsPage:function(){this.debug("Save Options")},createTrainingView:function(){var e=$("#training_view");e.append("<h7>Training Orders</h7>");var t=$("<table/>");e.append(t);var i,s=0;for(var o in this.attackUnits)this.attackUnits[o].trainable&&(s%3===0&&(i=$("<tr/>"),t.append(i)),i.append($("<td/>").text(o).append($("<td/>").append($("<input class='number'/>").attr("id","unit_"+o)))),this.options.trainOrders&&this.options.trainOrders[o]&&$("#unit_"+o).val(this.options.trainOrders[o]),s++);this.drawButton("Save",this.saveTrainOrder,$("#trainview"))},saveTrainOrder:function(){this.trace(),this.options.trainOrders||(this.options.trainOrders={});for(var e in this.attackUnits)this.options.trainOrders[e]=$("#unit_"+e).val();this.saveOptions()},createOverviewView:function(){var e=$("#overview_view");this.drawButton("Update",this.updateOverview,e),e.append("<table id='overview_table'></table>"),$("#overview_table").append(" <tr><th>City</th> <th>Cash</th><th>Cement</th><th>Food</th><th>Steel</th> <th>Jobs</th> <th>Units / Bail</th> </tr> <tr id='total'> <th>Total</th> <th id='cash'>0</th><th id='cement'>0</th> <th id='food'>0</th><th id='steel'>0</th> <th id='jobs'></th> <th id='units'></th> </tr>"),e.append($("<div></div>").addClass("stats").attr("id","stats")),this.listen("jobs:update",this.updateOverview),this.listen("cities:update",this.updateOverview),this.listen("resources:update",this.updateOverview),this.listen("stats:update",this.updateStats),this.updateOverview(),this.updateStats()},updateOverview:function(){var e=$("#overview_table"),t=e.find("#total"),i=this.numberToString;if(this.cities){for(var s={},o=0,a=0,n=0;n<this.cities.length;n++){var r=this.cities[n];if(r&&r.type){var l=e.find("#"+r.type);if(0===l.length&&(t.before(" <tr id='"+r.type+"'> <th>"+r.type+"</th> <td id='cash'>0</td><td id='cement'>0</td> <td id='food'>0</td><td id='steel'>0</td> <td id='jobs'></td> <td id='units'></td> </tr>"),l=e.find("#"+r.type)),r.resources&&$.each(r.resources,function(e,t){var o=s[e]||0;o+=parseInt(t,10),s[e]=o,l.find("#"+e).html(i(t))}),r.jobs){var d,c,u,h,p;d=c=u=h=p=" ";for(var f=0;f<r.jobs.length;f++)"research"==r.jobs[f].queue&&(c="R"),"building"==r.jobs[f].queue&&(d="B"),"units"==r.jobs[f].queue&&(u="U"),"defense_units"==r.jobs[f].queue&&(h="D"),"march"==r.jobs[f].queue&&(p="M");l.find("#jobs").html("("+r.jobs.length+") "+d+" "+c+" "+u+" "+h+" "+p)}if(r.units){var m=0,b=0;$.each(r.units,function(e){m+=r.units[e]}),r.bailout&&$.each(r.bailout,function(e){b+=r.bailout[e]}),o+=m,a+=b,l.find("#units").html(i(m)+" / "+i(b))}}}$.each(s,function(e,s){t.find("#"+e).html(i(s))}),t.find("#units").html(i(o)+" / "+i(a))}}},frame=document.getElementById("game_frame");if(frame&&($(frame).width("1481px"),setTimeout(function(){location.reload()},72e5)),document.URL.search(/apps.facebook.com\/play_godfather/i)>=0&&setup_facebook(),GM_addStyle(css),-1!=window.location.href.indexOf("platforms/facebook/game")){combine(bot,attackBot,bondsBot,buildBot,itemBot,cityscapeBot,reportBot,trainBot,bailoutBot,collectBot,prizeBot,researchBot,optionsBot,parserBot,queueBot,debugBot,utilBot,armorBot,ajaxBot,financierBot),guiBot&&combine(bot,guiBot),bot.attackUnits=attackUnits,bot.defenseUnits=defenseUnits,bot.buildings=buildings,bot.research=research,bot.items=items;var src=convertToSource(bot);src="var underboss = "+src+";\n",src+="underboss.start();",inject(src)}