turf/tiles/green/Click(obj/pieces/red/r, obj/pieces/blue/b)
if(usr.player!=turn) return /*There are 2 players. One has an ID called usr.player and the other player's ID is called !usr.player*/
if(!usr.hold) return /* usr.hold is src of obj/pieces/blue/Click() or red depending on the ID*/
if(get_dist(usr.hold,src)>1) return /*Distance between the piece I'm holding and the source of where I am clicking*/
if((usr.player && usr.hold.y>src.y) | (!usr.player && usr.hold.y<src.y)) return /*Limiting the move from going backwards depending on who's turn it is*/
else if(usr.hold && !usr.mustjump && get_dist(usr.hold,src)>0) // must jump is true if there is a jump available
usr.hold.Move(src)
turn=!turn
world << "Global Turn is [turn]"
else if(usr.hold && usr.mustjump)
usr << "You must jump!"
Edited coding (coding I tried messing with to get results):
turf/tiles/green/Click(obj/pieces/red/r, obj/pieces/blue/b) //original coding
if(usr.player!=turn) return // if your player ID does not equal the turn number(1 or 0), its not your turn
if(!usr.hold) return // if you are not holding a piece, you can't move
if(usr.player)
for(b in get_step(usr.hold,get_dir(usr.hold,src))) // for as long as there's a piece in the tile where your piece is moving to
if(get_dist(usr.hold,src)==1) return // if the distance is 1, if its right by you, then do nothing
if(get_dist(usr.hold,src)>1) // if the distance between your figure and where you want to go is greater than 1 tile away
for(var/obj/pieces/p in get_step(usr.hold,get_dir(usr.hold,src))) // if there is a blue piece in the tile northwest, jump over it
del p
usr.hold.Move(src)
turn=!turn
usr.mustjump=1
for(var/obj/pieces/p in oview(1,/obj/pieces/red))
if(istype(p,/obj/pieces/red))
world << "You must jump"
return
if((usr.player && usr.hold.y>src.y) | (!usr.player && usr.hold.y<src.y)) return
else if(usr.hold && !usr.mustjump && get_dist(usr.hold,src)>0)
usr.hold.Move(src)
turn=!turn
world << "Global Turn is [turn]"
else if(usr.hold && usr.mustjump)
usr << "You must jump!"
Problem description: I am making a checkers game for DM practice. But I am stuck here! I am trying to do these:
1)Make it so my piece jumps over enemy pieces
2)Make it so my piece must jump over other piece when its time. Alert and cancel out any other jump.
3)Make so it won't jump 2 tiles in another direction
4)When locked pieces at the end of both sides, you can move
5)If pieces block the jump, the piece can move elsewhere
But I can't figure out how to do it. For one thing I can't figure out how to separate each individual pieces. If I wanted to make it so when 2 pieces are near each other to make the piece jump over another, I don't know how to do it.
Note: the above isn't intended to be used, it wont work. It is only meant to show an example to what I am talking about.