10-02-2020, 10:36 AM
Consider the small file I have attached. The code is as follows:
When you select a site Foo is called.
This is what I expect: Foo will go through all the sites and add a number of discs equal to (var) in each site while increasing (var) by 1 in between each iteration. The result should be that one site has a single disc, one has a 2-stack, one has a 3-stack and one has a 4-stack.
This is what happens: Foo adds 1 disc to each site.
My question is: Why?
Code:
(define "Foo"
(do
(set Var 1)
next:(forEach Site
(sites Board)
(do
(add (to (site)) count:(var) stack:true)
next:(set Var (+ 1 (var)))
)
)
)
)
(game "IterationTest"
(equipment
{
(board (square 2))
(piece "Disc" Each)
}
)
(rules
(play
(move Select (from (sites Board))
(then
"Foo"
)
)
)
(end
(if
(= 2 (next))
(result P1 Win)
)
)
)
)
This is what I expect: Foo will go through all the sites and add a number of discs equal to (var) in each site while increasing (var) by 1 in between each iteration. The result should be that one site has a single disc, one has a 2-stack, one has a 3-stack and one has a 4-stack.
This is what happens: Foo adds 1 disc to each site.
My question is: Why?