Bushwhacking

A game based on MoleWhack, where plastic heads featuring the American President pop up out of holes.

Author: Walker@M*U*S*H
Category: Games
Features: regexp commands.
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Bushwhacking

@create Bushwhacking
@lock/Basic Bushwhacking==me
@lset Bushwhacking/Basic=no_inherit
@set Bushwhacking = LINK_OK
@set Bushwhacking = VISUAL
@AMHEAR Bushwhacking=th set(me,play.round:[v(s.numrounds)]); @wait 15=@trigger me/trg.cycler
@set Bushwhacking/AMHEAR=no_command prefixmatch
&AUTHOR Bushwhacking=Walker@M*U*S*H
&CAN.START Bushwhacking=gt(words(v(players)),0)
&CAN.USE Bushwhacking=gt(match(if(cand(v(playing),match(v(players),%#)),iter(v(whackers),after(##,:)),start clear join depart),first(edit(%c,teach%b,))),0)
&CMD.CLEAR Bushwhacking=$clear:think u(fun.clear)
&CMD.DEPART Bushwhacking=$depart:think u(fun.depart)
&CMD.HITIT Bushwhacking=$^(.*):think if(match(v(whackers),*:%1),u(fun.hitit,%1))
@set Bushwhacking/CMD.HITIT=no_command regexp
&CMD.JOIN Bushwhacking=$join:think u(fun.join)
&CMD.START Bushwhacking=$^start ([3-9])$:think u(fun.start,%1)
@set Bushwhacking/CMD.START=regexp
@DESCRIBE Bushwhacking=A bushwhacking game. A game based on MoleWhack, where plastic heads featuring the American President pop up out of holes! There are [words(v(whackers))] holes, and you need to type the correct command to whack the head in the right hole!%r%r%b[mix(mix.fordesc,v(whackers),Player [edit(lattr(me/score.#*),SCORE.,)])]%r%rType: [ansi(h,use [name(me)])] for help.%r[if(words(v(players)),Currently [if(v(playing),playing,joined)] players: [edit(itemize(edit(iter(v(players),name(##)),%b,_)),_,%b)]%r)]
@set Bushwhacking/DESCRIBE=no_command visual prefixmatch
&FUN.CLEAR Bushwhacking=set(me,playing:0)[set(me,players:)][pemit(%#,u(s.clear))][oemit(%#,u(s.oclear))][u(on.clear)]
&FUN.DEPART Bushwhacking=if(v(playing),pemit(%#,u(s.started)),if(eq(match(v(players),%#),0),pemit(%#,u(s.departed)),pemit(%#,u(s.depart))[oemit(%#,u(s.odepart))][u(on.depart)][set(me,players:[setdiff(v(players),%#)])])]
&FUN.HITIT Bushwhacking=if(grab(v(play.%#),%0),emit(u(hit.%0))[set(me,play.%#:[setdiff(v(play.%#),ucstr(%0))])][set(me,score.%#:[add(v(score.%#),1)])],[emit(u(miss.%0))][set(me,score.%#:[dec(v(score.%#))])])
&FUN.JOIN Bushwhacking=if(v(playing),pemit(%#,u(s.started)),if(gt(match(v(players),%#),0),pemit(%#,u(s.joined)),pemit(%#,u(s.join))[oemit(%#,u(s.ojoin))][u(on.join)][set(me,players:[setunion(v(players),%#)])])]
&FUN.NEWHEADS Bushwhacking=switch(rand(9),<2,first(shuffle(v(whackers))),<6,elements(shuffle(v(whackers)),1 2),<8,elements(shuffle(v(whackers)),1 2 3),v(whackers))
&FUN.NEWROUND Bushwhacking=[wipe(me/play.#*)][set(me,play.round:[dec(v(play.round))])][setq(0,u(fun.newheads))][emit(u(s.newround,iter(%q0,before(itext(0),:))))][setq(1,iter(%q0,after(itext(0),:)))][set(me,score.total:[add(v(score.total),words(%q1))])][iter(v(players),set(me,play.##:%q1),%b,)]
&FUN.START Bushwhacking=if(v(playing),pemit(%#,u(s.started)),if(u(can.start),pemit(%#,u(s.start))[oemit(%#,u(s.ostart))][u(on.start,%0)][set(me,playing:1)],pemit(%#,u(s.sfail))))]
&HIT.BAP Bushwhacking=%n gives our vacationing president a well-deserved BAP!
&HIT.BASH Bushwhacking=%n BASHes the American President!
&HIT.BAT Bushwhacking=%n BATs the yet-to-be-underestimated Texan!
&HIT.BEAN Bushwhacking=%n BEANs the hollow skull with an excellent shot!
&HIT.BEAT Bushwhacking=%n BEATs about the bush!
&HIT.BONK Bushwhacking=A violent BONK is delivered to our president by %n!
&HIT.SLAP Bushwhacking=%n SLAPs the head so loudly, it's ears ring!
&HIT.THUMP Bushwhacking=%n THUMPs the primate's bust where it hurts the least: in the head!
&HIT.THWAP Bushwhacking=%n winds up and solidly THWAPs America's Representative!
&HIT.WHACK Bushwhacking=%n delivers a solid WHACK to the Commander In Chief!
&LICENSE Bushwhacking=GPL
@LISTEN Bushwhacking=start_cycle
@set Bushwhacking/LISTEN=no_command prefixmatch
&MISS.BAP Bushwhacking=%n baps a hole without a head.
&MISS.BASH Bushwhacking=%ns bash rings hollow as it misses.
&MISS.BAT Bushwhacking=%n strikes out with his batting.
&MISS.BEAN Bushwhacking=%n shoots a bean down a hole. It rattles, but doesn't score.
&MISS.BEAT Bushwhacking=%n beats a poor defenseless hole.
&MISS.BONK Bushwhacking=%n bonks the board with %p bare hands. Ow ow ow!
&MISS.SLAP Bushwhacking=%n fans the air above a hole with %p slap.

&MISS.THUMP Bushwhacking=%n thumps an empty hole. drat!
&MISS.THWAP Bushwhacking=%n winds up, swings, and misses with his thwap.
&MISS.WHACK Bushwhacking=%n whacks the board. D'oh!
&MIX.FORDESC Bushwhacking=[ljust(if(%0,Hole '[before(%0,:)]' is: [ansi(h,after(%0,:))]),25)]%b[if(%1,[rjust(left(switch(%1,Player,Player,name(%1)),10),12)]: [u(score.%1)])]%r
&ON.CLEAR Bushwhacking=wipe(me/play.#*)[set(me/cmd.hitit,no_command)]
&ON.START Bushwhacking=[wipe(me/score.#*)][set(me/cmd.hitit,!no_command)][iter(v(players),[set(me,play.##:)][set(me,score.##:0)])][set(me,score.total:0)][pemit(%!,start_cycle)][set(me,whackers:[iter(extract(shuffle(v(s.whackers)),1,%0),#@:##)])]
&PLAYERS Bushwhacking=
&PLAYING Bushwhacking=0
&PLAY.ROUND Bushwhacking=1
&S.CLEAR Bushwhacking=The Bushwhacking game is over.
&SCORE.#8308 Bushwhacking=5
&SCORE.PLAYER Bushwhacking=Score (of [v(score.total)])
&SCORE.TOTAL Bushwhacking=47
&S.DEPART Bushwhacking=You leave the [u(s.name)].
&S.DEPARTED Bushwhacking=You are not involved.
&S.JOIN Bushwhacking=You join the [u(s.name)].
&S.JOINED Bushwhacking=You are already joined.
&S.NAME Bushwhacking=Bushwhacking Game
&S.NEWROUND Bushwhacking=All the heads go down, and up pop more in holes [itemize(%0)]
&S.NUMROUNDS Bushwhacking=20
&S.OCLEAR Bushwhacking=%N clears the [u(s.name)].
&S.ODEPART Bushwhacking=%N leaves the [u(s.name)].
&S.OJOIN Bushwhacking=%N joins the [u(s.name)].
&S.ONCLEAR Bushwhacking=The Bushwhacking game is over.
&S.OSTART Bushwhacking=%N starts the [u(s.name)].
&S.SFAIL Bushwhacking=Not enough players.
&S.START Bushwhacking=You start the [u(s.name)].
&S.STARTED Bushwhacking=The [u(s.name)] is in progress.
&S.WHACKERS Bushwhacking=BAP BEAT THUMP WHACK BASH THWAP BAT SLAP BONK BEAN
&TRG.CYCLER Bushwhacking=@switch mul(v(play.round),v(playing))=>1,{th u(fun.newround) ; @wait 1=@trig me/trg.cycler},{ th u(fun.clear) ; @drain me }
@USE Bushwhacking=Bushwhacking game!%r%r[ljust(Command, 12)]Function%r[ljust(ansi(h,join),12)]Join the game.%r[ljust(ansi(h,depart),12)]Leave the game before it starts.%r[ljust(ansi(h,start <num>),12)]Start the game with <num> noles, from 3-9.%r[ljust(ansi(h,<verb>),12)]Deal a blow to a popup bush head.
@set Bushwhacking/USE=no_command prefixmatch
&WHACKERS Bushwhacking=1:BAT 2:BEAT 3:BONK