How to use Hover method of rod Package

Best Rod code snippet using rod.Hover

phases.go

Source:phases.go Github

copy

Full Screen

1package cmd2import (3 "strconv"4)5/*6 * Copyright (c) 1977, 2005 by Will Crowther and Don Woods7 * Copyright (c) 2017 by Eric S. Raymond8 * Translate to GO by Robert Shofner (c) 20229 * BSD License - see file "COPYING"10 */11/* Attack. Assume target if unambiguous. "Throw" also links here.12 * Attackable objects fall into two categories: enemies (snake,13 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 214 * enemies, or no enemies but 2 others. */15func attack(command Command) PhaseCodeType {16 verb := command.verb17 object := command.obj18 if object == INTRANSITIVE {19 changes := 020 if atdwrf(game.Loc) > 0 {21 object = DWARF22 changes++23 }24 if isHere(SNAKE) {25 object = SNAKE26 changes++27 }28 if isAt(DRAGON) && game.Prop[DRAGON] == DRAGON_BARS {29 object = DRAGON30 changes++31 }32 if isAt(TROLL) {33 object = TROLL34 changes++35 }36 if isAt(OGRE) {37 object = OGRE38 changes++39 }40 if isHere(BEAR) && game.Prop[BEAR] == UNTAMED_BEAR {41 object = BEAR42 changes++43 }44 /* check for low-priority targets */45 if object == INTRANSITIVE {46 /* Can't attack bird or machine by throwing axe. */47 if isHere(BIRD) && verb != THROW {48 object = BIRD49 changes++50 }51 if isHere(VEND) && verb != THROW {52 object = VEND53 changes++54 }55 /* Clam and oyster both treated as clam for intransitive case;56 * no harm done. */57 if isHere(CLAM) || isHere(OYSTER) {58 object = CLAM59 changes++60 }61 }62 if changes >= 2 {63 return GO_UNKNOWN64 }65 }66 if object == BIRD {67 if game.Closed {68 speak(true, messages[UNHAPPY_BIRD])69 } else {70 destroy(BIRD)71 speak(true, messages[BIRD_DEAD])72 }73 return GO_CLEAROBJ74 }75 if object == VEND {76 ifElse(game.Prop[VEND] == VEND_BLOCKS,77 func() { stateChange(VEND, VEND_UNBLOCKS) },78 func() { stateChange(VEND, VEND_BLOCKS) })79 return GO_CLEAROBJ80 }81 if object == BEAR {82 switch game.Prop[BEAR] {83 case UNTAMED_BEAR:84 speak(true, messages[BEAR_HANDS])85 case SITTING_BEAR, CONTENTED_BEAR:86 speak(true, messages[BEAR_CONFUSED])87 case BEAR_DEAD:88 speak(true, messages[ALREADY_DEAD])89 }90 return GO_CLEAROBJ91 }92 if object == DRAGON && game.Prop[DRAGON] == DRAGON_BARS {93 /* Fun stuff for dragon. If he insists on attacking it, win!94 * Set game.Prop to dead, move dragon to central Loc (still95 * Fixed), move rug there (not Fixed), and move him there,96 * too. Then do a null motion to get new description. */97 speak(true, messages[BARE_HANDS_QUERY])98 if !silentYesNo() {99 speak(true, messages[NASTY_DRAGON])100 settings.CRT.Show(false, "dragon")101 return GO_MOVE102 }103 stateChange(DRAGON, DRAGON_DEAD)104 game.Prop[RUG] = RUG_FLOOR105 /* Hardcoding LOC_SECRET5 as the dragon's death location is ugly.106 * The way it was computed before was worse; it depended on the107 * two dragon locations being LOC_SECRET4 and LOC_SECRET6 and108 * LOC_SECRET5 being right between them. */109 move(DRAGON+NOBJECTS, FIXED)110 move(RUG+NOBJECTS, FREE)111 move(DRAGON, LOC_SECRET5)112 move(RUG, LOC_SECRET5)113 drop(BLOOD, LOC_SECRET5)114 var i ObjectType115 for i = 1; i <= NOBJECTS; i++ {116 if game.Place[i] == objects[DRAGON].plac || game.Place[i] == objects[DRAGON].fixd {117 move(i, LOC_SECRET5)118 }119 }120 game.Loc = LOC_SECRET5121 return GO_MOVE122 }123 if object == OGRE {124 speak(true, messages[OGRE_DODGE])125 if atdwrf(game.Loc) == 0 {126 return GO_CLEAROBJ127 }128 settings.CRT.Show(false, "knife")129 speak(true, messages[KNIFE_THROWN])130 settings.CRT.Show(false, "knife")131 destroy(OGRE)132 dwarves := 0133 for i := 1; i < PIRATE; i++ {134 if game.Dloc[i] == game.Loc {135 dwarves++136 game.Dloc[i] = LOC_LONGWEST137 game.Dseen[i] = false138 }139 }140 ifElse(dwarves > 1,141 func() { speak(true, messages[OGRE_PANIC1]) },142 func() { speak(true, messages[OGRE_PANIC2]) })143 return GO_CLEAROBJ144 }145 switch object {146 case INTRANSITIVE:147 speak(true, messages[NO_TARGET])148 case CLAM, OYSTER:149 speak(true, messages[SHELL_IMPERVIOUS])150 case SNAKE:151 speak(true, messages[SNAKE_WARNING])152 case DWARF:153 if game.Closed {154 return GO_DWARFWAKE155 }156 speak(true, messages[BARE_HANDS_QUERY])157 case DRAGON:158 speak(true, messages[ALREADY_DEAD])159 break160 case TROLL:161 speak(true, messages[ROCKY_TROLL])162 default:163 speak(true, actions[verb].message)164 }165 return GO_CLEAROBJ166}167/* Only called on FEE FIE FOE FOO (AND FUM). Advance to next state if given168 * in proper order. Look up foo in special section of vocab to determine which169 * word we've got. Last word zips the eggs back to the giant room (unless170 * already there). */171func bigWords(id VocabType) PhaseCodeType {172 var fum = func() {173 if game.Loc == LOC_GIANTROOM {174 speak(true, messages[START_OVER])175 } else {176 /* This is new behavior in Open Adventure - sounds better when177 * player isn't in the Giant Room. */178 speak(true, messages[NOTHING_HAPPENS])179 }180 game.Foobar = WORD_EMPTY181 }182 if (game.Foobar == WORD_EMPTY && id == FEE) ||183 (game.Foobar == FEE && id == FIE) ||184 (game.Foobar == FIE && id == FOE) ||185 (game.Foobar == FOE && id == FOO) ||186 (game.Foobar == FOE && id == FUM) {187 game.Foobar = int(id)188 if (id != FOO) && (id != FUM) {189 speak(true, messages[OK_MAN])190 return GO_CLEAROBJ191 }192 game.Foobar = WORD_EMPTY193 if game.Place[EGGS] == objects[EGGS].plac || (isToting(EGGS) && game.Loc == objects[EGGS].plac) {194 speak(false, messages[NOTHING_HAPPENS])195 return GO_CLEAROBJ196 } else if id == FUM {197 fum()198 return GO_CLEAROBJ199 } else {200 /* Bring back troll if we steal the eggs back from him before201 * crossing. */202 if game.Place[EGGS] == LOC_NOWHERE && game.Place[TROLL] == LOC_NOWHERE && game.Prop[TROLL] == TROLL_UNPAID {203 game.Prop[TROLL] = TROLL_PAIDONCE204 }205 if isHere(EGGS) {206 pspeak(EGGS, look, true, EGGS_VANISHED)207 } else if game.Loc == objects[EGGS].plac {208 pspeak(EGGS, look, true, EGGS_HERE)209 } else {210 pspeak(EGGS, look, true, EGGS_DONE)211 }212 move(EGGS, objects[EGGS].plac)213 return GO_CLEAROBJ214 }215 }216 fum()217 return GO_CLEAROBJ218}219/* Blast. No effect unless you've got dynamite, which is a neat trick! */220func blast() {221 if game.Prop[ROD2] == STATE_NOTFOUND || !game.Closed {222 speak(true, messages[REQUIRES_DYNAMITE])223 } else {224 if isHere(ROD2) {225 game.Bonus = bonus_splatter226 speak(true, messages[SPLATTER_MESSAGE])227 } else if game.Loc == LOC_NE {228 game.Bonus = bonus_defeat229 speak(true, messages[DEFEAT_MESSAGE])230 } else {231 game.Bonus = bonus_victory232 speak(true, messages[VICTORY_MESSAGE])233 }234 terminate(ENDGAME_SIGN)235 }236}237/* Break. Only works for mirror in repository and, of course, the vase. */238func vbreak(verb VerbType, object ObjectType) PhaseCodeType {239 switch object {240 case MIRROR:241 if game.Closed {242 stateChange(MIRROR, MIRROR_BROKEN)243 return GO_DWARFWAKE244 }245 speak(true, messages[TOO_FAR])246 case VASE:247 if game.Prop[VASE] == VASE_WHOLE {248 if isToting(VASE) {249 drop(VASE, game.Loc)250 }251 stateChange(VASE, VASE_BROKEN)252 game.Fixed[VASE] = FIXED253 break254 }255 fallthrough256 default:257 speak(true, actions[verb].message)258 }259 return GO_CLEAROBJ260}261/* Brief. Intransitive only. Suppress full descriptions after first time. */262func brief() PhaseCodeType {263 game.AbbNum = 10000264 game.Detail = 3265 speak(true, messages[BRIEF_CONFIRM])266 return GO_CLEAROBJ267}268/* Carry an object. Special cases for bird and cage (if bird in cage, can't269 * take one without the other). Liquids also special, since they depend on270 * status of bottle. Also, various side effects, etc. */271// C: vcarry272func vcarry(verb VerbType, object ObjectType) PhaseCodeType {273 if object == INTRANSITIVE {274 /* Carry, no object given yet. OK if only one object present. */275 if game.Atloc[game.Loc] == NO_OBJECT ||276 game.Link[game.Atloc[game.Loc]] != 0 ||277 atdwrf(game.Loc) > 0 {278 return GO_UNKNOWN279 }280 object = game.Atloc[game.Loc]281 }282 if isToting(object) {283 speak(true, actions[verb].message)284 return GO_CLEAROBJ285 }286 if object == MESSAG {287 speak(true, messages[REMOVE_MESSAGE])288 destroy(MESSAG)289 return GO_CLEAROBJ290 }291 if game.Fixed[object] != FREE {292 switch object {293 case PLANT:294 /* Next guard tests whether plant is tiny or stashed */295 ifElse(game.Prop[PLANT] <= PLANT_THIRSTY,296 func() { speak(true, messages[DEEP_ROOTS]) },297 func() { speak(true, messages[YOU_JOKING]) })298 case BEAR:299 ifElse(game.Prop[BEAR] == SITTING_BEAR,300 func() { speak(true, messages[BEAR_CHAINED]) },301 func() { speak(true, messages[YOU_JOKING]) })302 case CHAIN:303 ifElse(game.Prop[BEAR] != UNTAMED_BEAR,304 func() { speak(true, messages[STILL_LOCKED]) },305 func() { speak(true, messages[YOU_JOKING]) })306 case RUG:307 ifElse(game.Prop[RUG] == RUG_HOVER,308 func() { speak(true, messages[RUG_HOVERS]) },309 func() { speak(true, messages[YOU_JOKING]) })310 case URN:311 speak(true, messages[URN_NOBUDGE])312 case CAVITY:313 speak(true, messages[DOUGHNUT_HOLES])314 case BLOOD:315 speak(true, messages[FEW_DROPS])316 case SIGN:317 speak(true, messages[HAND_PASSTHROUGH])318 default:319 speak(true, messages[YOU_JOKING])320 }321 return GO_CLEAROBJ322 }323 if object == WATER || object == OIL {324 if !isHere(BOTTLE) || liquid() != object {325 if !isToting(BOTTLE) {326 speak(true, messages[NO_CONTAINER])327 return GO_CLEAROBJ328 }329 if game.Prop[BOTTLE] == EMPTY_BOTTLE {330 return fill(verb, BOTTLE)331 } else {332 speak(true, messages[BOTTLE_FULL])333 }334 return GO_CLEAROBJ335 }336 object = BOTTLE337 }338 if game.Holdng >= INVLIMIT { // 7 items maximum339 speak(true, messages[CARRY_LIMIT])340 return GO_CLEAROBJ341 }342 if object == BIRD && game.Prop[BIRD] != BIRD_CAGED && stashed(BIRD) != BIRD_CAGED {343 if game.Prop[BIRD] == BIRD_FOREST_UNCAGED {344 destroy(BIRD)345 speak(true, messages[BIRD_CRAP])346 return GO_CLEAROBJ347 }348 if !isToting(CAGE) {349 speak(true, messages[CANNOT_CARRY])350 return GO_CLEAROBJ351 }352 if isToting(ROD) {353 speak(true, messages[BIRD_EVADES])354 return GO_CLEAROBJ355 }356 game.Prop[BIRD] = BIRD_CAGED357 }358 if (object == BIRD || object == CAGE) &&359 (game.Prop[BIRD] == BIRD_CAGED || stashed(BIRD) == BIRD_CAGED) {360 /* expression maps BIRD to CAGE and CAGE to BIRD */361 carry(BIRD+CAGE-object, game.Loc)362 settings.CRT.Show(false, "cage_bird")363 objects[CAGE].pic = "cage_bird"364 }365 carry(object, game.Loc)366 if object == BOTTLE && liquid() != NO_OBJECT {367 game.Place[liquid()] = CARRIED368 }369 if isGemstone(object) && game.Prop[object] != STATE_FOUND {370 game.Prop[object] = STATE_FOUND371 game.Prop[CAVITY] = CAVITY_EMPTY372 }373 speak(false, messages[OK_MAN])374 return GO_CLEAROBJ375}376/* Do something to the bear's chain */377// C: chain378func chain(verb VerbType) PhaseCodeType {379 if verb != LOCK {380 if game.Prop[BEAR] == UNTAMED_BEAR {381 speak(true, messages[BEAR_BLOCKS])382 return GO_CLEAROBJ383 }384 if game.Prop[CHAIN] == CHAIN_HEAP {385 speak(true, messages[ALREADY_UNLOCKED])386 return GO_CLEAROBJ387 }388 game.Prop[CHAIN] = CHAIN_HEAP389 game.Fixed[CHAIN] = FREE390 if game.Prop[BEAR] != BEAR_DEAD {391 game.Prop[BEAR] = CONTENTED_BEAR392 }393 switch game.Prop[BEAR] {394 case BEAR_DEAD:395 /* Can't be reached until the bear can die in some way other396 * than a bridge collapse. Leave in incase this states, but397 * exclude from coverage testing. */398 game.Fixed[BEAR] = FIXED399 default:400 game.Fixed[BEAR] = FREE401 }402 speak(true, messages[CHAIN_UNLOCKED])403 return GO_CLEAROBJ404 }405 if game.Prop[CHAIN] != CHAIN_HEAP {406 speak(true, messages[ALREADY_LOCKED])407 return GO_CLEAROBJ408 }409 if game.Loc != objects[CHAIN].plac {410 speak(true, messages[NO_LOCKSITE])411 return GO_CLEAROBJ412 }413 game.Prop[CHAIN] = CHAIN_FIXED414 if isToting(CHAIN) {415 drop(CHAIN, game.Loc)416 }417 game.Fixed[CHAIN] = FIXED418 speak(true, messages[CHAIN_LOCKED])419 return GO_CLEAROBJ420}421/* Discard object. "Throw" also comes here for most objects. Special cases for422 * bird (might attack snake or dragon) and cage (might contain bird) and vase.423 * Drop coins at vending machine for extra batteries. */424// C: discard425func discard(verb VerbType, object ObjectType) PhaseCodeType {426 if object == ROD && !isToting(ROD) && isToting(ROD2) {427 object = ROD2428 }429 if !isToting(object) {430 speak(true, actions[verb].message)431 return GO_CLEAROBJ432 }433 if isGemstone(object) && isAt(CAVITY) && game.Prop[CAVITY] != CAVITY_FULL {434 speak(true, messages[GEM_FITS])435 game.Prop[object] = STATE_IN_CAVITY436 game.Prop[CAVITY] = CAVITY_FULL437 if isHere(RUG) && ((object == EMERALD && game.Prop[RUG] != RUG_HOVER) ||438 (object == RUBY && game.Prop[RUG] == RUG_HOVER)) {439 switch {440 case object == RUBY:441 speak(true, messages[RUG_SETTLES])442 case isToting(RUG):443 speak(true, messages[RUG_WIGGLES])444 default:445 speak(true, messages[RUG_RISES])446 }447 if !isToting(RUG) || object == RUBY {448 var loc LocationType = RUG_FLOOR449 if game.Prop[RUG] == RUG_HOVER {450 loc = RUG_HOVER451 }452 game.Prop[RUG] = int(loc)453 if loc == RUG_HOVER {454 loc = objects[SAPPH].plac455 }456 move(RUG+NOBJECTS, loc)457 }458 }459 drop(object, game.Loc)460 return GO_CLEAROBJ461 }462 if object == COINS && isHere(VEND) {463 destroy(COINS)464 drop(BATTERY, game.Loc)465 pspeak(BATTERY, look, true, FRESH_BATTERIES)466 return GO_CLEAROBJ467 }468 if liquid() == object {469 object = BOTTLE470 }471 if object == BOTTLE && liquid() != NO_OBJECT {472 game.Place[liquid()] = LOC_NOWHERE473 }474 if object == BEAR && isAt(TROLL) {475 stateChange(TROLL, TROLL_GONE)476 move(TROLL, LOC_NOWHERE)477 move(TROLL+NOBJECTS, FREE)478 move(TROLL2, objects[TROLL].plac)479 move(TROLL2+NOBJECTS, objects[TROLL].fixd)480 juggle(CHASM)481 drop(object, game.Loc)482 return GO_CLEAROBJ483 }484 if object == VASE {485 if game.Loc != objects[PILLOW].plac {486 ifElse(isAt(PILLOW),487 func() { stateChange(VASE, VASE_WHOLE) },488 func() { stateChange(VASE, VASE_DROPPED) })489 if game.Prop[VASE] != VASE_WHOLE {490 game.Fixed[VASE] = FIXED491 }492 drop(object, game.Loc)493 return GO_CLEAROBJ494 }495 }496 if object == CAGE && game.Prop[BIRD] == BIRD_CAGED {497 drop(BIRD, game.Loc)498 }499 if object == BIRD {500 settings.CRT.Show(false, "bird")501 if isAt(DRAGON) && game.Prop[DRAGON] == DRAGON_BARS {502 speak(true, messages[BIRD_BURNT])503 destroy(BIRD)504 return GO_CLEAROBJ505 }506 if isHere(SNAKE) {507 speak(true, messages[BIRD_ATTACKS])508 if game.Closed {509 return GO_DWARFWAKE510 }511 destroy(SNAKE)512 /* Set game.Prop for use by travel options */513 game.Prop[SNAKE] = SNAKE_CHASED514 } else {515 speak(true, messages[OK_MAN])516 }517 ifElse(isForest(game.Loc),518 func() { game.Prop[BIRD] = BIRD_FOREST_UNCAGED },519 func() { game.Prop[BIRD] = BIRD_UNCAGED })520 drop(object, game.Loc)521 return GO_CLEAROBJ522 }523 speak(false, messages[OK_MAN])524 drop(object, game.Loc)525 return GO_CLEAROBJ526}527/* Drink. If no object, assume water and look for it here. If water is in528 * the bottle, drink that, else must be at a water Loc, so drink stream. */529// C: drink530func drink(verb VerbType, object ObjectType) PhaseCodeType {531 if object == INTRANSITIVE && liquidLoc(game.Loc) != WATER &&532 (liquid() != WATER || !isHere(BOTTLE)) {533 return GO_UNKNOWN534 }535 if object == BLOOD {536 destroy(BLOOD)537 stateChange(DRAGON, DRAGON_BLOODLESS)538 game.Blooded = true539 return GO_CLEAROBJ540 }541 if object != INTRANSITIVE && object != WATER {542 speak(true, messages[RIDICULOUS_ATTEMPT])543 return GO_CLEAROBJ544 }545 if liquid() == WATER && isHere(BOTTLE) {546 game.Place[WATER] = LOC_NOWHERE547 stateChange(BOTTLE, EMPTY_BOTTLE)548 return GO_CLEAROBJ549 }550 speak(true, actions[verb].message)551 return GO_CLEAROBJ552}553/* Eat. Intransitive: assume food if present, else ask what. Transitive: food554 * ok, some things lose appetite, rest are ridiculous. */555// C: eat556func eat(verb VerbType, object ObjectType) PhaseCodeType {557 if object == INTRANSITIVE && !isHere(FOOD) { // INTRANSITIVE has special value == -1558 return GO_UNKNOWN559 }560 switch object {561 case FOOD:562 destroy(FOOD)563 speak(true, messages[THANKS_DELICIOUS])564 case BIRD, SNAKE, CLAM, OYSTER, DWARF, DRAGON, TROLL, BEAR, OGRE:565 speak(true, messages[LOST_APPETITE])566 default:567 speak(true, actions[verb].message)568 }569 return GO_CLEAROBJ570}571/* Extinguish. Lamp, urn, dragon/volcano (nice try). */572// C: extinguish573func extinguish(verb VerbType, object ObjectType) PhaseCodeType {574 if object == INTRANSITIVE { // deduce a known extinguishable object575 if isHere(LAMP) && game.Prop[LAMP] == LAMP_BRIGHT {576 object = LAMP577 }578 if isHere(URN) && game.Prop[URN] == URN_LIT {579 object = URN580 }581 if object == INTRANSITIVE {582 return GO_UNKNOWN583 }584 }585 switch object {586 case URN:587 if game.Prop[URN] != URN_EMPTY {588 stateChange(URN, URN_DARK)589 } else {590 pspeak(URN, change, true, URN_DARK)591 }592 case LAMP:593 stateChange(LAMP, LAMP_DARK)594 ifElse(isDark(game.Loc),595 func() { speak(true, messages[PITCH_DARK]) },596 func() { speak(true, messages[NO_MESSAGE]) })597 case DRAGON, VOLCANO:598 speak(true, messages[BEYOND_POWER])599 default:600 speak(true, actions[verb].message)601 }602 return GO_CLEAROBJ603}604/* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him605 * mad. Bear, special. */606// C: feed607func feed(verb VerbType, object ObjectType) PhaseCodeType {608 switch object {609 case BIRD:610 speak(true, messages[BIRD_PINING])611 case DRAGON:612 ifElse(game.Prop[DRAGON] != DRAGON_BARS,613 func() { speak(true, messages[RIDICULOUS_ATTEMPT]) },614 func() { speak(true, messages[NOTHING_EDIBLE]) })615 case SNAKE:616 ifElse(!game.Closed && isHere(BIRD),617 func() {618 destroy(BIRD)619 speak(true, messages[BIRD_DEVOURED])620 },621 func() { speak(true, messages[NOTHING_EDIBLE]) })622 case TROLL:623 speak(true, messages[TROLL_VICES])624 case DWARF:625 ifElse(isHere(FOOD),626 func() {627 game.Dflag += 2628 speak(true, messages[REALLY_MAD])629 },630 func() { speak(true, actions[verb].message) })631 case BEAR:632 if game.Prop[BEAR] == BEAR_DEAD {633 speak(true, messages[RIDICULOUS_ATTEMPT])634 } else if game.Prop[BEAR] == UNTAMED_BEAR {635 if isHere(FOOD) {636 destroy(FOOD)637 game.Fixed[AXE] = FREE638 game.Prop[AXE] = AXE_HERE639 stateChange(BEAR, SITTING_BEAR)640 } else {641 speak(true, messages[NOTHING_EDIBLE])642 }643 } else {644 speak(true, actions[verb].message)645 }646 case OGRE:647 ifElse(isHere(FOOD),648 func() { speak(true, messages[OGRE_FULL]) },649 func() { speak(true, actions[verb].message) })650 default:651 speak(true, messages[AM_GAME])652 }653 return GO_CLEAROBJ654}655/* Fill. Bottle or urn must be empty, and liquid available. (Vase656 * is nasty.) */657// C: fill658func fill(verb VerbType, object ObjectType) PhaseCodeType {659 if object == VASE {660 if liquidLoc(game.Loc) == NO_OBJECT {661 speak(true, messages[FILL_INVALID])662 return GO_CLEAROBJ663 }664 if !isToting(VASE) {665 speak(true, messages[ARENT_CARRYING])666 return GO_CLEAROBJ667 }668 speak(true, messages[SHATTER_VASE])669 game.Prop[VASE] = VASE_BROKEN670 game.Fixed[VASE] = FIXED671 drop(VASE, game.Loc)672 return GO_CLEAROBJ673 }674 if object == URN {675 if game.Prop[URN] != URN_EMPTY {676 speak(true, messages[FULL_URN])677 return GO_CLEAROBJ678 }679 if !isHere(BOTTLE) {680 speak(true, messages[FILL_INVALID])681 return GO_CLEAROBJ682 }683 k := liquid()684 switch k {685 case WATER:686 game.Prop[BOTTLE] = EMPTY_BOTTLE687 speak(true, messages[WATER_URN])688 case OIL:689 game.Prop[URN] = URN_DARK690 game.Prop[BOTTLE] = EMPTY_BOTTLE691 speak(true, messages[OIL_URN])692 case NO_OBJECT:693 fallthrough694 default:695 speak(true, messages[FILL_INVALID])696 return GO_CLEAROBJ697 }698 game.Place[k] = LOC_NOWHERE699 return GO_CLEAROBJ700 }701 if object != INTRANSITIVE && object != BOTTLE {702 speak(true, actions[verb].message)703 return GO_CLEAROBJ704 }705 if object == INTRANSITIVE && !isHere(BOTTLE) {706 return GO_UNKNOWN707 }708 if isHere(URN) && game.Prop[URN] != URN_EMPTY {709 speak(true, messages[URN_NOPOUR])710 return GO_CLEAROBJ711 }712 if liquid() != NO_OBJECT {713 speak(true, messages[BOTTLE_FULL])714 return GO_CLEAROBJ715 }716 if liquidLoc(game.Loc) == NO_OBJECT {717 speak(true, messages[NO_LIQUID])718 return GO_CLEAROBJ719 }720 ifElse(liquidLoc(game.Loc) == OIL,721 func() { stateChange(BOTTLE, OIL_BOTTLE) },722 func() { stateChange(BOTTLE, WATER_BOTTLE) })723 return GO_CLEAROBJ724}725/* Find. Might be carrying it, or it might be here. Else give caveat. */726// C: find727func find(verb VerbType, object ObjectType) PhaseCodeType {728 if isToting(object) {729 speak(true, messages[ALREADY_CARRYING])730 return GO_CLEAROBJ731 }732 if game.Closed {733 speak(true, messages[NEEDED_NEARBY])734 return GO_CLEAROBJ735 }736 if isAt(object) || (liquid() == object && isAt(BOTTLE)) ||737 object == liquidLoc(game.Loc) || (object == DWARF && atdwrf(game.Loc) > 0) {738 speak(true, messages[YOU_HAVEIT])739 return GO_CLEAROBJ740 }741 speak(true, actions[verb].message)742 return GO_CLEAROBJ743}744/* Fly. Snide remarks unless hovering rug is here. */745// C: fly746func fly(verb VerbType, object ObjectType) PhaseCodeType {747 if object == INTRANSITIVE {748 if !isHere(RUG) {749 speak(true, messages[FLAP_ARMS])750 return GO_CLEAROBJ751 }752 if game.Prop[RUG] != RUG_HOVER {753 speak(true, messages[RUG_NOTHING2])754 return GO_CLEAROBJ755 }756 object = RUG757 }758 if object != RUG {759 speak(true, actions[verb].message)760 return GO_CLEAROBJ761 }762 if game.Prop[RUG] != RUG_HOVER {763 speak(true, messages[RUG_NOTHING1])764 return GO_CLEAROBJ765 }766 if game.Loc == LOC_CLIFF {767 game.Oldlc2 = game.Oldloc768 game.Oldloc = game.Loc769 game.Newloc = LOC_LEDGE770 speak(true, messages[RUG_GOES])771 } else if game.Loc == LOC_LEDGE {772 game.Oldlc2 = game.Oldloc773 game.Oldloc = game.Loc774 game.Newloc = LOC_CLIFF775 speak(true, messages[RUG_RETURNS])776 } else {777 /* should never happen */778 speak(true, messages[NOTHING_HAPPENS])779 }780 return GO_TERMINATE781}782/* Inventory. If object treat same as find. Else report on current burden. */783// C: inven784func inven() PhaseCodeType {785 empty := true786 var i ObjectType787 for i = 1; i <= NOBJECTS; i++ {788 if i == BEAR || !isToting(i) {789 continue790 }791 if empty {792 speak(true, messages[NOW_HOLDING])793 empty = false794 }795 pspeak(i, touch, false, -1)796 }797 if isToting(BEAR) {798 speak(false, messages[TAME_BEAR])799 }800 if empty {801 speak(true, messages[NO_CARRY])802 }803 return GO_CLEAROBJ804}805/* Light. Applicable only to lamp and urn. */806// C: light807func light(verb VerbType, object ObjectType) PhaseCodeType {808 if object == INTRANSITIVE {809 selects := 0810 if isHere(LAMP) && game.Prop[LAMP] == LAMP_DARK && game.Limit >= 0 {811 object = LAMP812 selects++813 }814 if isHere(URN) && game.Prop[URN] == URN_DARK {815 object = URN816 selects++817 }818 if selects != 1 {819 return GO_UNKNOWN820 }821 }822 switch object {823 case URN:824 ifElse(game.Prop[URN] == URN_EMPTY,825 func() { stateChange(URN, URN_EMPTY) },826 func() { stateChange(URN, URN_LIT) })827 case LAMP:828 if game.Limit < 0 {829 speak(true, messages[LAMP_OUT])830 break831 }832 stateChange(LAMP, LAMP_BRIGHT)833 if game.Wzdark {834 return GO_TOP835 }836 default:837 speak(true, actions[verb].message)838 }839 return GO_CLEAROBJ840}841/* Listen. Intransitive only. Print stuff based on object sound proprties. */842// C: listen843func listen() PhaseCodeType {844 soundlatch := false845 var sound = locations[game.Loc].sound846 if sound != SILENT {847 speak(true, messages[sound])848 if !locations[game.Loc].loud {849 speak(true, messages[NO_MESSAGE])850 }851 soundlatch = true852 }853 var i ObjectType854 for i = 1; i <= NOBJECTS; i++ {855 if !isHere(i) || objects[i].sounds[0] == "" || game.Prop[i] < 0 {856 continue857 }858 mi := game.Prop[i]859 /* (ESR) Some unpleasant magic on object states here. Ideally860 * we'd have liked the bird to be a normal object that we can861 * use state_change() on; can't do it, because there are862 * actually two different series of per-state birdsounds863 * depending on whether player has drunk dragon's blood. */864 if i == BIRD && game.Blooded {865 mi += 3866 }867 pspeak(i, hear, true, mi, game.ZZword)868 speak(true, messages[NO_MESSAGE])869 if i == BIRD && mi == BIRD_ENDSTATE {870 destroy(BIRD)871 }872 soundlatch = true873 }874 if !soundlatch {875 speak(true, messages[ALL_SILENT])876 }877 return GO_CLEAROBJ878}879/* Lock, unlock, no object given. Assume various things if present. */880// C: lock881func lock(verb VerbType, object ObjectType) PhaseCodeType {882 if object == INTRANSITIVE { // try to find which locakable Object883 if isHere(CLAM) {884 object = CLAM885 }886 if isHere(OYSTER) {887 object = OYSTER888 }889 if isAt(DOOR) {890 object = DOOR891 }892 if isAt(GRATE) {893 object = GRATE894 }895 if isHere(CHAIN) {896 object = CHAIN897 }898 if object == INTRANSITIVE {899 speak(true, messages[NOTHING_LOCKED])900 return GO_CLEAROBJ901 }902 }903 switch object {904 case CHAIN:905 if isHere(KEYS) {906 return chain(verb)907 } else {908 speak(true, messages[NO_KEYS])909 }910 case GRATE:911 if isHere(KEYS) {912 if game.Closng {913 speak(true, messages[EXIT_CLOSED])914 if !game.Panic {915 game.Clock2 = PANICTIME916 }917 game.Panic = true918 } else {919 ifElse(verb == LOCK,920 func() { stateChange(GRATE, GRATE_CLOSED) },921 func() { stateChange(GRATE, GRATE_OPEN) })922 }923 } else {924 speak(true, messages[NO_KEYS])925 }926 case CLAM:927 if verb == LOCK {928 speak(true, messages[HUH_MAN])929 } else if isToting(CLAM) {930 speak(true, messages[DROP_CLAM])931 } else if !isToting(TRIDENT) {932 speak(true, messages[CLAM_OPENER])933 } else {934 destroy(CLAM)935 drop(OYSTER, game.Loc)936 drop(PEARL, LOC_CULDESAC)937 speak(true, messages[PEARL_FALLS])938 }939 case OYSTER:940 if verb == LOCK {941 speak(true, messages[HUH_MAN])942 } else if isToting(OYSTER) {943 speak(true, messages[DROP_OYSTER])944 } else if !isToting(TRIDENT) {945 speak(true, messages[OYSTER_OPENER])946 } else {947 speak(true, messages[OYSTER_OPENS])948 }949 case DOOR:950 ifElse(game.Prop[DOOR] == DOOR_UNRUSTED,951 func() { speak(true, messages[OK_MAN]) },952 func() { speak(true, messages[RUSTY_DOOR]) })953 case CAGE:954 speak(true, messages[NO_LOCK])955 case KEYS:956 speak(true, messages[CANNOT_UNLOCK])957 default:958 speak(true, actions[verb].message)959 }960 return GO_CLEAROBJ961}962/* Pour. If no object, or object is bottle, assume contents of bottle.963 * special tests for pouring water or oil on plant or rusty door. */964// C: pour965func pour(verb VerbType, object ObjectType) PhaseCodeType {966 if object == BOTTLE || object == INTRANSITIVE {967 object = liquid()968 }969 if object == NO_OBJECT {970 return GO_UNKNOWN971 }972 if !isToting(object) {973 speak(true, actions[verb].message)974 return GO_CLEAROBJ975 }976 if object != OIL && object != WATER {977 speak(true, messages[CANT_POUR])978 return GO_CLEAROBJ979 }980 if isHere(URN) && game.Prop[URN] == URN_EMPTY {981 return fill(verb, URN)982 }983 game.Prop[BOTTLE] = EMPTY_BOTTLE984 game.Place[object] = LOC_NOWHERE985 if !(isAt(PLANT) || isAt(DOOR)) {986 speak(true, messages[GROUND_WET])987 return GO_CLEAROBJ988 }989 if !isAt(DOOR) {990 if object == WATER {991 /* cycle through the three plant states */992 n := (game.Prop[PLANT] + 1) % 3993 stateChange(PLANT, n)994 game.Prop[PLANT2] = game.Prop[PLANT]995 return GO_MOVE996 } else {997 speak(true, messages[SHAKING_LEAVES])998 return GO_CLEAROBJ999 }1000 } else {1001 ifElse(object == OIL,1002 func() { stateChange(DOOR, DOOR_UNRUSTED) },1003 func() { stateChange(DOOR, DOOR_RUSTED) })1004 return GO_CLEAROBJ1005 }1006}1007/* Quit. Intransitive only. Verify intent and exit if that's what he wants. */1008func quit() PhaseCodeType {1009 if askYesNo(messages[REALLY_QUIT], messages[OK_MAN], messages[OK_MAN]) {1010 terminate(term_quit)1011 }1012 return GO_CLEAROBJ1013}1014/* Read. Print stuff based on objtxt. Oyster (?) is special case. */1015func read(command Command) PhaseCodeType {1016 if command.obj == INTRANSITIVE {1017 command.obj = NO_OBJECT1018 var i ObjectType1019 for i = 1; i <= NOBJECTS; i++ {1020 if isHere(i) && objects[i].texts[0] != "" && game.Prop[i] >= 0 {1021 command.obj = command.obj*NOBJECTS + i1022 }1023 }1024 if command.obj > NOBJECTS || command.obj == NO_OBJECT || isDark(game.Loc) {1025 return GO_UNKNOWN1026 }1027 }1028 if isDark(game.Loc) {1029 speak(true, messages[NO_SEE], command.word[0].raw)1030 } else if command.obj == OYSTER {1031 if !isToting(OYSTER) || !game.Closed {1032 speak(true, messages[DONT_UNDERSTAND])1033 } else if !game.Clshnt {1034 game.Clshnt = askYesNo(messages[CLUE_QUERY], messages[WAYOUT_CLUE], messages[OK_MAN])1035 } else {1036 pspeak(OYSTER, hear, true, 1) // Not really a sound, but oh well.1037 }1038 } else if objects[command.obj].texts[0] == "" || game.Prop[command.obj] == STATE_NOTFOUND {1039 speak(true, actions[command.verb].message)1040 } else {1041 pspeak(command.obj, study, true, game.Prop[command.obj])1042 }1043 return GO_CLEAROBJ1044}1045/* Z'ZZZ (word gets recomputed at startup; different each game). */1046// C: reservoir1047func reservoir() PhaseCodeType {1048 if !isAt(RESER) && game.Loc != LOC_RESBOTTOM {1049 speak(true, messages[NOTHING_HAPPENS])1050 return GO_CLEAROBJ1051 }1052 ifElse(game.Prop[RESER] == WATERS_PARTED,1053 func() { stateChange(RESER, WATERS_UNPARTED) },1054 func() { stateChange(RESER, WATERS_PARTED) })1055 if isAt(RESER) {1056 return GO_CLEAROBJ1057 }1058 game.Oldlc2 = game.Loc1059 game.Newloc = LOC_NOWHERE1060 speak(true, messages[NOT_BRIGHT])1061 return GO_TERMINATE1062}1063/* Rub. Yields various snide remarks except for lit urn. */1064// C: rub1065func rub(verb VerbType, object ObjectType) PhaseCodeType {1066 if object == URN && game.Prop[URN] == URN_LIT {1067 destroy(URN)1068 drop(AMBER, game.Loc)1069 game.Prop[AMBER] = AMBER_IN_ROCK1070 game.Tally--1071 drop(CAVITY, game.Loc)1072 speak(true, messages[URN_GENIES])1073 } else if object != LAMP {1074 speak(true, messages[PECULIAR_NOTHING])1075 } else {1076 speak(true, actions[verb].message)1077 }1078 return GO_CLEAROBJ1079}1080/* Say. Echo WD2. Magic words override. */1081// C: say1082func say(command Command) PhaseCodeType {1083 if command.word[1].typ == MOTION &&1084 (command.word[1].id == XYZZY || command.word[1].id == PLUGH || command.word[1].id == PLOVER) {1085 return GO_WORD21086 }1087 if command.word[1].typ == ACTION && command.word[1].id == PART {1088 return reservoir()1089 }1090 if command.word[1].typ == ACTION &&1091 (command.word[1].id == FEE || command.word[1].id == FIE || command.word[1].id == FOE ||1092 command.word[1].id == FOO || command.word[1].id == FUM || command.word[1].id == PART) {1093 return bigWords(command.word[1].id)1094 }1095 speak(true, messages[OKEY_DOKEY], command.word[1].raw)1096 return GO_CLEAROBJ1097}1098func throwSupport(spk VocabType) PhaseCodeType {1099 speak(true, messages[spk])1100 drop(AXE, game.Loc)1101 return GO_MOVE1102}1103/* Throw. Same as discard unless axe. Then same as attack except1104 * ignore bird, and if dwarf is present then one might be killed.1105 * (Only way to do so!) Axe also special for dragon, bear, and1106 * troll. Treasures special for troll. */1107// C: throwit1108func throwit(command Command) PhaseCodeType {1109 if !isToting(command.obj) {1110 speak(true, actions[command.verb].message)1111 return GO_CLEAROBJ1112 }1113 if objects[command.obj].treasure && isAt(TROLL) {1114 /* Snarf a treasure for the troll. */1115 drop(command.obj, LOC_NOWHERE)1116 move(TROLL, LOC_NOWHERE)1117 move(TROLL+NOBJECTS, FREE)1118 drop(TROLL2, objects[TROLL].plac)1119 drop(TROLL2+NOBJECTS, objects[TROLL].fixd)1120 juggle(CHASM)1121 speak(true, messages[TROLL_SATISFIED])1122 return GO_CLEAROBJ1123 }1124 if command.obj == FOOD && isHere(BEAR) {1125 /* But throwing food is another story. */1126 command.obj = BEAR1127 return feed(command.verb, command.obj)1128 }1129 if command.obj != AXE {1130 return discard(command.verb, command.obj)1131 }1132 if atdwrf(game.Loc) <= 0 {1133 if isAt(DRAGON) && game.Prop[DRAGON] == DRAGON_BARS {1134 return throwSupport(DRAGON_SCALES)1135 }1136 if isAt(TROLL) {1137 return throwSupport(TROLL_RETURNS)1138 }1139 if isAt(OGRE) {1140 return throwSupport(OGRE_DODGE)1141 }1142 if isHere(BEAR) && game.Prop[BEAR] == UNTAMED_BEAR {1143 /* This'll teach him to throw the axe at the bear! */1144 drop(AXE, game.Loc)1145 game.Fixed[AXE] = FIXED1146 juggle(BEAR)1147 stateChange(AXE, AXE_LOST)1148 return GO_CLEAROBJ1149 }1150 command.obj = INTRANSITIVE1151 return attack(command)1152 }1153 if randrange(NDWARVES+1) < int32(game.Dflag) {1154 return throwSupport(DWARF_DODGES)1155 }1156 loc := atdwrf(game.Loc)1157 game.Dseen[loc] = false1158 game.Dloc[loc] = LOC_NOWHERE1159 game.Dkill++1160 var p PhaseCodeType1161 ifElse(game.Dkill == 1,1162 func() { p = throwSupport(DWARF_SMOKE) },1163 func() { p = throwSupport(KILLED_DWARF) })1164 return p1165}1166/* Wake. Only use is to disturb the dwarves. */1167// C: wake1168func wake(verb VerbType, object ObjectType) PhaseCodeType {1169 if object != DWARF || !game.Closed {1170 speak(true, actions[verb].message)1171 return GO_CLEAROBJ1172 }1173 speak(true, messages[PROD_DWARF])1174 return GO_DWARFWAKE1175}1176/* Set seed */1177func seed(verb VerbType, arg string) PhaseCodeType {1178 s, err := strconv.Atoi(arg)1179 if err == nil {1180 speak(true, actions[verb].message, s)1181 setSeed(int32(s))1182 game.Turns++1183 }1184 return GO_TOP1185}1186/* Burn Turns */1187func waste(verb VerbType, turns TurnType) PhaseCodeType {1188 game.Limit -= turns1189 speak(true, actions[verb].message, game.Limit)1190 return GO_TOP1191}1192/* Wave. No effect unless waving rod at fissure or at bird. */1193// C: wave1194func wave(verb VerbType, object ObjectType) PhaseCodeType {1195 if object != ROD || !isToting(object) || (!isHere(BIRD) && (game.Closng || !isAt(FISSURE))) {1196 ifElse(!isToting(object) && (object != ROD || !isToting(ROD2)),1197 func() { speak(true, messages[ARENT_CARRYING]) },1198 func() { speak(true, actions[verb].message) })1199 return GO_CLEAROBJ1200 }1201 if game.Prop[BIRD] == BIRD_UNCAGED && game.Loc == game.Place[STEPS] && game.Prop[JADE] == STATE_NOTFOUND {1202 drop(COND_JADE, game.Loc)1203 game.Prop[JADE] = STATE_FOUND1204 game.Tally--1205 speak(true, messages[NECKLACE_FLY])1206 return GO_CLEAROBJ1207 } else {1208 if game.Closed {1209 ifElse(game.Prop[BIRD] == BIRD_CAGED,1210 func() { speak(true, messages[CAGE_FLY]) },1211 func() { speak(true, messages[FREE_FLY]) })1212 return GO_DWARFWAKE1213 }1214 if game.Closng || !isAt(FISSURE) {1215 ifElse(game.Prop[BIRD] == BIRD_CAGED,1216 func() { speak(true, messages[CAGE_FLY]) },1217 func() { speak(true, messages[FREE_FLY]) })1218 return GO_CLEAROBJ1219 }1220 if isHere(BIRD) {1221 ifElse(game.Prop[BIRD] == BIRD_CAGED,1222 func() { speak(true, messages[CAGE_FLY]) },1223 func() { speak(true, messages[FREE_FLY]) })1224 }1225 ifElse(game.Prop[FISSURE] == BRIDGED,1226 func() { stateChange(FISSURE, UNBRIDGED) },1227 func() { stateChange(FISSURE, BRIDGED) })1228 return GO_CLEAROBJ1229 }1230}...

Full Screen

Full Screen

ui.go

Source:ui.go Github

copy

Full Screen

...415 if globals.GetPlayerData().GetInventory().NewBootsAcquired {416 indicatorDrawColor := color.RGBA{255, 100, 0, 255}417 ebitenutil.DrawRect(screen, u.bootEquip.X, u.bootEquip.Y, 8, 8, indicatorDrawColor)418 }419 // draws the Hover info for key items420 if u.openButton {421 if u.reelEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {422 u.txtRenderer.SetSizePx(invTextSize)423 drawHover("Reel", screen, &u.reelEquip, u.cursorPos, u.txtRenderer, u)424 }425 if u.rodEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {426 u.txtRenderer.SetSizePx(invTextSize)427 drawHover("Rod", screen, &u.rodEquip, u.cursorPos, u.txtRenderer, u)428 }429 if u.lineEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {430 u.txtRenderer.SetSizePx(invTextSize)431 drawHover("Line", screen, &u.lineEquip, u.cursorPos, u.txtRenderer, u)432 }433 if u.magEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {434 u.txtRenderer.SetSizePx(invTextSize)435 drawHover("Magnet", screen, &u.magEquip, u.cursorPos, u.txtRenderer, u)436 }437 if u.bootEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {438 u.txtRenderer.SetSizePx(invTextSize)439 drawHover("Boots", screen, &u.bootEquip, u.cursorPos, u.txtRenderer, u)440 }441 if u.elecEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {442 u.txtRenderer.SetSizePx(invTextSize)443 drawHover("Electromagnet", screen, &u.elecEquip, u.cursorPos, u.txtRenderer, u)444 }445 if u.repEquip.OpenKeyItemListButton.IsHoveredOver(u.cursorPos) {446 u.txtRenderer.SetSizePx(invTextSize)447 drawHover("Repulsor", screen, &u.repEquip, u.cursorPos, u.txtRenderer, u)448 }449 }450 }451}452func drawHover(keyItemType string, screen *ebiten.Image, slot *EquippableSlot, cursorPosition basics.Vector2f, txtRenderer *etxt.Renderer, u *Ui) {453 if globals.GetPlayerData().CheckKeyItemTypeSlotIfOccupied(keyItemType) {454 // buttonDrawColor := color.RGBA{12, 159, 7, 255}455 // ebitenutil.DrawRect(screen, cursorPosition.X, cursorPosition.Y-110, 100, 100, buttonDrawColor)456 tooltip := &ebiten.DrawImageOptions{}457 tooltip.GeoM.Translate(cursorPosition.X, cursorPosition.Y-120)458 screen.DrawImage(u.tooltipSprite, tooltip)459 // change color here460 // txtRenderer.SetColor(color.RGBA{0, 0, 0, 255})461 // draw u.magEquip key item name and modifier here462 txtRenderer.Draw(fmt.Sprintf("%s", slot.KeyItem.GetKeyItemName()), int(cursorPosition.X+25), int(cursorPosition.Y-110))463 if len(globals.GetPlayerData().GetInventory().GetKeyItemsByType(keyItemType)) > 0 {464 txtRenderer.Draw(465 fmt.Sprintf(466 "%d/%d",...

