Best JavaScript code snippet using storybook-root
buttons.js
Source:buttons.js
1// Define", "unit-button.2//3 // DefineButton( { Pos = n, Level = n 'icon ident Action = name ['value value]4// ['allowed check ['values]] Key = key, Hint = hint 'for-unit", "units)5//6 // general commands // almost all", "units have it //////////////////////////////-7buttons.push( { Pos : 1, Level : 0, Icon : "icon-move-peasant",8 Action : "move",9 Key : "m", Hint : "~!MOVE",10 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",11 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-peasant",12 "unit-female-hero",13 "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",14 "unit-man-of-light", "unit-white-mage", "unit-balloon",15 "unit-gryphon-rider", "unit-mage", "unit-critter",16 "human-group"]},17 { Pos : 2, Level : 0, Icon : "icon-human-shield1",18 Action : "stop",19 Key : "s", Hint : "~!STOP",20 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",21 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-peasant",22 "unit-female-hero",23 "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",24 "unit-man-of-light", "unit-white-mage", "unit-balloon",25 "unit-gryphon-rider", "unit-mage", "unit-critter",26 "human-group"]},27 { Pos : 2, Level : 0, Icon : "icon-human-shield2",28 Action : "stop",29 Allowed : "check-upgrade", AllowArg : ["upgrade-human-shield1"],30 Key : "s", Hint : "~!STOP",31 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",32 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-arthor-literios", "unit-knight-rider",33 "unit-wise-man", "unit-man-of-light"]},34 { Pos : 2, Level : 0, Icon : "icon-human-shield3",35 Action : "stop",36 Allowed : "check-upgrade", AllowArg : ["upgrade-human-shield2"],37 Key : "s", Hint : "~!STOP",38 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",39 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-arthor-literios", "unit-knight-rider",40 "unit-wise-man", "unit-man-of-light"]},41 { Pos : 3, Level : 0, Icon : "icon-sword1",42 Action : "attack",43 Key : "a", Hint : "~!ATTACK",44 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",45 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-peasant",46 "unit-female-hero",47 "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",48 "unit-man-of-light", "unit-white-mage", "unit-gryphon-rider", "human-group"]},49 { Pos : 3, Level : 0, Icon : "icon-sword2",50 Action : "attack",51 Allowed : "check-upgrade", AllowArg : ["upgrade-sword1"],52 Key : "a", Hint : "~!ATTACK",53 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",54 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-arthor-literios", "unit-knight-rider",55 "unit-wise-man", "unit-man-of-light"]},56 { Pos : 3, Level : 0, Icon : "icon-sword3",57 Action : "attack",58 Allowed : "check-upgrade", AllowArg : ["upgrade-sword2"],59 Key : "a", Hint : "~!ATTACK",60 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",61 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-arthor-literios", "unit-knight-rider",62 "unit-wise-man", "unit-man-of-light"]},63 { Pos : 3, Level : 0, Icon : "icon-arrow1",64 Action : "attack",65 Key : "a", Hint : "~!ATTACK",66 ForUnit : ["unit-archer", "unit-ranger", "unit-female-hero"]},67 { Pos : 3, Level : 0, Icon : "icon-arrow2",68 Action : "attack",69 Allowed : "check-upgrade", AllowArg : ["upgrade-arrow1"],70 Key : "a", Hint : "~!ATTACK",71 ForUnit : ["unit-archer", "unit-ranger", "unit-female-hero"]},72 { Pos : 3, Level : 0, Icon : "icon-arrow3",73 Action : "attack",74 Allowed : "check-upgrade", AllowArg : ["upgrade-arrow2"],75 Key : "a", Hint : "~!ATTACK",76 ForUnit : ["unit-archer", "unit-ranger", "unit-female-hero"]},77//if (wargus.extensions) then78{ Pos : 4, Level : 0, Icon : "icon-human-patrol-land",79 Action : "patrol",80 Key : "p", Hint : "~!PATROL",81 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",82 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-female-hero",83 "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",84 "unit-man-of-light", "unit-gryphon-rider", "human-group",85 "unit-balloon"]},86//else87//{ Pos : 4, Level : 0, Icon : "icon-human-patrol-land",88// Action : "patrol",89// Key : "p", Hint : "~!PATROL",90// ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",91// "unit-dwarves", "unit-ranger", "unit-ballista", "unit-female-hero",92// "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",93// "unit-man-of-light", "unit-gryphon-rider", "human-group"]},94//end95 { Pos : 5, Level : 0, Icon : "icon-human-stand-ground",96 Action : "stand-ground",97 Key : "t", Hint : "S~!TAND GROUND",98 ForUnit : ["unit-footman", "unit-knight", "unit-archer", "unit-paladin",99 "unit-dwarves", "unit-ranger", "unit-ballista", "unit-female-hero",100 "unit-flying-angel", "unit-arthor-literios", "unit-knight-rider", "unit-wise-man",101 "unit-man-of-light", "unit-gryphon-rider", "human-group",102 "unit-human-submarine", "unit-battleship", "unit-human-destroyer"]},103 { Pos : 6, Level : 0, Icon : "icon-human-attack-ground",104 Action : "attack-ground",105 Key : "g", Hint : "ATTACK ~!GROUND",106 ForUnit : ["unit-ballista", "unit-battleship", "human-group"]},107 { Pos : 9, Level : 0, Icon : "icon-human-demolish",108 Action : "cast-spell", Value : "spell-suicide-bomber",109 Allowed : "check-true",110 Key : "d", Hint : "~!DEMOLISH",111 ForUnit : ["unit-dwarves"]},112// paladin specific actions //////////////////////////////////////////////////-113 { Pos : 7, Level : 0, Icon : "icon-holy-vision",114 Action : "cast-spell", Value : "spell-holy-vision",115 Allowed : "check-upgrade", AllowArg : ["upgrade-holy-vision"],116 Key : "v", Hint : "HOLY ~!VISION",117 ForUnit : ["unit-paladin", "unit-knight-rider",118 "unit-man-of-light"]},119 { Pos : 8, Level : 0, Icon : "icon-heal",120 Action : "cast-spell", Value : "spell-healing",121 Allowed : "check-upgrade", AllowArg : ["upgrade-healing"],122 Key : "h", Hint : "~!HEALING (per 1 HP)",123 ForUnit : ["unit-paladin", "unit-knight-rider",124 "unit-man-of-light"]},125 { Pos : 9, Level : 0, Icon : "icon-exorcism",126 Action : "cast-spell", Value : "spell-exorcism",127 Allowed : "check-upgrade", AllowArg : ["upgrade-exorcism"],128 Key : "e", Hint : "~!EXORCISM",129 ForUnit : ["unit-paladin", "unit-knight-rider",130 "unit-man-of-light"]},131// mage specific actions //////////////////////////////////////////////////////132 { Pos : 3, Level : 0, Icon : "icon-lightning",133 Action : "attack",134 Key : "a", Hint : "LIGHTNING ~!ATTACK",135 ForUnit : ["unit-mage", "unit-white-mage"]},136 { Pos : 4, Level : 0, Icon : "icon-fireball",137 Action : "cast-spell", Value : "spell-fireball",138 Allowed : "check-upgrade", AllowArg : ["upgrade-fireball"],139 Key : "f", Hint : "~!FIREBALL",140 ForUnit : ["unit-mage", "unit-white-mage"]},141 { Pos : 5, Level : 0, Icon : "icon-slow",142 Action : "cast-spell", Value : "spell-slow",143 Allowed : "check-upgrade", AllowArg : ["upgrade-slow"],144 Key : "o", Hint : "SL~!OW",145 ForUnit : ["unit-mage", "unit-white-mage"]},146 { Pos : 6, Level : 0, Icon : "icon-flame-shield",147 Action : "cast-spell", Value : "spell-flame-shield",148 Allowed : "check-upgrade", AllowArg : ["upgrade-flame-shield"],149 Key : "l", Hint : "F~!LAME SHIELD",150 ForUnit : ["unit-mage", "unit-white-mage"]},151 { Pos : 7, Level : 0, Icon : "icon-invisibility",152 Action : "cast-spell", Value : "spell-invisibility",153 Allowed : "check-upgrade", AllowArg : ["upgrade-invisibility"],154 Key : "i", Hint : "~!INVISIBILITY",155 ForUnit : ["unit-mage", "unit-white-mage"]},156 { Pos : 8, Level : 0, Icon : "icon-polymorph",157 Action : "cast-spell", Value : "spell-polymorph",158 // Action : "cast-spell", Value : "spell-suicide-bomber",159 Allowed : "check-upgrade", AllowArg : ["upgrade-polymorph"],160 Key : "p", Hint : "~!POLYMORPH",161 ForUnit : ["unit-mage", "unit-white-mage"]},162 { Pos : 9, Level : 0, Icon : "icon-blizzard",163 Action : "cast-spell", Value : "spell-blizzard",164 Allowed : "check-upgrade", AllowArg : ["upgrade-blizzard"],165 Key : "b", Hint : "~!BLIZZARD",166 ForUnit : ["unit-mage", "unit-white-mage"]},167// peasant specific actions //////////////////////////////////////////////////-168 { Pos : 4, Level : 0, Icon : "icon-repair",169 Action : "repair",170 Key : "r", Hint : "~!REPAIR",171 ForUnit : ["unit-peasant"]},172 { Pos : 5, Level : 0, Icon : "icon-harvest",173 Action : "harvest",174 Key : "h", Hint : "~!HARVEST LUMBER/MINE GOLD",175 ForUnit : ["unit-peasant"]},176 { Pos : 6, Level : 0, Icon : "icon-return-goods-peasant",177 Action : "return-goods",178 Key : "g", Hint : "RETURN WITH ~!GOODS",179 ForUnit : ["unit-peasant"]},180// build basic/advanced structs //////////////////////////////////////////////-181 { Pos : 7, Level : 0, Icon : "icon-build-basic",182 Action : "button", Value : 1,183 Key : "b", Hint : "~!BUILD BASIC STRUCTURE",184 ForUnit : ["unit-peasant"]},185 { Pos : 8, Level : 0, Icon : "icon-build-advanced",186 Action : "button", Value : 2,187 Allowed : "check-units-or", AllowArg : ["unit-elven-lumber-mill", "unit-keep"],188 Key : "v", Hint : "BUILD AD~!VANCED STRUCTURE",189 ForUnit : ["unit-peasant"]},190// simple buildings human ////////////////////////////////////////////////////-191 { Pos : 1, Level : 1, Icon : "icon-farm",192 Action : "build", Value : "unit-farm",193 Key : "f", Hint : "BUILD ~!FARM",194 ForUnit : ["unit-peasant"]},195 { Pos : 2, Level : 1, Icon : "icon-human-barracks",196 Action : "build", Value : "unit-human-barracks",197 Key : "b", Hint : "BUILD ~!BARRACKS",198 ForUnit : ["unit-peasant"]},199 { Pos : 3, Level : 1, Icon : "icon-town-hall",200 Action : "build", Value : "unit-town-hall",201 Key : "h", Hint : "BUILD TOWN ~!HALL",202 ForUnit : ["unit-peasant"]},203 { Pos : 4, Level : 1, Icon : "icon-elven-lumber-mill",204 Action : "build", Value : "unit-elven-lumber-mill",205 Key : "l", Hint : "BUILD ELVEN ~!LUMBER MILL",206 ForUnit : ["unit-peasant"]},207 { Pos : 5, Level : 1, Icon : "icon-human-blacksmith",208 Action : "build", Value : "unit-human-blacksmith",209 Key : "s", Hint : "BUILD BLACK~!SMITH",210 ForUnit : ["unit-peasant"]},211 { Pos : 7, Level : 1, Icon : "icon-human-watch-tower",212 Action : "build", Value : "unit-human-watch-tower",213 Key : "t", Hint : "BUILD ~!TOWER",214 ForUnit : ["unit-peasant"]},215 { Pos : 8, Level : 1, Icon : "icon-human-wall",216 Action : "build", Value : "unit-human-wall",217 Allowed : "check-network",218 Key : "w", Hint : "BUILD ~!WALL",219 ForUnit : ["unit-peasant"]},220 { Pos : 9, Level : 1, Icon : "icon-cancel",221 Action : "button", Value : 0,222 Key : "\27", Hint : "~<ESC~> CANCEL",223 ForUnit : ["unit-peasant"]},224// human advanced buildings //////////////////////////////////////////////////-225 { Pos : 1, Level : 2, Icon : "icon-human-shipyard",226 Action : "build", Value : "unit-human-shipyard",227 Key : "s", Hint : "BUILD ~!SHIPYARD",228 ForUnit : ["unit-peasant"]},229 { Pos : 2, Level : 2, Icon : "icon-human-foundry",230 Action : "build", Value : "unit-human-foundry",231 Key : "f", Hint : "BUILD ~!FOUNDRY",232 ForUnit : ["unit-peasant"]},233 { Pos : 3, Level : 2, Icon : "icon-human-refinery",234 Action : "build", Value : "unit-human-refinery",235 Key : "r", Hint : "BUILD ~!REFINERY",236 ForUnit : ["unit-peasant"]},237 { Pos : 4, Level : 2, Icon : "icon-gnomish-inventor",238 Action : "build", Value : "unit-inventor",239 Key : "i", Hint : "BUILD GNOMISH ~!INVENTOR",240 ForUnit : ["unit-peasant"]},241 { Pos : 5, Level : 2, Icon : "icon-stables",242 Action : "build", Value : "unit-stables",243 Key : "a", Hint : "BUILD ST~!ABLES",244 ForUnit : ["unit-peasant"]},245 { Pos : 6, Level : 2, Icon : "icon-mage-tower",246 Action : "build", Value : "unit-mage-tower",247 Key : "m", Hint : "BUILD ~!MAGE TOWER",248 ForUnit : ["unit-peasant"]},249 { Pos : 7, Level : 2, Icon : "icon-church",250 Action : "build", Value : "unit-church",251 Key : "c", Hint : "BUILD ~!CHURCH",252 ForUnit : ["unit-peasant"]},253 { Pos : 8, Level : 2, Icon : "icon-gryphon-aviary",254 Action : "build", Value : "unit-gryphon-aviary",255 Key : "g", Hint : "BUILD ~!GRYPHON AVIARY",256 ForUnit : ["unit-peasant"]},257 { Pos : 9, Level : 2, Icon : "icon-cancel",258 Action : "button", Value : 0,259 Key : "\27", Hint : "~<ESC~> CANCEL",260 ForUnit : ["unit-peasant"]},261// buildings commands ////////////////////////////////////////////////////////-262//if (wargus.extensions) then263{ Pos : 1, Level : 0, Icon : "icon-critter",264 Action : "train-unit", Value : "unit-critter",265 Key : "c", Hint : "TRAIN ~!CRITTER",266 ForUnit : ["unit-farm"]},267//end268{ Pos : 1, Level : 0, Icon : "icon-peasant",269 Action : "train-unit", Value : "unit-peasant",270 Allowed : "check-no-research",271 Key : "p", Hint : "TRAIN ~!PEASANT",272 ForUnit : ["unit-town-hall", "unit-keep", "unit-castle"]},273// town hall upgrades ////////////////////////////////////////////////////////-274{ Pos : 2, Level : 0, Icon : "icon-keep",275 Action : "upgrade-to", Value : "unit-keep",276 Allowed : "check-upgrade-to",277 Key : "k", Hint : "UPGRADE TO ~!KEEP",278 ForUnit : ["unit-town-hall"]},279 { Pos : 2, Level : 0, Icon : "icon-castle-upgrade",280 Action : "upgrade-to", Value : "unit-castle",281 Allowed : "check-upgrade-to",282 Key : "c", Hint : "UPGRADE TO ~!CASTLE",283 ForUnit : ["unit-keep"]},284//if (wargus.extensions) then285//do286{ Pos : 5, Level : 0, Icon : "icon-harvest",287 Action : "harvest",288 Key : "h", Hint : "SET ~!HARVEST LUMBER/MINE GOLD",289 ForUnit : ["unit-town-hall", "unit-keep", "unit-castle"]},290 { Pos : 7, Level : 0, Icon : "icon-move-peasant",291 Action : "move",292 Key : "m", Hint : "SET ~!MOVE",293 ForUnit : ["unit-town-hall", "unit-keep", "unit-castle", "unit-human-barracks",294 "unit-mage-tower", "unit-gryphon-aviary", "unit-inventor"]},295 { Pos : 8, Level : 0, Icon : "icon-human-shield1",296 Action : "stop",297 Key : "z", Hint : "SET ~!ZTOP",298 ForUnit : ["unit-town-hall", "unit-keep", "unit-castle", "unit-human-barracks",299 "unit-mage-tower", "unit-gryphon-aviary", "unit-inventor"]},300 { Pos : 9, Level : 0, Icon : "icon-sword1",301 Action : "attack",302 Key : "e", Hint : "S~!ET ATTACK",303 ForUnit : ["unit-town-hall", "unit-keep", "unit-castle", "unit-human-barracks",304 "unit-mage-tower", "unit-gryphon-aviary", "unit-inventor"]},305//end306//end307{ Pos : 1, Level : 0, Icon : "icon-footman",308 Action : "train-unit", Value : "unit-footman",309 Key : "f", Hint : "TRAIN ~!FOOTMAN",310 ForUnit : ["unit-human-barracks"]},311 { Pos : 2, Level : 0, Icon : "icon-archer",312 Action : "train-unit", Value : "unit-archer",313 Key : "a", Hint : "TRAIN ~!ARCHER",314 ForUnit : ["unit-human-barracks"]},315 { Pos : 2, Level : 0, Icon : "icon-ranger",316 Action : "train-unit", Value : "unit-ranger",317 Key : "r", Hint : "TRAIN ~!RANGER",318 ForUnit : ["unit-human-barracks"]},319 { Pos : 3, Level : 0, Icon : "icon-ballista",320 Action : "train-unit", Value : "unit-ballista",321 Key : "b", Hint : "BUILD ~!BALLISTA",322 ForUnit : ["unit-human-barracks"]},323 { Pos : 4, Level : 0, Icon : "icon-knight",324 Action : "train-unit", Value : "unit-knight",325 Key : "k", Hint : "TRAIN ~!KNIGHT",326 ForUnit : ["unit-human-barracks"]},327 { Pos : 4, Level : 0, Icon : "icon-paladin",328 Action : "train-unit", Value : "unit-paladin",329 Key : "p", Hint : "TRAIN ~!PALADIN",330 ForUnit : ["unit-human-barracks"]},331 { Pos : 1, Level : 0, Icon : "icon-gnomish-flying-machine",332 Action : "train-unit", Value : "unit-balloon",333 Key : "f", Hint : "BUILD GNOMISH ~!FLYING MACHINE",334 ForUnit : ["unit-inventor"]},335 { Pos : 2, Level : 0, Icon : "icon-dwarves",336 Action : "train-unit", Value : "unit-dwarves",337 Key : "d", Hint : "TRAIN ~!DWARVEN DEMOLITION SQUAD",338 ForUnit : ["unit-inventor"]},339 { Pos : 1, Level : 0, Icon : "icon-mage",340 Action : "train-unit", Value : "unit-mage",341 Key : "t", Hint : "~!TRAIN MAGE",342 ForUnit : ["unit-mage-tower"]},343 { Pos : 1, Level : 0, Icon : "icon-gryphon-rider",344 Action : "train-unit", Value : "unit-gryphon-rider",345 Key : "g", Hint : "TRAIN ~!GRYPHON RIDER",346 ForUnit : ["unit-gryphon-aviary"]},347 { Pos : 1, Level : 0, Icon : "icon-human-oil-tanker",348 Action : "train-unit", Value : "unit-human-oil-tanker",349 Key : "o", Hint : "BUILD ~!OIL TANKER",350 ForUnit : ["unit-human-shipyard"]},351 { Pos : 2, Level : 0, Icon : "icon-human-destroyer",352 Action : "train-unit", Value : "unit-human-destroyer",353 Key : "d", Hint : "BUILD ~!DESTROYER",354 ForUnit : ["unit-human-shipyard"]},355 { Pos : 3, Level : 0, Icon : "icon-human-transport",356 Action : "train-unit", Value : "unit-human-transport",357 Key : "t", Hint : "BUILD ~!TRANSPORT",358 ForUnit : ["unit-human-shipyard"]},359 { Pos : 4, Level : 0, Icon : "icon-gnomish-submarine",360 Action : "train-unit", Value : "unit-human-submarine",361 Key : "s", Hint : "BUILD GNOMISH ~!SUBMARINE",362 ForUnit : ["unit-human-shipyard"]},363 { Pos : 5, Level : 0, Icon : "icon-battleship",364 Action : "train-unit", Value : "unit-battleship",365 Key : "b", Hint : "BUILD ~!BATTLESHIP",366 ForUnit : ["unit-human-shipyard"]},367//if (wargus.extensions) then368////////////////////////////////////////////////////-369{ Pos : 6, Level : 0, Icon : "icon-human-ship-haul-oil",370 Action : "harvest",371 Key : "h", Hint : "SET ~!HAUL OIL",372 ForUnit : ["unit-human-shipyard"]},373////////////////////////////////////////////////////-374// end375{ Pos : 1, Level : 0, Icon : "icon-human-guard-tower",376 Action : "upgrade-to", Value : "unit-human-guard-tower",377 Key : "g", Hint : "UPGRADE TO ~!GUARD TOWER",378 ForUnit : ["unit-human-watch-tower"]},379 { Pos : 2, Level : 0, Icon : "icon-human-cannon-tower",380 Action : "upgrade-to", Value : "unit-human-cannon-tower",381 Key : "c", Hint : "UPGRADE TO ~!CANNON TOWER",382 ForUnit : ["unit-human-watch-tower"]},383// ships //////////////////////////////////////////////////////////////////////384{ Pos : 1, Level : 0, Icon : "icon-human-ship-move",385 Action : "move",386 Key : "m", Hint : "~!MOVE",387 ForUnit : ["unit-human-oil-tanker",388 "unit-human-submarine", "unit-battleship", "unit-human-destroyer",389 "unit-human-transport"]},390 { Pos : 2, Level : 0, Icon : "icon-human-ship-armor1",391 Action : "stop",392 Key : "s", Hint : "~!STOP",393 ForUnit : ["unit-human-oil-tanker",394 "unit-human-submarine", "unit-battleship", "unit-human-destroyer",395 "unit-human-transport"]},396 { Pos : 3, Level : 0, Icon : "icon-human-unload",397 Action : "unload",398 Key : "u", Hint : "~!UNLOAD",399 ForUnit : ["unit-human-transport"]},400 { Pos : 4, Level : 0, Icon : "icon-human-oil-platform",401 Action : "build", Value : "unit-human-oil-platform",402 Key : "b", Hint : "~!BUILD OIL PLATFORM",403 ForUnit : ["unit-human-oil-tanker"]},404 { Pos : 5, Level : 0, Icon : "icon-human-ship-haul-oil",405 Action : "harvest",406 Key : "h", Hint : "~!HAUL OIL",407 ForUnit : ["unit-human-oil-tanker"]},408 { Pos : 6, Level : 0, Icon : "icon-human-ship-return-oil",409 Action : "return-goods",410 Key : "g", Hint : "RETURN WITH ~!GOODS",411 ForUnit : ["unit-human-oil-tanker"]},412 { Pos : 3, Level : 0, Icon : "icon-human-ship-cannon1",413 Action : "attack",414 Key : "a", Hint : "~!ATTACK",415 ForUnit : ["unit-human-submarine", "unit-battleship", "unit-human-destroyer"]},416 { Pos : 3, Level : 0, Icon : "icon-human-ship-cannon2",417 Action : "attack",418 Allowed : "check-upgrade", AllowArg : ["upgrade-human-ship-cannon1"],419 Key : "a", Hint : "~!ATTACK",420 ForUnit : ["unit-human-submarine", "unit-battleship", "unit-human-destroyer"]},421 { Pos : 3, Level : 0, Icon : "icon-human-ship-cannon3",422 Action : "attack",423 Allowed : "check-upgrade", AllowArg : ["upgrade-human-ship-cannon2"],424 Key : "a", Hint : "~!ATTACK",425 ForUnit : ["unit-human-submarine", "unit-battleship", "unit-human-destroyer"]},426 { Pos : 4, Level : 0, Icon : "icon-human-patrol-naval",427 Action : "patrol",428 Key : "p", Hint : "~!PATROL",429 ForUnit : ["unit-human-submarine", "unit-battleship", "unit-human-destroyer"]},430//if (wargus.extensions) then431//do432{ Pos : 7, Level : 0, Icon : "icon-human-ship-move",433 Action : "move",434 Key : "m", Hint : "SET ~!MOVE",435 ForUnit : ["unit-human-shipyard"]},436 { Pos : 8, Level : 0, Icon : "icon-human-ship-armor1",437 Action : "stop",438 Key : "z", Hint : "SET ~!ZTOP",439 ForUnit : ["unit-human-shipyard"]},440 { Pos : 9, Level : 0, Icon : "icon-human-ship-cannon1",441 Action : "attack",442 Key : "e", Hint : "S~!ET ATTACK",443 ForUnit : ["unit-human-shipyard"]},444//end445//end446// upgrades //////////////////////////////////////////////////////////////////-447{ Pos : 1, Level : 0, Icon : "icon-sword2",448 Action : "research", Value : "upgrade-sword1",449 Allowed : "check-single-research",450 Key : "w", Hint : "UPGRADE S~!WORDS (Damage +2)",451 ForUnit : ["unit-human-blacksmith"]},452 { Pos : 1, Level : 0, Icon : "icon-sword3",453 Action : "research", Value : "upgrade-sword2",454 Allowed : "check-single-research",455 Key : "w", Hint : "UPGRADE S~!WORDS (Damage +2)",456 ForUnit : ["unit-human-blacksmith"]},457 { Pos : 2, Level : 0, Icon : "icon-human-shield2",458 Action : "research", Value : "upgrade-human-shield1",459 Allowed : "check-single-research",460 Key : "s", Hint : "UPGRADE ~!SHIELDS (Armor +2)",461 ForUnit : ["unit-human-blacksmith"]},462 { Pos : 2, Level : 0, Icon : "icon-human-shield3",463 Action : "research", Value : "upgrade-human-shield2",464 Allowed : "check-single-research",465 Key : "s", Hint : "UPGRADE ~!SHIELDS (Armor +2)",466 ForUnit : ["unit-human-blacksmith"]},467 { Pos : 3, Level : 0, Icon : "icon-ballista1",468 Action : "research", Value : "upgrade-ballista1",469 Allowed : "check-single-research",470 Key : "b", Hint : "UPGRADE ~!BALLISTA (Damage +15)",471 ForUnit : ["unit-human-blacksmith"]},472 { Pos : 3, Level : 0, Icon : "icon-ballista2",473 Action : "research", Value : "upgrade-ballista2",474 Allowed : "check-single-research",475 Key : "b", Hint : "UPGRADE ~!BALLISTA (Damage +15)",476 ForUnit : ["unit-human-blacksmith"]},477 { Pos : 1, Level : 0, Icon : "icon-arrow2",478 Action : "research", Value : "upgrade-arrow1",479 Allowed : "check-single-research",480 Key : "u", Hint : "~!UPGRADE ARROWS (Damage +1)",481 ForUnit : ["unit-elven-lumber-mill"]},482 { Pos : 1, Level : 0, Icon : "icon-arrow3",483 Action : "research", Value : "upgrade-arrow2",484 Allowed : "check-single-research",485 Key : "u", Hint : "~!UPGRADE ARROWS (Damage +1)",486 ForUnit : ["unit-elven-lumber-mill"]},487 { Pos : 4, Level : 0, Icon : "icon-ranger",488 Action : "research", Value : "upgrade-ranger",489 Allowed : "check-single-research",490 Key : "r", Hint : "ELVEN ~!RANGER TRAINING",491 ForUnit : ["unit-elven-lumber-mill"]},492 { Pos : 4, Level : 0, Icon : "icon-ranger-scouting",493 Action : "research", Value : "upgrade-ranger-scouting",494 Allowed : "check-single-research",495 Key : "s", Hint : "RANGER ~!SCOUTING (Sight:9)",496 ForUnit : ["unit-elven-lumber-mill"]},497 { Pos : 5, Level : 0, Icon : "icon-longbow",498 Action : "research", Value : "upgrade-longbow",499 Allowed : "check-single-research",500 Key : "l", Hint : "RESEARCH ~!LONGBOW (Range +1)",501 ForUnit : ["unit-elven-lumber-mill"]},502 { Pos : 6, Level : 0, Icon : "icon-ranger-marksmanship",503 Action : "research", Value : "upgrade-ranger-marksmanship",504 Allowed : "check-single-research",505 Key : "m", Hint : "RANGER ~!MARKSMANSHIP (Damage +3)",506 ForUnit : ["unit-elven-lumber-mill"]},507 { Pos : 1, Level : 0, Icon : "icon-paladin",508 Action : "research", Value : "upgrade-paladin",509 Allowed : "check-single-research",510 Key : "p", Hint : "UPGRADES KNIGHTS TO ~!PALADINS",511 ForUnit : ["unit-church"]},512 { Pos : 2, Level : 0, Icon : "icon-heal",513 Action : "research", Value : "upgrade-healing",514 Allowed : "check-single-research",515 Key : "h", Hint : "RESEARCH ~!HEALING",516 ForUnit : ["unit-church"]},517 { Pos : 3, Level : 0, Icon : "icon-exorcism",518 Action : "research", Value : "upgrade-exorcism",519 Allowed : "check-single-research",520 Key : "e", Hint : "RESEARCH ~!EXORCISM",521 ForUnit : ["unit-church"]},522 { Pos : 2, Level : 0, Icon : "icon-slow",523 Action : "research", Value : "upgrade-slow",524 Allowed : "check-single-research",525 Key : "o", Hint : "RESEARCH SL~!OW",526 ForUnit : ["unit-mage-tower"]},527 { Pos : 3, Level : 0, Icon : "icon-flame-shield",528 Action : "research", Value : "upgrade-flame-shield",529 Allowed : "check-single-research",530 Key : "l", Hint : "RESEARCH F~!LAME SHIELD",531 ForUnit : ["unit-mage-tower"]},532 { Pos : 4, Level : 0, Icon : "icon-invisibility",533 Action : "research", Value : "upgrade-invisibility",534 Allowed : "check-single-research",535 Key : "i", Hint : "RESEARCH ~!INVISIBILITY",536 ForUnit : ["unit-mage-tower"]},537 { Pos : 5, Level : 0, Icon : "icon-polymorph",538 Action : "research", Value : "upgrade-polymorph",539 Allowed : "check-single-research",540 Key : "p", Hint : "RESEARCH ~!POLYMORPH",541 ForUnit : ["unit-mage-tower"]},542 { Pos : 6, Level : 0, Icon : "icon-blizzard",543 Action : "research", Value : "upgrade-blizzard",544 Allowed : "check-single-research",545 Key : "b", Hint : "RESEARCH ~!BLIZZARD",546 ForUnit : ["unit-mage-tower"]},547 { Pos : 1, Level : 0, Icon : "icon-human-ship-cannon2",548 Action : "research", Value : "upgrade-human-ship-cannon1",549 Allowed : "check-single-research",550 Key : "c", Hint : "UPGRADE ~!CANNONS (Damage +5)",551 ForUnit : ["unit-human-foundry"]},552 { Pos : 1, Level : 0, Icon : "icon-human-ship-cannon3",553 Action : "research", Value : "upgrade-human-ship-cannon2",554 Allowed : "check-single-research",555 Key : "c", Hint : "UPGRADE ~!CANNONS (Damage +5)",556 ForUnit : ["unit-human-foundry"]},557 { Pos : 2, Level : 0, Icon : "icon-human-ship-armor2",558 Action : "research", Value : "upgrade-human-ship-armor1",559 Allowed : "check-single-research",560 Key : "a", Hint : "UPGRADE SHIP ~!ARMOR (Armor +5)",561 ForUnit : ["unit-human-foundry"]},562 { Pos : 2, Level : 0, Icon : "icon-human-ship-armor3",563 Action : "research", Value : "upgrade-human-ship-armor2",564 Allowed : "check-single-research",565 Key : "a", Hint : "UPGRADE SHIP ~!ARMOR (Armor +5)",566 ForUnit : ["unit-human-foundry"]}...
args.ts
Source:args.ts
...71 return Object.entries(argTypes).reduce((acc, [key, { options }]) => {72 // Don't set args that are not defined in `args` (they can be undefined in there)73 // see https://github.com/storybookjs/storybook/issues/15630 and74 // https://github.com/storybookjs/storybook/issues/1706375 function allowArg() {76 if (key in args) {77 acc[key] = args[key];78 }79 return acc;80 }81 if (!options) return allowArg();82 if (!Array.isArray(options)) {83 once.error(dedent`84 Invalid argType: '${key}.options' should be an array.85 More info: https://storybook.js.org/docs/react/api/argtypes86 `);87 return allowArg();88 }89 if (options.some((opt) => opt && ['object', 'function'].includes(typeof opt))) {90 once.error(dedent`91 Invalid argType: '${key}.options' should only contain primitives. Use a 'mapping' for complex values.92 More info: https://storybook.js.org/docs/react/writing-stories/args#mapping-to-complex-arg-values93 `);94 return allowArg();95 }96 const isArray = Array.isArray(args[key]);97 const invalidIndex = isArray && args[key].findIndex((val: any) => !options.includes(val));98 const isValidArray = isArray && invalidIndex === -1;99 if (args[key] === undefined || options.includes(args[key]) || isValidArray) {100 return allowArg();101 }102 const field = isArray ? `${key}[${invalidIndex}]` : key;103 const supportedOptions = options104 .map((opt: any) => (typeof opt === 'string' ? `'${opt}'` : String(opt)))105 .join(', ');106 once.warn(`Received illegal value for '${field}'. Supported options: ${supportedOptions}`);107 return acc;108 }, {} as Args);109};110// TODO -- copied from router, needs to be in a shared location111export const DEEPLY_EQUAL = Symbol('Deeply equal');112export const deepDiff = (value: any, update: any): any => {113 if (typeof value !== typeof update) return update;114 if (deepEqual(value, update)) return DEEPLY_EQUAL;...
Using AI Code Generation
1import { allowArg } from 'storybook-root-decorator';2import React from 'react';3import { storiesOf } from '@storybook/react';4import { action } from '@storybook/addon-actions';5import { linkTo } from '@storybook/addon-links';6import { Button, Welcome } from '@storybook/react/demo';7storiesOf('Button', module)8 .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)9 .add('with some emoji', () => (10 <Button onClick={action('clicked')}>π π π π―</Button>11 .add('with some emoji', () => (12 <Button onClick={action('clicked')}>π π π π―</Button>13 .add('with some emoji', () => (14 <Button onClick={action('clicked')}>π π π π―</Button>15 .add('with some emoji', () => (16 <Button onClick={action('clicked')}>π π π π―</Button>17 .add('with some emoji', () => (18 <Button onClick={action('clicked')}>π π π π―</Button>19 .add('with some emoji', () => (20 <Button onClick={action('clicked')}>π π π π―</Button>21 .add('with some emoji', () => (22 <Button onClick={action('clicked')}>π π π π―</Button>23 .add('with some emoji', () => (24 <Button onClick={action('clicked')}>π π π π―</Button>25 .add('with some emoji', () => (26 <Button onClick={action('clicked')}>π π π π―</Button>27 ));28storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);29import { addDecorator, configure } from '@storybook/react';30import { withRootDecorator } from 'storybook-root-decorator';31addDecorator(withRootDecorator);32configure(require.context('../src', true, /\.stories\.js$/), module);
Using AI Code Generation
1import { allowArg } from 'storybook-root-decorator';2import React from 'react';3import MyComponent from './MyComponent';4export default {5};6export const Default = () => <MyComponent />;7Default.story = {8 parameters: {9 rootDecorator: allowArg('foo'),10 },11};12export const NoArg = () => <MyComponent />;13NoArg.story = {14 parameters: {15 rootDecorator: allowArg('bar'),16 },17};18export const NoArg2 = () => <MyComponent />;19NoArg2.story = {20 parameters: {21 rootDecorator: allowArg('baz'),22 },23};24export const NoArg3 = () => <MyComponent />;25NoArg3.story = {26 parameters: {27 rootDecorator: allowArg('foo'),28 },29};30export const NoArg4 = () => <MyComponent />;31NoArg4.story = {32 parameters: {33 rootDecorator: allowArg('foo'),34 },35};36export const NoArg5 = () => <MyComponent />;37NoArg5.story = {38 parameters: {39 rootDecorator: allowArg('foo'),40 },41};42export const NoArg6 = () => <MyComponent />;43NoArg6.story = {44 parameters: {45 rootDecorator: allowArg('foo'),46 },47};48export const NoArg7 = () => <MyComponent />;49NoArg7.story = {50 parameters: {51 rootDecorator: allowArg('foo'),52 },53};54export const NoArg8 = () => <MyComponent />;55NoArg8.story = {56 parameters: {57 rootDecorator: allowArg('foo'),58 },59};60export const NoArg9 = () => <MyComponent />;61NoArg9.story = {62 parameters: {63 rootDecorator: allowArg('foo'),64 },65};66export const NoArg10 = () => <MyComponent />;67NoArg10.story = {68 parameters: {69 rootDecorator: allowArg('foo'),70 },71};72export const NoArg11 = () => <MyComponent />;73NoArg11.story = {74 parameters: {75 rootDecorator: allowArg('foo'),76 },77};78export const NoArg12 = () => <MyComponent />;79NoArg12.story = {80 parameters: {81 rootDecorator: allowArg('foo'),82 },83};84export const NoArg13 = () => <MyComponent />;
Using AI Code Generation
1module.exports = {2 webpackFinal: async (config) => {3 return config;4 },5};6module.exports = {7 webpackFinal: async (config) => {8 return config;9 },10};
Using AI Code Generation
1import { allowArg } from 'storybook-root-decorator';2import { storiesOf } from '@storybook/react';3storiesOf('test', module)4 .add('test', () => <div>test</div>)5 .add('test2', () => <div>test2</div>)6 .add('test3', () => <div>test3</div>)7 .add('test4', () => <div>test4</div>)8 .add('test5', () => <div>test5</div>)9 .add('test6', () => <div>test6</div>)10 .add('test7', () => <div>test7</div>)11 .add('test8', () => <div>test8</div>)12 .add('test9', () => <div>test9</div>)13 .add('test10', () => <div>test10</div>)14 .add('test11', () => <div>test11</div>)15 .add('test12', () => <div>test12</div>)16 .add('test13', () => <div>test13</div>)17 .add('test14', () => <div>test14</div>)18 .add('test15', () => <div>test15</div>)19 .add('test16', () => <div>test16</div>)20 .add('test17', () => <div>test17</div>)21 .add('test18', () => <div>test18</div>)22 .add('test19', () => <div>test19</div>)23 .add('test20', () => <div>test20</div>)24 .add('test21', () => <div>test21</div>)25 .add('test22', () => <div>test22</div>)26 .add('test23', () => <div>test23</div>)27 .add('test24', () => <div>test24</div>)28 .add('test25', () => <div>test25</div>)29 .add('test26', () => <div>test26</div>)30 .add('test27', () => <div>test27</div>)31 .add('test28', () =>
Using AI Code Generation
1import { allowArg } from 'storybook-root';2allowArg('myArg', 'myValue');3import { storiesOf } from '@storybook/react';4import { withArgs } from '@storybook/addon-args';5import { withKnobs, text } from '@storybook/addon-knobs';6import { MyComponent } from './test';7storiesOf('MyComponent', module)8 .addDecorator(withKnobs)9 .addDecorator(withArgs)10 .add('with text', () => (11 text={text('text', 'Hello Storybook')}12 ));
Using AI Code Generation
1export default {2 argTypes: {3 onClick: {4 },5 },6};7const Template = (args) => <Story {...args} />;8export const Primary = Template.bind({});9Primary.args = {10};11export const Secondary = Template.bind({});12Secondary.args = {13};14export const Success = Template.bind({});15Success.args = {16};17export const Danger = Template.bind({});18Danger.args = {19};20export const Warning = Template.bind({});21Warning.args = {22};23export const Info = Template.bind({});24Info.args = {25};26export const Light = Template.bind({});27Light.args = {28};29export const Dark = Template.bind({});30Dark.args = {31};32export const Link = Template.bind({});33Link.args = {34};35export const OutlinePrimary = Template.bind({});36OutlinePrimary.args = {37};38export const OutlineSecondary = Template.bind({});39OutlineSecondary.args = {40};41export const OutlineSuccess = Template.bind({});42OutlineSuccess.args = {43};44export const OutlineDanger = Template.bind({});45OutlineDanger.args = {46};47export const OutlineWarning = Template.bind({});48OutlineWarning.args = {49};50export const OutlineInfo = Template.bind({});51OutlineInfo.args = {
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!