app

package
v0.0.0-...-0387dd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldValue

type FieldValue uint8

func (FieldValue) PlayerIndex

func (v FieldValue) PlayerIndex() channel.Index

func (FieldValue) String

func (v FieldValue) String() string

type TicTacToeApp

type TicTacToeApp struct {
	Addr wallet.Address
}

TicTacToeApp is a channel app.

func NewTicTacToeApp

func NewTicTacToeApp(addr wallet.Address) *TicTacToeApp

func (*TicTacToeApp) Def

func (a *TicTacToeApp) Def() wallet.Address

Def returns the app address.

func (*TicTacToeApp) InitData

func (a *TicTacToeApp) InitData(firstActor channel.Index) *TicTacToeAppData

func (*TicTacToeApp) NewData

func (a *TicTacToeApp) NewData() channel.Data

func (*TicTacToeApp) Set

func (*TicTacToeApp) Set(s *channel.State, x, y int, actorIdx channel.Index) error

func (*TicTacToeApp) ValidInit

func (a *TicTacToeApp) ValidInit(p *channel.Params, s *channel.State) error

ValidInit checks that the initial state is valid.

func (*TicTacToeApp) ValidTransition

func (a *TicTacToeApp) ValidTransition(params *channel.Params, from, to *channel.State, actor channel.Index) error

ValidTransition is called whenever the channel state transitions.

type TicTacToeAppData

type TicTacToeAppData struct {
	NextActor uint8
	Grid      [9]FieldValue
}

TicTacToeAppData is the app data struct. Grid: 0 1 2 3 4 5 6 7 8

func (TicTacToeAppData) CheckFinal

func (d TicTacToeAppData) CheckFinal() (isFinal bool, winner *channel.Index)

func (*TicTacToeAppData) Clone

func (d *TicTacToeAppData) Clone() channel.Data

Clone returns a deep copy of the app data.

func (*TicTacToeAppData) MarshalBinary

func (d *TicTacToeAppData) MarshalBinary() ([]byte, error)

MarshalBinary encodes the data to bytes.

func (*TicTacToeAppData) Set

func (d *TicTacToeAppData) Set(row, col int, actorIdx channel.Index) error

func (*TicTacToeAppData) String

func (d *TicTacToeAppData) String() string

func (*TicTacToeAppData) UnmarshalBinary

func (d *TicTacToeAppData) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes channel data from bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL