////////////////////////////////////////////////////////////////////////////// // // File : chess_board_reset.skrit // Author(s): mcarp, Brkopac // ////////////////////////////////////////////////////////////////////////////// Property Bool _server_only$ = true; //true is correct, dont change, mcarp property scid white_rook_queen$ doc =" Scid of chess piece"; property scid white_knight_queen$ doc = "Scid of chess piece"; property scid white_bishop_queen$ doc = "Scid of chess piece"; property scid white_queen$ doc = "Scid of chess piece"; property scid white_king$ doc = "Scid of chess piece"; property scid white_bishop_king$ doc = "Scid of chess piece"; property scid white_knight_king$ doc = "Scid of chess piece"; property scid white_rook_king$ doc = "Scid of chess piece"; property scid white_pawn_rook_queen$ doc = "Scid of chess piece"; property scid white_pawn_knight_queen$ doc = "Scid of chess piece"; property scid white_pawn_bishop_queen$ doc = "Scid of chess piece"; property scid white_pawn_queen$ doc = "Scid of chess piece"; property scid white_pawn_king$ doc = "Scid of chess piece"; property scid white_pawn_bishop_king$ doc = "Scid of chess piece"; property scid white_pawn_knight_king$ doc = "Scid of chess piece"; property scid white_pawn_rook_king$ doc = "Scid of chess piece"; property scid black_rook_queen$ doc = "Scid of chess piece"; property scid black_knight_queen$ doc = "Scid of chess piece"; property scid black_bishop_queen$ doc = "Scid of chess piece"; property scid black_queen$ doc = "Scid of chess piece"; property scid black_king$ doc = "Scid of chess piece"; property scid black_bishop_king$ doc = "Scid of chess piece"; property scid black_knight_king$ doc = "Scid of chess piece"; property scid black_rook_king$ doc = "Scid of chess piece"; property scid black_pawn_rook_queen$ doc = "Scid of chess piece"; property scid black_pawn_knight_queen$ doc = "Scid of chess piece"; property scid black_pawn_bishop_queen$ doc = "Scid of chess piece"; property scid black_pawn_queen$ doc = "Scid of chess piece"; property scid black_pawn_king$ doc = "Scid of chess piece"; property scid black_pawn_bishop_king$ doc = "Scid of chess piece"; property scid black_pawn_knight_king$ doc = "Scid of chess piece"; property scid black_pawn_rook_king$ doc = "Scid of chess piece"; property scid sq_a1$ doc = "Scid identifying board square"; property scid sq_b1$ doc = "Scid identifying board square"; property scid sq_c1$ doc = "Scid identifying board square"; property scid sq_d1$ doc = "Scid identifying board square"; property scid sq_e1$ doc = "Scid identifying board square"; property scid sq_f1$ doc = "Scid identifying board square"; property scid sq_g1$ doc = "Scid identifying board square"; property scid sq_h1$ doc = "Scid identifying board square"; property scid sq_a2$ doc = "Scid identifying board square"; property scid sq_b2$ doc = "Scid identifying board square"; property scid sq_c2$ doc = "Scid identifying board square"; property scid sq_d2$ doc = "Scid identifying board square"; property scid sq_e2$ doc = "Scid identifying board square"; property scid sq_f2$ doc = "Scid identifying board square"; property scid sq_g2$ doc = "Scid identifying board square"; property scid sq_h2$ doc = "Scid identifying board square"; property scid sq_a3$ doc = "Scid identifying board square"; property scid sq_b3$ doc = "Scid identifying board square"; property scid sq_c3$ doc = "Scid identifying board square"; property scid sq_d3$ doc = "Scid identifying board square"; property scid sq_e3$ doc = "Scid identifying board square"; property scid sq_f3$ doc = "Scid identifying board square"; property scid sq_g3$ doc = "Scid identifying board square"; property scid sq_h3$ doc = "Scid identifying board square"; property scid sq_a4$ doc = "Scid identifying board square"; property scid sq_b4$ doc = "Scid identifying board square"; property scid sq_c4$ doc = "Scid identifying board square"; property scid sq_d4$ doc = "Scid identifying board square"; property scid sq_e4$ doc = "Scid identifying board square"; property scid sq_f4$ doc = "Scid identifying board square"; property scid sq_g4$ doc = "Scid identifying board square"; property scid sq_h4$ doc = "Scid identifying board square"; property scid sq_a5$ doc = "Scid identifying board square"; property scid sq_b5$ doc = "Scid identifying board square"; property scid sq_c5$ doc = "Scid identifying board square"; property scid sq_d5$ doc = "Scid identifying board square"; property scid sq_e5$ doc = "Scid identifying board square"; property scid sq_f5$ doc = "Scid identifying board square"; property scid sq_g5$ doc = "Scid identifying board square"; property scid sq_h5$ doc = "Scid identifying board square"; property scid sq_a6$ doc = "Scid identifying board square"; property scid sq_b6$ doc = "Scid identifying board square"; property scid sq_c6$ doc = "Scid identifying board square"; property scid sq_d6$ doc = "Scid identifying board square"; property scid sq_e6$ doc = "Scid identifying board square"; property scid sq_f6$ doc = "Scid identifying board square"; property scid sq_g6$ doc = "Scid identifying board square"; property scid sq_h6$ doc = "Scid identifying board square"; property scid sq_a7$ doc = "Scid identifying board square"; property scid sq_b7$ doc = "Scid identifying board square"; property scid sq_c7$ doc = "Scid identifying board square"; property scid sq_d7$ doc = "Scid identifying board square"; property scid sq_e7$ doc = "Scid identifying board square"; property scid sq_f7$ doc = "Scid identifying board square"; property scid sq_g7$ doc = "Scid identifying board square"; property scid sq_h7$ doc = "Scid identifying board square"; property scid sq_a8$ doc = "Scid identifying board square"; property scid sq_b8$ doc = "Scid identifying board square"; property scid sq_c8$ doc = "Scid identifying board square"; property scid sq_d8$ doc = "Scid identifying board square"; property scid sq_e8$ doc = "Scid identifying board square"; property scid sq_f8$ doc = "Scid identifying board square"; property scid sq_g8$ doc = "Scid identifying board square"; property scid sq_h8$ doc = "Scid identifying board square"; property scid registrar_white$ doc = "Scid of white registrar"; property scid registrar_black$ doc = "Scid of black registrar"; property SiegeId board_node$ doc = "Chess board node"; Owner = GoSkritComponent; SiegePos pos$; Goid p_Goid$; Goid m_Owner$; Go m_Actor$; Goid rw_Goid$ = null; //white registrar goid Goid rb_Goid$ = null; //black registrar goid bool rw_active = false; bool rb_active = false; Goid p1_Goid$ = null; //a player goid Goid p2_Goid$ = null; //another player goid Goid t_Goid$ = null; //temp goid scid t_scid$; string p1_screen_name$ = "Nobody"; string p2_screen_name$ = "No one"; eWorldEvent s_msg$; Startup State STARTUP$ { Trigger OnGoHandleMessage$ ( WE_ENTERED_WORLD ) { // Declare the go that this skrit is attachted to m_Owner$ = Owner.Goid; // Switch states SetState ( Wait$ ); return; } } State Wait$ { Event OnEnterState$ { rw_Goid$ = registrar_white$.GetGoid(); rb_Goid$ = registrar_black$.GetGoid(); } Event OnGoHandleMessage$ ( eWorldEvent e$, WorldMessage msg$ ) { /* if ( e$ == WE_REQ_USE ) { SetState( ResetTheBoard$ ); return; } */ if ( e$ == WE_REQ_ACTIVATE ) { t_Goid$ = msg$.GetSendFrom(); report.screenf("t_Goid 0x%08x sendfrom 0x%08x ", makeint( t_Goid$ ), makeint( msg$.GetSendFrom() ) ); if ( t_Goid$ == rw_Goid$) { rw_active$ = true; report.screenf( "reset white active 0x%08x 0x%08x", makeint( t_Goid$ ), makeint( rw_Goid$ ) ); e$ = ""; return; } if ( t_Goid$ == rb_Goid$ ) { rb_active$ = true; report.screenf( "reset black active 0x%08x 0x%08x", makeint( t_Goid$ ), makeint( rb_Goid$ ) ); e$ = ""; return; } if ( ( rw_active == true ) && ( rb_active$ == true ) ) { report.screenf( "reset registered and activated! 0x%08x 0x%08x", makeint( rw_Goid$ ), makeint( rb_Goid$ ) ); SetState( ResetActive$ ); return; } report.screenf( "reset activate message but no action" ); } if ( e$ == WE_REQ_DEACTIVATE ) { t_Goid$ = msg$.GetSendFrom(); if ( t_Goid$ == rw_Goid$) { rw_active$ = false; report.screenf( "reset white de-activated" ); return; } if ( t_Goid$ == rb_Goid$ ) { rb_active$ = false; report.screenf( "reset black de-activated" ); return; } } } } State ResetActive$ { Event OnGoHandleMessage$ ( eWorldEvent e$, WorldMessage msg$ ) { if ( e$ == WE_REQ_DEACTIVATE ) { t_Goid$ = msg$.GetSendFrom(); if ( t_Goid$ == rw_Goid$) { rw_active$ = false; report.screenf( "reset white de-activatedd" ); SetState( Wait$ ); return; } if ( t_Goid$ == rb_Goid$ ) { rb_active$ = false; report.screenf( "reset black de-activated" ); SetState( Wait$ ); return; } } if ( e$ == WE_REQ_USE ) { /* t_Goid$ = msg$.GetSendFrom(); if (t_goid$ == p1_Goid$ ) { SetState( waitForP1$ ); return; } if (t_Goid$ == p2_Goid$ ) { SetState( WaitForP2$ ); return; } */ SetState( ResetTheBoard$ ); return; } } } /* State WaitForP1$ { Event OnEnterState$ { report.screenf( "%s has requested board reset! %s has 15 seconds to respond!", p2_screen_name$, p1_screen_name$ ); this.CreateTimer( 1, 15.0 ); } trigger OnTimer( 1 ); { this.DestroyTimer( 1 ); report.screenf( "Reset timer expired!" ); SetState( Wait$ ); return; } Event OnGoHandleMessage$ ( eWorldEvent e$, WorldMessage msg$ ) { if ( e$ == WE_REQ_USE ) { t_Goid$ = msg$.GetSendFrom(); if (t_Goid$ == p1_Goid$ ) { SetState( ResetTheBoard$ ); return; } } } } State WaitForP2$ { Event OnEnterState$ { report.screenf( "%s has requested board reset! %s has 15 seconds to respond!", p1_screen_name$, p2_screen_name$ ); this.CreateTimer( 1, 15.0 ); } trigger OnTimer( 1 ); { this.DestroyTimer( 1 ); report.screenf( "Reset timer expired!" ); SetState( Wait$ ); return; } Event OnGoHandleMessage$ ( eWorldEvent e$, WorldMessage msg$ ) { if ( e$ == WE_REQ_USE ) { t_Goid$ = msg$.GetSendFrom(); if (t_Goid$ == p2_Goid$ ) { SetState( ResetTheBoard$ ); return; } } } } */ State ResetTheBoard$ { Event OnEnterState$ { report.screenf ( " The board has been reset." ); //reset board code here....... //white court p_Goid$ = sq_a1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_rook_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_b1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_knight_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_c1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_bishop_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_d1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_e1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_f1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_bishop_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_g1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_knight_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_h1$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_rook_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); //white pawns p_Goid$ = sq_a2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_rook_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_b2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_knight_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_c2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_bishop_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_d2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_e2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_f2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_bishop_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_g2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_knight_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_h2$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = white_pawn_rook_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); //black court p_Goid$ = sq_a8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_rook_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_b8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_knight_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_c8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_bishop_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_d8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_e8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_f8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_bishop_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_g8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_knight_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_h8$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_rook_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); //black pawns p_Goid$ = sq_a7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_rook_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_b7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_knight_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_c7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_bishop_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_d7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_queen$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_e7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_f7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_bishop_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_g7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_knight_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); p_Goid$ = sq_h7$.getgoid; pos$ = p_Goid$.go.Placement.Position; p_Goid$ = black_pawn_rook_king$.getgoid; p_Goid$.Go.Mind.RSMove( pos$, QP_CLEAR, AO_REFLEX, p_Goid$ ); // Move states SetState ( wasReset$ ); return; } } State wasReset$ { Event OnEnterState$ { SetState ( Wait$ ); return; } }