Skip to content

Instantly share code, notes, and snippets.

@lefthandedgoat
Created June 16, 2013 20:07
Show Gist options
  • Save lefthandedgoat/5793236 to your computer and use it in GitHub Desktop.
Save lefthandedgoat/5793236 to your computer and use it in GitHub Desktop.
Chakra Duel
open canopy
open runner
open Microsoft.FSharp.Reflection
type command =
| Ram
| Dragon
| Rat
| Tiger
| Dog
| Snake
| Ox
let selector command player =
let GetUnionCaseName (x:'a) =
match FSharpValue.GetUnionFields(x, typeof<'a>) with
| case, _ -> case.Name
match player with
| 1 -> "#playerdiv .btn-group.pull-left button[value='" + GetUnionCaseName(command).ToLower() + "']"
| _ -> "#playerdiv .btn-group.pull-right button[value='" + GetUnionCaseName(command).ToLower() + "']"
let play commands =
commands |> List.iter (fun (command1, command2) ->
click (selector command1 1)
click (selector command2 2)
click "img" //cheese hack, the mouse over helper things are messing with clicking the submit button
click "input[type='submit']"
on "http://chakraduel.herokuapp.com/games/level_")
"#playerdiv .opponent" == "Game Over: You Won"
start chrome
context "Chakra Duel"
before (fun _ -> url "http://chakraduel.herokuapp.com/")
"beat level 1" &&& fun _ ->
click "Level 1"
on "http://chakraduel.herokuapp.com/games/level_1?"
[(Ram, Dragon);
(Ram, Ram);
(Ram, Ram);
(Ram, Ram);
(Ram, Ram);
(Ram, Ram);
(Ram, Ram);
(Ram, Ram);]
|> play
"beat level 2" &&& fun _ ->
click "Level 2"
on "http://chakraduel.herokuapp.com/games/level_2?"
//light and heavy wounds at the same time
[(Rat, Rat);
(Tiger, Dragon);
(Dragon, Tiger);
(Dragon, Dog);
(Rat, Rat);
(Tiger, Dragon);
(Dragon, Tiger);
(Dragon, Dog);
(Rat, Rat);
(Tiger, Dragon);
(Dragon, Tiger);
(Dragon, Dog);]
|> play
"beat level 3" &&& fun _ ->
click "Level 3"
on "http://chakraduel.herokuapp.com/games/level_3?"
//double lightening bolt
[(Dog, Dog);
(Tiger, Tiger);
(Tiger, Tiger);
(Dog, Dog);
(Dog, Dog);
(Dog, Dog);
(Tiger, Tiger);
(Tiger, Tiger);
(Dog, Dog);
(Dog, Dog);]
|> play
"beat level 4" &&& fun _ ->
click "Level 4"
on "http://chakraduel.herokuapp.com/games/level_4?"
//double fast lightening bolt
[(Rat, Rat);
(Dog, Dog);
(Dog, Dog);
(Ox, Ox);
//shock + missle
(Ram, Snake);
(Ram, Dog);
(Ram, Snake);
(Ram, Dog);]
|> play
"beat level 5" &&& fun _ ->
click "Level 5"
on "http://chakraduel.herokuapp.com/games/level_5?"
//double fast lightening bolt
[(Rat, Rat);
(Dog, Dog);
(Dog, Dog);
(Ox, Ox);
//ultimate defense x2 staggered
(Ram, Ox);
(Ox, Dog);
(Dog, Dragon);
(Dragon, Rat);
(Rat, Ram);
//heavy wounds
(Rat, Dragon);
(Dragon, Ram);
(Tiger, Dragon);
(Dog, Dragon);]
|> play
run ()
System.Console.ReadKey()
quit ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment