Jump to content
chain

Hi-Lo Multiplayer Version (with AIs + Stats + 4 Players Max)

Recommended Posts

  • Administrators

COMMANDS -

!high - go high
!low - go low
!stats user - See the stats of any user
!hilo - Start game
!start solo - Start a solo game , i.e, play alone.
!start multi : Start a multiplayer game with given number of players

 

############################################################
##       Hi-Lo Multiplayer Version Script ( with Stats and AI Players)            ##
##       Version: 1.0              ##
##       By: manish17               ##
##       irc.lunarirc.net   #LunarIRC   User - manish  
  Follow my blog : https://manishsnippets.blogspot.com ##
############################################################
on *:TEXT:!hilo*:#: {
  if ( %hilo != on ) && (%ongoing == $null) {
    set %hilo on
set %chan $chan
    set %o 0
    msg $chan 3 Hi-Lo game has been started. 13 cards are taken, and a random card is drawn and removed every time. You need to guess whether the next card is higher or lower than the previous card.
    msg $chan 9 Type !start Solo or !start multi to start a Solo Game or a Multiplayer Game respectively.    
  }
  else {
    msg $chan 9 Type !start Solo or !start multi to start a Solo Game or a Multiplayer Game respectively.
  }  
}

on *:TEXT:!start*:#: {
  if ( %hilo == on ) && ( %o == 0 ) && ( $2 == solo ) {
    inc %o
    set %gamemode solo
    set %nick $nick
    set %chan $chan
    msg $chan 6 Game of High-Low has been started by $nick . Current champion: %champ .
    startg
    msg %chan 4,0 $+ %oldcard 4,010 has been chosen! 12 cards remaining in the deck.
    msg %chan 6 $nick may choose to go !high or go !low
    timer 1 30 timeout
  }
  elseif ( %hilo == on ) && ( %o == 0 ) && ( $2 == multi ) {
    inc %o
    set %chan $chan
    set %gamemode multiplayer
    unset %game
    set %multi started
    set %cards 2.3.4.5.6.7.8.9.10.J.Q.K.A
    set %AInames ProMan LucyFir StupidTolga
    if ( $3 isnum ) && ( $3 >= 2 ) && ( $3 <= 4 ) {
      set %playing $3
    }
    else { set %playing 4 }
    msg %chan 6 A game of Hi-Lo Multiplayer has been started. Type !join to join. You have 30 seconds..
    set %joining on
    timer 1 15 msg %chan 10 15 seconds left... If enough players do not join, AI Players will be joining.
    timer 1 30 timeup

  }
  elseif ( %o == 1 ) {
    msg $chan 7 A game of High-Low %gamemode is already in progress in %chan .
  }
  else {
  msg $chan 6 Please start a game of High-Low by typing !hilo . }
}
alias startg {
  getinfo %nick
  inc %sgp
  makedata %nick
  set %score 0
  set %cards 2.3.4.5.6.7.8.9.10.J.Q.K.A
  set %total $numtok(%cards,46)
  set %x $rand(1,%total)
  set %oldcard $gettok(%cards,%x,46)
  %cards = $deltok(%cards,%x,46)
}
on *:TEXT:!stophilo*:#: {
  if ( $nick isop %chan ) {
    end
    msg %chan 14  Game has been stopped by $nick .
  }
}
on *:TEXT:!high*:#: {
  timers off
  if ( $nick == %tplayer ) {
    go high
  }
  elseif ( $nick == %nick) {  
    ignore %nick
    timer 1 1 msg %chan 10 $nick goes for high.
    set %total $numtok(%cards,46)
    set %x $rand(1,%total)
    set %newcard $gettok(%cards,%x,46)
    %cards = $deltok(%cards,%x,46)
    set %oldval $value(%oldcard)
    set %newval $value(%newcard)
    if ( %newval > %oldval ) {
      inc %score
      timer 1 5 msg %chan 14  The next card is 4,0 $+ %newcard 4,0 .
      timer 1 5 msg %chan 6 $numtok(%cards,46) cards remaining in the deck.
      timer 1 5 msg %chan 6 $nick makes a correct choice and is still in the game.
      timer 1 7 msg %chan 10 Current score of $nick : %score
      timer 1 7 ignore -r %nick
      timer 1 37 timeout
      if ( %score == 12 ) {
        timer 1 8 msg %chan 9 $nick has won the game of High-Low with a top-class score of 12, and is the new champion!
        getinfo %nick
        if ( %score > %hs ) { set %hs %score }
        makedata %nick
        set %champ $nick
        unset %o
        set %hilo off
        unset %nick
timers off
      }

    }
    else {
      timer 1 4 msg %chan 14  The next card is 4,0 $+ %newcard 4,0 .
      timer 1 5 msg %chan 4 Game Over! $nick loses the game with a total score of %score . Well played!
      ignore -r %nick
      getinfo %nick
      if ( %score > %hs ) { set %hs %score }
      makedata %nick
      unset %o
      set %hilo off
      unset %nick
    }
    set %oldcard %newcard
  }
}
on *:TEXT:!low*:#: {
  timers off
  if ( $nick == %tplayer ) {
    go low
  }
  elseif ( $nick == %nick) {  
    ignore %nick
    timer 1 1 msg $chan 10 $nick goes for low.
    set %total $numtok(%cards,46)
    set %x $rand(1,%total)
    set %newcard $gettok(%cards,%x,46)
    %cards = $deltok(%cards,%x,46)
    set %oldval $value(%oldcard)
    set %newval $value(%newcard)
    if ( %newval < %oldval ) {
      inc %score
      timer 1 5 msg %chan 14  The next card is 4,0 $+ %newcard 4,0 .
      timer 1 5 msg %chan 6 $numtok(%cards,46) cards remaining in the deck.
      timer 1 5 msg %chan 6 $nick makes a correct choice and is still in the game.
      timer 1 7 msg %chan 10 Current score of $nick : %score
      timer 1 7 ignore -r %nick
      timer 1 37 timeout
      if ( %score == 12) {
        timer 1 8 msg %chan 9 $nick has won the game of High-Low with a top-class score of 12, and is the new champion!
        getinfo %nick
        if ( %score > %hs ) { set %hs %score }
        makedata %nick
        set %champ $nick
        unset %o
        set %hilo off
        unset %nick
        timers off
      }
    }
    else {
      timer 1 4 msg %chan 14  The next card is 4,0 $+ %newcard 4,0 .
      timer 1 5 msg %chan 4 Game Over! $nick loses the game with a total score of %score . Well played!
      ignore -r %nick
      getinfo %nick
      if ( %score > %hs ) { set %hs %score }
      makedata %nick
      unset %o
      set %hilo off
      unset %nick

    }
    set %oldcard %newcard
  }
}

alias -l value return $iif($1 isnum,$1,$+(1,$pos(JQKA,$1,1)))

alias  timeout {
  msg %chan 4 Sorry %nick , you ran out of the time-limit (30 seconds) and eventually lose the game with the score %score .
  getinfo %nick
  if ( %score > %hs ) { set %hs %score }
  makedata %nick
  unset %o
  set %hilo off
  notice %nick Please Wait 30 seconds if you want to play again.
  ignore -cu30 %nick
  unset %nick
}
alias  go {
  timers off
  ignore %tplayer
  timer 1 1 msg %chan 10 %tplayer decides to go $1 .
  getnewcard
  set %decision $1
  set %oldval $value(%oldcard)
  set %newval $value(%newcard)
  timer 1 3 msg %chan The next card is 4,0 $+ %newcard 4,0 .
  if ( %decision == high ) && ( %newval > %oldval ) {
    timer 1 4 msg %chan 9 %tplayer makes a correct choice and is still in the game.
    set %mcb $gettok(%corr,%turn,46)
    inc %mcb
    set %corr $deltok(%corr,%turn,46)
    set %corr $instok(%corr,%mcb,%turn,46)
  }
  elseif ( %decision == low ) && ( %newval < %oldval ) {
    timer 1 4 msg %chan 9 %tplayer makes a correct choice and is still in the game.
    set %mcb $gettok(%corr,%turn,46)
    inc %mcb
    set %corr $deltok(%corr,%turn,46)
    set %corr $instok(%corr,%mcb,%turn,46)

  }
  else {
    timer 1 4 msg %chan 4 %tplayer makes a wrong choice and loses a life.
    %life = $gettok(%lifes,%turn,46)
    set %life $calc(%life - 1)
    set %lifes $deltok(%lifes,%turn,46)
    set %lifes $instok(%lifes,%life,%turn,46)

  }
  timer 1 6 showlifes
  timer 1 8 getout
}

alias -l showlifes {
  var %pk = 1
  while ( %pk <= %playing ) {
    set %display %display 6   $gettok(%players,%pk,32) $+ : $gettok(%lifes,%pk,46)
    inc %pk
  }
  msg %chan 3 Current Lives : %display
  unset %display
}

alias -l getout {
  if ( $istok(%lifes,0,46) ) {
    getinfo %tplayer
    set %correct $gettok(%corr,%turn,46)
    set %cg $calc(%cg + %correct)
    set %wg $calc(%wg + 3)
    set %corr $deltok(%corr,%turn,46)
    makedata %tplayer
    set %lifes $remtok(%lifes,0,0,46)
    msg %chan 4 %tplayer has lost all their lives and is now out of the game, finishing with 10 coins. Adieu!  
coins %tplayer 10
    ignore -r %tplayer
    set %players $remtok(%players,%tplayer,0,32)
    set %playing $calc(%playing - 1)
    set %turn $calc(%turn - 1)
  }
  if ( %playing == 1 ) {
    timer 1 2 winner
  }
  else { continuegame }
}

alias -l shuffle {
  if ( $numtok(%cards,46) == 0 ) {
    msg %chan 13 The other cards are being taken again and re-shuffled!
    set %cards 2.3.4.5.6.7.8.9.10.J.Q.K.A
    set %cards $remtok(%cards,%newcard,1,46)
} }
alias -l aiornot {
  if ( $1 == $gettok(%AInames,1,32) ) {
    var %highchance = 0
    var %lowchance = 0
    var %p = 1
    while ( %p <= $numtok(%cards,46) ) {
      set %curcard $gettok(%cards,%p,46)
      set %curvalue $value(%curcard)
      if ( %curvalue > $value(%newcard) ) { inc %highchance }
      else { inc %lowchance }
      inc %p
    }
    if ( %highchance > %lowchance ) {
      go high
    }
    else {
      go low
    }
  }
  elseif ( $1 == $gettok(%AInames,2,32) ) {
    set %newval $value(%newcard)
    var %highchance = 14 - %newval
    var %lowchance = %newval - 2
    if ( %highchance > %lowchance ) {
      go high
    }
    else {
      go low
    }
  }
  elseif ( $1 == $gettok(%AInames,3,32) ) {
    set %y $rand(1,2)
    if ( %y == 1 ) {
      go high
    }
    else {
      go low
    }
  }
}
alias -l winner {
  set %winner $gettok(%players,1,32)
  msg %chan 10 $gettok(%players,1,32) has won the game with %lifes lives remaining, earning 25 coins.
coins %winner 25
  ignore -r %winner
  getinfo %players
  set %correct %corr
  set %cg $calc(%cg + %correct)
  set %wg $calc(3 - %lifes)
  inc %mgw
  makedata %players
  end
}
alias -l end {
  timers off
  ignore -r
  unset %players %ongoing %turn %tplayer %multi %playing %ai %life %lifes %m %hilo %o %corr
  set %game over
}

alias -l continuegame {
  if ( %game == $null ) {
    inc %turn
    if ( %turn > %playing ) {
      set %turn 1
      ignoreall
    }
    set %tplayer $gettok(%players,%turn,32)
    msg %chan 10 Its %tplayer 's turn to continue. They may choose to go !high or go !low .
    ignore -r %tplayer
    timer 1 20 gone
    aiornot %tplayer
  }
}

alias -l getnewcard {
  if ( $numtok(%cards,32) == 0 ) {  shuffle }
  set %oldcard %newcard
  set %total $numtok(%cards,46)
  set %x $rand(1,%total)
  set %newcard $gettok(%cards,%x,46)
  %cards = $deltok(%cards,%x,46)
}
alias -l getai {
  var %i = 1
  while ( %i <= 3 ) {
    set %ai $gettok(%AInames,%i,32)
    set %players %players %ai
    inc %i
  }
  set %players $gettok(%players,1- $+ %playing $+ ,32)
  msg %chan 9 AI Player(s) have joined the game.
}
on *:TEXT:!join*:#: {
  if ( %playing != $null ) && ( %joining == on ) {
    if ( $nick isin %players ) { notice $nick You are already playing. }
    elseif ( $istok(%AInames,$nick,32) ) { notice $nick You cannot use that nickname. }
    else {
      getinfo $nick
      inc %mgp
      makedata $nick
      msg %chan 3 $nick has joined the game.
      set %players %players $nick
      if ( $numtok(%players,32) == %playing ) {
        msg %chan 13 The game may be started now.
        set %joining off
        timers off
        start
} } } }

alias -l timeup {
  msg %chan 10 Time is up!
  if ( $numtok(%players,32) == 0 ) {
    msg %chan 10 Nobody has joined. Game is turning off.
    unset %playing
    unset %multi
    end
  }
  else {
    getai
    set %joining off
    start
  }
}

alias -l start {
  set %turn 1
  set %tplayer $gettok(%players,1,32)
  set %lifes $left(3.3.3.3, $+ $calc(2 * %playing - 1))
  set %corr $replace(%lifes,3,0)
  set %total $numtok(%cards,46)
  set %x $rand(1,%total)
  set %oldcard $gettok(%cards,%x,46)
  %cards = $deltok(%cards,%x,46)
  set %newcard %oldcard
  msg %chan 4,0 $+ %oldcard 4,010 has been chosen! 12 cards remaining.
  msg %chan 6 Its %tplayer 's turn to start the game. They may choose to go !high or go !low .
  timer 1 20 gone
}

alias -l gone {
  msg %chan 4 %tplayer ran out of time to make a choice and loses a life.
  ignoreall
  %life = $gettok(%lifes,%turn,46)
  set %life $calc(%life - 1)
  set %lifes $deltok(%lifes,%turn,46)
  set %lifes $instok(%lifes,%life,%turn,46)
  showlifes
  getout
}
alias -l ignoreall {
  var %pq = 1
  while ( %pq <= %playing ) {
    if ( $1 == $null ) { ignore $gettok(%players,%pq,32) }
    else { ignore -r $gettok(%players,%pq,32) }
    inc %pq
  }
}

alias getinfo {
  if ( $istok(%AInames,$1,32) ) { return }
  elseif (!$read(hilo.txt,w,* $+ $1 $+ * ) ) { write hilo.txt $1 0 0 0 0 0 0 | getinfo $1 }
  set %info $read(hilo.txt,w,* $+ $1 $+ * )
set %in $gettok(%info,1,32)
  set %mgp $gettok(%info,2,32)
  set %mgw $gettok(%info,3,32)
  set %cg $gettok(%info,4,32)
  set %wg $gettok(%info,5,32)
  set %sgp $gettok(%info,6,32)
  set %hs $gettok(%info,7,32)
}

alias -l makedata {
  if ( $istok(%AInames,$1,32) ) { return }
  set %todel $read(hilo.txt,w,* $+ $1 $+ * )
  set %no $readn $+
  write -dl $+ %no hilo.txt
  write hilo.txt $1 %mgp %mgw %cg %wg %sgp %hs

}

alias -l coins {
if ( $istok(%AInames,$1,32) ) { return }
  elseif ($read(coins.txt,w,* $+ $1 $+ *)) {
    set %n $readn $+
    set %data $read(coins.txt,w,* $+ $1 $+ *)
    set %current $gettok(%data,2,32)
    set %new $calc(%current + $2)
    set %data $replace(%data,%current,%new)
    write -dl $+ %n coins.txt
    write coins.txt %data
  }
  else {
    write coins.txt $1 $2
  }
}

on *:TEXT:!stats*:#: {
  if ( $2 == $null) { return }
  getinfo $2
  msg $chan 6 Hi-Lo Stats for %in :
  msg $chan 10Multiplayer:11 Games Played:6 %mgp 11 Games Won:6 %mgw 11 Guesses (9☑/4☒): 6 %cg $+ / $+ %wg
  msg $chan 10Solo:11 Games Played:6 %sgp 11 Highest Score:6 %hs
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...