Need help with chess game

I need some help with my chess game, it’s been in development for about 3 months now. I’ve challenged myself to not use a SINGLE extension! I’ve run into an issue, where, no matter what I do, none of the pawns say they can take, even though they can. I even switched the “cantake” variable to false to see if that’ll fix it, but nothing changed, can anyone help? (Also, this post is the 4000th post with the “game” tag)

Project Link: https://makecode.com/_FY4Uq1g6Ya1j

3 Likes

i think oh yeah let me call him in @Sofa has made a Chess game maybe he can help

Did Someone Summon me

1 Like

So what I used to do this was to add to my code

// Normal move

            if (dx == 0) {

if (dy == dir && target.type == PieceType.None) valid = true;

else if (fy == startRow && dy == 2 \* dir && target.type == PieceType.None && board\[fx\]\[fy + dir\].type == PieceType.None) valid = true;

            }

// Capture

else if (Math.abs(dx) == 1 && dy == dir) {

if (target.side != Side.None && target.side != p.side) valid = true;

// En Passant check

else if (tx === lastPawnDoubleMoveX && ty === lastPawnDoubleMoveY) valid = true;

Sorry about all the spaces. I also see you cant Select black peices. (unless your adding some code where an Ai can play) So you can sort out your code and I really don’t mind if you add that code that I pasted in from my code. If that doesn’t work just tell me and I’ll give you a rundown.

I haven’t yet made selecting black peices possible, but it will be with player 2!

I’m not using javascript, can you show me how to do this is blocks?

Sorry I’m not good at blocks. When I first did coding I started with JavaScript because I was advanced in code. So sorry. But I can put that code into blocks if you need it.

the Math.abs is the absolute(number) blockthe Piece.Type.None seems to be a enum (the drop-down list) I’m not sure if that’s possible in blocks if and else if are the logic blocks the dy,dir,dx,fy,startRow etc look to be variables the / is the math block with (number) drop-down Menu(/) (number)

You can click the “blocks” button next to the “javascript” button to convert the code to blocks

yeah well not every block has a javascript counter part some only have JavaScript