Saturday, November 6, 2010

Trying to get SyntaxHighligter working


def readConsole(){
println("Enter position to move from and to in \"[A-H][1-8] [A-H][1-8]\" format:")
val positionParser = "([A-H])([1-8]) ([A-H])([1-8])".r
val s = Console.readLine;

s.toUpperCase match {
// check user entered position in (Col1, Row1, Col2, Row2) format
case positionParser(cy1, cx1, cy2, cx2) => {
print("You entered to move from ")
printf("Col:%s Row:%s to Col:%s Row:%s", cy1, cx1, cy2, cx2)
println()

// convert user entered X values to int
val x1 = cx1.toInt
val x2 = cx2.toInt

// lookup the user entered values for Y and find their respective position in colConversionArray
val y1 = colConversionArray.indexOf(cy1)+1
val y2 = colConversionArray.indexOf(cy2)+1

makeMove(x1, y1, x2, y2)
}
// Catch all non-matching entries
case _ => println ("Incorrect position, try again")
}
}