Dim sideLength As Integer
Sub changeX(amount As Integer)
Sub changey(amount As Integer)
Sub increaseUsedCount(amount As Integer)
Sub changeX(amount As Integer)
If amount > 0 And amount < sideLength Then
Sub changey(amount As Integer)
If amount > 0 And amount < sideLength Then
Dim bandits As New List(Of coordinate)
Dim treasures As New List(Of treasure)
Dim placeholders As New List(Of coordinate)
Dim startnumberoftreasure As Integer
Dim startnumberofbandits As Integer
Dim movecount As Integer = 0
Console.WriteLine("what Do you want the sidelength Of your grid To be")
sideLength = Console.ReadLine
Console.WriteLine("Too big")
ElseIf sideLength < 6 Then
Console.WriteLine("Too small")
Console.WriteLine("How many bandits would you like")
startnumberofbandits = Console.ReadLine
If startnumberofbandits > sideLength Then
Console.WriteLine("Too many")
ElseIf startnumberofbandits < 5 Then
Console.WriteLine("Too few")
Console.WriteLine("how many treasure chests would you like")
startnumberoftreasure = Console.ReadLine
If startnumberoftreasure > sideLength * 2 Then
Console.WriteLine("Too many")
ElseIf startnumberoftreasure < sideLength Then
Console.WriteLine("Too few")
Dim Validchoice As Boolean = False
While Validchoice = False
Console.WriteLine("Welcome To Treasure Hunt! press 'p' to play and 'q' to quit")
userinput = Console.ReadLine
Console.WriteLine("You are continueing to the GAME")
Console.WriteLine("Exiting")
player.y = sideLength - 1
For i = 0 To startnumberofbandits + startnumberoftreasure - 1
Dim duplicate As Boolean = True
x = CInt(Math.Floor((sideLength - 1 - 0 + 1) * Rnd())) + 0
y = CInt(Math.Floor((sideLength - 1 - 0 + 1) * Rnd())) + 0
duplicate = checkDuplicate(x, y)
Function checkDuplicate(x As Integer, y As Integer) As Boolean
If x = player.x And y = player.y Then
For Each coord In placeholders
If coord.x = x And coord.y = y Then
For i = 0 To startnumberoftreasure - 1
coord.x = placeholders(i).x
coord.y = placeholders(i).y
For i = startnumberoftreasure To startnumberofbandits +
startnumberoftreasure - 1
coord.x = placeholders(i).x
coord.y = placeholders(i).y
Console.WriteLine("You have " + Convert.ToString(score) + " golden coins")
Console.WriteLine("You have made " + Convert.ToString(movecount) + " Moves")
Console.WriteLine("There are " + Convert.ToString(treasureCount()) + " Treasure chests")
Console.WriteLine("There are " + Convert.ToString(banditCount()) + " Bandits")
Console.WriteLine("Please enter Up or Down in the form u or d")
Dim verticleDir As String = Console.ReadLine()
Console.WriteLine("Please enter the number of spaces you would like to move in the given direction")
Dim verticleDis As Integer = Convert.ToInt32(Console.ReadLine())
If verticleDir = "u" Then
player.changey(verticleDis)
ElseIf verticleDir = "d" Then
player.changey(-verticleDis)
Console.WriteLine("Invalid Request")
Console.WriteLine("Please enter Left or Right in the form l or r")
Dim horizontalDir As String = Console.ReadLine()
Console.WriteLine("Please enter the number of spaces you would like to move in the given direction")
Dim horizontalDis As Integer = Convert.ToInt32(Console.ReadLine())
If horizontalDir = "l" Then
player.changeX(-horizontalDis)
ElseIf horizontalDir = "r" Then
player.changeX(horizontalDis)
Console.WriteLine("Invalid request")
movecount = movecount + 1
If isbandit(player.x, player.y) Then
If checkTreasure(player.x, player.y) Then
Console.WriteLine("You win well done :-)")
Function isbandit(x As Integer, y As Integer) As Boolean
For Each coord In bandits
If coord.x = x And coord.y = y Then
Console.WriteLine("You were ambushed by a bandit :-(")
Function istreasure(x As Integer, y As Integer) As Boolean
For Each coord In treasures
If coord.x = x And coord.y = y Then
Function getTreasure(x As Integer, y As Integer) As treasure
For Each coord In treasures
If coord.x = x And coord.y = y Then
Function checkTreasure(x As Integer, y As Integer) As Boolean
For Each coord In treasures
If coord.x = x And coord.y = y Then
If coord.usedcount >= 2 Then
treasures.Remove(getTreasure(x, y))
Dim newBandit As coordinate
Console.WriteLine(Convert.ToString(coord.usedcount))
coord.increaseUsedCount(1)
Console.WriteLine(Convert.ToString(coord.usedcount))
For y = 0 To sideLength - 1
For x = 0 To sideLength - 1
If y = player.y And x = player.x Then
ElseIf istreasure(x, y) Then
ElseIf isbandit(x, y) Then
Function treasureCount() As Integer
For Each treasure In treasures
Function banditCount() As Integer
For Each coordinate In bandits