Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-instantiate Board on NewBoard #129

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions realm/lobby.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package chess

import (
"bytes"
"math"
"std"
"strconv"
"time"

"gno.land/p/demo/avl"
Expand Down Expand Up @@ -63,8 +65,16 @@ var (
)

// XXX: REMOVE BEFORE PRODUCTION
func LobbyData() ([tcLobbyMax][]lobbyPlayer, avl.Tree) {
return lobby, lobbyPlayer2Game
func LobbyData() string {
var buf bytes.Buffer
for idx, sublob := range lobby {
buf.WriteString("Sublobby " + strconv.Itoa(idx))
for _, player := range sublob {
buf.WriteString("- " + player.player.Address.String())
}
buf.WriteByte('\n')
}
return buf.String()
}

func LobbyJoin(seconds, increment int) {
Expand Down
44 changes: 22 additions & 22 deletions realm/rules.gno
Original file line number Diff line number Diff line change
Expand Up @@ -509,28 +509,28 @@ type Board [64]Piece

// NewBoard returns a Board normally set up at the initial position for standard
// chess.
func NewBoard() Board { return defaultBoard }

var defaultBoard = Board{
// row 1
p['R'], p['N'], p['B'], p['Q'],
p['K'], p['B'], p['N'], p['R'],
// row 2
p['P'], p['P'], p['P'], p['P'],
p['P'], p['P'], p['P'], p['P'],

// rows 3, 4, 5, 6
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,

// row 7
p['p'], p['p'], p['p'], p['p'],
p['p'], p['p'], p['p'], p['p'],
// row 8
p['r'], p['n'], p['b'], p['q'],
p['k'], p['b'], p['n'], p['r'],
func NewBoard() Board {
return Board{
// row 1
p['R'], p['N'], p['B'], p['Q'],
p['K'], p['B'], p['N'], p['R'],
// row 2
p['P'], p['P'], p['P'], p['P'],
p['P'], p['P'], p['P'], p['P'],

// rows 3, 4, 5, 6
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,

// row 7
p['p'], p['p'], p['p'], p['p'],
p['p'], p['p'], p['p'], p['p'],
// row 8
p['r'], p['n'], p['b'], p['q'],
p['k'], p['b'], p['n'], p['r'],
}
}

func (b Board) findPiece(pWant Piece) Square {
Expand Down