How to use spawn method in mountebank

Best JavaScript code snippet using mountebank

mapLoader.py

Source:mapLoader.py Github

copy

Full Screen

1from map import arkMap2#the island3islandRegions = ["DinoSpawnEntriesArcha", "DinoSpawnEntriesBeach", "DinoSpawnEntriesBee", "DinoSpawnEntriesCave1", "DinoSpawnEntriesCave2-LowSpiderScorp", "DinoSpawnEntriesCave5", "DinoSpawnEntriesCave7-Fliers", "DinoSpawnEntriesCaveIceWater", "DinoSpawnEntriesCaveLava", "DinoSpawnEntriesCaveMegalo", "DinoSpawnEntriesCaveTek_Easy_11", "DinoSpawnEntriesCaveTek_Easy_12", "DinoSpawnEntriesCaveTek_Easy_13", "DinoSpawnEntriesCaveTek_Easy_14", "DinoSpawnEntriesCaveTek_Easy_15", "DinoSpawnEntriesCaveTek_Easy_16", "DinoSpawnEntriesCaveTek_Hard_11", "DinoSpawnEntriesCaveTek_Hard_12", "DinoSpawnEntriesCaveTek_Hard_13", "DinoSpawnEntriesCaveTek_Hard_14", "DinoSpawnEntriesCaveTek_Hard_15", "DinoSpawnEntriesCaveTek_Hard_16", "DinoSpawnEntriesCaveTek_Medium_11", "DinoSpawnEntriesCaveTek_Medium_12", "DinoSpawnEntriesCaveTek_Medium_13", "DinoSpawnEntriesCaveTek_Medium_14", "DinoSpawnEntriesCaveTek_Medium_15", "DinoSpawnEntriesCaveTek_Medium_16", "DinoSpawnEntriesCaveWater", "DinoSpawnEntriesDamiensAtoll", "DinoSpawnEntriesGigant", "DinoSpawnEntriesGigantTekCave", "DinoSpawnEntriesGrassland", "DinoSpawnEntriesIceCave", "DinoSpawnEntriesJungle", "DinoSpawnEntriesMegalania", "DinoSpawnEntriesMonsterIsland", "DinoSpawnEntriesMountain", "DinoSpawnEntriesPelican", "DinoSpawnEntriesPenguins", "DinoSpawnEntriesQuetz", "DinoSpawnEntriesRedwoods", "DinoSpawnEntriesSnow", "DinoSpawnEntriesSwamp", "DinoSpawnEntriesSwampCave", "DinoSpawnEntriesSwampCaveWater", "DinoSpawnEntriesThy", "DinoSpawnEntriesTinyCave", "DinoSpawnEntriesTitano", "DinoSpawnEntriesUnderwaterGround", "DinoSpawnEntriesUnicorn", "DinoSpawnEntries_Beavers", "DinoSpawnEntries_DarkWater", "DinoSpawnEntries_DarkWaterAngler", "DinoSpawnEntries_DarkWater_Lio", "DinoSpawnEntries_DarkWater_Mosa", "DinoSpawnEntries_DarkWater_Mosa_Caves", "DinoSpawnEntries_DarkWater_Plesia", "DinoSpawnEntries_DarkWater_Tuso", "DinoSpawnEntries_DeepWater", "DinoSpawnEntries_InlandWater", "DinoSpawnEntries_Ocean", "DinoSpawnEntries_OceanCaveHard", "DinoSpawnEntries_OceanCaveMedium", "DinoSpawnEntries_RedwoodWater", "DinoSpawnEntries_ShallowWater", "DinoSpawnEntries_SwampWater"]4theIsland = arkMap("The Island", islandRegions)5#the center6centerRegions = ["CustomAnglerSpawner","CustomPenguinSpawner","GrasslandsUnderArea_WaterSpawn","IceCaveWater_Spawner","IceCave_Spawner","LavaBeach_Spawn","LavaWater_Spawn","Lava_Spawn","Lava_Upper_Spawn","MiniCaveBearSpawner","SnowGrasslandsUnderArea_Spawn","SnowGrasslands_Spawn","SnowyMountain_Spawn","UnderwaterCaveSpawn","DinoSpawnEntriesArcha","DinoSpawnEntriesBeach","DinoSpawnEntriesBee","DinoSpawnEntriesCave1","DinoSpawnEntriesCave5","DinoSpawnEntriesCave5_Tough","DinoSpawnEntriesCaveMegalo","DinoSpawnEntriesGigant","DinoSpawnEntriesGrassland","DinoSpawnEntriesJungle","DinoSpawnEntriesMegalania","DinoSpawnEntriesMonsterIsland","DinoSpawnEntriesMountain","DinoSpawnEntriesPelican","DinoSpawnEntriesQuetz","DinoSpawnEntriesRedwoods","DinoSpawnEntriesSnow","DinoSpawnEntriesSwamp","DinoSpawnEntriesThy","DinoSpawnEntriesTitano","DinoSpawnEntries_Beavers","DinoSpawnEntries_DarkWater","DinoSpawnEntries_DarkWater_Lio","DinoSpawnEntries_DarkWater_Mosa","DinoSpawnEntries_DarkWater_Tuso","DinoSpawnEntries_DeepWater","DinoSpawnEntries_GenericWater","DinoSpawnEntries_InlandWater","DinoSpawnEntries_Ocean","DinoSpawnEntries_OceanUnderworld","DinoSpawnEntries_ShallowWater","DinoSpawnEntries_SwampWater"]7theCenter = arkMap("The Center", centerRegions)8#scorched earth9scorchedRegions = ["DinoSpawnEntriesBee","DinoSpawnEntriesCaveMegalo","DinoSpawnEntriesMegalania","DinoSpawnEntriesPhoenix","SE_DinoSpawnEntriesBadlands","SE_DinoSpawnEntriesCanyonCave","SE_DinoSpawnEntriesCanyons","SE_DinoSpawnEntriesDunes","SE_DinoSpawnEntriesEZMode","SE_DinoSpawnEntriesGreenDesert","SE_DinoSpawnEntriesMountain","SE_DinoSpawnEntriesMountainCave","SE_DinoSpawnEntriesOasis","SE_DinoSpawnEntriesRuinsCave","SE_DinoSpawnEntriesRuinsCaveNoGolem","SE_DinoSpawnEntriesSandworm","SE_DinoSpawnEntriesWater","SE_DinoSpawnEntriesWyvern","SE_DinoSpawnEntriesWyvernTrench","SE_DinoSpawnEntries_RexSolo"]10scorchedEarth = arkMap("Scorched Earth", scorchedRegions)11#aberration12aberrationRegions = ["AB_DinoSpawnEntriesRockDrake","AB_DinoSpawnEntries_Basilisks","AB_DinoSpawnEntries_BioLumCave","AB_DinoSpawnEntries_DrakeTrench","AB_DinoSpawnEntries_ElementCave","AB_DinoSpawnEntries_ElementWater","AB_DinoSpawnEntries_ElementalChamber","AB_DinoSpawnEntries_FertileCave","AB_DinoSpawnEntries_OctoBat","AB_DinoSpawnEntries_RockDrake","AB_DinoSpawnEntries_TwitchBioLand","AB_DinoSpawnEntries_TwitchBioWater","AB_DinoSpawnEntries_TwitchFertileLand","AB_DinoSpawnEntries_TwitchFertileLandEasy","AB_DinoSpawnEntries_TwitchFertileWater","AB_DinoSpawnEntries_TwitchFertileWaterCave3","AB_DinoSpawnEntries_TwitchFertileWaterEasy","AB_DinoSpawnEntries_XenoQueens","AB_DinoSpawnEntries_Xenos","SE_DinoSpawnEntries_ChupaCabraSurface","DinoSpawnEntriesBee","DinoSpawnEntriesChupa"]13aberration = arkMap("Aberration", aberrationRegions)14#ragnarok15ragnarokRegions = ["Ragnarok_DinoSpawnEntriesIceWyvern","DinoSpawnEntries_Lobster","DinoSpawnEntries_Ragnarok_Bear","DinoSpawnEntries_Ragnarok_Castle","DinoSpawnEntries_Ragnarok_Center","DinoSpawnEntries_Ragnarok_CenterWater","DinoSpawnEntries_Ragnarok_DeepWater","DinoSpawnEntries_Ragnarok_Golem","DinoSpawnEntries_Ragnarok_Griffin","DinoSpawnEntries_Ragnarok_Iceworm","DinoSpawnEntries_Ragnarok_Jerboa","DinoSpawnEntries_Ragnarok_Jungle","DinoSpawnEntries_Ragnarok_MonkeyIsland","DinoSpawnEntries_Ragnarok_Mudslide","DinoSpawnEntries_Ragnarok_Ocean","DinoSpawnEntries_Ragnarok_PolarBear","DinoSpawnEntries_Ragnarok_Scotland","DinoSpawnEntries_Ragnarok_SnowForest","DinoSpawnEntries_Ragnarok_SnowPlains","DinoSpawnEntriesArcha","DinoSpawnEntriesBeach","DinoSpawnEntriesBee","DinoSpawnEntriesCave1","DinoSpawnEntriesCave2","DinoSpawnEntriesCave5_Tough","DinoSpawnEntriesCaveMegalo","DinoSpawnEntriesDamiensAtoll","DinoSpawnEntriesGigant","DinoSpawnEntriesGrassland","DinoSpawnEntriesMegalania","DinoSpawnEntriesMonsterIsland","DinoSpawnEntriesMountain","DinoSpawnEntriesPelican","DinoSpawnEntriesPenguins","DinoSpawnEntriesQuetz","DinoSpawnEntriesRedwoods","DinoSpawnEntriesSnow","DinoSpawnEntriesSwamp","DinoSpawnEntriesThy","DinoSpawnEntriesTinyCave","DinoSpawnEntriesTitano","DinoSpawnEntriesUnicorn","DinoSpawnEntriesWater","DinoSpawnEntries_Beavers","DinoSpawnEntries_DarkWater","DinoSpawnEntries_DarkWaterAngler","DinoSpawnEntries_DarkWater_Lio","DinoSpawnEntries_DarkWater_Mosa","DinoSpawnEntries_DarkWater_Tuso","DinoSpawnEntries_DeepWater","DinoSpawnEntries_InlandWater","DinoSpawnEntries_RedwoodWater","DinoSpawnEntries_SwampWater","SE_DinoSpawnEntriesBadlands","SE_DinoSpawnEntriesCanyons","SE_DinoSpawnEntriesDunes","SE_DinoSpawnEntriesGreenDesert","SE_DinoSpawnEntriesMountain","SE_DinoSpawnEntriesOasis","SE_DinoSpawnEntriesSandworm","SE_DinoSpawnEntriesWyvern","SE_DinoSpawnEntriesWyvernTrench"]16ragnarok = arkMap("Ragnarok", ragnarokRegions)17#extinction18extinctionRegions = ["DinoSpawnEntriesQuetz_EX","DinoSpawnEntries_CityCenter","DinoSpawnEntries_CityCenter_DangerClose","DinoSpawnEntries_CityObelisk","DinoSpawnEntries_CityTier2_Building","DinoSpawnEntries_CityTier2_Building_DangerClose","DinoSpawnEntries_CityTier2_Fliers","DinoSpawnEntries_City_Park2","DinoSpawnEntries_Wasteland_City_Buffer_1","DinoSpawnEntries_Wasteland_City_Buffer_2","DinoSpawnEntries_Wasteland_Easy","DinoSpawnEntries_Wasteland_Hard","DinoSpawnEntries_Wasteland_Medium","Ext_DinoSpawnEntries_DesertCave","Ext_DinoSpawnEntries_DesertMountain","Ext_DinoSpawnEntries_DesertOasis","Ext_DinoSpawnEntries_Forest","Ext_DinoSpawnEntries_ShallowWater_Cave","Ext_DinoSpawnEntries_ShallowWater_Desert","Ext_DinoSpawnEntries_ShallowWater_Ice","DinoSpawnEntries_City_Trench","DinoSpawnEntries_ParkWater","DinoSpawnEntries_ParkWater2","DinoSpawnEntries_Wasteland_DesertBuffer","DinoSpawnEntries_Wasteland_ForbiddenZone","DinoSpawnEntries_Wasteland_North","DinoSpawnEntries_Wasteland_NorthCraterForest","DinoSpawnEntries_Wasteland_OilFields","DinoSpawnEntries_Wasteland_OilFields_Fliers","DinoSpawnEntries_Wasteland_SnowBuffer","DinoSpawnEntries_Wasteland_South","DinoSpawnEntries_Wasteland_Sulfur","T_Ext_DinoSpawnEntriesSnow_1","T_Ext_DinoSpawnEntriesSnow_Purlovia","T_Ext_DinoSpawnEntriesSnow_TEMP","DinoSpawnEntriesBee","DinoSpawnEntriesCaveTek_Hard","DinoSpawnEntriesCaveTek_Hard_11","DinoSpawnEntriesCaveTek_Hard_12","DinoSpawnEntriesIceCave","DinoSpawnEntriesSwamp","DinoSpawnEntries_Beavers","DinoSpawnEntries_RedwoodWater"]19extinction = arkMap("Extinction", extinctionRegions)20#valguero21valgueroRegions = ["VAL_DinoSpawnEntries_TwitchFertileLand_C","VAL_DinoSpawnEntries_TwitchFertileLand_Mix_C","VAL_DinoSpawnEntries_TwitchFertileLandEasy_C","VAL_DinoSpawnEntries_TwitchBioWater_C","DinoSpawnEntriesBee_C","Val_DinoSpawnEntries_DrakeTrench_C","DinoSpawnEntries_DarkWater_Mosa_C","DinoSpawnEntries_DarkWater_Tuso_C","DinoSpawnEntries_DarkWater_C","DinoSpawnEntries_DarkWater_Lio_C","DinoSpawnEntries_DarkWaterAngler_C","DinoSpawnEntries_Ocean_C","DinoSpawnEntriesCave_JungleTemple_C","DinoSpawnEntries_Eel_CaveWater_C","DinoSpawnEntriesSwampCave_C","DinoSpawnEntriesSwampCaveWater_C","DinoSpawnEntries_SmallLakeWithPiranha_C","DinoSpawnEntries_Deinonychus_C","DinoSpawnEntriesDamiensAtoll_C","DinoSpawnEntriesBeach_C","DinoSpawnEntries_Beavers_C","DinoSpawnEntriesGigant_C","DinoSpawnEntriesGrassland_C","DinoSpawnEntriesMountain_C","DinoSpawnEntriesMonsterIsland_C","DinoSpawnEntries_Valguero_Scotland_C","DinoSpawnEntriesSavana_C","DinoSpawnEntriesJungle_C","DinoSpawnEntriesTundra_C","DinoSpawnEntriesRedwoods_C","Val_DinoSpawnEntriesWyvernTrench_C","Valguero_IceWyvernEntries_C","DinoSpawnEntriesPelican_C","DinoSpawnEntriesQuetz_C","DinoSpawnEntriesUnicorn_C","DinoSpawnEntriesSwamp_C","DinoSpawnEntries_SwampWater_C","DinoSpawnEntries_ShallowWater_C","DinoSpawnEntries_InlandWater_C","DinoSpawnEntries_DeepWater_C","DinoSpawnEntries_NormalLakeWater_C","DinoSpawnEntries_SmallLakeNoPiranha_C","DinoSpawnEntries_RedwoodWater_C","DinoSpawnEntriesWater_C","DinoSpawnEntries_SpiderCave_Entrance_C","DinoSpawnEntries_Valguero_SnowForest_C","DinoSpawnEntries_Valguero_SnowPlains_C","DinoSpawnEntries_PolarBear_C","DinoSpawnEntriesPenguins_C","DinoSpawnEntries_Valguero_IceDesert_C","DinoSpawnEntries_Iceworm_C","DinoSpawnEntriesArcha_C","DinoSpawnEntriesThy_C","DinoSpawnEntries_ChalkHills_C","DinoSpawnEntries_ChalkHills_Golem_C","DinoSpawnEntries_ChalkHills_Plains_C","DinoSpawnEntriesBrood_C"]22valguero = arkMap("Valguero", valgueroRegions)23"AB_DinoSpawnEntries_Basilisks", "AB_DinoSpawnEntries_BioCaveWater", "AB_DinoSpawnEntries_TwitchBioWater", "AB_DinoSpawnEntries_TwitchFertileWaterCave3", "AB_DinoSpawnEntries_TwitchFertileWaterEasy", "CI_CaveWolves", "CI_DinoSpawnEntries_AggressiveCrysWyv", "CI_DinoSpawnEntries_Ants", "CI_DinoSpawnEntries_Bog", "CI_DinoSpawnEntries_CavernEasy", "CI_DinoSpawnEntries_DevilsWater", "CI_DinoSpawnEntries_ElementBubbles_Large", "CI_DinoSpawnEntries_ElementalChamber", "CI_DinoSpawnEntries_EmberWyverns", "CI_DinoSpawnEntries_FloatingIslands_Main", "CI_DinoSpawnEntries_FloatingIslands_Small", "CI_DinoSpawnEntries_OtterPonds", "CI_DinoSpawnEntries_PoohBears", "CI_DinoSpawnEntries_SaberPride", "CI_DinoSpawnEntries_Tropeo", "CI_DinoSpawnEntries_WaterTunnels", "CI_DinoSpawnEntries_WolfPack", "CI_HoneyBees", "DinoSpawnEntriesBeach", "DinoSpawnEntriesBee", "DinoSpawnEntriesCave1", "DinoSpawnEntriesCave5", "DinoSpawnEntriesCaveMegalo", "DinoSpawnEntriesGigant", "DinoSpawnEntriesGrassland", "DinoSpawnEntriesIceCave", "DinoSpawnEntriesJungle", "DinoSpawnEntriesMegalania", "DinoSpawnEntriesMonsterIsland", "DinoSpawnEntriesMountain", "DinoSpawnEntriesPelican", "DinoSpawnEntriesPenguins", "DinoSpawnEntriesQuetz", "DinoSpawnEntriesRedwoods", "DinoSpawnEntriesSnowShoreline_PGM", "DinoSpawnEntriesSnow", "DinoSpawnEntriesSwamp", "DinoSpawnEntriesThy", "DinoSpawnEntriesTitano", "DinoSpawnEntriesUnicorn", "DinoSpawnEntries_Beavers", "DinoSpawnEntries_CW_Bloodfall", "DinoSpawnEntries_CW_WhiteShoals", "DinoSpawnEntries_DarkWaterAngler", "DinoSpawnEntries_DarkWater", "DinoSpawnEntries_DarkWater_Lio", "DinoSpawnEntries_DarkWater_Mosa", "DinoSpawnEntries_DarkWater_Tuso", "DinoSpawnEntries_DeepWater", "DinoSpawnEntries_GenericWater", "DinoSpawnEntries_Griffin", "DinoSpawnEntries_InlandWater", "DinoSpawnEntries_Ocean", "DinoSpawnEntries_RedwoodWater", "DinoSpawnEntries_ShallowWater", "DinoSpawnEntries_SwampWater", "SE_DinoSpawnEntriesBadlands", "SE_DinoSpawnEntriesCanyons", "SE_DinoSpawnEntriesDunes", "SE_DinoSpawnEntriesGreenDesert", "SE_DinoSpawnEntriesMountain", "SE_DinoSpawnEntriesOasis"24#extinction25crystalIslesRegions = ["AB_DinoSpawnEntries_Basilisks", "AB_DinoSpawnEntries_BioCaveWater", "AB_DinoSpawnEntries_TwitchBioWater", "AB_DinoSpawnEntries_TwitchFertileWaterCave3", "AB_DinoSpawnEntries_TwitchFertileWaterEasy", "CI_CaveWolves", "CI_DinoSpawnEntries_AggressiveCrysWyv", "CI_DinoSpawnEntries_Ants", "CI_DinoSpawnEntries_Bog", "CI_DinoSpawnEntries_CavernEasy", "CI_DinoSpawnEntries_DevilsWater", "CI_DinoSpawnEntries_ElementBubbles_Large", "CI_DinoSpawnEntries_ElementalChamber", "CI_DinoSpawnEntries_EmberWyverns", "CI_DinoSpawnEntries_FloatingIslands_Main", "CI_DinoSpawnEntries_FloatingIslands_Small", "CI_DinoSpawnEntries_OtterPonds", "CI_DinoSpawnEntries_PoohBears", "CI_DinoSpawnEntries_SaberPride", "CI_DinoSpawnEntries_Tropeo", "CI_DinoSpawnEntries_WaterTunnels", "CI_DinoSpawnEntries_WolfPack", "CI_HoneyBees", "DinoSpawnEntriesBeach", "DinoSpawnEntriesBee", "DinoSpawnEntriesCave1", "DinoSpawnEntriesCave5", "DinoSpawnEntriesCaveMegalo", "DinoSpawnEntriesGigant", "DinoSpawnEntriesGrassland", "DinoSpawnEntriesIceCave", "DinoSpawnEntriesJungle", "DinoSpawnEntriesMegalania", "DinoSpawnEntriesMonsterIsland", "DinoSpawnEntriesMountain", "DinoSpawnEntriesPelican", "DinoSpawnEntriesPenguins", "DinoSpawnEntriesQuetz", "DinoSpawnEntriesRedwoods", "DinoSpawnEntriesSnowShoreline_PGM", "DinoSpawnEntriesSnow", "DinoSpawnEntriesSwamp", "DinoSpawnEntriesThy", "DinoSpawnEntriesTitano", "DinoSpawnEntriesUnicorn", "DinoSpawnEntries_Beavers", "DinoSpawnEntries_CW_Bloodfall", "DinoSpawnEntries_CW_WhiteShoals", "DinoSpawnEntries_DarkWaterAngler", "DinoSpawnEntries_DarkWater", "DinoSpawnEntries_DarkWater_Lio", "DinoSpawnEntries_DarkWater_Mosa", "DinoSpawnEntries_DarkWater_Tuso", "DinoSpawnEntries_DeepWater", "DinoSpawnEntries_GenericWater", "DinoSpawnEntries_Griffin", "DinoSpawnEntries_InlandWater", "DinoSpawnEntries_Ocean", "DinoSpawnEntries_RedwoodWater", "DinoSpawnEntries_ShallowWater", "DinoSpawnEntries_SwampWater", "SE_DinoSpawnEntriesBadlands", "SE_DinoSpawnEntriesCanyons", "SE_DinoSpawnEntriesDunes", "SE_DinoSpawnEntriesGreenDesert", "SE_DinoSpawnEntriesMountain", "SE_DinoSpawnEntriesOasis"]26crystalIsles = arkMap("Crystal Isles", crystalIslesRegions)27mapList = [theIsland, theCenter, scorchedEarth, aberration, ragnarok, extinction, valguero, crystalIsles]28def getMapByName(mapOptions, name):29 for m in mapOptions:30 if m.getName() == name:31 return m...

Full Screen

Full Screen

expect.py

Source:expect.py Github

copy

Full Screen

1import time2from .exceptions import EOF, TIMEOUT3class Expecter(object):4 def __init__(self, spawn, searcher, searchwindowsize=-1):5 self.spawn = spawn6 self.searcher = searcher7 if searchwindowsize == -1:8 searchwindowsize = spawn.searchwindowsize9 self.searchwindowsize = searchwindowsize10 def new_data(self, data):11 spawn = self.spawn12 searcher = self.searcher13 pos = spawn._buffer.tell()14 spawn._buffer.write(data)15 spawn._before.write(data)16 # determine which chunk of data to search; if a windowsize is17 # specified, this is the *new* data + the preceding <windowsize> bytes18 if self.searchwindowsize:19 spawn._buffer.seek(max(0, pos - self.searchwindowsize))20 window = spawn._buffer.read(self.searchwindowsize + len(data))21 else:22 # otherwise, search the whole buffer (really slow for large datasets)23 window = spawn.buffer24 index = searcher.search(window, len(data))25 if index >= 0:26 spawn._buffer = spawn.buffer_type()27 spawn._buffer.write(window[searcher.end:])28 spawn.before = spawn._before.getvalue()[0:-(len(window) - searcher.start)]29 spawn._before = spawn.buffer_type()30 spawn.after = window[searcher.start: searcher.end]31 spawn.match = searcher.match32 spawn.match_index = index33 # Found a match34 return index35 elif self.searchwindowsize:36 spawn._buffer = spawn.buffer_type()37 spawn._buffer.write(window)38 def eof(self, err=None):39 spawn = self.spawn40 spawn.before = spawn.buffer41 spawn._buffer = spawn.buffer_type()42 spawn._before = spawn.buffer_type()43 spawn.after = EOF44 index = self.searcher.eof_index45 if index >= 0:46 spawn.match = EOF47 spawn.match_index = index48 return index49 else:50 spawn.match = None51 spawn.match_index = None52 msg = str(spawn)53 msg += '\nsearcher: %s' % self.searcher54 if err is not None:55 msg = str(err) + '\n' + msg56 raise EOF(msg)57 58 def timeout(self, err=None):59 spawn = self.spawn60 spawn.before = spawn.buffer61 spawn.after = TIMEOUT62 index = self.searcher.timeout_index63 if index >= 0:64 spawn.match = TIMEOUT65 spawn.match_index = index66 return index67 else:68 spawn.match = None69 spawn.match_index = None70 msg = str(spawn)71 msg += '\nsearcher: %s' % self.searcher72 if err is not None:73 msg = str(err) + '\n' + msg74 raise TIMEOUT(msg)75 def errored(self):76 spawn = self.spawn77 spawn.before = spawn.buffer78 spawn.after = None79 spawn.match = None80 spawn.match_index = None81 82 def expect_loop(self, timeout=-1):83 """Blocking expect"""84 spawn = self.spawn85 if timeout is not None:86 end_time = time.time() + timeout87 try:88 incoming = spawn.buffer89 spawn._buffer = spawn.buffer_type()90 spawn._before = spawn.buffer_type()91 while True:92 idx = self.new_data(incoming)93 # Keep reading until exception or return.94 if idx is not None:95 return idx96 # No match at this point97 if (timeout is not None) and (timeout < 0):98 return self.timeout()99 # Still have time left, so read more data100 incoming = spawn.read_nonblocking(spawn.maxread, timeout)101 if self.spawn.delayafterread is not None:102 time.sleep(self.spawn.delayafterread)103 if timeout is not None:104 timeout = end_time - time.time()105 except EOF as e:106 return self.eof(e)107 except TIMEOUT as e:108 return self.timeout(e)109 except:110 self.errored()111 raise112class searcher_string(object):113 '''This is a plain string search helper for the spawn.expect_any() method.114 This helper class is for speed. For more powerful regex patterns115 see the helper class, searcher_re.116 Attributes:117 eof_index - index of EOF, or -1118 timeout_index - index of TIMEOUT, or -1119 After a successful match by the search() method the following attributes120 are available:121 start - index into the buffer, first byte of match122 end - index into the buffer, first byte after match123 match - the matching string itself124 '''125 def __init__(self, strings):126 '''This creates an instance of searcher_string. This argument 'strings'127 may be a list; a sequence of strings; or the EOF or TIMEOUT types. '''128 self.eof_index = -1129 self.timeout_index = -1130 self._strings = []131 for n, s in enumerate(strings):132 if s is EOF:133 self.eof_index = n134 continue135 if s is TIMEOUT:136 self.timeout_index = n137 continue138 self._strings.append((n, s))139 def __str__(self):140 '''This returns a human-readable string that represents the state of141 the object.'''142 ss = [(ns[0], ' %d: %r' % ns) for ns in self._strings]143 ss.append((-1, 'searcher_string:'))144 if self.eof_index >= 0:145 ss.append((self.eof_index, ' %d: EOF' % self.eof_index))146 if self.timeout_index >= 0:147 ss.append((self.timeout_index,148 ' %d: TIMEOUT' % self.timeout_index))149 ss.sort()150 ss = list(zip(*ss))[1]151 return '\n'.join(ss)152 def search(self, buffer, freshlen, searchwindowsize=None):153 '''This searches 'buffer' for the first occurrence of one of the search154 strings. 'freshlen' must indicate the number of bytes at the end of155 'buffer' which have not been searched before. It helps to avoid156 searching the same, possibly big, buffer over and over again.157 See class spawn for the 'searchwindowsize' argument.158 If there is a match this returns the index of that string, and sets159 'start', 'end' and 'match'. Otherwise, this returns -1. '''160 first_match = None161 # 'freshlen' helps a lot here. Further optimizations could162 # possibly include:163 #164 # using something like the Boyer-Moore Fast String Searching165 # Algorithm; pre-compiling the search through a list of166 # strings into something that can scan the input once to167 # search for all N strings; realize that if we search for168 # ['bar', 'baz'] and the input is '...foo' we need not bother169 # rescanning until we've read three more bytes.170 #171 # Sadly, I don't know enough about this interesting topic. /grahn172 for index, s in self._strings:173 if searchwindowsize is None:174 # the match, if any, can only be in the fresh data,175 # or at the very end of the old data176 offset = -(freshlen + len(s))177 else:178 # better obey searchwindowsize179 offset = -searchwindowsize180 n = buffer.find(s, offset)181 if n >= 0 and (first_match is None or n < first_match):182 first_match = n183 best_index, best_match = index, s184 if first_match is None:185 return -1186 self.match = best_match187 self.start = first_match188 self.end = self.start + len(self.match)189 return best_index190class searcher_re(object):191 '''This is regular expression string search helper for the192 spawn.expect_any() method. This helper class is for powerful193 pattern matching. For speed, see the helper class, searcher_string.194 Attributes:195 eof_index - index of EOF, or -1196 timeout_index - index of TIMEOUT, or -1197 After a successful match by the search() method the following attributes198 are available:199 start - index into the buffer, first byte of match200 end - index into the buffer, first byte after match201 match - the re.match object returned by a successful re.search202 '''203 def __init__(self, patterns):204 '''This creates an instance that searches for 'patterns' Where205 'patterns' may be a list or other sequence of compiled regular206 expressions, or the EOF or TIMEOUT types.'''207 self.eof_index = -1208 self.timeout_index = -1209 self._searches = []210 for n, s in zip(list(range(len(patterns))), patterns):211 if s is EOF:212 self.eof_index = n213 continue214 if s is TIMEOUT:215 self.timeout_index = n216 continue217 self._searches.append((n, s))218 def __str__(self):219 '''This returns a human-readable string that represents the state of220 the object.'''221 #ss = [(n, ' %d: re.compile("%s")' %222 # (n, repr(s.pattern))) for n, s in self._searches]223 ss = list()224 for n, s in self._searches:225 ss.append((n, ' %d: re.compile(%r)' % (n, s.pattern)))226 ss.append((-1, 'searcher_re:'))227 if self.eof_index >= 0:228 ss.append((self.eof_index, ' %d: EOF' % self.eof_index))229 if self.timeout_index >= 0:230 ss.append((self.timeout_index, ' %d: TIMEOUT' %231 self.timeout_index))232 ss.sort()233 ss = list(zip(*ss))[1]234 return '\n'.join(ss)235 def search(self, buffer, freshlen, searchwindowsize=None):236 '''This searches 'buffer' for the first occurrence of one of the regular237 expressions. 'freshlen' must indicate the number of bytes at the end of238 'buffer' which have not been searched before.239 See class spawn for the 'searchwindowsize' argument.240 If there is a match this returns the index of that string, and sets241 'start', 'end' and 'match'. Otherwise, returns -1.'''242 first_match = None243 # 'freshlen' doesn't help here -- we cannot predict the244 # length of a match, and the re module provides no help.245 if searchwindowsize is None:246 searchstart = 0247 else:248 searchstart = max(0, len(buffer) - searchwindowsize)249 for index, s in self._searches:250 match = s.search(buffer, searchstart)251 if match is None:252 continue253 n = match.start()254 if first_match is None or n < first_match:255 first_match = n256 the_match = match257 best_index = index258 if first_match is None:259 return -1260 self.start = first_match261 self.match = the_match262 self.end = self.match.end()...

Full Screen

Full Screen

BossQuestCHAOS.js

Source:BossQuestCHAOS.js Github

copy

Full Screen

1var eventmapid = 610030600;2var returnmap = 910000000;3var monster = Array(/*8300006, */8510000/*, 8810130*/, 0, 8850010, 8870107/*, 8860000*/, 2, 1);4function init() {5// After loading, ChannelServer6}7function setup(partyid) {8 var instanceName = "BossQuest" + partyid;9 var eim = em.newInstance(instanceName);10 // If there are more than 1 map for this, you'll need to do mapid + instancename11 var map = eim.createInstanceMapS(eventmapid);12 map.toggleDrops();13 map.spawnNpc(9250156, new java.awt.Point(148, 1));14 eim.setProperty("points", 0);15 eim.setProperty("monster_number", 0);16 eim.setProperty("n_spawn", 0);17 eim.setProperty("f_spawn", 0);18 eim.setProperty("c_spawn", 0);19 beginQuest(eim);20 return eim;21}22function beginQuest(eim) { // Custom function23 if (eim != null) {24 eim.startEventTimer(5000); // After 5 seconds -> scheduledTimeout()25 }26}27function monsterSpawn(eim) { // Custom function28 var monsterid = monster[parseInt(eim.getProperty("monster_number"))];29 if (monsterid == 0) {30 if (parseInt(eim.getProperty("f_spawn")) == 0) {31 monsterid = 8610000;32 eim.setProperty("f_spawn", "1");33 monsterSpawn(eim); //double spawn34 } else if (parseInt(eim.getProperty("f_spawn")) == 1) {35 monsterid = 8610001;36 eim.setProperty("f_spawn", "2");37 monsterSpawn(eim); //double spawn38 } else if (parseInt(eim.getProperty("f_spawn")) == 2) {39 monsterid = 8610002;40 eim.setProperty("f_spawn", "3");41 monsterSpawn(eim); //double spawn42 } else if (parseInt(eim.getProperty("f_spawn")) == 3) {43 monsterid = 8610003;44 eim.setProperty("f_spawn", "4");45 monsterSpawn(eim); //double spawn46 } else if (parseInt(eim.getProperty("f_spawn")) == 4) {47 monsterid = 8610004;48 }49 } else if (monsterid == 1) {50 if (parseInt(eim.getProperty("n_spawn")) == 0) {51 monsterid = 8850005;52 eim.setProperty("n_spawn", "1");53 monsterSpawn(eim); //double spawn54 } else if (parseInt(eim.getProperty("n_spawn")) == 1) {55 monsterid = 8850006;56 eim.setProperty("n_spawn", "2");57 monsterSpawn(eim); //double spawn58 } else if (parseInt(eim.getProperty("n_spawn")) == 2) {59 monsterid = 8850007;60 eim.setProperty("n_spawn", "3");61 monsterSpawn(eim); //double spawn62 } else if (parseInt(eim.getProperty("n_spawn")) == 3) {63 monsterid = 8850008;64 eim.setProperty("n_spawn", "4");65 monsterSpawn(eim); //double spawn66 } else if (parseInt(eim.getProperty("n_spawn")) == 4) {67 monsterid = 8850009;68 eim.setProperty("n_spawn", "5");69 monsterSpawn(eim); //double spawn70 } else if (parseInt(eim.getProperty("n_spawn")) == 5) {71 monsterid = 8870200;72 }73 } else if (monsterid == 2) {74 if (parseInt(eim.getProperty("c_spawn")) == 0) {75 monsterid = 8820018;76 eim.setProperty("c_spawn", "1");77 //for (var i = 0; i < 10; i++) {78 monsterSpawn(eim);79 //}80 } else if (parseInt(eim.getProperty("c_spawn")) == 1) {81 monsterid = 8820015;82 eim.setProperty("c_spawn", "2");83 monsterSpawn(eim); //double spawn84 } else if (parseInt(eim.getProperty("c_spawn")) == 2) {85 monsterid = 8820016;86 eim.setProperty("c_spawn", "3");87 monsterSpawn(eim); //double spawn88 } else if (parseInt(eim.getProperty("c_spawn")) == 3) {89 monsterid = 8820017;90 eim.setProperty("c_spawn", "4");91 monsterSpawn(eim); //double spawn92 } else if (parseInt(eim.getProperty("c_spawn")) == 4) {93 monsterid = 8820018;94 eim.setProperty("c_spawn", "5");95 monsterSpawn(eim); //double spawn96 } else if (parseInt(eim.getProperty("c_spawn")) == 5) {97 monsterid = 8860003;98 }99 }100 var mob = em.getMonster(monsterid);101 var modified = em.newMonsterStats();102 modified.setOMp(mob.getMobMaxMp());103 switch (monsterid) {104 case 8840000:105 modified.setOExp(mob.getMobExp());106 modified.setOHp(mob.getMobMaxHp() * 2.4); //1b107 break;108 case 8800100:109 case 8800101:110 case 8800102:111 case 9400289:112 modified.setOExp(mob.getMobExp());113 modified.setOHp(mob.getMobMaxHp() * 1.8); //1b114 break;115 case 9400300:116 modified.setOExp(mob.getMobExp());117 modified.setOHp(mob.getMobMaxHp() * 6);118 break;119 case 9400589:120 case 9400590:121 case 9400591:122 case 9400592:123 case 9400593:124 modified.setOExp(mob.getMobExp());125 modified.setOHp(mob.getMobMaxHp() * 1.1);126 break;127 case 8850005:128 case 8850006:129 case 8850007:130 case 8850008:131 case 8850009:132 modified.setOExp(mob.getMobExp());133 modified.setOHp(mob.getMobMaxHp() * 2.2);134 break;135 case 8820002:136 case 8820015:137 case 8820016:138 case 8820017:139 case 8820018:140 modified.setOExp(mob.getMobExp());141 modified.setOHp(mob.getMobMaxHp() * 1.8);142 break;143 case 8300006:144 modified.setOExp(mob.getMobExp());145 modified.setOHp(mob.getMobMaxHp());146 break;147 case 8610000:148 case 8610001:149 case 8610002:150 case 8610003:151 case 8610004:152 modified.setOExp(mob.getMobExp() * 50);153 modified.setOHp(mob.getMobMaxHp() * 50 * 3);154 break;155 case 8860000:156 modified.setOExp(mob.getMobExp() * 1.2);157 modified.setOHp(mob.getMobMaxHp());158 break;159 case 8870200:160 modified.setOExp(mob.getMobExp() * 0.2);161 modified.setOHp(mob.getMobMaxHp() * 10);162 break;163 case 8510000:164 case 8850010:165 modified.setOExp(mob.getMobExp() * 2);166 modified.setOHp(mob.getMobMaxHp() * 10);167 break;168 case 8820018:169 modified.setOExp(mob.getMobExp() * 50);170 modified.setOHp(mob.getMobMaxHp() * 50);171 break;172 default:173 modified.setOExp(mob.getMobExp());174 modified.setOHp(mob.getMobMaxHp());175 break;176 }177 mob.setOverrideStats(modified);178 //var stats = mob.getStats();179 //stats.setFixedDamage(stats.getFixedDamage() * 2);180 //stats.setPhysicalAttack(stats.getPhysicalAttack() * 2);181 //stats.setMagicAttack(stats.getMagicAttack() * 2);182 //stats.setPDRate(Math.min(90, stats.getPDRate() * 1.5));183 //stats.setMDRate(Math.min(90, stats.getMDRate() * 1.5));184 eim.registerMonster(mob);185 var map = eim.getMapInstance(0);186 map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(0, 276));187}188function playerEntry(eim, player) {189 var map = eim.getMapInstance(0);190 player.changeMap(map, map.getPortal(0));191}192function changedMap(eim, player, mapid) {193 if (mapid != eventmapid) {194 eim.unregisterPlayer(player);195 eim.disposeIfPlayerBelow(0, 0);196 }197}198function scheduledTimeout(eim) {199 var num = parseInt(eim.getProperty("monster_number"));200 if (num < monster.length) {201 monsterSpawn(eim);202 eim.setProperty("monster_number", num + 1);203 } else {204 eim.disposeIfPlayerBelow(100, returnmap);205 }206// When event timeout..207// restartEventTimer(long time)208// stopEventTimer()209// startEventTimer(long time)210// isTimerStarted()211}212function allMonstersDead(eim) {213 eim.restartEventTimer(3000);214 var mobnum = parseInt(eim.getProperty("monster_number"));215 var num = mobnum * 6000;216 var totalp = parseInt(eim.getProperty("points")) + num;217 eim.setProperty("points", totalp);218 eim.broadcastPlayerMsg(5, "Your team've gained "+num+" points! With a total of "+totalp+".");219 220 eim.saveBossQuest(num);221 if (mobnum < monster.length) {222 eim.broadcastPlayerMsg(6, "Prepare! The next boss will appear in a glimpse of an eye!");223 } else {224 eim.saveBossQuest(100000);225 eim.saveNX(300000);226 eim.broadcastPlayerMsg(5, "Your team've beaten the Chaos mode and have gained an extra 100,000 points and extra 150,000 Cash!");227 eim.giveAchievement(22);228 }229// When invoking unregisterMonster(MapleMonster mob) OR killed230// Happens only when size = 0231}232function playerDead(eim, player) {233// Happens when player dies234}235function playerRevive(eim, player) {236 return true;237// Happens when player's revived.238// @Param : returns true/false239}240function playerDisconnected(eim, player) {241 return 0;242// return 0 - Deregister player normally + Dispose instance if there are zero player left243// return x that is > 0 - Deregister player normally + Dispose instance if there x player or below244// return x that is < 0 - Deregister player normally + Dispose instance if there x player or below, if it's leader = boot all245}246function monsterValue(eim, mobid) {247 if (mobid == 8820002 || mobid == 8820015 || mobid == 8820016 || mobid == 8820017 || mobid == 8820018) { //ariel248 eim.getMapInstance(0).killMonster(8820019);249 }250 return 0;251// Invoked when a monster that's registered has been killed252// return x amount for this player - "Saved Points"253}254function leftParty(eim, player) {255 // Happens when a player left the party256 eim.unregisterPlayer(player);257 var map = em.getMapFactory().getMap(returnmap);258 player.changeMap(map, map.getPortal(0));259 eim.disposeIfPlayerBelow(0, 0);260}261function disbandParty(eim, player) {262 // Boot whole party and end263 eim.disposeIfPlayerBelow(100, returnmap);264}265function clearPQ(eim) {266// Happens when the function EventInstanceManager.finishPQ() is invoked by NPC/Reactor script267}268function removePlayer(eim, player) {269 eim.dispose();270// Happens when the funtion NPCConversationalManager.removePlayerFromInstance() is invoked271}272function registerCarnivalParty(eim, carnivalparty) {273// Happens when carnival PQ is started. - Unused for now.274}275function onMapLoad(eim, player) {276// Happens when player change map - Unused for now.277}278function cancelSchedule() {...

Full Screen

Full Screen

SpawnManager.ts

Source:SpawnManager.ts Github

copy

Full Screen

1export class SpawnManager {2 spawn : StructureSpawn;3 containers: Structure[];4 strategy: string;5 constructor(spawn : StructureSpawn, containers : Structure[]) {6 this.spawn = spawn;7 this.containers = containers;8 9 if(this.spawn.room.memory.strategy == undefined) {10 this.spawn.room.memory.oldStrategy = "none";11 this.spawn.room.memory.strategy = "init";12 }13 this.strategy = this.spawn.room.memory.strategy;14 if(this.spawn.memory.spawnQueue == undefined) {15 this.spawn.memory.spawnQueue = [];16 }17 if(this.spawn.memory.minimumNumber == undefined) {18 this.spawn.memory.minimumNumber = {19 "lowenergyharvester": 4,20 "harvester" : 0,21 "handyworker": 0,22 "upgrader": 0,23 "claimer": 0,24 "longrangebuilder": 025 }; 26 }27 if(this.spawn.memory.budget == undefined) {28 this.spawn.memory.budget = 600;29 }30 if (this.spawn.room.memory.creepAllocation == undefined) {31 this.spawn.room.memory.creepAllocation = {};32 }33 }34 updateStrategy() {35 var strategy = this.spawn.room.memory.strategy;36 if(this.spawn.room.memory.strategy != this.spawn.room.memory.oldStrategy) {37 this.spawn.room.memory.oldStrategy = strategy;38 if(strategy == "init") {39 this.spawn.memory.minimumNumber = {40 "lowenergyharvester": 4,41 "harvester" : 0,42 "handyworker": 0,43 "upgrader": 0,44 "claimer": 0,45 "longrangebuilder": 046 }; 47 }48 if(strategy == "building") {49 var n_containers = Object.keys(this.spawn.room.memory.containerSource).length;50 this.spawn.memory.minimumNumber = {51 "lowenergyharvester": 0,52 "harvester" : n_containers,53 "handyworker": 5,54 "upgrader": 0,55 "claimer": 0,56 "longrangebuilder": 057 }; 58 }59 if(strategy == "upgrading") {60 var n_containers = Object.keys(this.spawn.room.memory.containerSource).length;61 this.spawn.memory.minimumNumber = {62 "lowenergyharvester": 0,63 "harvester" : n_containers,64 "handyworker": 3,65 "upgrader": 2,66 "claimer": 0,67 "longrangebuilder": 068 }; 69 }70 71 this.spawn.memory.spawnQueue = [];72 }73 new RoomVisual(this.spawn.room.name).text(strategy,2,1);74 }75 run() {76 this.updateQueue()77 if(this.spawn.memory.spawnQueue.length > 0) {78 var role = this.peekQueue();79 var energy = this.getRoleBudget(role, this.spawn.memory.budget)80 console.log(role, energy)81 if(this.spawn.room.energyAvailable >= energy) {82 console.log("Trying to spawn")83 var spawn_name = this.spawn.name;84 var name = role + spawn_name + Game.time.toString();85 var body = this.getBody(role, energy)86 var memory = this.getMemory(role)87 var result = this.spawn.spawnCreep(body, name, {memory: memory});88 if (result == OK) {89 this.popQueue();90 this.postCreepCreation(role, name);91 } else if (result != ERR_BUSY && result != ERR_NOT_ENOUGH_ENERGY) {92 console.log(this.spawn.name + " error: " + result)93 }94 }95 }96 this.updateStrategy()97 this.updateStats()98 }99 updateStats() {100 Memory.stats.creepRoles[this.spawn.name] = this.spawn.memory.numberOf;101 Memory.stats.minCreepRoles[this.spawn.name] = this.spawn.memory.minimumNumber;102 }103 getRoleBudget(role: string, defaultEnergy: number) {104 if(role == "claimer") {105 return 1000106 }107 if(role == "longrangebuilder") {108 return 1000109 }110 if(role == "handyworker") {111 if(defaultEnergy > 600) {112 return 600113 }114 return defaultEnergy115 }116 return defaultEnergy117 }118 getBody(role : string, energy : number) : BodyPartConstant[] {119 if(role == "harvester") {120 // for a harvester we make a body composed of MOVE and up to 5 WALK modules121 var body : BodyPartConstant[] = [MOVE]122 var maxworkparts = Math.floor((energy - BODYPART_COST[MOVE])/BODYPART_COST[WORK])123 for(var i = 0; i < 5 && i < maxworkparts; i++) {124 body.push(WORK)125 }126 return body;127 } else if(role == "handyworker" || role == "upgrader" || role == "longrangebuilder") {128 // as many work, move, carry parts as you can with the energy129 var currentEnergy = energy;130 var body : BodyPartConstant[] = [];131 while(currentEnergy >= 50) {132 if(currentEnergy >= 50) {133 body.push(MOVE);134 currentEnergy -= 50;135 }136 if(currentEnergy >= 50) {137 body.push(CARRY);138 currentEnergy -= 50;139 }140 if(currentEnergy >= 100) {141 body.push(WORK);142 currentEnergy -= 100;143 }144 }145 return body;146 } else if(role == "claimer") {147 var currentEnergy = energy;148 var body : BodyPartConstant[] = [CLAIM];149 150 currentEnergy -= BODYPART_COST[CLAIM];151 while(currentEnergy >= 50) {152 if(currentEnergy >= 50) {153 body.push(MOVE);154 currentEnergy -= 50;155 }156 }157 return body158 } 159 // else we return a generic body worth 300160 return [WORK, CARRY, MOVE, MOVE]161 }162 getMemory(role : string) : CreepMemory {163 if(role == "harvester") { 164 return { role: role, source_room: this.spawn.room.name }165 } else if (role == "handyworker" || role == "upgrader") {166 return { role: role, working: false, job: undefined, source_room: this.spawn.room.name }167 } else if (role == "lowenergyharvester") {168 return { role: role, working: false, source_room: this.spawn.room.name }169 } else if (role == "claimer") {170 var dest_room = undefined;171 if(Game.flags.claim.room != undefined) {172 dest_room = Game.flags.claim.pos.roomName;173 }174 return { role: role, working: false, source_room: this.spawn.room.name, dest_room: dest_room }175 } else if (role == "longrangebuilder") {176 var dest_room = undefined;177 if(Game.flags.build != undefined && Game.flags.build.room != undefined) {178 dest_room = Game.flags.build.pos.roomName;179 }180 return { role: role, working: false, source_room: this.spawn.room.name, dest_room: dest_room }181 }182 else return {role: role, source_room: this.spawn.room.name}183 }184 postCreepCreation(role: string, name: string) {185 if(role == "harvester") { 186 var containers = this.spawn.room.find<StructureContainer>(FIND_STRUCTURES, 187 { filter: { structureType: STRUCTURE_CONTAINER } });188 189 var nameAssigned = false;190 for(var container of containers) {191 var assigned = false;192 for(let creepId in this.spawn.room.memory.creepAllocation) {193 if(container.id == this.spawn.room.memory.creepAllocation[creepId]) {194 assigned = true;195 }196 }197 if(!assigned) {198 this.spawn.room.memory.creepAllocation[name] = container.id;199 nameAssigned = true;200 break;201 }202 }203 204 if(!nameAssigned) {205 console.log("Something went wrong! Couldn't assign " + name + " in room " +this.spawn.room.name);206 if(containers.length == 0) {207 console.log("No containers found in room " + this.spawn.room.name +", starting low energy mode...")208 this.spawn.room.memory.lowEnergyMode = true;209 }210 }211 }212 }213 updateQueue() {214 var needsUpdate = false;215 this.spawn.memory.numberOf = {};216 for(var role in this.spawn.memory.minimumNumber) {217 var current = _.sum(Game.creeps, (c) => (c.memory.role == role && c.memory.source_room == this.spawn.room.name) ? 1 : 0) + 218 _.sum(this.spawn.memory.spawnQueue, (r) => r == role ? 1 : 0);219 this.spawn.memory.numberOf[role] = current;220 for(var i = 0; i < this.spawn.memory.minimumNumber[role] - current; i++) {221 needsUpdate = true;222 this.enqueueCreep(role)223 }224 }225 226 if(needsUpdate) {227 this.sortQueue()228 }229 }230 enqueueCreep(role : string) {231 return this.spawn.memory.spawnQueue.push(role);232 }233 sortQueue() {234 var creepPriority = new Map<string, number>();235 creepPriority.set("lowenergyharvester", 0);236 creepPriority.set("harvester", 1);237 creepPriority.set("handyworker", 2);238 creepPriority.set("upgrader", 3);239 creepPriority.set("claimer", 4);240 return this.spawn.memory.spawnQueue.sort(function(a,b) {241 var aval = creepPriority.get(a);242 var bval = creepPriority.get(b);243 if(aval == undefined) {244 aval = 1000;245 }246 if(bval == undefined) {247 bval = 1000;248 }249 return aval - bval;250 })251 } 252 peekQueue() {253 return this.spawn.memory.spawnQueue[0];254 }255 popQueue() {256 return this.spawn.memory.spawnQueue.shift();257 }...

Full Screen

Full Screen

player-spawn-service.js

Source:player-spawn-service.js Github

copy

Full Screen

1'use strict';2const Direction = require('../models/direction');3/**4 * Spawns and/or respawns a player with other entities in mind5 */6class PlayerSpawnService {7 constructor(boardOccupancyService) {8 this.boardOccupancyService = boardOccupancyService;9 }10 // Try to spawn the player in a safe area with enough time to react. Otherwise don't spawn player if no safe areas11 setupNewSpawn(player, playerLength, requiredFreeLength) {12 let spawnCoordinate;13 let newDirection;14 if (Math.random() < 0.5) {15 // Horizontal16 const randomValue = Math.random();17 if (randomValue < 0.25) {18 // Top Left19 const possibleSpawnCoordinates =20 this.boardOccupancyService.getUnoccupiedHorizontalCoordinatesFromTopLeft(requiredFreeLength);21 if (possibleSpawnCoordinates.length === 0) {22 return;23 }24 if (Math.random() < 0.5) {25 newDirection = Direction.LEFT;26 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];27 } else {28 newDirection = Direction.RIGHT;29 spawnCoordinate = possibleSpawnCoordinates[0];30 }31 } else if (randomValue < 0.5) {32 // Top Right33 const possibleSpawnCoordinates =34 this.boardOccupancyService.getUnoccupiedHorizontalCoordinatesFromTopRight(requiredFreeLength);35 if (possibleSpawnCoordinates.length === 0) {36 return;37 }38 if (Math.random() < 0.5) {39 newDirection = Direction.LEFT;40 spawnCoordinate = possibleSpawnCoordinates[0];41 } else {42 newDirection = Direction.RIGHT;43 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];44 }45 } else if (randomValue < 0.75) {46 // Bottom Right47 const possibleSpawnCoordinates =48 this.boardOccupancyService.getUnoccupiedHorizontalCoordinatesFromBottomRight(requiredFreeLength);49 if (possibleSpawnCoordinates.length === 0) {50 return;51 }52 if (Math.random() < 0.5) {53 newDirection = Direction.LEFT;54 spawnCoordinate = possibleSpawnCoordinates[0];55 } else {56 newDirection = Direction.RIGHT;57 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];58 }59 } else {60 // Bottom Left61 const possibleSpawnCoordinates =62 this.boardOccupancyService.getUnoccupiedHorizontalCoordinatesFromBottomLeft(requiredFreeLength);63 if (possibleSpawnCoordinates.length === 0) {64 return;65 }66 if (Math.random() < 0.5) {67 newDirection = Direction.LEFT;68 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];69 } else {70 newDirection = Direction.RIGHT;71 spawnCoordinate = possibleSpawnCoordinates[0];72 }73 }74 } else {75 // Vertical76 const randomValue = Math.random();77 if (randomValue < 0.25) {78 // Top Left79 const possibleSpawnCoordinates =80 this.boardOccupancyService.getUnoccupiedVerticalCoordinatesFromTopLeft(requiredFreeLength);81 if (possibleSpawnCoordinates.length === 0) {82 return;83 }84 if (Math.random() < 0.5) {85 newDirection = Direction.UP;86 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];87 } else {88 newDirection = Direction.DOWN;89 spawnCoordinate = possibleSpawnCoordinates[0];90 }91 } else if (randomValue < 0.5) {92 // Top Right93 const possibleSpawnCoordinates =94 this.boardOccupancyService.getUnoccupiedVerticalCoordinatesFromTopRight(requiredFreeLength);95 if (possibleSpawnCoordinates.length === 0) {96 return;97 }98 if (Math.random() < 0.5) {99 newDirection = Direction.UP;100 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];101 } else {102 newDirection = Direction.DOWN;103 spawnCoordinate = possibleSpawnCoordinates[0];104 }105 } else if (randomValue < 0.75) {106 // Bottom Right107 const possibleSpawnCoordinates =108 this.boardOccupancyService.getUnoccupiedVerticalCoordinatesFromBottomRight(requiredFreeLength);109 if (possibleSpawnCoordinates.length === 0) {110 return;111 }112 if (Math.random() < 0.5) {113 newDirection = Direction.UP;114 spawnCoordinate = possibleSpawnCoordinates[0];115 } else {116 newDirection = Direction.DOWN;117 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];118 }119 } else {120 // Bottom Left121 const possibleSpawnCoordinates =122 this.boardOccupancyService.getUnoccupiedVerticalCoordinatesFromBottomLeft(requiredFreeLength);123 if (possibleSpawnCoordinates.length === 0) {124 return;125 }126 if (Math.random() < 0.5) {127 newDirection = Direction.UP;128 spawnCoordinate = possibleSpawnCoordinates[0];129 } else {130 newDirection = Direction.DOWN;131 spawnCoordinate = possibleSpawnCoordinates[possibleSpawnCoordinates.length - 1];132 }133 }134 }135 this.boardOccupancyService.addPlayerOccupancy(player.id, [spawnCoordinate]);136 player.setStartingSpawn(newDirection, spawnCoordinate, playerLength - 1);137 }138}...

Full Screen

Full Screen

WaveMng.js

Source:WaveMng.js Github

copy

Full Screen

...122 if (this.currentSpawn.finished) {123 this.endSpawn();124 return;125 }126 let newFoe = this.currentSpawn.spawn(this.game.poolMng);127 if (newFoe) {128 this.foeGroup.addChild(newFoe);129 newFoe.setPosition(this.getNewFoePosition());130 newFoe.getComponent('Foe').init(this);131 // this.curFoeCount++;132 }133 },134 spawnBossFoe () {135 if (this.bossSpawn.finished) {136 this.unschedule(this.spawnBossFoe);137 }138 let newFoe = this.bossSpawn.spawn(this.game.poolMng);139 if (newFoe) {140 this.foeGroup.addChild(newFoe);141 newFoe.setPosition(this.getNewFoePosition());142 newFoe.getComponent('Foe').init(this);143 }144 },145 spawnProjectile (projectileType, pos, dir, rot) {146 let newProjectile = this.game.poolMng.requestProjectile(projectileType);147 if (newProjectile) {148 this.foeGroup.addChild(newProjectile);149 newProjectile.setPosition(pos);150 newProjectile.getComponent('Projectile').init(this, dir);151 } else {152 cc.log('requesting too many projectiles! please increase size');...

Full Screen

Full Screen

once.py

Source:once.py Github

copy

Full Screen

...6 """7 __slots__ = ["spawns"]8 def __init__(self, *spawns):9 self.spawns = spawns # type: list10 def spawn(self, game, origin):11 selected_set = self.select_spawn()12 return self.spawn_set(game, selected_set, origin)13 def select_spawn(self):14 randomized_spawns = list(self.spawns)15 random.shuffle(randomized_spawns)16 for spawn_set in randomized_spawns:17 if random.randrange(1, 100) <= spawn_set.percent:18 return spawn_set19 @classmethod20 def spawn_set(cls, game, spawn_set, origin):21 if spawn_set is None:22 return []23 spawn_sets = []24 spawned_objects = []25 if isinstance(spawn_set, SpawnChain):26 cls.expand_spawn_chains(spawn_set, spawn_sets)27 else:28 spawn_sets.append(spawn_set)29 for spawn_set in spawn_sets:30 spawn_x, spawn_y = spawn_set.spawn_point31 offset_x, offset_y = origin32 new_spawn_point = (spawn_x + offset_x, spawn_y + offset_y)33 if spawn_set.amount:34 for _ in range(spawn_set.amount):35 spawned_objects.append(game.factory.route(spawn_set.spawn_type))36 else:37 spawned_objects.append(game.factory.route(spawn_set.spawn_type))38 for spawned_object in spawned_objects:39 spawned_object.location.set_local_coords(new_spawn_point)40 spawn_set.on_spawn(game, spawned_object, origin)41 return spawned_objects42 @classmethod43 def expand_spawn_chains(cls, spawn_chain, spawn_sets):44 for spawn_set in spawn_chain.spawn_sets:45 if isinstance(spawn_set, SpawnChain):46 cls.expand_spawn_chains(spawn_set, spawn_sets)47 else:...

Full Screen

Full Screen

spawnpoint.ts

Source:spawnpoint.ts Github

copy

Full Screen

1import { WriteLock } from "./module/region";2import { Scoreboard } from "@mcbe/scoreboard";3import { Vector3, Box } from "krgeometry";4import { command } from "@mcbe/system_server";5import { UserExtra, User, AttackEvent } from "@bdsx/ruakr_user";6const board = new Scoreboard('$spawn');7export const SPAWN_SIZE = 50;8export let SPAWN_POINT:Vector3;9export const SPAWN_GUARD_AREA = 20;10export let spawnLock:WriteLock;11function setSpawn(pos:Vector3):void12{13 SPAWN_POINT = pos;14 spawnLock = new WriteLock('스폰 지점', new Box(15 pos.x - SPAWN_SIZE, -Infinity, pos.z - SPAWN_SIZE, 16 pos.x + SPAWN_SIZE, Infinity, pos.z + SPAWN_SIZE), pos.y - 3);17}18export function setWorldSpawn(pos:Vector3):void19{20 pos = pos.floor();21 board.set('x', pos.x);22 board.set('y', pos.y);23 board.set('z', pos.z);24 spawnLock.remove();25 setSpawn(pos);26 27 command(`setworldspawn ${pos.x} ${pos.y} ${pos.z}`);28}29export class SpawnPointExtra implements UserExtra30{31 constructor(public readonly user:User)32 {33 }34 onAttack(ev:AttackEvent)35 {36 const other = ev.targetUser;37 if (other)38 {39 if (new Box(40 SPAWN_POINT.x - SPAWN_GUARD_AREA, spawnLock.cube.y1, SPAWN_POINT.z - SPAWN_GUARD_AREA,41 SPAWN_POINT.x + SPAWN_GUARD_AREA, Infinity, SPAWN_POINT.z + SPAWN_GUARD_AREA42 ).contains(other.position))43 {44 this.user.kill();45 }46 }47 }48 49 static onInstall():void50 {51 Promise.all([board.get('x'), board.get('y'), board.get('z')]).then(([x, y, z])=>{52 if (x === undefined)53 {54 setSpawn(new Vector3(12, 64, 4));55 }56 else57 {58 setSpawn(new Vector3(x, y!, z!));59 }60 });61 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var mb = spawn('mb', ['start', '--configfile', 'config.json', '--allowInjection']);3mb.stdout.on('data', function (data) {4 console.log('stdout: ' + data);5});6mb.stderr.on('data', function (data) {7 console.log('stderr: ' + data);8});9mb.on('close', function (code) {10 console.log('child process exited with code ' + code);11});12mb.stdin.write('Hello');13mb.stdin.end();14{

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var mb = spawn('mb', ['start', '--allowInjection', '--port', '2525', '--pidfile', 'mb.pid', '--logfile', 'mb.log', '--protofile', 'protofile.json', '--configfile', 'config.json', '--localOnly']);3var exec = require('child_process').exec;4exec('mb start --allowInjection --port 2525 --pidfile mb.pid --logfile mb.log --protofile protofile.json --configfile config.json --localOnly', function (error, stdout, stderr) {5 console.log(stdout);6 console.log(stderr);7 if (error !== null) {8 console.log('exec error: ' + error);9 }10});11var exec = require('child_process').exec;12exec('mb stop --pidfile mb.pid', function (error, stdout, stderr) {13 console.log(stdout);14 console.log(stderr);15 if (error !== null) {16 console.log('exec error: ' + error);17 }18});19var exec = require('child_process').exec;20exec('mb restart --allowInjection --port 2525 --pidfile mb.pid --logfile mb.log --protofile protofile.json --configfile config.json --localOnly', function (error, stdout, stderr) {21 console.log(stdout);22 console.log(stderr);23 if (error !== null) {24 console.log('exec error: ' + error);25 }26});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { spawn } = require('child_process');2const mb = spawn('mb', ['start', '--mock', '--configfile', 'mocks.ejs']);3mb.stdout.on('data', (data) => {4 console.log(`stdout: ${data}`);5});6mb.stderr.on('data', (data) => {7 console.log(`stderr: ${data}`);8});9mb.on('close', (code) => {10 console.log(`child process exited with code ${code}`);11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var mb = spawn('mb', ['--configfile', 'imposters.ejs', '--allowInjection', '--port', '2525', '--pidfile', 'mb.pid', '--logfile', 'mb.log', '--loglevel', 'debug']);3mb.stdout.on('data', function (data) {4 console.log('stdout: ' + data);5});6mb.stderr.on('data', function (data) {7 console.log('stderr: ' + data);8});9mb.on('close', function (code) {10 console.log('child process exited with code ' + code);11});12{13 {14 {15 "is": {16 }17 }18 {19 "equals": {20 }21 }22 }23}

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var mb = spawn('mb', ['start', '--configfile', 'test.json', '--allowInjection', '--loglevel', 'debug']);3mb.stdout.on('data', function (data) {4 console.log('stdout: ' + data);5});6mb.stderr.on('data', function (data) {7 console.log('stderr: ' + data);8});9mb.on('close', function (code) {10 console.log('child process exited with code ' + code);11});12{13 {14 {15 {16 "is": {17 }18 }19 }20 }21}

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn;2var mb = spawn('mb', ['start', '--configfile', 'imposters.ejs', '--logfile', 'mb.log', '--loglevel', 'debug']);3mb.stdout.on('data', function (data) {4 console.log('stdout: ' + data);5});6mb.stderr.on('data', function (data) {7 console.log('stderr: ' + data);8});9mb.on('close', function (code) {10 console.log('child process exited with code ' + code);11});12{13 {14 {15 "is": {16 "headers": {17 },18 }19 }20 }21}

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var port = 2525;3var host = 'localhost';4var protocol = 'http';5mb.create({6}, function (error, mbInstance) {7 if (error) {8 console.error(error);9 } else {10 console.log('Mountebank started on port ' + port);11 mbInstance.createImposter({12 stubs: [{13 responses: [{14 is: {15 }16 }]17 }]18 }, function (error, imposter) {19 if (error) {20 console.error(error);21 } else {22 console.log('Imposter created with protocol ' + imposter.protocol + ' and port ' + imposter.port);23 mbInstance.get(url, function (error, response) {24 if (error) {25 console.error(error);26 } else {27 console.log('Response from imposter: ' + response.body);28 }29 mbInstance.del(url, function (error) {30 if (error) {31 console.error(error);32 } else {33 console.log('Imposter deleted');34 mbInstance.stop(function (error) {35 if (error) {36 console.error(error);37 } else {38 console.log('Mountebank stopped');39 }40 });41 }42 });43 });44 }45 });46 }47});

Full Screen

Using AI Code Generation

copy

Full Screen

1var spawn = require('child_process').spawn,2 mb = spawn('mb', ['start', '--allowInjection', '--configfile', 'config.json', '--mock', '--pidfile', 'mb.pid', '--logfile', 'mb.log', '--loglevel', 'debug', '--localOnly', '--ipWhitelist', '*']);3mb.stdout.on('data', function (data) {4 console.log('stdout: ' + data);5});6mb.stderr.on('data', function (data) {7 console.log('stderr: ' + data);8});9mb.on('close', function (code) {10 console.log('child process exited with code ' + code);11});12var mocha = spawn('mocha', ['test.js']);13mocha.stdout.on('data', function (data) {14 console.log('stdout: ' + data);15});16mocha.stderr.on('data', function (data) {17 console.log('stderr: ' + data);18});19mocha.on('close', function (code) {20 console.log('child process exited with code ' + code);21});22var mbStop = spawn('mb', ['stop', '--pidfile', 'mb.pid']);23mbStop.stdout.on('data', function (data) {24 console.log('stdout: ' + data);25});26mbStop.stderr.on('data', function (data) {27 console.log('stderr: ' + data);28});29mbStop.on('close', function (code) {30 console.log('child process exited with code ' + code);31});32var fs = require('fs');33fs.unlinkSync('mb.pid');34fs.unlinkSync('mb.log');35fs.unlinkSync('config.json');36fs.unlinkSync('test.js');37fs.unlinkSync('package.json');38fs.unlinkSync('package-lock.json');39var rimraf = require('rimraf');40rimraf('node_modules', function () {41 console.log('done');42});43rimraf('test', function () {44 console.log('done');45});46fs.unlinkSync('mb.log');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful