Simple board game: Goose (PicWin)

By SykO on Feb 18, 2015

I was looking around my files and found this old game I created. It is a simple board game "Goose". You can play with up to 14 other people, the objective of the game is simple: just get to the 63 box. There are some boxes that may push you closer to the goal or further away from it. The game uses notice as communication, so you and the other players must be connected to a server. The current player rolling the dice is colored red.

How to use:
To open the game window use /goose
To invite other to the game use /gooseInv

Note: The game is not quite finished. Once a player gets to 63 the game continues and it just does not end, so to start over one must close the window and restart the game. Graphics are not the best. Dice at the beginning of the game is gray.

/*
Goose v0.1 Created by SykO

This is an open source code, you may copy, modify and redistribute the source as you please.
Comments, suggestions, or questions? Send an email at syko-c5@live.com
*/

alias -l COO16 return 100 132 115 132 129 132 143 132 157 132 172 132 185 132 199 132 213 132 232 132 232 108 232 88 232 69 232 50 232 31 232 12
alias -l COO32 return 204 12 184 12 164 12 144 12 126 12 106 12 88 12 70 12 50 12 30 12 13 12 13 36 13 56 13 76 13 94 13 113
alias -l COO46 return 44 113 62 113 80 113 100 113 120 113 140 113 158 113 176 113 194 113 213 113 213 90 213 70 213 51 213 32
alias -l COO63 return 184 32 164 32 144 32 126 32 106 32 88 32 70 32 50 32 32 32 32 56 32 76 32 94 62 94 80 94 100 94 120 94 160 70
alias -l P1C return 0
alias -l P2C return 8323072
alias -l P3C return 37632
alias -l P4C return 255
alias -l P5C return 127
alias -l P6C return 10223772
alias -l P7C return 32764
alias -l P8C return 65535
alias -l P9C return 64512
alias -l P10C return 9671424
alias -l P11C return 16776960
alias -l P12C return 16515072
alias -l P13C return 16711935
alias -l P14C return 8355711
alias -l P15C return 13816530
alias Goose {
  if ($window(@Goose)) {
    window -a @Goose
  }
  else {
    if (!$hget(Goose)) {
      hmake Goose 5
      hadd Goose Player1 $me
      hadd Goose Player1Pos 0
      hadd Goose Player2Pos 0
      hadd Goose Player3Pos 0
      hadd Goose Player4Pos 0
      hadd Goose Player5Pos 0
      hadd Goose Player6Pos 0
      hadd Goose Player7Pos 0
      hadd Goose Player8Pos 0
      hadd Goose Player9Pos 0
      hadd Goose Player10Pos 0
      hadd Goose Player11Pos 0
      hadd Goose Player12Pos 0
      hadd Goose Player13Pos 0
      hadd Goose Player14Pos 0
      hadd Goose Player15Pos 0
      hadd Goose Turn 1
      hadd Goose Host $true
    }
    window -pkCBfD +l @Goose 0 0 250 200
    titlebar @Goose v0.1 Created by SykO
    window -phBf @GooseBuf 0 0 250 200
    drawrect -rf @GooseBuf 16777215 1 0 0 250 200
    drawrect -rd @GooseBuf 0 1 5 5 240 140
    drawline -r @GooseBuf 0 1 5 125 230 125 235 120 240 125 245 125
    drawfill -r @GooseBuf 16751360 0 6 126
    drawtext -ro @GooseBuf 0 tahoma 9 20 130 Start
    drawline -r @GooseBuf 0 1 75 125 90 135 75 145
    drawrect -r @GooseBuf 0 1 110 125 15 20 124 125 15 20 138 125 15 20 152 125 15 20 166 125 15 20 180 125 16 20 195 125 16 20 210 125 16 20
    var %n = 1
    while (%n <= 10) {
      drawtext -ro @GooseBuf 0 tahoma 9 $calc(87 + (%n * 14)) 130 %n 
      inc %n
    }
    drawline -r @GooseBuf 0 1 225 5 225 10 220 15 225 20 225 125
    drawfill -r @GooseBuf 15571712 0 226 6
    drawrect -r @GooseBuf 0 1 225 25 20 20 225 44 20 20 225 63 20 20 225 82 20 20
    while (%n <= 16) {
      drawtext -ro @GooseBuf 0 tahoma 9 228 $calc(104 - ((16 - %n) * 19)) $calc(27 - %n)
      inc %n
    }
    drawline -r @GooseBuf 0 1 5 25 10 25 15 30 20 25 225 25
    drawfill -r @GooseBuf 14392064 0 6 20
    drawrect -r @GooseBuf 0 1 25 5 20 21 44 5 20 21 63 5 20 21 82 5 20 21 101 5 20 21 120 5 20 21 139 5 20 21 158 5 20 21 177 5 20 21
    while (%n <= 27) {
      drawtext -ro @GooseBuf 0 tahoma 9 $calc(9 + ((27 - %n) * 19)) 10 %n
      inc %n
    }
    drawline -r @GooseBuf 0 1 25 25 25 110 30 115 25 120 25 125
    drawfill -r @GooseBuf 13212416 0 6 26
    drawrect -r @GooseBuf 0 1 5 87 21 20 5 68 21 20 5 49 21 20
    while (%n <= 32) {
      drawtext -ro @GooseBuf 0 tahoma 9 9 $calc(15 + ((%n - 27) * 19)) %n
      inc %n
    }
    drawline -r @GooseBuf 0 1 25 106 210 106 215 101 220 106 225 106
    drawfill -r @GooseBuf 12032768 0 46 107
    drawrect -r @GooseBuf 0 1 187 106 20 20 168 106 20 20 149 106 20 20 130 106 20 20 111 106 20 20 92 106 20 20 73 106 20 20 54 106 20 20
    while (%n <= 42) {
      drawtext -ro @GooseBuf 0 tahoma 9 $calc(19 + (%n - 32) * 19) 111 %n
      inc %n
    }
    drawline -r @GooseBuf 0 1 206 106 206 40 201 35 206 30 206 25
    drawfill -r @GooseBuf 10853120 0 220 27
    drawrect -r @GooseBuf 0 1 206 44 20 20 206 63 20 20
    while (%n <= 46) {
      drawtext -ro @GooseBuf 0 tahoma 9 208 $calc(106 - ((%n - 42) * 19)) %n
      inc %n
    }
    drawline -r @GooseBuf 0 1 25 44 30 44 35 49 40 44 206 44
    drawfill -r @GooseBuf 9673472 0 30 30
    drawrect -r @GooseBuf 0 1 44 25 20 20 63 25 20 20 82 25 20 20 101 25 20 20 120 25 20 20 139 25 20 20 158 25 20 20
    while (%n <= 55) {
      drawtext -ro @GooseBuf 0 tahoma 9 $calc(28 + ((55 - %n) * 19)) 30 %n
      inc %n
    }
    drawline -r @GooseBuf 0 1 44 45 44 92 49 97 44 102 44 107
    drawfill -r @GooseBuf 8493824 0 30 60
    drawrect -r @GooseBuf 0 1 25 68 20 20
    drawtext -ro @GooseBuf 0 tahoma 9 28 53 56
    drawtext -ro @GooseBuf 0 tahoma 9 28 72 57
    drawtext -ro @GooseBuf 0 tahoma 9 28 91 58
    drawline -r @GooseBuf 0 1 44 87 115 87 120 82 125 87 130 87 130 92 135 97 130 102 130 107
    drawfill -r @GooseBuf 7314176 0 60 88
    drawrect -r @GooseBuf 0 1 73 87 20 20 92 87 20 20
    drawtext -ro @GooseBuf 0 tahoma 9 57 91 59
    drawtext -ro @GooseBuf 0 tahoma 9 76 91 60
    drawtext -ro @GooseBuf 0 tahoma 9 95 91 61
    drawtext -ro @GooseBuf 0 tahoma 9 114 91 62
    drawline -r @GooseBuf 0 1 111 44 111 87
    drawfill -r @GooseBuf 6134528 0 115 50
    drawtext -ro @GooseBuf 0 tahoma 50 130 44 63
    drawrect -rf @GooseBuf 11842740 1 62 50 32 32
    drawrect -r @GooseBuf 0 1 62 50 32 32
    drawrect -rfe @GooseBuf $P1C 1 5 152 6 6
    drawrect -rfe @GooseBuf $P2C 1 5 162 6 6
    drawrect -rfe @GooseBuf $P3C 1 5 172 6 6
    drawrect -rfe @GooseBuf $P4C 1 5 182 6 6
    drawrect -rfe @GooseBuf $P5C 1 5 192 6 6
    drawrect -rfe @GooseBuf $P6C 1 90 152 6 6
    drawrect -rfe @GooseBuf $P7C 1 90 162 6 6
    drawrect -rfe @GooseBuf $P8C 1 90 172 6 6
    drawrect -rfe @GooseBuf $P9C 1 90 182 6 6
    drawrect -rfe @GooseBuf $P10C 1 90 192 6 6
    drawrect -rfe @GooseBuf $P11C 1 175 152 6 6
    drawrect -rfe @GooseBuf $P12C 1 175 162 6 6
    drawrect -rfe @GooseBuf $P13C 1 175 172 6 6
    drawrect -rfe @GooseBuf $P14C 1 175 182 6 6
    drawrect -rfe @GooseBuf $P15C 1 175 192 6 6
    drawPlayers
  }
}
alias -l drawPlayers {
  drawcopy -n @GooseBuf 0 0 250 200 @Goose 0 0
  var %p = 15
  var %t = $hget(Goose,Turn)
  var %x = 182
  var %y = 190
  var %c16 = $COO16
  var %c32 = $COO32
  var %c46 = $COO46
  var %c63 = $COO63
  while (%p) {
    var %n = $hget(Goose,$+(Player,%p))
    if (%n) {
      drawtext -rn @Goose $iif(%t == %p,255,0) tahoma 8 %x %y %n
      if ($hget(Goose,$+(Player,%p,Pos))) {
        var %l = $v1
        var %d = drawrect -rfen @Goose $P [ $+ [ $+(%p,C) ] ] 1
        if (%l <= 16) {
          var %xy = $gettok(%c16,$+($calc(%l * 2 - 1),-,$calc(%l * 2)),32)
        }
        elseif (%l <= 32) {
          dec %l 16
          var %xy = $gettok(%c32,$+($calc(%l * 2 - 1),-,$calc(%l * 2)),32)
        }
        elseif (%l <= 46) {
          dec %l 32
          var %xy = $gettok(%c46,$+($calc(%l * 2 - 1),-,$calc(%l * 2)),32)
        }
        elseif (%l <= 63) {
          dec %l 46
          var %xy = $gettok(%c63,$+($calc(%l * 2 - 1),-,$calc(%l * 2)),32)
        }
        if ($numtok(%xy,32) == 2) {
          drawrect -rfen @Goose $P [ $+ [ $+(%p,C) ] ] 1 %xy 6 6
        }
      }
    }
    dec %p
    dec %y 10
    if ($calc(%p % 5) == 0) {
      dec %x 85
      %y = 190
    }
  }
  drawdot @Goose
}
;
on *:close:@Goose: {
  if ($hget(Goose,Host)) {
    noticePlayers Part $me
  }
  else {
    .notice $hget(Goose,HostNick) 0100011101101111011011110111001101100101 Part
  }
  hfree Goose
  window -c @GooseBuf
}
alias -l checkBox {
  var %a = $1
  if (%a == 5) { %a = 9 }
  elseif (%a == 6) { %a = 12 }
  elseif (%a == 9) { %a = 14 }
  elseif (%a == 12) { %a = 6 }
  elseif (%a == 14) { %a = 18 }
  elseif (%a == 18) { %a = 23 }
  elseif (%a == 23) { %a = 27 }
  elseif (%a == 26) { %a = 53 }
  elseif (%a == 27) { %a = 32 }
  elseif (%a == 32) { %a = 36 }
  elseif (%a == 36) { %a = 41 }
  elseif (%a == 41) { %a = 45 }
  elseif (%a == 45) { %a = 50 }
  elseif (%a == 53) { %a = 26 }
  elseif (%a == 54) { %a = 59 }
  elseif (%a == 58) { %a = 0 }
  elseif (%a == 59) { %a = 63 }
  elseif (%a > 63) { %a = $calc(63 - (%a - 63)) }
  return %a
}
alias -l nextTurn {
  var %c = 1
  var %r = 0
  var %p = $hget(Goose,Turn)
  var %t = %p
  while (%c) {
    inc %p
    if ($hget(Goose,$+(Player,%p))) {
      if ($hget(Goose,$+(Player,%p,Pos)) != 63) {
        hadd Goose Turn %p
        dec %c
      }
    }
    elseif (%p == 15) {
      dec %p 15
    }
    inc %r
    if (%r > 15) {
      dec %c
      %p = %t
    }
  }
  if (%t == %p) && ($hget(Goose,$+(Player,%p,Pos)) == 63) {
    hadd Goose Turn 0
  }
}
alias -l addPlayer {
  var %p = 1
  var %t = 1
  while (%t) {
    if (!$hget(Goose,$+(Player,%p))) {
      hadd Goose $+(Player,%P) $1
      dec %t
    }
    inc %p
    if (%p > 15) {
      dec %t
    }
  }
}
alias -l num4Nick {
  return  $right($hfind(Goose,$1,1).data,-6)
}
alias -l removePlayer {
  var %p = $num4Nick($1)
  hdel Goose $+(Player,%p)
  hadd Goose $+(Player,%p,Pos) 0
}
menu @Goose {
  sclick: {
    var %x = $mouse.x
    var %y = $mouse.y
    if ($inrect(%x,%y,62,50,32,32)) && (!$hget(Goose,RollAni)) {
      var %t = $hget(Goose,Turn)
      if ($hget(Goose,$+(Player,%t)) == $me) {
        roll 1 %t
      }
    }
  }
}
alias -l roll {
  if ($hget(Goose,Host)) {
    .noticePlayers Rolling $me
    hadd Goose RollAni 1
    rollAni
  }
  else {
    .notice $hget(Goose,HostNick) 0100011101101111011011110111001101100101 Rolling
  }
  .timerEndRollAni 1 3 endRollAni
}
alias -l rollAni {
  drawDice $rand(1,6)
  drawdot @Goose
  if ($hget(Goose,RollAni)) {
    .timerGooseRoll -m 1 100 rollAni
  }
}
alias -l drawDice {
  drawrect -rfn @Goose 11842740 1 62 50 32 32
  drawrect -rn @Goose 0 1 62 50 32 32
  drawtext -ron @Goose 0 tahoma 25 70 51 $1
}
alias -l endRollAni {
  if ($hget(Goose,Host)) {
    var %r = $rand(1,6)
    .noticePlayers Rolled $me %r
    hadd Goose RollAni 0
    .timer -m 1 200 drawDice %r
    .timer -m 1 200 drawdot @Goose
    var %n = $num4Nick($me)
    var %p = $hget(Goose,$+(Player,%n,Pos))
    inc %p %r
    hadd Goose $+(Player,%n,Pos) $checkBox(%p)
    noticePlayers PlayersPos $hget(Goose,Player1Pos) $hget(Goose,Player2Pos) $hget(Goose,Player3Pos) $hget(Goose,Player4Pos) $hget(Goose,Player5Pos) $hget(Goose,Player6Pos) $&
    $hget(Goose,Player7Pos) $hget(Goose,Player8Pos) $hget(Goose,Player9Pos) $hget(Goose,Player10Pos) $hget(Goose,Player11Pos) $hget(Goose,Player12Pos) $hget(Goose,Player13Pos) $&
    $hget(Goose,Player14Pos) $hget(Goose,Player15Pos)
    nextTurn
    noticePlayers Turn $hget(Goose,Turn)
    drawPlayers
  }
  else {
    .notice $hget(Goose,HostNick) 0100011101101111011011110111001101100101 Rolled $rand(1,6)
  }
}
alias GooseInv {
  if ($hget(Goose,Host)) {
    .notice $1 0100011101101111011011110111001101100101 Invite
  }
}
on ^!*:notice:0100011101101111011011110111001101100101 *:*: {
  if ($2 == Invite) {
    if ($hget(Goose)) {
      .notice $nick 0100011101101111011011110111001101100101 InGame
    }
    else {
      .timer 1 0 ask1 $nick
    }
  }
  elseif ($2 == InGame) {
    .timer 1 0 inGame $nick
  }
  elseif ($2 == Joining) {
    var %c = $chr(160)
    addPlayer $nick
    .notice $nick 0100011101101111011011110111001101100101 Join
    noticePlayers Players $iif($hget(Goose,Player1),$v1,%c) $iif($hget(Goose,Player2),$v1,%c) $iif($hget(Goose,Player3),$v1,%c) $&
    $iif($hget(Goose,Player4),$v1,%c) $iif($hget(Goose,Player5),$v1,%c) $iif($hget(Goose,Player6),$v1,%c) $iif($hget(Goose,Player7),$v1,%c) $&
    $iif($hget(Goose,Player8),$v1,%c) $iif($hget(Goose,Player9),$v1,%c) $iif($hget(Goose,Player10),$v1,%c) $iif($hget(Goose,Player11),$v1,%c) $&
    $iif($hget(Goose,Player12),$v1,%c) $iif($hget(Goose,Player13),$v1,%c) $iif($hget(Goose,Player14),$v1,%c) $iif($hget(Goose,Player15),$v1,%c)
    noticePlayers PlayersPos $hget(Goose,Player1Pos) $hget(Goose,Player2Pos) $hget(Goose,Player3Pos) $hget(Goose,Player4Pos) $hget(Goose,Player5Pos) $hget(Goose,Player6Pos) $&
    $hget(Goose,Player7Pos) $hget(Goose,Player8Pos) $hget(Goose,Player9Pos) $hget(Goose,Player10Pos) $hget(Goose,Player11Pos) $hget(Goose,Player12Pos) $hget(Goose,Player13Pos) $&
    $hget(Goose,Player14Pos) $hget(Goose,Player15Pos)
    .notice $nick 0100011101101111011011110111001101100101 Turn $hget(Goose,Turn)
    drawPlayers
  }
  elseif ($2 == NotJoining) {
    .timer 1 0 notJoining $nick
  }
  elseif ($2 == Join) {
    hmake Goose 5
    hadd Goose Host $false
    hadd Goose HostNick $nick
    Goose
  }
  elseif ($2 == Players) {
    var %p = 15
    while (%p) {
      if ($gettok($3-,%p,32) != $chr(160)) {
        hadd Goose $+(Player,%p) $v1
      }
      dec %p
    }
    drawPlayers
  }
  elseif ($2 == PlayersPos) {
    hadd Goose Player1Pos $3
    hadd Goose Player2Pos $4
    hadd Goose Player3Pos $5
    hadd Goose Player4Pos $6
    hadd Goose Player5Pos $7
    hadd Goose Player6Pos $8
    hadd Goose Player7Pos $9
    hadd Goose Player8Pos $10
    hadd Goose Player9Pos $11
    hadd Goose Player10Pos $12
    hadd Goose Player11Pos $13
    hadd Goose Player12Pos $14
    hadd Goose Player13Pos $15
    hadd Goose Player14Pos $16
    hadd Goose Player15Pos $17
    drawPlayers
  }
  elseif ($2 == Turn) {
    hadd Goose Turn $3
    drawPlayers
  }
  elseif ($2 == Part) {
    if ($hget(Goose,Host)) {
      removePlayer $nick
      drawPlayers
      noticePlayers Part $nick
    }
    else {
      if ($hget(Goose,HostNick) == $3) {
        hfree Goose
        window -c @GooseBuff
        window -c @Goose
      }
      else {
        removePlayer $3
        drawPlayers
      }
    }
  }
  elseif ($2 == Rolling) {
    hadd Goose RollAni 1
    rollAni
    if ($hget(Goose,Host)) {
      .noticePlayers Rolling $nick
    }
    else {
      if ($3 == $me) {
        .timerEndRollAni 1 3 endRollAni
      }
    }
  }
  elseif ($2 == Rolled) {
    if ($hget(Goose,Host)) {
      noticePlayers Rolled $nick $3
      var %n = $num4Nick($nick)
      var %p = $hget(Goose,$+(Player,%n,Pos))
      inc %p $3
      hadd Goose $+(Player,%n,Pos) $checkBox(%p)
      noticePlayers PlayersPos $hget(Goose,Player1Pos) $hget(Goose,Player2Pos) $hget(Goose,Player3Pos) $hget(Goose,Player4Pos) $hget(Goose,Player5Pos) $hget(Goose,Player6Pos) $&
      $hget(Goose,Player7Pos) $hget(Goose,Player8Pos) $hget(Goose,Player9Pos) $hget(Goose,Player10Pos) $hget(Goose,Player11Pos) $hget(Goose,Player12Pos) $hget(Goose,Player13Pos) $&
      $hget(Goose,Player14Pos) $hget(Goose,Player15Pos)
      nextTurn
      noticePlayers Turn $hget(Goose,Turn)
      drawPlayers
    }
    hadd Goose RollAni 0
    .timer -m 1 200 drawDice $iif($hget(Goose,Host),$3,$4)
    .timer -m 1 200 drawdot @Goose
  }
  haltdef
}
alias -l ask1 {
  if ($input(Jugar Goose con $1 $+ ?,y)) {
    .notice $1 0100011101101111011011110111001101100101 Joining
  }
  else {
    .notice $1 0100011101101111011011110111001101100101 NotJoining
  }
}
alias -l inGame {
  noop $input($1 is in game!,oi)
}
alias -l notJoining {
  noop $input($1 will not play!,oi)
}
alias -l noticePlayers {
  var %p = 15
  while (%p) {
    if ($hget(Goose,$+(Player,%p))) {
      var %n = $v1
      if (%n != $me) {
        .notice %n 0100011101101111011011110111001101100101 $1-
      }
    }
    dec %p
  }
}

Comments

Sign in to comment.
dma   -  Oct 25, 2015

ok this is the thing you cant do / in mirc

SykO  -  Dec 16, 2015

why not?

Sign in to comment

Wims   -  Feb 22, 2015

So i played with Glowball, noticed some things:
-We have no idea of the rules being applied to the player, we just see the pawns moving on the board, you should perhaps adds some messages to what is happening cause right now it's really just a click game :p
-At the end, Glowball needed a 5 to win, he got a 1 and won anyway,

SykO  -  Feb 22, 2015

Thanks for testing it, I do have plans on finishing it, adding messages, better animations, and maybe a socket connection option. About Glowball winning, he might of landed on box 59 which pushes you to the end, if he had landed on 58 he would have gone back to the start. As I have mention on the original post, some boxes take you closer to the goal, while other take you further away from it.

Sign in to comment

Wims   -  Feb 22, 2015

Awesome Syko! I'd love to try it with you, you should finish it :)

@Hawkee Adding a comment (starting a thread) from my phone didn't work and the UI is very not responsive

Hawkee  -  Feb 24, 2015

@Wims What phone and browser are you using? Do you see part of the page going off the screen?

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.