Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

kewrchess_v2 source realm

Variables 2

var ChallengeWindowSeconds

1var ChallengeWindowSeconds int64 = 180 // 3-minute challenge window for settlement proposals
source

Timeout duration (seconds) for challenge proposals and turn timeouts

var TurnTimeoutSeconds

1var TurnTimeoutSeconds int64 = 120 // 2-minute move timeout when opponent is AFK (Abandonment)
source

Functions 45

func AcceptDraw

crossing Action
1func AcceptDraw(cur realm, gameID int) error
source

AcceptDraw accepts a draw offer from the opponent

func ClaimTimeout

crossing Action
1func ClaimTimeout(cur realm, gameID int) error
source

ClaimTimeout allows the challenger to win the game after the opponent goes AFK/rage quits and turnDeadline has passed without a response move from the opponent.

func ConfirmSettlement

crossing Action
1func ConfirmSettlement(cur realm, gameID int) error
source

ConfirmSettlement allows opponent to immediately approve final result without waiting for challenge window

func CreateGame

crossing Action
1func CreateGame(cur realm, opponent address) error
source

CreateGame creates a new direct game challenge

func DeclineDraw

crossing Action
1func DeclineDraw(cur realm, gameID int) error
source

DeclineDraw declines a draw offer from the opponent

func DisputeSettlement

crossing Action
1func DisputeSettlement(cur realm, gameID int) error
source

DisputeSettlement allows opponent to dispute a fraudulent settlement proposal

func FinalizeSettlement

crossing Action
1func FinalizeSettlement(cur realm, gameID int) error
source

FinalizeSettlement officially finalizes the game after the challenge period has passed

func GetActiveGameForPlayer

Action
1func GetActiveGameForPlayer(addr address) int
source

GetActiveGameForPlayer searches for the latest active game ("PLAYING") for a given address. Returns -1 if no active game found.

func GetBoard

Action
1func GetBoard(gameID int) [8][8]string
source

GetBoard returns the 8x8 board for a given game ID

func GetChallengeDeadline

Action
1func GetChallengeDeadline(gameID int) int64
source

GetChallengeDeadline returns the deadline unix timestamp for challenging settlement

func GetQueueCount

Action
1func GetQueueCount() int
source

GetQueueCount returns the number of players waiting in the matchmaking queue

func GetTurnDeadline

Action
1func GetTurnDeadline(gameID int) int64
source

GetTurnDeadline returns the deadline unix timestamp for turn timeout

func IsInQueue

Action
1func IsInQueue(addr address) bool
source

IsInQueue checks if an address is currently waiting in the matchmaking queue

func IsWhiteTurn

Action
1func IsWhiteTurn(gameID int) bool
source

IsWhiteTurn returns whether it is White's turn for a given game ID

func JoinQueue

crossing Action
1func JoinQueue(cur realm) error
source

JoinQueue registers a player into the on-chain matchmaking queue. If the queue is empty, the player is added to the queue. If another player is already waiting, both players are immediately matched into a new game.

func LeaveQueue

crossing Action
1func LeaveQueue(cur realm) error
source

LeaveQueue cancels and removes a player from the on-chain matchmaking queue

func MakeMove

crossing Action
1func MakeMove(cur realm, gameID int, fromRow, fromCol, toRow, toCol int) error
source

MakeMove moves a piece (defaults to Queen on promotion)

func MakeMovePromote

crossing Action
1func MakeMovePromote(cur realm, gameID int, fromRow, fromCol, toRow, toCol int, promoPiece string) error
source

MakeMovePromote moves a piece with a specified promotion piece (Q, R, B, N)

func OfferDraw

crossing Action
1func OfferDraw(cur realm, gameID int) error
source

OfferDraw offers a draw to the opponent

func ProposeSettlement

crossing Action
1func ProposeSettlement(cur realm, gameID int, movesUCI string) error
source

ProposeSettlement submits a victory claim for off-chain chess results. Prevents fraudulent opponent moves: proposal opens a challenge period. Opponent can confirm immediately (ConfirmSettlement), or dispute if cheated (DisputeSettlement). If opponent does not respond, winner can finalize after ChallengeWindowSeconds expires. ProposeSettlement submits a victory claim for off-chain chess results. Prevents fraudulent opponent moves: proposal opens a challenge period. Opponent can confirm immediately (ConfirmSettlement), or dispute if cheated (DisputeSettlement). If opponent does not respond, winner can finalize after ChallengeWindowSeconds expires.

func Resign

crossing Action
1func Resign(cur realm, gameID int) error
source

Resign resigns the game for the calling player

func SettleGame

crossing Action
1func SettleGame(cur realm, gameID int, movesUCI string) error
source

SettleGame proposes settlement and finalizes immediately if challenge window is 0

func StartTurnTimer

crossing Action
1func StartTurnTimer(cur realm, gameID int, currentMovesUCI string) error
source

StartTurnTimer is initiated when opponent goes AFK or closes browser (Rage Quit) during an off-chain game. Player submits current move history (currentMovesUCI). Smart contract validates the board and ensures it is the OPPONENT'S TURN.

func NewGame

Action
1func NewGame(id int, white, black address) *Game
source

NewGame initializes a new game with the standard chess starting layout

Types 1

type Game

struct
 1type Game struct {
 2	id            int
 3	white         address              // Wallet address of White player
 4	black         address              // Wallet address of Black player
 5	board         chess.Board          // 8x8 chess board from package chess
 6	isWhiteTurn   bool                 // True = White's turn, False = Black's turn
 7	status        string               // "PLAYING", "WHITE_WON", "BLACK_WON", "DRAW"
 8	castling      chess.CastlingRights // Castling rights for White & Black
 9	enPassantCol  int                  // Pawn column vulnerable to en passant (-1 if none)
10	drawOfferedBy address              // Address of player offering a draw ("" if none)
11	resignedBy    address              // Address of player who resigned ("" if none)
12	settledBy     address              // Address of player who recorded final settlement on blockchain ("" if not yet)
13
14	// Anti-Cheat Protection: Proposal & Challenge Period
15	proposedBy        address // Player submitting victory claim
16	pendingStatus     string  // Proposed settlement status ("WHITE_WON", "BLACK_WON", "DRAW")
17	challengeDeadline int64   // Unix timestamp deadline for challenging settlement proposal
18
19	// Anti-RageQuit Protection: Timeout & Abandonment
20	turnDeadline     int64   // Unix timestamp deadline for opponent's turn response
21	turnChallengedBy address // Player demanding turn response due to AFK opponent
22}
source

Game represents an on-chain chess game session

Imports 4

Source Files 5