本文整理汇总了Golang中github.com/svera/acquire/interfaces.Tile类的典型用法代码示例。如果您正苦于以下问题:Golang Tile类的具体用法?Golang Tile怎么用?Golang Tile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tile类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: HasTile
// HasTile checks if the passed tile is in player's hand
func (p *Player) HasTile(tile interfaces.Tile) bool {
for _, currentTile := range p.tiles {
if currentTile.Number() == tile.Number() && currentTile.Letter() == tile.Letter() {
return true
}
}
return false
}
开发者ID:svera,项目名称:acquire,代码行数:9,代码来源:player.go
示例2: DiscardTile
// DiscardTile removes passed tile from the tileset
func (t *Tileset) DiscardTile(tl interfaces.Tile) {
for i, currentTile := range t.tiles {
if currentTile.Number() == tl.Number() && currentTile.Letter() == tl.Letter() {
t.tiles = append(t.tiles[:i], t.tiles[i+1:]...)
break
}
}
}
开发者ID:svera,项目名称:acquire,代码行数:9,代码来源:tileset.go
示例3: TileMergeCorporations
// TileMergeCorporations checks if the passed tile merges two or more corporations, returns a map of
// corporations categorized between "acquirer" and "defunct"
func (b *Board) TileMergeCorporations(t interfaces.Tile) (bool, map[string][]interfaces.Corporation) {
corporations := b.AdjacentCorporations(t.Number(), t.Letter())
if len(corporations) > 1 {
return true, categorizeMerge(corporations)
}
return false, map[string][]interfaces.Corporation{}
}
开发者ID:svera,项目名称:acquire,代码行数:10,代码来源:board.go
示例4: DiscardTile
// DiscardTile discards the passed tile from player's hand
func (p *Player) DiscardTile(tile interfaces.Tile) interfaces.Player {
for i, currentTile := range p.tiles {
if currentTile.Number() == tile.Number() && currentTile.Letter() == tile.Letter() {
p.tiles = append(p.tiles[:i], p.tiles[i+1:]...)
return p
}
}
return p
}
开发者ID:svera,项目名称:acquire,代码行数:10,代码来源:player.go
示例5: isTilePermanentlyUnplayable
// Returns true if a tile is permanently unplayable, that is,
// that putting it on the board would merge two or more safe corporations
func (g *Game) isTilePermanentlyUnplayable(tl interfaces.Tile) bool {
adjacents := g.board.AdjacentCorporations(tl.Number(), tl.Letter())
safeNeighbours := 0
for _, adjacent := range adjacents {
if adjacent.IsSafe() {
safeNeighbours++
}
if safeNeighbours == 2 {
return true
}
}
return false
}
开发者ID:svera,项目名称:acquire,代码行数:15,代码来源:game.go
示例6: TileFoundCorporation
// TileFoundCorporation checks if the passed tile founds a new corporation, returns a slice of tiles
// composing this corporation
func (b *Board) TileFoundCorporation(t interfaces.Tile) (bool, []interfaces.Tile) {
var newCorporationTiles []interfaces.Tile
adjacent := b.adjacentTiles(t.Number(), t.Letter())
for _, adjacentTile := range adjacent {
if adjacentTile.Type() == interfaces.CorporationOwner {
return false, []interfaces.Tile{}
}
newCorporationTiles = append(newCorporationTiles, adjacentTile.(interfaces.Tile))
}
if len(newCorporationTiles) > 0 {
newCorporationTiles = append(newCorporationTiles, t)
return true, newCorporationTiles
}
return false, newCorporationTiles
}
开发者ID:svera,项目名称:acquire,代码行数:17,代码来源:board.go
示例7: isTileTemporarilyUnplayable
// Returns true if a tile is temporarily unplayable, that is,
// that putting it on the board would create an 8th corporation
func (g *Game) isTileTemporarilyUnplayable(tl interfaces.Tile) bool {
if len(g.activeCorporations()) < totalCorporations {
return false
}
adjacents := g.board.AdjacentCells(tl.Number(), tl.Letter())
emptyAdjacentCells := 0
for _, adjacent := range adjacents {
if adjacent.Type() == interfaces.CorporationOwner {
return false
}
if adjacent.Type() == interfaces.EmptyOwner {
emptyAdjacentCells++
}
}
if emptyAdjacentCells == len(adjacents) {
return false
}
return true
}
开发者ID:svera,项目名称:acquire,代码行数:21,代码来源:game.go
示例8: TileGrowCorporation
// TileGrowCorporation checks if the passed tile grows a corporation.
// Returns true if that's the case, the tiles to append to the corporation and
// the ID of the corporation which grows
func (b *Board) TileGrowCorporation(tl interfaces.Tile) (bool, []interfaces.Tile, interfaces.Corporation) {
tilesToAppend := []interfaces.Tile{tl}
var corporationToGrow, nullCorporation interfaces.Corporation
corporations := b.AdjacentCorporations(tl.Number(), tl.Letter())
if len(corporations) != 1 {
return false, []interfaces.Tile{}, nullCorporation
}
corporationToGrow = corporations[0]
adjacent := b.adjacentTiles(tl.Number(), tl.Letter())
for _, adjacentCell := range adjacent {
if adjacentCell.Type() == interfaces.UnincorporatedOwner {
tilesToAppend = append(tilesToAppend, adjacentCell.(interfaces.Tile))
}
}
return true, tilesToAppend, corporationToGrow
}
开发者ID:svera,项目名称:acquire,代码行数:21,代码来源:board.go
示例9: PutTile
// PutTile puts the passed tile on the board
func (b *Board) PutTile(t interfaces.Tile) interfaces.Board {
b.grid[t.Number()][t.Letter()] = t
return b
}
开发者ID:svera,项目名称:acquire,代码行数:5,代码来源:board.go
注:本文中的github.com/svera/acquire/interfaces.Tile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论