Full Screen

Full Screen

capcha.go

Source:capcha.go Github

copy

Full Screen

...174func slide(el *rod.Element, posX, posY float64) error {175 mouse := page.Mouse176 mouseStep := randInt(5, 8)177 mouseSleep := randInt(50, 150)178 err := el.Hover()179 if err != nil {180 handleError(err)181 return err182 }183 err = mouse.Down("left", 0)184 if err != nil {185 log.Println("mouse.Down", err)186 return err187 }188 time.Sleep(time.Millisecond * time.Duration(mouseSleep))189 err = mouse.Move(posX, posY, mouseStep)190 if err != nil {191 log.Println("mouse.move", err)192 return err...

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().Connect()4 page.Element("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").Input("Rod").Press(input.Enter)5 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()6 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()7 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()8 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()9 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()10 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()11 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()12 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()13 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()14 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()15 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Hover()16 page.Element("#rso > div:nth-child(1) > div > div > div > div > div > div.r > a > h3").Click()17 page.Element("#rso > div:nth-child(

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().ControlURL(launcher.New().MustLaunch()).MustConnect()4 page.MustElement("button").MustHover()5 page.MustElement("button:nth-child(2)").MustHover()6 page.MustElement("button:nth-child(3)").MustHover()7 page.MustElement("button:nth-child(3)").MustClick()8 page.MustElement("button:nth-child(4)").MustHover()9 page.MustElement("button:nth-child(4)").MustClick()10 page.MustElement("button:nth-child(5)").MustHover()11 page.MustElement("button:nth-child(5)").MustClick()12 page.MustElement("button:nth-child(6)").MustHover()13 page.MustElement("button:nth-child(6)").MustClick()14 page.MustElement("button:nth-child(7)").MustHover()15 page.MustElement("button:nth-child(7)").MustClick()16 page.MustElement("button:nth-child(8)").MustHover()17 page.MustElement("button:nth-child(8)").MustClick()18 page.MustElement("button:nth-child(9)").MustHover()19 page.MustElement("button:nth-child(9)").MustClick()20 page.MustElement("button:nth-child(10)").MustHover()21 page.MustElement("button:nth-child(10)").MustClick()22 page.MustElement("button:nth-child(11)").MustHover()23 page.MustElement("button:nth-child(11)").MustClick()

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 input := page.MustElement("input[name=q]")5 input.MustInput("rod").MustPress("enter")6 link := page.MustElement("h3").MustElement("a")7 fmt.Println(link.MustText())8 link.MustHover()9}10import (11func main() {12 browser := rod.New().MustConnect()13 input := page.MustElement("input[name=q]")14 input.MustInput("rod").MustPress("enter")15 link := page.MustElement("h3").MustElement("a")16 fmt.Println(link.MustText())17 link.MustHover()18 page.MustScreenshot("screenshot.png")19}20import (21func main() {22 browser := rod.New().MustConnect()23 input := page.MustElement("input[name=q]")24 input.MustInput("rod").MustPress("enter")25 link := page.MustElement("h3").MustElement("a")26 fmt.Println(link.MustText())27 link.MustHover()28 page.MustScreenshot("screenshot.png")29 page.MustViewport(1920, 1080, 1, false)30}31import (32func main() {33 browser := rod.New().MustConnect()34 input := page.MustElement("input[name=q]")35 input.MustInput("rod").MustPress("enter")36 link := page.MustElement("h3").MustElement("a")37 fmt.Println(link.MustText())38 link.MustHover()39 page.MustScreenshot("screenshot.png")40 page.MustViewport(1920, 1080, 1, false)41}42import (

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 page.MustElement("input[name=q]").MustInput("rod").MustPress(input.Enter)5 page.MustElement("h3").MustHover()6 fmt.Println(page.MustScreenshot())7}8import (9func main() {10 browser := rod.New().MustConnect()11 page.MustElement("input[name=q]").MustInput("rod").MustPress(input.Enter)12 fmt.Println(page.MustElement("h3").MustText())13}14import (15func main() {16 browser := rod.New().MustConnect()17 page.MustElement("input[name=q]").MustInput("rod").MustPress(input.Enter)18 fmt.Println(page.MustElements("h3").MustText())19}20import (21func main() {22 browser := rod.New().MustConnect()23 page := browser.MustPage("https

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 defer browser.MustClose()5 e := page.MustElement("#lst-ib")6 e.MustHover()7 page.MustWaitVisible("#tsf > div:nth-child(2) > div > div.FPdoLc.tfB0Bf > center > input[type=\"submit\"]:nth-child(1)")8 page.MustElement("#tsf > div:nth-child(2) > div > div.FPdoLc.tfB0Bf > center > input[type=\"submit\"]:nth-child(1)").MustClick()9 page.MustWaitVisible("#resultStats")10 res := page.MustElement("#resultStats").MustText()11 fmt.Println(res)12}13About 1,000,000,000 results (0.22 seconds)

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 l := launcher.New().Delete("default", "cache").MustLaunch()4 defer l.Close()5 browser := rod.New().ControlURL(l).MustConnect()6 page.MustWaitLoad()7 page.MustElement("input.gLFyf").MustInput("rod").MustPress("Enter")8 page.MustWaitLoad()9 el := page.MustElement("h3")10 fmt.Println(el.MustText())11 el.MustHover()12 page.Wait(1)13 browser.MustClose()14}

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().MustConnect()4 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustWaitVisible()5 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustHover()6 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustWaitVisible()7 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustClick()8 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustWaitVisible()9 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustInput("hello world")10 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustWaitVisible()11 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustPress(input.Enter)12 page.MustElement("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input").MustWaitVisible()13 text := page.MustElement("#tsf > div:nth-child

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 browser := rod.New().Connect()4 searchBox := page.Element(".gLFyf.gsfi")5 searchBox.Input("Hello")6 page.Element(".gNO89b").Click()7 time.Sleep(5 * time.Second)8 firstResult := page.Element(".LC20lb.DKV0Md")9 firstResult.Hover()10 time.Sleep(5 * time.Second)11 text, err := firstResult.Text()12 if err != nil {13 log.Fatal(err)14 }15 fmt.Println(text)16}

Full Screen

Full Screen

Hover

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 rod.Hover()4}5import "fmt"6func main() {7 rod.Hover()8}9import "fmt"10func main() {11 rod.Hover()12}13import "fmt"14func main() {15 rod.Hover()16}17import "fmt"18func main() {19 rod.Hover()20}21import "fmt"22func main() {23 rod.Hover()24}25import "fmt"26func main() {27 rod.Hover()28}29import "fmt"30func main() {31 rod.Hover()32}33import "fmt"34func main() {35 rod.Hover()36}37import "fmt"38func main() {39 rod.Hover()40}41import "fmt"42func main() {43 rod.Hover()44}45import "fmt"46func main() {47 rod.Hover()48}49import "fmt"50func main() {51 rod.Hover()52}

Full Screen

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 Rod automation tests on LambdaTest cloud grid

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

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful